diff options
| author | 2026-10-14 09:09:21 +0330 | |
|---|---|---|
| committer | 2026-10-14 09:09:21 +0330 | |
| commit | dc7f7407e08f54e4a2a3c1d1723b2a7d6959532d (patch) | |
| tree | d1de9f471a99951c57896f85b5e5523eeb96cee1 /docs/history/10-zc/code/test.sh | |
| parent | todo: sync docs, examples and fixtures with the include format, and test acto... (diff) | |
docs: archive the frozen stage code as one compressed tarball
docs/history kept six stages with a full copy of the project under code/,
3.8 mb of sources duplicated from stage to stage and already superseded. store
them as docs/history/code-snapshots.tar.gz, 0.66 mb, and extract one in place
to read it. every stage's notes.md stays browsable, and the index says where the
code went and how to get it back.
the top-level README points at the archive too. its other two links into
docs/history, 21-micro and 35-bench, were notes that were never kept and do not
resolve; the index now records that.
Diffstat (limited to 'docs/history/10-zc/code/test.sh')
| -rwxr-xr-x | docs/history/10-zc/code/test.sh | 48 |
1 files changed, 0 insertions, 48 deletions
diff --git a/docs/history/10-zc/code/test.sh b/docs/history/10-zc/code/test.sh deleted file mode 100755 index 09b92c3..0000000 --- a/docs/history/10-zc/code/test.sh +++ /dev/null @@ -1,48 +0,0 @@ -#!/bin/bash -# full check: bootstraps the compiler from zc0, verifies the fixpoint, then runs -# the examples and tests on the portable interpreter (host) and on the arm64 -# jit under qemu. needs gcc; the jit half needs aarch64-linux-gnu-gcc and -# qemu-aarch64 (it's skipped if they're missing). -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/rt.zc src/compiler.zc; } -selfc(){ (cat tools/build.zc; printf '`'; src) | $1 > $2; } - -# bootstrap: zc0 (c) -> g0, g0 compiles compiler.zc -> g1, g1 compiles it -> g2 -gcc -O1 -w zc0.c -o $T/zc0 && gcc -O1 -w mkgenome.c -o $T/mkg || exit 1 -mkdir $T/s0 $T/s1 -cp core.c io_linux.c $T/s0/; cp core.c io_linux.c $T/s1/ -src | $T/zc0 > $T/s0/genome.h || exit 1 -gcc -O2 -w -DJTYPE=int $T/s0/core.c $T/s0/io_linux.c -o $T/zy0 -selfc $T/zy0 $T/g1.bin; $T/mkg < $T/g1.bin > $T/s1/genome.h -gcc -O2 -w -DJTYPE=int $T/s1/core.c $T/s1/io_linux.c -o $T/zy1 -selfc $T/zy1 $T/g2.bin -cmp -s $T/g1.bin $T/g2.bin && chk 1 1 "fixpoint: the compiler compiles itself to the same $(($(stat -c %s $T/g1.bin) / 4)) words" || chk 0 1 "fixpoint" -cmp -s $T/s1/genome.h genome.h && chk 1 1 "genome.h is up to date" || chk 0 1 "genome.h is stale (cp the bootstrap output over it)" - -run(){ # $1 = vm command, $2 = label - local vm="$1" l="$2" - chk "$($vm < examples/hello.zc)" "hello, world!" "$l hello" - chk "$($vm < examples/fact.zc | tr '\n' '/')" "1101110101111100000000/3628800/" "$l factorial" - chk "$( (cat examples/echo.zc; printf '`abc\n') | $vm)" "abc" "$l echo after the backtick" - chk "$($vm < examples/selfpatch.zc)" "ABC" "$l self-patching code" - chk "$($vm < examples/lists.zc | tr '\n' '/')" "[0 1 4 9 16 25]/live: 7/after the block: 0/" "$l ownership frees everything" - chk "$( (cat examples/repl.zc; printf '`fn sq(x) { return x * x; }`putn(sq(7)); putc(10);`puts("hi\\n");') | $vm | tr '\n' '/')" "49/hi/" "$l repl on the resident compiler" - chk "$($vm < tests/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/umd.zc)" "100 6 0 15 99 5 5" "$l u m d lifetimes" - chk "$($vm < tests/gc.zc)" "1000 1 900 1 199900" "$l mark-sweep collector" - chk "$($vm < tests/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/misc.zc | tr '\n' '/')" "45/54321/ok/" "$l compile-time eval, patched mnemonics, unchecked" - local r; r=$(tests/runerr.sh "$vm" | tail -1) - chk "$r" "analyzer rejects: $(ls tests/errors/*.zc | wc -l) passed, 0 failed" "$l analyzer rejects every bad program" -} -gcc -O2 -w -DJTYPE=int core.c io_linux.c -o $T/zy -run $T/zy "interp" -if command -v aarch64-linux-gnu-gcc >/dev/null && command -v qemu-aarch64 >/dev/null; then - aarch64-linux-gnu-gcc -O2 -w -DJTYPE=int -static core.c io_linux.c -o $T/zyj || exit 1 - printf '#!/bin/sh\nexec qemu-aarch64 %s "$@"\n' $T/zyj > $T/jit; chmod +x $T/jit - run $T/jit "jit" - selfc $T/jit $T/gj.bin; cmp -s $T/g1.bin $T/gj.bin && chk 1 1 "jit self-compile matches" || chk 0 1 "jit self-compile matches" -else echo "skip jit (no aarch64 toolchain or qemu)"; fi -echo "$ok passed, $bad failed"; [ $bad = 0 ] |
