added function test with gcd calculation

This commit is contained in:
Bob Polis 2020-09-09 12:35:32 +02:00
parent 41c83877a7
commit 79715ad9df
2 changed files with 41 additions and 2 deletions

39
code/gcd.txt Normal file
View File

@ -0,0 +1,39 @@
>main
gto
:gcd
=v
=u
$u
$v
>loop
gge
$u
=t
$v
=u
$t
=v
:loop
$v
0
>ret
gle
$v
=t
$u
$v
mod
=v
$t
=u
>loop
gto
:ret
$u
ret
:main
4
16
>gcd
fun
end

View File

@ -68,7 +68,7 @@ int main(int argc, const char * argv[]) {
bool done {false};
std::string base_url {"https://www.swiftcoder.nl/cpp1/"};
std::string next_url {"start.txt"};
std::string next_url {"gcd.txt"};
std::string code;
requester req;
interpreter proc;
@ -77,7 +77,7 @@ int main(int argc, const char * argv[]) {
// std::cerr << code << '\n';
std::istringstream in {code};
next_url = proc.eval(in, done);
std::cerr << next_url << '\n';
SCInfo(logger, next_url);
}
std::cout << next_url << '\n';