diff options
Diffstat (limited to 'tests/other.sh')
-rwxr-xr-x | tests/other.sh | 120 |
1 files changed, 75 insertions, 45 deletions
diff --git a/tests/other.sh b/tests/other.sh index 4f491a64c770..c3a739a32e7e 100755 --- a/tests/other.sh +++ b/tests/other.sh @@ -112,14 +112,14 @@ set +e printf '\nRunning %s quit test...' "$d" -printf '%s\n' "$halt" | "$exe" "$@" > /dev/null 2>&1 +printf '%s\n' "$halt" 2> /dev/null | "$exe" "$@" > /dev/null 2>&1 checktest_retcode "$d" "$?" "quit" # bc has two halt or quit commands, so test the second as well. if [ "$d" = bc ]; then - printf '%s\n' "quit" | "$exe" "$@" > /dev/null 2>&1 + printf '%s\n' "quit" 2> /dev/null | "$exe" "$@" > /dev/null 2>&1 checktest_retcode "$d" "$?" quit @@ -142,11 +142,11 @@ if [ "$d" = "bc" ]; then export BC_ENV_ARGS=" '-l' '' -q" - printf 's(.02893)\n' | "$exe" "$@" > /dev/null + printf 's(.02893)\n' 2> /dev/null | "$exe" "$@" > /dev/null checktest_retcode "$d" "$?" "environment var" - printf 'halt\n' | "$exe" "$@" -e 4 > /dev/null + printf 'halt\n' 2> /dev/null | "$exe" "$@" -e 4 > /dev/null err="$?" checktest_retcode "$d" "$?" "environment var" @@ -168,19 +168,19 @@ if [ "$d" = "bc" ]; then printf '5\n0\n' > "$redefine_res" - printf 'halt\n' | "$exe" "$@" --redefine=print -e 'define print(x) { x }' -e 'print(5)' > "$redefine_out" + printf 'halt\n' 2> /dev/null | "$exe" "$@" --redefine=print -e 'define print(x) { x }' -e 'print(5)' > "$redefine_out" err="$?" checktest "$d" "$err" "keyword redefinition" "$redefine_res" "$redefine_out" - printf 'halt\n' | "$exe" "$@" -r "abs" -r "else" -e 'abs = 5;else = 0' -e 'abs;else' > "$redefine_out" + printf 'halt\n' 2> /dev/null | "$exe" "$@" -r "abs" -r "else" -e 'abs = 5;else = 0' -e 'abs;else' > "$redefine_out" err="$?" checktest "$d" "$err" "keyword redefinition" "$redefine_res" "$redefine_out" if [ "$extra_math" -ne 0 ]; then - printf 'halt\n' | "$exe" "$@" -lr abs -e "perm(5, 1)" -e "0" > "$redefine_out" + printf 'halt\n' 2> /dev/null | "$exe" "$@" -lr abs -e "perm(5, 1)" -e "0" > "$redefine_out" err="$?" checktest "$d" "$err" "keyword not redefined in builtin library" "$redefine_res" "$redefine_out" @@ -204,7 +204,7 @@ if [ "$d" = "bc" ]; then multiline_expr_out="$outputdir/bc_outputs/multiline_expr_results.txt" # tests/bc/misc1.txt happens to have a multiline comment in it. - printf 'halt\n' | "$exe" "$@" -f "$testdir/bc/misc1.txt" > "$multiline_expr_out" + printf 'halt\n' 2> /dev/null | "$exe" "$@" -f "$testdir/bc/misc1.txt" > "$multiline_expr_out" err="$?" checktest "$d" "$err" "multiline comment in expression file" "$testdir/bc/misc1_results.txt" \ @@ -213,7 +213,7 @@ if [ "$d" = "bc" ]; then printf 'pass\n' printf 'Running multiline comment expression file error test...' - printf 'halt\n' | "$exe" "$@" -f "$testdir/bc/errors/05.txt" 2> "$multiline_expr_out" + printf 'halt\n' 2> /dev/null | "$exe" "$@" -f "$testdir/bc/errors/05.txt" 2> "$multiline_expr_out" err="$?" checkerrtest "$d" "$err" "multiline comment in expression file error" \ @@ -223,7 +223,7 @@ if [ "$d" = "bc" ]; then printf 'Running multiline string expression file test...' # tests/bc/strings.txt happens to have a multiline string in it. - printf 'halt\n' | "$exe" "$@" -f "$testdir/bc/strings.txt" > "$multiline_expr_out" + printf 'halt\n' 2> /dev/null | "$exe" "$@" -f "$testdir/bc/strings.txt" > "$multiline_expr_out" err="$?" checktest "$d" "$err" "multiline string in expression file" "$testdir/bc/strings_results.txt" \ @@ -232,13 +232,13 @@ if [ "$d" = "bc" ]; then printf 'pass\n' printf 'Running multiline string expression file error test...' - printf 'halt\n' | "$exe" "$@" -f "$testdir/bc/errors/16.txt" 2> "$multiline_expr_out" + printf 'halt\n' 2> /dev/null | "$exe" "$@" -f "$testdir/bc/errors/16.txt" 2> "$multiline_expr_out" err="$?" checkerrtest "$d" "$err" "multiline string in expression file with backslash error" \ "$multiline_expr_out" "$d" - printf 'halt\n' | "$exe" "$@" -f "$testdir/bc/errors/04.txt" 2> "$multiline_expr_out" + printf 'halt\n' 2> /dev/null | "$exe" "$@" -f "$testdir/bc/errors/04.txt" 2> "$multiline_expr_out" err="$?" checkerrtest "$d" "$err" "multiline string in expression file error" \ @@ -251,7 +251,7 @@ else export DC_ENV_ARGS="'-x'" export DC_EXPR_EXIT="1" - printf '4s stuff\n' | "$exe" "$@" > /dev/null + printf '4s stuff\n' 2> /dev/null | "$exe" "$@" > /dev/null checktest_retcode "$d" "$?" "environment var" @@ -266,15 +266,15 @@ else # dc has an extra test for a case that someone found running this easter.dc # script. It went into an infinite loop, so we want to check that we did not # regress. - printf 'three\n' | cut -c1-3 > /dev/null + printf 'three\n' 2> /dev/null | cut -c1-3 > /dev/null err=$? if [ "$err" -eq 0 ]; then printf 'Running dc Easter script...' - easter_res="$outputdir/dc_outputs/easter.txt" - easter_out="$outputdir/dc_outputs/easter_results.txt" + easter_out="$outputdir/dc_outputs/easter.txt" + easter_res="$outputdir/dc_outputs/easter_results.txt" outdir=$(dirname "$easter_out") @@ -284,14 +284,44 @@ else printf '4 April 2021\n' > "$easter_res" - "$testdir/dc/scripts/easter.sh" "$exe" 2021 "$@" | cut -c1-12 > "$easter_out" + "$testdir/dc/scripts/easter.sh" "$exe" 2021 "$@" 2> /dev/null | cut -c1-12 > "$easter_out" err="$?" - checktest "$d" "$err" "Easter script" "$easter_res" "$easter_out" + checktest "$d" "$err" "Easter script" "$easter_out" "$easter_res" printf 'pass\n' fi + unset DC_ENV_ARGS + unset DC_EXPR_EXIT + + printf 'Running dc extended register command tests...' + + ext_reg_out="$outputdir/dc_outputs/ext_reg.txt" + ext_reg_res="$outputdir/dc_outputs/ext_reg_results.txt" + + outdir=$(dirname "$ext_reg_out") + + if [ ! -d "$outdir" ]; then + mkdir -p "$outdir" + fi + + printf '0\n' > "$ext_reg_res" + + "$exe" "$@" -e "gxpR" 2> /dev/null > "$ext_reg_out" + err="$?" + + checktest "$d" "$err" "Extended register command" "$ext_reg_out" "$ext_reg_res" + + printf '1\n' > "$ext_reg_res" + + "$exe" "$@" -x -e "gxpR" 2> /dev/null > "$ext_reg_out" + err="$?" + + checktest "$d" "$err" "Extended register command" "$ext_reg_out" "$ext_reg_res" + + printf 'pass\n' + fi out1="$outputdir/${d}_outputs/${d}_other.txt" @@ -302,26 +332,26 @@ printf 'Running %s line length tests...' "$d" printf '%s\n' "$numres" > "$out1" export "$line_var"=80 -printf '%s\n' "$num" | "$exe" "$@" > "$out2" +printf '%s\n' "$num" 2> /dev/null | "$exe" "$@" > "$out2" checktest "$d" "$?" "line length" "$out1" "$out2" printf '%s\n' "$num70" > "$out1" export "$line_var"=2147483647 -printf '%s\n' "$num" | "$exe" "$@" > "$out2" +printf '%s\n' "$num" 2> /dev/null | "$exe" "$@" > "$out2" checktest "$d" "$?" "line length 2" "$out1" "$out2" printf '%s\n' "$num2" > "$out1" export "$line_var"=62 -printf '%s\n' "$num" | "$exe" "$@" -L > "$out2" +printf '%s\n' "$num" 2> /dev/null | "$exe" "$@" -L > "$out2" checktest "$d" "$?" "line length 3" "$out1" "$out2" printf '0\n' > "$out1" -printf '%s\n' "$lltest" | "$exe" "$@" -L > "$out2" +printf '%s\n' "$lltest" 2> /dev/null | "$exe" "$@" -L > "$out2" checktest "$d" "$?" "line length 3" "$out1" "$out2" @@ -342,23 +372,23 @@ printf '%s\n%s\n%s\n%s\n' "$results" "$results" "$results" "$results" > "$out1" checktest "$d" "$?" "arg" "$out1" "$out2" -printf '%s\n' "$halt" | "$exe" "$@" -- "$f" "$f" "$f" "$f" > "$out2" +printf '%s\n' "$halt" 2> /dev/null | "$exe" "$@" -- "$f" "$f" "$f" "$f" > "$out2" checktest "$d" "$?" "arg" "$out1" "$out2" if [ "$d" = "bc" ]; then - printf '%s\n' "$halt" | "$exe" "$@" -i > /dev/null 2>&1 + printf '%s\n' "$halt" 2> /dev/null | "$exe" "$@" -i > /dev/null 2>&1 fi -printf '%s\n' "$halt" | "$exe" "$@" -h > /dev/null +printf '%s\n' "$halt" 2> /dev/null | "$exe" "$@" -h > /dev/null checktest_retcode "$d" "$?" "arg" -printf '%s\n' "$halt" | "$exe" "$@" -P > /dev/null +printf '%s\n' "$halt" 2> /dev/null | "$exe" "$@" -P > /dev/null checktest_retcode "$d" "$?" "arg" -printf '%s\n' "$halt" | "$exe" "$@" -R > /dev/null +printf '%s\n' "$halt" 2> /dev/null | "$exe" "$@" -R > /dev/null checktest_retcode "$d" "$?" "arg" -printf '%s\n' "$halt" | "$exe" "$@" -v > /dev/null +printf '%s\n' "$halt" 2> /dev/null | "$exe" "$@" -v > /dev/null checktest_retcode "$d" "$?" "arg" -printf '%s\n' "$halt" | "$exe" "$@" -V > /dev/null +printf '%s\n' "$halt" 2> /dev/null | "$exe" "$@" -V > /dev/null checktest_retcode "$d" "$?" "arg" out=$(printf '0.1\n-0.1\n1.1\n-1.1\n0.1\n-0.1\n') @@ -370,12 +400,12 @@ else data=$(printf '0.1pR\n_0.1pR\n1.1pR\n_1.1pR\n.1pR\n_.1pR\n') fi -printf '%s\n' "$data" | "$exe" "$@" -z > "$out2" +printf '%s\n' "$data" 2> /dev/null | "$exe" "$@" -z > "$out2" checktest "$d" "$?" "leading zero" "$out1" "$out2" if [ "$d" = "bc" ] && [ "$extra_math" -ne 0 ]; then - printf '%s\n' "$halt" | "$exe" "$@" -lz "$testdir/bc/leadingzero.txt" > "$out2" + printf '%s\n' "$halt" 2> /dev/null | "$exe" "$@" -lz "$testdir/bc/leadingzero.txt" > "$out2" checktest "$d" "$?" "leading zero script" "$testdir/bc/leadingzero_results.txt" "$out2" @@ -446,10 +476,10 @@ if [ "$extra_math" -ne 0 ]; then data=$(printf 'J2@OIKAiAopRpRpRpR') fi - printf '%s\n' "$data" | "$exe" "$@" -S14 -I15 -O16 -E17.25 > "$out2" + printf '%s\n' "$data" 2> /dev/null | "$exe" "$@" -S14 -I15 -O16 -E17.25 > "$out2" checktest "$d" "$?" "builtin variable args" "$out1" "$out2" - printf '%s\n' "$data" | "$exe" "$@" --scale=14 --ibase=15 --obase=16 --seed=17.25 > "$out2" + printf '%s\n' "$data" 2> /dev/null | "$exe" "$@" --scale=14 --ibase=15 --obase=16 --seed=17.25 > "$out2" checktest "$d" "$?" "builtin variable long args" "$out1" "$out2" else @@ -463,10 +493,10 @@ else data=$(printf 'OIKAiAopRpRpR') fi - printf '%s\n' "$data" | "$exe" "$@" -S14 -I15 -O16 > "$out2" + printf '%s\n' "$data" 2> /dev/null | "$exe" "$@" -S14 -I15 -O16 > "$out2" checktest "$d" "$?" "builtin variable args" "$out1" "$out2" - printf '%s\n' "$data" | "$exe" "$@" --scale=14 --ibase=15 --obase=16 > "$out2" + printf '%s\n' "$data" 2> /dev/null | "$exe" "$@" --scale=14 --ibase=15 --obase=16 > "$out2" checktest "$d" "$?" "builtin variable long args" "$out1" "$out2" fi @@ -476,40 +506,40 @@ if [ "$d" = "bc" ]; then out=$(printf '100\n') printf '%s\n' "$out" > "$out1" - printf 'scale\n' | "$exe" "$@" -S100 -l > "$out2" + printf 'scale\n' 2> /dev/null | "$exe" "$@" -S100 -l > "$out2" checktest "$d" "$?" "builtin variable args with math lib" "$out1" "$out2" - printf 'scale\n' | "$exe" "$@" --scale=100 --mathlib > "$out2" + printf 'scale\n' 2> /dev/null | "$exe" "$@" --scale=100 --mathlib > "$out2" checktest "$d" "$?" "builtin variable long args with math lib" "$out1" "$out2" export BC_ENV_ARGS="-l" - printf 'scale\n' | "$exe" "$@" -S100 > "$out2" + printf 'scale\n' 2> /dev/null | "$exe" "$@" -S100 > "$out2" checktest "$d" "$?" "builtin variable args with math lib env arg" "$out1" "$out2" - printf 'scale\n' | "$exe" "$@" --scale=100 > "$out2" + printf 'scale\n' 2> /dev/null | "$exe" "$@" --scale=100 > "$out2" checktest "$d" "$?" "builtin variable long args with math lib env arg" "$out1" "$out2" export BC_ENV_ARGS="-S100" - printf 'scale\n' | "$exe" "$@" -l > "$out2" + printf 'scale\n' 2> /dev/null | "$exe" "$@" -l > "$out2" checktest "$d" "$?" "builtin variable args with math lib arg" "$out1" "$out2" export BC_ENV_ARGS="--scale=100" - printf 'scale\n' | "$exe" "$@" -l > "$out2" + printf 'scale\n' 2> /dev/null | "$exe" "$@" -l > "$out2" checktest "$d" "$?" "builtin variable long args with math lib arg" "$out1" "$out2" fi -printf 'scale\n' | "$exe" "$@" --scale=18923c.rlg > /dev/null 2> "$out2" +printf 'scale\n' 2> /dev/null | "$exe" "$@" --scale=18923c.rlg > /dev/null 2> "$out2" err="$?" checkerrtest "$d" "$err" "invalid command-line arg for builtin variable" "$out2" "$d" if [ "$extra_math" -ne 0 ]; then - printf 'seed\n' | "$exe" "$@" --seed=18923c.rlg > /dev/null 2> "$out2" + printf 'seed\n' 2> /dev/null | "$exe" "$@" --seed=18923c.rlg > /dev/null 2> "$out2" err="$?" checkerrtest "$d" "$err" "invalid command-line arg for seed" "$out2" "$d" @@ -540,7 +570,7 @@ printf 'pass\n' printf 'Running %s binary stdin test...' "$d" -cat "$bin" | "$exe" "$@" > /dev/null 2> "$out2" +cat "$bin" 2> /dev/null | "$exe" "$@" > /dev/null 2> "$out2" err="$?" checkerrtest "$d" "$err" "binary stdin" "$out2" "$d" @@ -550,7 +580,7 @@ printf 'pass\n' if [ "$d" = "bc" ]; then printf 'Running %s limits tests...' "$d" - printf 'limits\n' | "$exe" "$@" /dev/null > "$out2" 2>&1 + printf 'limits\n' 2> /dev/null | "$exe" "$@" /dev/null > "$out2" 2>&1 checktest_retcode "$d" "$?" "limits" |