X-Git-Url: https://secure.softndesign.org/git/?a=blobdiff_plain;f=calc.c;h=920099b46a504c1fc88cd6d3ce733705ebd67584;hb=c91672f948d371d3ba2b1a47db9a31fcabb763f5;hp=4ef05d76dd50daccd656e41a9b996031a393ce95;hpb=a24bd5195f9990159a974c98751f1473f29b9fa4;p=calc.git diff --git a/calc.c b/calc.c index 4ef05d7..920099b 100644 --- a/calc.c +++ b/calc.c @@ -1,6 +1,6 @@ /* depend: */ /* cflags: */ -/* linker: alloc.o debug.o element.o format.o parser.o program.o stack.o storage.o -lm -lreadline */ +/* linker: alloc.o argument.o debug.o element.o format.o parser.o program.o stack.o storage.o tabular.o -lm -lreadline */ #include #include @@ -321,7 +321,7 @@ int main (int argc, char *argv[]) // test: echo -e '\n\n\n' | calc.exe | grep -qv 'error' // test: echo -e '\n\n\n' | calc.exe -n | grep -qv 'error' // test: echo -e '1.5\nsto (2)\n3 + rcl(2) * 4\nsto (5)' | calc.exe | grep -q 9 -// test: echo -e '1\nsto (0)\nsto (11)\nrcl (0)\nrcl (11)' | calc.exe | grep -c invalid | xargs test 4 = +// test: echo -e '1\nsto (0)\nsto (11)\nrcl (0)\nrcl (11)' | calc.exe | grep -c error | xargs test 4 = // test: echo -e '1\nsto (2)\n3\nsto (5, 7)\nsto(9)\ndisp' | calc.exe | grep -q '0 1 0 0 7 0 0 0 7 0' // test: echo -e '1+1 == 2' | calc.exe | grep -q '=> 1' // test: echo -e '1 + 1 == 2 - 0' | calc.exe | grep -q '=> 1' @@ -360,8 +360,8 @@ int main (int argc, char *argv[]) // test: echo -e 'cond\ncond (\ncond (1 >0,'| calc.exe | grep -c error | xargs test 3 = // test: echo -e 'sto (1, 4)\ninc (1)\ninc (1)\ndec (1)\ninc (1)\nrcl (1) == 6\nquit' | calc.exe -v 3 | grep -q '=> 1' // test: echo -e 'inc\ninc (\ndec\ndec (' | calc.exe | grep -c error | xargs test 4 = -// test: echo -e 'inc (11)\ndec (0)' | calc.exe | grep -c invalid | xargs test 2 = -// test: echo -e 'while (inc (1) < 100, sto (2, rcl (1) + rcl (2)))' | calc.exe | grep -q '=> 5050' +// test: echo -e 'inc (11)\ndec (0)' | calc.exe | grep -c error | xargs test 2 = +// test: echo -e 'while (inc (1) < 100, sto (2, rcl (1) + rcl (2)))' | calc.exe | grep -q '=> 4950' // test: echo -e 'while\nwhile (inc (1) < 3,\nwhile (inc (1) < 100, sto (2, rcl (1) + rcl (2))' | calc.exe | grep -c error | xargs test 3 = // test: echo -e 'while (0, 1)\nquit' | calc.exe -v 3 | grep -q While // test: echo -e '{sto (1, 1 + 1), rcl (1) * 3}\nquit' | calc.exe -v 3 | grep -q 'Code' @@ -372,7 +372,7 @@ int main (int argc, char *argv[]) // test: echo -e 'si\t\t (pi / 2)' | calc.exe | grep -q '=> 1' // test: echo -e '\t\t' | calc.exe | grep -q 'print' // test: echo -e '1 + 1;\nans + 1' | calc.exe | grep -qv 2 -// test: echo -e 'mem (3)\nsto (4, pi)' | calc.exe | grep -q "invalid index" +// test: echo -e 'mem (3)\nsto (4, pi)' | calc.exe | grep -q error // test: echo -e 'sto (2, 3)\nmem (2)\ndisp' | calc.exe | grep -q 'storage: 0 3$' // test: echo -e 'disp' | calc.exe | grep -q "storage: 0 0 0 0 0 0 0 0 0 0" // test: echo -e 'sto (3, 10)\ndisp' | calc.exe | grep -q "storage: 0 0 10 0 0 0 0 0 0 0" @@ -402,10 +402,10 @@ int main (int argc, char *argv[]) // test: echo -e 'min\nmean\nmed\nmax\nprod\nsum\nvar\nord' | calc.exe -n | grep -c error | xargs test 8 = // test: echo -e 'prog (1, cos(pi * arg (1))) / 4' | calc.exe | grep -c error | xargs test 1 = // Gauss sequence -// test: echo -e '{sto (1, 0), sto (10, 0), while (inc (10) < 100, {sto (1, rcl (1) + rcl (10)), print (rcl (1))})};' | calc.exe | grep -q '=> 5050' +// test: echo -e '{sto (1, 0), sto (10, 0), while (inc (10) <= 100, {sto (1, rcl (1) + rcl (10)), print (rcl (1))})};' | calc.exe | grep -q '=> 5050' // Fibonacci sequence -// test: echo -e '{sto (1, 1), sto (2, 1), sto (10, 1), while (inc (10) < 12 - 1, {sto (3, rcl (1) + rcl (2)), sto (1, rcl (2)), print (sto (2, rcl (3)))})};' | calc.exe | grep -q '=> 144' +// test: echo -e '{sto (1, 1), sto (2, 1), sto (10, 1), while (inc (10) <= 12 - 1, {sto (3, rcl (1) + rcl (2)), sto (1, rcl (2)), print (sto (2, rcl (3)))})};' | calc.exe | grep -q '=> 144' // 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'