2 # Copyright 2015 by Bernhard Reutner-Fischer
3 # Licensed under GPLv2 or later, see file LICENSE in this source tree.
7 # testing "test name" "command" "expected result" "file input" "stdin"
9 testing
"dc basic syntax (stdin, multiple args)" \
14 testing
"dc basic syntax (argv, single arg)" \
19 testing
"dc basic syntax (argv, multiple args)" \
24 testing
"dc complex with spaces (single arg)" \
25 "dc -e'8 8 * 2 2 + / p'" \
29 testing
"dc complex without spaces (single arg)" \
34 testing
"dc complex with spaces (multiple args)" \
35 "dc -e8 -e8 -e\* -e2 -e2 -e+ -e/ -ep" \
39 testing
"dc complex without spaces (multiple args)" \
40 "dc -e8 -e8\*2 -e2+/p" \
44 optional FEATURE_DC_BIG
45 # All tests below depend on FEATURE_DC_BIG
47 testing
"dc: x should execute strings" \
48 "dc -e'[40 2 +] x f'" \
52 testing
"dc: x should not execute or pop non-strings" \
57 testing
"dc: x should work with strings created from a" \
62 testing
"dc: p should print invalid escapes" \
67 testing
"dc: p should print trailing backslashes" \
72 testing
"dc: p should parse/print single backslashes" \
77 testing
"dc: p should print single backslash strings" \
87 testing
"dc read string" \
92 testing
"dc '>a' (conditional execute string) 1" \
95 "" "[1p]sa [2p]sb 1 2>a\n9p"
97 testing
"dc '>a' (conditional execute string) 2" \
100 "" "[1p]sa [2p]sb 2 1>a\n9p"
102 testing
"dc '>aeb' (conditional execute string with else)" \
105 "" "[1p]sa [2p]sb 2 1>aeb\n9p"
107 testing
"dc space can be a register" \
110 "" "[2p]s \n[3p]\nl x\n9p"
112 testing
"dc newline can be a register" \
115 "" "[2p]s\n[3p]l\nx\n9p"
117 testing
"dc Z (length) for numbers" \
119 "1\n1\n3\n1\n3\n1\n" \
120 "" "0Zp\n0.000Zp\n100Zp\n0.01Zp\n0.00120Zp\n0.0012 0.0012 - Zp\n"
123 r
="`basename "$f" .dc`_results.txt"
124 test -f "$r" ||
continue
125 # testing "test name" "command" "expected result" "file input" "stdin"
127 "{ { dc $f 2>&1; echo E:\$? >&2; } | diff -u - $r; echo E:\$?; } 2>&1" \
132 for f
in dcx_
*.
dc; do
133 r
="`basename "$f" .dc`_results.txt"
134 test -f "$r" ||
continue
135 # testing "test name" "command" "expected result" "file input" "stdin"
137 "{ { dc -x $f 2>&1; echo E:\$? >&2; } | diff -u - $r; echo E:\$?; } 2>&1" \