badf683b0a
function old new delta zbc_program_read - 268 +268 zdc_program_printStream - 146 +146 zbc_program_exec 4046 4182 +136 zdc_program_execStr 472 512 +40 zdc_parse_exprs_until_eof - 26 +26 zbc_vm_process 740 765 +25 zbc_lex_next 2225 2240 +15 zdc_parse_expr 569 535 -34 zbc_program_pushArray 147 - -147 zdc_program_asciify 370 - -370 ------------------------------------------------------------------------------ (add/remove: 3/2 grow/shrink: 4/1 up/down: 656/-551) Total: 105 bytes Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
80 lines
1.7 KiB
Bash
Executable File
80 lines
1.7 KiB
Bash
Executable File
#!/bin/sh
|
|
# Copyright 2015 by Bernhard Reutner-Fischer
|
|
# Licensed under GPLv2 or later, see file LICENSE in this source tree.
|
|
|
|
. ./testing.sh
|
|
|
|
# testing "test name" "command" "expected result" "file input" "stdin"
|
|
|
|
testing "dc basic syntax (stdin, multiple args)" \
|
|
"dc" \
|
|
"30\n" \
|
|
"" "10 20+p"
|
|
|
|
testing "dc basic syntax (argv, single arg)" \
|
|
"dc -e'10 20+p'" \
|
|
"30\n" \
|
|
"" ""
|
|
|
|
testing "dc basic syntax (argv, multiple args)" \
|
|
"dc -e10 -e20+p" \
|
|
"30\n" \
|
|
"" ""
|
|
|
|
testing "dc complex with spaces (single arg)" \
|
|
"dc -e'8 8 * 2 2 + / p'" \
|
|
"16\n" \
|
|
"" ""
|
|
|
|
testing "dc complex without spaces (single arg)" \
|
|
"dc -e'8 8*2 2+/p'" \
|
|
"16\n" \
|
|
"" ""
|
|
|
|
testing "dc complex with spaces (multiple args)" \
|
|
"dc -e8 -e8 -e\* -e2 -e2 -e+ -e/ -ep" \
|
|
"16\n" \
|
|
"" ""
|
|
|
|
testing "dc complex without spaces (multiple args)" \
|
|
"dc -e8 -e8\*2 -e2+/p" \
|
|
"16\n" \
|
|
"" ""
|
|
|
|
testing "dc '>a' (conditional execute string) 1" \
|
|
"dc" \
|
|
"1\n9\n" \
|
|
"" "[1p]sa [2p]sb 1 2>a\n9p"
|
|
|
|
testing "dc '>a' (conditional execute string) 2" \
|
|
"dc" \
|
|
"9\n" \
|
|
"" "[1p]sa [2p]sb 2 1>a\n9p"
|
|
|
|
testing "dc '>aeb' (conditional execute string with else)" \
|
|
"dc" \
|
|
"2\n9\n" \
|
|
"" "[1p]sa [2p]sb 2 1>aeb\n9p"
|
|
|
|
for f in dc_*.dc; do
|
|
r="`basename "$f" .dc`_results.txt"
|
|
test -f "$r" || continue
|
|
# testing "test name" "command" "expected result" "file input" "stdin"
|
|
testing "dc $f" \
|
|
"{ { dc $f 2>&1; echo E:\$? >&2; } | diff -u - $r; echo E:\$?; } 2>&1" \
|
|
"E:0\nE:0\n" \
|
|
"" ""
|
|
done
|
|
|
|
for f in dcx_*.dc; do
|
|
r="`basename "$f" .dc`_results.txt"
|
|
test -f "$r" || continue
|
|
# testing "test name" "command" "expected result" "file input" "stdin"
|
|
testing "dc -x $f" \
|
|
"{ { dc -x $f 2>&1; echo E:\$? >&2; } | diff -u - $r; echo E:\$?; } 2>&1" \
|
|
"E:0\nE:0\n" \
|
|
"" ""
|
|
done
|
|
|
|
exit $FAILCOUNT
|