diff options
author | Stefan Eßer <se@FreeBSD.org> | 2022-06-11 09:50:28 +0000 |
---|---|---|
committer | Stefan Eßer <se@FreeBSD.org> | 2022-06-11 09:50:28 +0000 |
commit | 5bdd626528a2bb3e341e283b2eb279235997b8f4 (patch) | |
tree | 76ed2ffea2671f693d61e61f456805da8c39c7b2 /tests | |
parent | ed0603704174b01c25b49efc08c82e1532dc5622 (diff) | |
download | src-5bdd626528a2bb3e341e283b2eb279235997b8f4.tar.gz src-5bdd626528a2bb3e341e283b2eb279235997b8f4.zip |
Diffstat (limited to 'tests')
-rw-r--r-- | tests/bcl.c | 69 | ||||
-rwxr-xr-x | tests/history.py | 10 | ||||
-rwxr-xr-x | tests/other.sh | 58 |
3 files changed, 88 insertions, 49 deletions
diff --git a/tests/bcl.c b/tests/bcl.c index e1d527ad8721..6f462ce9dc4f 100644 --- a/tests/bcl.c +++ b/tests/bcl.c @@ -43,12 +43,15 @@ * Takes an error code and aborts if it actually is an error. * @param e The error code. */ -static void err(BclError e) { +static void +err(BclError e) +{ if (e != BCL_ERROR_NONE) abort(); } -int main(void) { - +int +main(void) +{ BclError e; BclContext ctxt; size_t scale; @@ -135,15 +138,13 @@ int main(void) { res = bcl_string(n5); - if (strcmp(res, "-351137.0060159482")) - err(BCL_ERROR_FATAL_UNKNOWN_ERR); + if (strcmp(res, "-351137.0060159482")) err(BCL_ERROR_FATAL_UNKNOWN_ERR); free(res); res = bcl_string(n6); - if (strcmp(res, ".00000152374405414")) - err(BCL_ERROR_FATAL_UNKNOWN_ERR); + if (strcmp(res, ".00000152374405414")) err(BCL_ERROR_FATAL_UNKNOWN_ERR); free(res); @@ -156,8 +157,7 @@ int main(void) { res = bcl_string(bcl_dup(n4)); - if (strcmp(res, "94538.1346457028")) - err(BCL_ERROR_FATAL_UNKNOWN_ERR); + if (strcmp(res, "94538.1346457028")) err(BCL_ERROR_FATAL_UNKNOWN_ERR); free(res); @@ -178,8 +178,7 @@ int main(void) { res = bcl_string(bcl_dup(n4)); - if (strcmp(res, "94538")) - err(BCL_ERROR_FATAL_UNKNOWN_ERR); + if (strcmp(res, "94538")) err(BCL_ERROR_FATAL_UNKNOWN_ERR); free(res); @@ -195,8 +194,7 @@ int main(void) { res = bcl_string(bcl_dup(n4)); - if (strcmp(res, "94538")) - err(BCL_ERROR_FATAL_UNKNOWN_ERR); + if (strcmp(res, "94538")) err(BCL_ERROR_FATAL_UNKNOWN_ERR); free(res); @@ -235,8 +233,7 @@ int main(void) { bcl_num_free(n); // Test leading zeroes. - if (bcl_leadingZeroes()) - err(BCL_ERROR_FATAL_UNKNOWN_ERR); + if (bcl_leadingZeroes()) err(BCL_ERROR_FATAL_UNKNOWN_ERR); n = bcl_parse("0.01"); err(bcl_err(n)); @@ -251,84 +248,70 @@ int main(void) { err(bcl_err(n4)); res = bcl_string(bcl_dup(n)); - if (strcmp(res, ".01")) - err(BCL_ERROR_FATAL_UNKNOWN_ERR); + if (strcmp(res, ".01")) err(BCL_ERROR_FATAL_UNKNOWN_ERR); free(res); res = bcl_string(bcl_dup(n2)); - if (strcmp(res, "-.01")) - err(BCL_ERROR_FATAL_UNKNOWN_ERR); + if (strcmp(res, "-.01")) err(BCL_ERROR_FATAL_UNKNOWN_ERR); free(res); res = bcl_string(bcl_dup(n3)); - if (strcmp(res, "1.01")) - err(BCL_ERROR_FATAL_UNKNOWN_ERR); + if (strcmp(res, "1.01")) err(BCL_ERROR_FATAL_UNKNOWN_ERR); free(res); res = bcl_string(bcl_dup(n4)); - if (strcmp(res, "-1.01")) - err(BCL_ERROR_FATAL_UNKNOWN_ERR); + if (strcmp(res, "-1.01")) err(BCL_ERROR_FATAL_UNKNOWN_ERR); free(res); bcl_setLeadingZeroes(true); - if (!bcl_leadingZeroes()) - err(BCL_ERROR_FATAL_UNKNOWN_ERR); + if (!bcl_leadingZeroes()) err(BCL_ERROR_FATAL_UNKNOWN_ERR); res = bcl_string(bcl_dup(n)); - if (strcmp(res, "0.01")) - err(BCL_ERROR_FATAL_UNKNOWN_ERR); + if (strcmp(res, "0.01")) err(BCL_ERROR_FATAL_UNKNOWN_ERR); free(res); res = bcl_string(bcl_dup(n2)); - if (strcmp(res, "-0.01")) - err(BCL_ERROR_FATAL_UNKNOWN_ERR); + if (strcmp(res, "-0.01")) err(BCL_ERROR_FATAL_UNKNOWN_ERR); free(res); res = bcl_string(bcl_dup(n3)); - if (strcmp(res, "1.01")) - err(BCL_ERROR_FATAL_UNKNOWN_ERR); + if (strcmp(res, "1.01")) err(BCL_ERROR_FATAL_UNKNOWN_ERR); free(res); res = bcl_string(bcl_dup(n4)); - if (strcmp(res, "-1.01")) - err(BCL_ERROR_FATAL_UNKNOWN_ERR); + if (strcmp(res, "-1.01")) err(BCL_ERROR_FATAL_UNKNOWN_ERR); free(res); bcl_setLeadingZeroes(false); - if (bcl_leadingZeroes()) - err(BCL_ERROR_FATAL_UNKNOWN_ERR); + if (bcl_leadingZeroes()) err(BCL_ERROR_FATAL_UNKNOWN_ERR); res = bcl_string(n); - if (strcmp(res, ".01")) - err(BCL_ERROR_FATAL_UNKNOWN_ERR); + if (strcmp(res, ".01")) err(BCL_ERROR_FATAL_UNKNOWN_ERR); free(res); res = bcl_string(n2); - if (strcmp(res, "-.01")) - err(BCL_ERROR_FATAL_UNKNOWN_ERR); + if (strcmp(res, "-.01")) err(BCL_ERROR_FATAL_UNKNOWN_ERR); free(res); res = bcl_string(n3); - if (strcmp(res, "1.01")) - err(BCL_ERROR_FATAL_UNKNOWN_ERR); + if (strcmp(res, "1.01")) err(BCL_ERROR_FATAL_UNKNOWN_ERR); free(res); res = bcl_string(n4); - if (strcmp(res, "-1.01")) - err(BCL_ERROR_FATAL_UNKNOWN_ERR); + if (strcmp(res, "-1.01")) err(BCL_ERROR_FATAL_UNKNOWN_ERR); free(res); diff --git a/tests/history.py b/tests/history.py index c74dfd72f0a7..f1787a27e864 100755 --- a/tests/history.py +++ b/tests/history.py @@ -251,7 +251,7 @@ def test_sigint_sigquit(exe, args, env): try: send(child, "\t") - expect(child, " ") + expect(child, "\t") send(child, "\x03") # send(child, "\x1c") wait(child) @@ -320,7 +320,7 @@ def test_sigint(exe, args, env): try: send(child, "\t") - expect(child, " ") + expect(child, "\t") send(child, "\x03") wait(child) except pexpect.TIMEOUT: @@ -355,7 +355,7 @@ def test_sigtstp(exe, args, env): try: send(child, "\t") - expect(child, " ") + expect(child, "\t") send(child, "\x13") time.sleep(1) if not child.isalive(): @@ -395,7 +395,7 @@ def test_sigstop(exe, args, env): try: send(child, "\t") - expect(child, " ") + expect(child, "\t") send(child, "\x14") time.sleep(1) if not child.isalive(): @@ -678,7 +678,7 @@ def test_bc7(exe, args, env): send(child, "\x1b[0;4\x1b[0A") send(child, "\n") expect(child, prompt) - send(child, " ") + send(child, "\t") send(child, "\x1bb\x1bb\x1bb\x1bb\x1bb\x1bb\x1bb\x1bb\x1bb\x1bb\x1bb\x1bb") send(child, "\x1bf\x1bf\x1bf\x1bf\x1bf\x1bf\x1bf\x1bf\x1bf\x1bf\x1bf\x1bf") send(child, "\n") diff --git a/tests/other.sh b/tests/other.sh index 64ba877a20c0..4e277059a32c 100755 --- a/tests/other.sh +++ b/tests/other.sh @@ -62,6 +62,8 @@ else halt="q" fi +mkdir -p "$outputdir" + # For tests later. num=100000000000000000000000000000000000000000000000000000000000000000000000000000 num2="$num" @@ -143,7 +145,7 @@ if [ "$d" = "bc" ]; then redefine_res="$outputdir/bc_outputs/redefine.txt" redefine_out="$outputdir/bc_outputs/redefine_results.txt" - outdir=$(dirname "$easter_out") + outdir=$(dirname "$redefine_out") if [ ! -d "$outdir" ]; then mkdir -p "$outdir" @@ -416,6 +418,60 @@ checkerrtest "$d" "$err" "colon long option" "$out2" "$d" printf 'pass\n' +printf 'Running %s builtin variable arg tests...' "$d" + +if [ "$extra_math" -ne 0 ]; then + + out=$(printf '14\n15\n16\n17.25\n') + printf '%s\n' "$out" > "$out1" + + if [ "$d" = "bc" ]; then + data=$(printf 's=scale;i=ibase;o=obase;t=seed@2;ibase=A;obase=A;s;i;o;t;') + else + data=$(printf 'J2@OIKAiAopRpRpRpR') + fi + + printf '%s\n' "$data" | "$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" + checktest "$d" "$?" "builtin variable long args" "$out1" "$out2" + +else + + out=$(printf '14\n15\n16\n') + printf '%s\n' "$out" > "$out1" + + if [ "$d" = "bc" ]; then + data=$(printf 's=scale;i=ibase;o=obase;ibase=A;obase=A;s;i;o;') + else + data=$(printf 'OIKAiAopRpRpR') + fi + + printf '%s\n' "$data" | "$exe" "$@" -S14 -I15 -O16 > "$out2" + checktest "$d" "$?" "builtin variable args" "$out1" "$out2" + + printf '%s\n' "$data" | "$exe" "$@" --scale=14 --ibase=15 --obase=16 > "$out2" + checktest "$d" "$?" "builtin variable long args" "$out1" "$out2" + +fi + +printf 'scale\n' | "$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" + err="$?" + + checkerrtest "$d" "$err" "invalid command-line arg for seed" "$out2" "$d" + +fi + +printf 'pass\n' + printf 'Running %s directory test...' "$d" "$exe" "$@" "$testdir" > /dev/null 2> "$out2" |