aboutsummaryrefslogtreecommitdiffstats
path: root/tests
diff options
context:
space:
mode:
authorGavin Howard <gavin@yzena.com>2021-07-20 23:47:47 -0600
committerGavin Howard <gavin@yzena.com>2021-07-20 23:49:27 -0600
commitf4e36d5707c0857f1761b85b4187c1c2d85c1771 (patch)
treebfefa0458ac4052fac21a5df35a4a50ab3d61a97 /tests
parente9f2581d6c5021d9bc5136e2053cab0171174501 (diff)
downloadplatform_external_bc-f4e36d5707c0857f1761b85b4187c1c2d85c1771.tar.gz
platform_external_bc-f4e36d5707c0857f1761b85b4187c1c2d85c1771.tar.bz2
platform_external_bc-f4e36d5707c0857f1761b85b4187c1c2d85c1771.zip
Change the keyword redefinition infrastructure
This changes it to use a command-line option. This is best because if a user encounters a problem; they *know* they are using my bc and can add the command-line option. This is also better because it allows the keyword to be used as variable and array names as well as function names, without editing the script. This has the double advantage that I can undo the change to the parser, though I need to keep the one line change to the lexer. The option is `-r` and `--redefine`, and they take an argument, which is the keyword to redefine. All docs and tests have been updated. Signed-off-by: Gavin Howard <gavin@yzena.com>
Diffstat (limited to 'tests')
-rwxr-xr-xtests/other.sh13
1 files changed, 5 insertions, 8 deletions
diff --git a/tests/other.sh b/tests/other.sh
index fed4fbf0..daa2ddec 100755
--- a/tests/other.sh
+++ b/tests/other.sh
@@ -114,7 +114,6 @@ printf 'Running %s environment var tests...' "$d"
if [ "$d" = "bc" ]; then
export BC_ENV_ARGS=" '-l' '' -q"
- export BC_EXPR_EXIT="1"
printf 's(.02893)\n' | "$exe" "$@" > /dev/null
@@ -127,9 +126,9 @@ if [ "$d" = "bc" ]; then
printf 'pass\n'
- printf 'Running Keyword Redefinition test...'
+ printf 'Running keyword redefinition test...'
- export BC_REDEFINE_KEYWORDS=1
+ unset BC_ENV_ARGS
redefine_res="$testdir/bc_outputs/redefine.txt"
redefine_out="$testdir/bc_outputs/redefine_results.txt"
@@ -142,23 +141,21 @@ if [ "$d" = "bc" ]; then
printf '5\n0\n' > "$redefine_res"
- "$exe" -e 'define print(x) { x }' -e 'print(5)' "$@" > "$redefine_out"
+ "$exe" --redefine=print -e 'define print(x) { x }' -e 'print(5)' "$@" > "$redefine_out"
checktest "$d" "$err" "keyword redefinition" "$redefine_res" "$redefine_out"
printf '5\n0\n' > "$redefine_res"
- "$exe" -e 'define void abs(x) { x }' -e 'abs(5);0' "$@" > "$redefine_out"
+ "$exe" -r "abs" -r "else" -e 'abs = 5;else = 0' -e 'abs;else' "$@" > "$redefine_out"
checktest "$d" "$err" "keyword redefinition" "$redefine_res" "$redefine_out"
- "$exe" -e 'define break(x) { x }' "$@" 2> "$redefine_out"
+ "$exe" -r "break" -e 'define break(x) { x }' "$@" 2> "$redefine_out"
err="$?"
checkerrtest "$d" "$err" "keyword redefinition error" "$redefine_out" "$d"
- unset BC_REDEFINE_KEYWORDS
-
"$exe" -e 'define read(x) { x }' "$@" 2> "$redefine_out"
err="$?"