aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGavin D. Howard <gavin@gavinhoward.com>2023-02-25 23:16:12 -0700
committerGavin D. Howard <gavin@gavinhoward.com>2023-02-25 23:16:12 -0700
commit0b669e88aabe436731d3ae845fd5fe9e67c32361 (patch)
tree89bbd53c0400c0f12e4ffbf7b8e822b93b8bfaca
parent4dc9f52a346264e6bd080ada9bd5521de8c56554 (diff)
downloadbc-0b669e88aabe436731d3ae845fd5fe9e67c32361.tar.gz
Add a test for multiple reads
Signed-off-by: Gavin D. Howard <gavin@gavinhoward.com>
-rwxr-xr-xtests/read.sh13
1 files changed, 13 insertions, 0 deletions
diff --git a/tests/read.sh b/tests/read.sh
index d7be18fd..4881c10d 100755
--- a/tests/read.sh
+++ b/tests/read.sh
@@ -74,6 +74,7 @@ results="$testdir/$d/read_results.txt"
errors="$testdir/$d/read_errors.txt"
out="$outputdir/${d}_outputs/read_results.txt"
+multiple_res="$outputdir/${d}_outputs/read_multiple_results.txt"
outdir=$(dirname "$out")
# Make sure the directory exists.
@@ -89,11 +90,13 @@ if [ "$d" = "bc" ]; then
halt="halt"
read_call="read()"
read_expr="${read_call}\n5+5;"
+ read_multiple=$(printf '%s\n%s\n%s\n' "3" "2" "1")
else
options="-x"
halt="q"
read_call="?"
read_expr="${read_call}"
+ read_multiple=$(printf '%spR\n%spR\n%spR\n' "3" "2" "1")
fi
# I use these, so unset them to make the tests work.
@@ -116,6 +119,16 @@ done < "$name"
printf 'pass\n'
+printf 'Running %s read multiple...' "$d"
+
+printf '3\n2\n1\n' > "$multiple_res"
+
+# Run multiple read() calls.
+printf '%s\n' "$read_multiple" | "$exe" "$@" "$options" -e "$read_call" -e "$read_call" -e "$read_call" > "$out"
+checktest "$d" "$?" 'read multiple' "$multiple_res" "$out"
+
+printf 'pass\n'
+
printf 'Running %s read errors...' "$d"
# Run read on every line.