dc: tweak parsing
https://bugs.debian.org/538685 dc requires whitespace between language elements. We were requiring 1 2 + p instead of the abbreviated 1 2+p (for example). function old new delta stack_machine 97 126 +29 dc_main 117 79 -38 ------------------------------------------------------------------------------ (add/remove: 0/0 grow/shrink: 1/1 up/down: 29/-38) Total: -9 bytes Signed-off-by: Bernhard Reutner-Fischer <rep.dot.nop@gmail.com> Signed-off-by: Denys Vlasenko <vda.linux@googlemail.com>
This commit is contained in:
committed by
Denys Vlasenko
parent
8e92df15b5
commit
70e30e8eec
56
testsuite/dc.tests
Executable file
56
testsuite/dc.tests
Executable file
@@ -0,0 +1,56 @@
|
||||
#!/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 '10 20+p'" \
|
||||
"30\n" \
|
||||
"" ""
|
||||
|
||||
testing "dc basic syntax (argv, multiple args)" \
|
||||
"dc 10 20+p" \
|
||||
"30\n" \
|
||||
"" ""
|
||||
|
||||
testing "dc complex with spaces (single arg)" \
|
||||
"dc '8 8 * 2 2 + / p'" \
|
||||
"16\n" \
|
||||
"" ""
|
||||
|
||||
testing "dc complex without spaces (single arg)" \
|
||||
"dc '8 8*2 2+/p'" \
|
||||
"16\n" \
|
||||
"" ""
|
||||
|
||||
testing "dc complex with spaces (multiple args)" \
|
||||
"dc 8 8 \* 2 2 + / p" \
|
||||
"16\n" \
|
||||
"" ""
|
||||
|
||||
testing "dc complex without spaces (multiple args)" \
|
||||
"dc 8 8\*2 2+/p" \
|
||||
"16\n" \
|
||||
"" ""
|
||||
|
||||
exit $FAILCOUNT
|
||||
|
||||
# we do not support arguments
|
||||
testing "dc -e <exprs>" \
|
||||
"dc -e '10 2+f'" \
|
||||
"12\n" \
|
||||
"" ""
|
||||
|
||||
testing "dc -f <exprs-from-given-file>" \
|
||||
"dc -f input" \
|
||||
"12\n" \
|
||||
"10 2+f" ""
|
||||
|
Reference in New Issue
Block a user