X-Git-Url: https://secure.softndesign.org/git/?a=blobdiff_plain;f=calc.c;h=cad608fe528f52bfcded3425a3c4bc5f5a595da3;hb=89a2c19deeb8b45dc8c655e59bc58f7a606ecd2c;hp=f9b77c295dbfbdb4835c7e128907cc69e7d2bd1f;hpb=d7eab259f4857b9a8ad792b6afe67bae3586ffb8;p=calc.git diff --git a/calc.c b/calc.c index f9b77c2..cad608f 100644 --- a/calc.c +++ b/calc.c @@ -1,6 +1,6 @@ /* depend: */ /* cflags: */ -/* linker: alloc.o argument.o debug.o element.o format.o parser.o program.o stack.o storage.o tabular.o -lm -lreadline */ +/* linker: alloc.o argument.o debug.o element.o format.o parser.o program.o stack.o storage.o tabular.o workspace.o -lm -lreadline */ #include #include @@ -383,7 +383,8 @@ int main (int argc, char *argv[]) // test: echo -e 'mem (3)\nclr\nquit' | calc.exe -v 3 | grep -q Clear // test: echo -e 'prog (2, {arg (2) - arg (1)})\nprog (1, {cos (arg (1)^2)})\ncall (1, pi/6)\nprog (2, {arg (1) * 3})\ncall (2, 1, 2)\nls' | calc.exe | grep -q 'programs: 2 1' // test: echo -e 'prog (1, {arg (2) - arg (1)})\ncall (1, 2, 3)\nls\nedit (1)\nprog (1, {arg (2) + arg (1)})\nedit (1)\ndel (1)\nquit' | calc.exe -v 3 | grep -q bye -// test: echo -e 'prog (2, {arg (2) - arg (1)})\nprog (3, cos(arg (1) * pi / 3))\ncall (1, 2, 3)\ncall (2, 1)\nls\nedit (1)\ndel (1)\n\ndel (2)\ncall (2, 1, 4)' | calc.exe | grep -c error | xargs test 5 = +// test: echo -e 'prog (2, {arg (2) - arg (1)})\nprog (3, cos(arg (1) * pi / 3))\ncall (1, 2, 3)\ncall (2, 1)\nls\nedit (1)\ndel (1)\ndel (3)\ndel (2)\ncall (2, 1, 4)' | calc.exe | grep -c error | xargs test 5 = +// test: echo -e 'prog (2, {arg (2) - arg (1)})\nprog (3, cos(arg (1) * pi / 3))\ndel (2)\ndel (3)\nls' | calc.exe | grep -q '^programs:$' // test: echo -e 'erf (1)\nerfc (1)\nquit' | calc.exe -v 3 | grep -q bye // test: echo -e 'erf ()\nerfc ()' | calc.exe | grep -c error | xargs test 2 = // test: echo -e 'set (1, 2, 3, 3.11, pi, 4)\nget (4)' | calc.exe | grep -q '=> 3.11' @@ -411,4 +412,7 @@ int main (int argc, char *argv[]) // Gold number // test: echo -e '{sto (1, 1), sto (2, 1), sto (10, 1), while (inc (10) < 15 - 1, {sto (3, rcl (1) + rcl (2)), sto (1, rcl (2)), print (sto (2, rcl (3)) / rcl (1))})};' | calc.exe | grep -q '=> 1.61803' +// Factorial sequence +// test: echo -e 'prog (1, cond (arg (1) > 1, arg (1) * call (1, arg (1) - 1), 1))\ncall (1, 10)' | ./calc.exe | grep -q '=> 3628800' + /* vim: set ts=4 sw=4 et: */