aboutsummaryrefslogtreecommitdiff
path: root/tests/test.sh
diff options
context:
space:
mode:
Diffstat (limited to 'tests/test.sh')
-rwxr-xr-xtests/test.sh16
1 files changed, 12 insertions, 4 deletions
diff --git a/tests/test.sh b/tests/test.sh
index 809da6e..ec93827 100755
--- a/tests/test.sh
+++ b/tests/test.sh
@@ -25,7 +25,9 @@
cd "$(dirname "$0")/.."; T=$(mktemp -d); trap 'rm -rf $T' EXIT
ok=0; bad=0
chk(){ if [ "$1" = "$2" ]; then echo "ok $3"; ok=$((ok+1)); else echo "FAIL $3: got [$1]"; bad=$((bad+1)); fi; }
-src(){ cat src/runtime/rt.zc src/core/core.zc src/compiler/compiler.zc; }
+# the compiler is the files listed in src/compiler/parts, in that order
+ccparts(){ tr -d '\r' < src/compiler/parts | sed 's|^|src/compiler/|'; }
+src(){ cat src/runtime/rt.zc src/core/core.zc $(ccparts); }
# -j N runs N sections at a time: j is how many cores to use. each section
# writes its own log, so the output still reads in the order it always did.
JOBS=1; QUICK=0; SELECT=""
@@ -65,7 +67,7 @@ mkdir -p build && $CC -shared -fPIC -w tests/data/sbv.c -o build/sbv.so || exit
selfc(){ (cat src/tools/build.zc; printf '`'; src) | $1 > $2; }
-# bootstrap: zc0 (c) -> g0, g0 compiles compiler.zc -> g1, g1 compiles it -> g2.
+# bootstrap: zc0 (c) -> g0, g0 compiles the compiler -> g1, g1 compiles it -> g2.
# each stage's core embeds the image in its own directory
mkdir $T/s0 $T/s1
src | $T/zc0 > $T/s0/g0.bin && $T/mkg < $T/s0/g0.bin > $T/s0/genome.bin || exit 1
@@ -103,6 +105,7 @@ run(){ # $1 = vm command, $2 = label
chk "$($vm < tests/programs/basics.zc | tr '\n' '/')" "285 610 42 512/hey 65 -3 -2 1024 -8/12456/757/9 100-101/5/ok/" "$l language basics"
chk "$($vm < tests/programs/umd.zc)" "100 6 0 15 99 5 5" "$l u m d lifetimes"
chk "$($vm < tests/programs/names.zc)" "12 1 8" "$l u, m and d are ordinary names"
+ chk "$($vm < tests/programs/zc0umd.zc | tr '\n' '/')" "6 6 28 24 37 10/42 41 336 59/21 6 72 120 105 21/" "$l u, m and d as names, products, recasts and tags (the zc0 subset)"
chk "$($vm < tests/programs/gc.zc)" "1000 1 900 1 199900" "$l mark-sweep collector"
chk "$($vm < tests/programs/meta.zc | tr '\n' '/')" "1024 19/unless ok/rrr/15 42/7/42/7/144/" "$l parse words, quote, eval, load, operator tables"
chk "$($vm < tests/programs/misc.zc | tr '\n' '/')" "45/54321/ok/" "$l compile-time eval, patched mnemonics, unchecked"
@@ -227,7 +230,7 @@ s_interp() {
grep -v '^ok' $T/arrays.out
chk $r 0 "native array receiver, algorithm and ownership contracts"
# actors are a library: nothing the compiler compiles or reads by default mentions them
- chk "$(grep -il actor src/compiler/compiler.zc src/runtime/rt.zc src/core/core.zc src/lib/std.zc src/lib/icon.zc src/tools/build.zc | wc -l)" "0" "no actor code in the compiler or anything it reads by default"
+ chk "$(grep -il actor $(ccparts) src/runtime/rt.zc src/core/core.zc src/lib/std.zc src/lib/icon.zc src/tools/build.zc | wc -l)" "0" "no actor code in the compiler or anything it reads by default"
python3 tests/drivers/actor_test.py $T/zy > $T/actor.out 2>&1; r=$?
grep -v '^ok' $T/actor.out
chk $r 0 "native isolated actor acceptance, rejection and regression fixtures"
@@ -359,6 +362,9 @@ s_runonly() {
runonly strings-ex examples/strings.zc
runonly share tests/programs/share.zc
runonly embed tests/programs/embed_top.zc
+ runonly zc0bstr tests/programs/zc0bstr.zc
+ runonly zc0umd tests/programs/zc0umd.zc
+ runonly wiring examples/wiring.zc
d=$T/run-echo; GENMAP=$T/genmap bash src/tools/automap.sh run $d src/runtime/run.zc examples/echo.zc >/dev/null && cp src/micro/micro.c src/micro/micro_port.h src/micro/port_linux.c src/micro/port_stub.c src/core/fops.h src/core/bops.h src/core/stack.h src/core/genome.h $d/ \
&& $CC -pthread -DZY_THREADS -O2 -w -fwrapv $d/micro.c $d/port_linux.c -o $T/zymr \
&& chk "$(printf 'abc\n' | $T/zymr | tr '\n' '/')" "$( (cat examples/echo.zc; printf '`abc\n') | $T/zy | tr '\n' '/')" "run echo" \
@@ -524,7 +530,9 @@ s_lsp() {
done
chk "$($lsp < examples/struct_closure_opt.zc | grep -c error)" "0" "lsp: methods and closures check clean"
# a file of a larger build checks on its own: its bodyless declarations are not errors in check mode
- for f in src/runtime/rt.zc src/runtime/run.zc src/compiler/compiler.zc src/lsp/server.zc; do chk "$($lsp < $f | grep -c ': error:')" "0" "lsp: $f checks alone"; done
+ for f in src/runtime/rt.zc src/runtime/run.zc src/lsp/server.zc; do chk "$($lsp < $f | grep -c ': error:')" "0" "lsp: $f checks alone"; done
+ # the compiler is several files that only make sense together: check them as one document
+ chk "$(cat $(ccparts) | $lsp | grep -c ': error:')" "0" "lsp: the compiler (src/compiler/parts) checks alone"
chk "$($lsp < tests/programs/decl_undefined.zc)" "no errors" "lsp: a bodyless declaration is not an error in check mode"
chk "$($lsp < tests/programs/undefined_call.zc | grep -c ': error:')" "1" "lsp: a call to a name nothing defines is still an error"
chk "$($lsp --annotate < tests/programs/annotate.zc | md5sum)" "$(md5sum < tests/programs/annotate.expected)" "lsp --annotate writes the types the compiler can see into a program"