Lines Matching +full:2 +full:d
3 # SPDX-License-Identifier: BSD-2-Clause
5 # Copyright (c) 2018-2024 Gavin D. Howard and contributors.
51 if [ "$#" -ge 2 ]; then
53 d="$1"
55 check_d_arg "$d"
62 usage "Not enough arguments; need 2"
66 exe="$testdir/../bin/$d"
74 if [ "$d" = "bc" ]; then
90 if [ "$d" = "bc" ]; then
113 printf '\nRunning %s quit test...' "$d"
115 printf '%s\n' "$halt" 2> /dev/null | "$exe" "$@" > /dev/null 2>&1
117 checktest_retcode "$d" "$?" "quit"
120 if [ "$d" = bc ]; then
122 printf '%s\n' "quit" 2> /dev/null | "$exe" "$@" > /dev/null 2>&1
124 checktest_retcode "$d" "$?" quit
128 checktest_retcode "$d" "$?" quit
130 if [ "$two" != "2" ]; then
131 err_exit "$d failed test quit" 1
139 printf 'Running %s environment var tests...' "$d"
141 if [ "$d" = "bc" ]; then
145 printf 's(.02893)\n' 2> /dev/null | "$exe" "$@" > /dev/null
147 checktest_retcode "$d" "$?" "environment var"
149 printf 'halt\n' 2> /dev/null | "$exe" "$@" -e 4 > /dev/null
152 checktest_retcode "$d" "$?" "environment var"
165 if [ ! -d "$outdir" ]; then
171 printf 'halt\n' 2> /dev/null | "$exe" "$@" --redefine=print -e 'define print(x) { x }' -e 'print(5)' > "$redefine_out"
174 checktest "$d" "$err" "keyword redefinition" "$redefine_res" "$redefine_out"
176 printf 'halt\n' 2> /dev/null | "$exe" "$@" -r "abs" -r "else" -e 'abs = 5;else = 0' -e 'abs;else' > "$redefine_out"
179 checktest "$d" "$err" "keyword redefinition" "$redefine_res" "$redefine_out"
183 printf 'halt\n' 2> /dev/null | "$exe" "$@" -lr abs -e "perm(5, 1)" -e "0" > "$redefine_out"
186 checktest "$d" "$err" "keyword not redefined in builtin library" "$redefine_res" "$redefine_out"
190 "$exe" "$@" -r "break" -e 'define break(x) { x }' 2> "$redefine_out"
193 checkerrtest "$d" "$err" "keyword redefinition error" "$redefine_out" "$d"
195 "$exe" "$@" -e 'define read(x) { x }' 2> "$redefine_out"
198 checkerrtest "$d" "$err" "Keyword redefinition error without BC_REDEFINE_KEYWORDS" "$redefine_out" "$d"
207 printf 'halt\n' 2> /dev/null | "$exe" "$@" -f "$testdir/bc/misc1.txt" > "$multiline_expr_out"
210 checktest "$d" "$err" "multiline comment in expression file" "$testdir/bc/misc1_results.txt" \
216 printf 'halt\n' 2> /dev/null | "$exe" "$@" -f "$testdir/bc/errors/05.txt" 2> "$multiline_expr_out"
219 checkerrtest "$d" "$err" "multiline comment in expression file error" \
220 "$multiline_expr_out" "$d"
226 printf 'halt\n' 2> /dev/null | "$exe" "$@" -f "$testdir/bc/strings.txt" > "$multiline_expr_out"
229 checktest "$d" "$err" "multiline string in expression file" "$testdir/bc/strings_results.txt" \
235 printf 'halt\n' 2> /dev/null | "$exe" "$@" -f "$testdir/bc/errors/16.txt" 2> "$multiline_expr_out"
238 checkerrtest "$d" "$err" "multiline string in expression file with backslash error" \
239 "$multiline_expr_out" "$d"
241 printf 'halt\n' 2> /dev/null | "$exe" "$@" -f "$testdir/bc/errors/04.txt" 2> "$multiline_expr_out"
244 checkerrtest "$d" "$err" "multiline string in expression file error" \
245 "$multiline_expr_out" "$d"
254 printf '4s stuff\n' 2> /dev/null | "$exe" "$@" > /dev/null
256 checktest_retcode "$d" "$?" "environment var"
260 checktest_retcode "$d" "$?" "environment var"
269 printf 'three\n' 2> /dev/null | cut -c1-3 > /dev/null
281 if [ ! -d "$outdir" ]; then
287 "$testdir/dc/scripts/easter.sh" "$exe" 2021 "$@" 2> /dev/null | cut -c1-12 > "$easter_out"
290 checktest "$d" "$err" "Easter script" "$easter_out" "$easter_res"
305 if [ ! -d "$outdir" ]; then
311 printf '%s\n' "$halt" | "$exe" "$@" -e "gxpR" 2> /dev/null > "$ext_reg_out"
314 checktest "$d" "$err" "Extended register command" "$ext_reg_out" "$ext_reg_res"
318 printf '%s\n' "$halt" | "$exe" "$@" -x -e "gxpR" 2> /dev/null > "$ext_reg_out"
321 checktest "$d" "$err" "Extended register command" "$ext_reg_out" "$ext_reg_res"
327 out1="$outputdir/${d}_outputs/${d}_other.txt"
328 out2="$outputdir/${d}_outputs/${d}_other_test.txt"
330 printf 'Running %s line length tests...' "$d"
335 printf '%s\n' "$num" 2> /dev/null | "$exe" "$@" > "$out2"
337 checktest "$d" "$?" "line length" "$out1" "$out2"
342 printf '%s\n' "$num" 2> /dev/null | "$exe" "$@" > "$out2"
344 checktest "$d" "$?" "line length 2" "$out1" "$out2"
349 printf '%s\n' "$num" 2> /dev/null | "$exe" "$@" -L > "$out2"
351 checktest "$d" "$?" "line length 3" "$out1" "$out2"
354 printf '%s\n' "$lltest" 2> /dev/null | "$exe" "$@" -L > "$out2"
356 checktest "$d" "$?" "line length 3" "$out1" "$out2"
363 printf 'Running %s arg tests...' "$d"
365 f="$testdir/$d/add.txt"
367 results=$(cat "$testdir/$d/add_results.txt")
373 checktest "$d" "$?" "arg" "$out1" "$out2"
375 printf '%s\n' "$halt" 2> /dev/null | "$exe" "$@" -- "$f" "$f" "$f" "$f" > "$out2"
377 checktest "$d" "$?" "arg" "$out1" "$out2"
379 if [ "$d" = "bc" ]; then
380 printf '%s\n' "$halt" 2> /dev/null | "$exe" "$@" -i > /dev/null 2>&1
383 printf '%s\n' "$halt" 2> /dev/null | "$exe" "$@" -h > /dev/null
384 checktest_retcode "$d" "$?" "arg"
385 printf '%s\n' "$halt" 2> /dev/null | "$exe" "$@" -P > /dev/null
386 checktest_retcode "$d" "$?" "arg"
387 printf '%s\n' "$halt" 2> /dev/null | "$exe" "$@" -R > /dev/null
388 checktest_retcode "$d" "$?" "arg"
389 printf '%s\n' "$halt" 2> /dev/null | "$exe" "$@" -v > /dev/null
390 checktest_retcode "$d" "$?" "arg"
391 printf '%s\n' "$halt" 2> /dev/null | "$exe" "$@" -V > /dev/null
392 checktest_retcode "$d" "$?" "arg"
397 if [ "$d" = "bc" ]; then
403 printf '%s\n' "$data" 2> /dev/null | "$exe" "$@" -z > "$out2"
404 checktest "$d" "$?" "leading zero" "$out1" "$out2"
406 if [ "$d" = "bc" ] && [ "$extra_math" -ne 0 ]; then
408 printf '%s\n' "$halt" 2> /dev/null | "$exe" "$@" -lz "$testdir/bc/leadingzero.txt" > "$out2"
410 checktest "$d" "$?" "leading zero script" "$testdir/bc/leadingzero_results.txt" "$out2"
414 "$exe" "$@" -f "saotehasotnehasthistohntnsahxstnhalcrgxgrlpyasxtsaosysxsatnhoy.txt" > /dev/null 2> "$out2"
417 checkerrtest "$d" "$err" "invalid file argument" "$out2" "$d"
419 "$exe" "$@" "-$opt" -e "$exprs" > /dev/null 2> "$out2"
422 checkerrtest "$d" "$err" "invalid option argument" "$out2" "$d"
424 "$exe" "$@" "--$lopt" -e "$exprs" > /dev/null 2> "$out2"
427 checkerrtest "$d" "$err" "invalid long option argument" "$out2" "$d"
429 "$exe" "$@" "-u" -e "$exprs" > /dev/null 2> "$out2"
432 checkerrtest "$d" "$err" "unrecognized option argument" "$out2" "$d"
434 "$exe" "$@" "--uniform" -e "$exprs" > /dev/null 2> "$out2"
437 checkerrtest "$d" "$err" "unrecognized long option argument" "$out2" "$d"
439 "$exe" "$@" -f > /dev/null 2> "$out2"
442 checkerrtest "$d" "$err" "missing required argument to short option" "$out2" "$d"
444 "$exe" "$@" --file > /dev/null 2> "$out2"
447 checkerrtest "$d" "$err" "missing required argument to long option" "$out2" "$d"
449 "$exe" "$@" --version=5 > /dev/null 2> "$out2"
452 checkerrtest "$d" "$err" "given argument to long option with no argument" "$out2" "$d"
454 "$exe" "$@" -: > /dev/null 2> "$out2"
457 checkerrtest "$d" "$err" "colon short option" "$out2" "$d"
459 "$exe" "$@" --: > /dev/null 2> "$out2"
462 checkerrtest "$d" "$err" "colon long option" "$out2" "$d"
466 printf 'Running %s builtin variable arg tests...' "$d"
473 if [ "$d" = "bc" ]; then
474 data=$(printf 's=scale;i=ibase;o=obase;t=seed@2;ibase=A;obase=A;s;i;o;t;')
479 printf '%s\n' "$data" 2> /dev/null | "$exe" "$@" -S14 -I15 -O16 -E17.25 > "$out2"
480 checktest "$d" "$?" "builtin variable args" "$out1" "$out2"
482 printf '%s\n' "$data" 2> /dev/null | "$exe" "$@" --scale=14 --ibase=15 --obase=16 --seed=17.25 > "$out2"
483 checktest "$d" "$?" "builtin variable long args" "$out1" "$out2"
490 if [ "$d" = "bc" ]; then
496 printf '%s\n' "$data" 2> /dev/null | "$exe" "$@" -S14 -I15 -O16 > "$out2"
497 checktest "$d" "$?" "builtin variable args" "$out1" "$out2"
499 printf '%s\n' "$data" 2> /dev/null | "$exe" "$@" --scale=14 --ibase=15 --obase=16 > "$out2"
500 checktest "$d" "$?" "builtin variable long args" "$out1" "$out2"
504 if [ "$d" = "bc" ]; then
509 printf 'scale\n' 2> /dev/null | "$exe" "$@" -S100 -l > "$out2"
510 checktest "$d" "$?" "builtin variable args with math lib" "$out1" "$out2"
512 printf 'scale\n' 2> /dev/null | "$exe" "$@" --scale=100 --mathlib > "$out2"
513 checktest "$d" "$?" "builtin variable long args with math lib" "$out1" "$out2"
517 printf 'scale\n' 2> /dev/null | "$exe" "$@" -S100 > "$out2"
518 checktest "$d" "$?" "builtin variable args with math lib env arg" "$out1" "$out2"
520 printf 'scale\n' 2> /dev/null | "$exe" "$@" --scale=100 > "$out2"
521 checktest "$d" "$?" "builtin variable long args with math lib env arg" "$out1" "$out2"
525 printf 'scale\n' 2> /dev/null | "$exe" "$@" -l > "$out2"
526 checktest "$d" "$?" "builtin variable args with math lib arg" "$out1" "$out2"
530 printf 'scale\n' 2> /dev/null | "$exe" "$@" -l > "$out2"
531 checktest "$d" "$?" "builtin variable long args with math lib arg" "$out1" "$out2"
535 printf 'scale\n' 2> /dev/null | "$exe" "$@" --scale=18923c.rlg > /dev/null 2> "$out2"
538 checkerrtest "$d" "$err" "invalid command-line arg for builtin variable" "$out2" "$d"
542 printf 'seed\n' 2> /dev/null | "$exe" "$@" --seed=18923c.rlg > /dev/null 2> "$out2"
545 checkerrtest "$d" "$err" "invalid command-line arg for seed" "$out2" "$d"
551 printf 'Running %s directory test...' "$d"
553 "$exe" "$@" "$testdir" > /dev/null 2> "$out2"
556 checkerrtest "$d" "$err" "directory" "$out2" "$d"
560 printf 'Running %s binary file test...' "$d"
564 "$exe" "$@" "$bin" > /dev/null 2> "$out2"
567 checkerrtest "$d" "$err" "binary file" "$out2" "$d"
571 printf 'Running %s binary stdin test...' "$d"
573 cat "$bin" 2> /dev/null | "$exe" "$@" > /dev/null 2> "$out2"
576 checkerrtest "$d" "$err" "binary stdin" "$out2" "$d"
580 if [ "$d" = "bc" ]; then
582 printf 'Running %s limits tests...' "$d"
583 printf 'limits\n' 2> /dev/null | "$exe" "$@" /dev/null > "$out2" 2>&1
585 checktest_retcode "$d" "$?" "limits"
588 err_exit "$d did not produce output on the limits test" 1