aboutsummaryrefslogtreecommitdiff
path: root/tests/test.sh
diff options
context:
space:
mode:
authorGravatar zinc <zinc@downsta.ir> 2026-10-14 05:55:19 +0000
committerGravatar zinc <zinc@downsta.ir> 2026-10-14 05:55:19 +0000
commit05f7b7e09ad503e4eac4f757de0d7329174f6437 (patch)
tree768931192a69eff878d8f149c418fff55b0fdf8e /tests/test.sh
parentdocs: archive the frozen stage code as one compressed tarball (diff)
analyzer: close the ownership gaps that stopped the compiler compiling itself
an owned local can now move into a released owner declared in the same or an outer block, and g = m*x lends a local owner to a global until the global is assigned again in the same block. leaving that block, giving the local away, or returning while the lend is open is an error. recasting a plain local now names it and says it has no ownership to recast. methdef and syntax_resident use the supported spellings, so make genome reaches its fixpoint from a clean checkout. runerr.sh reads the first // expect: line, since the include headers moved it off line 1.
Diffstat (limited to 'tests/test.sh')
-rwxr-xr-xtests/test.sh5
1 files changed, 3 insertions, 2 deletions
diff --git a/tests/test.sh b/tests/test.sh
index b80f548..16aa1a9 100755
--- a/tests/test.sh
+++ b/tests/test.sh
@@ -116,6 +116,7 @@ run(){ # $1 = vm command, $2 = label
chk "$($vm < tests/programs/o3push.zc | md5sum)" "$(md5sum < tests/programs/o3push.expected)" "$l push and pop of a growable array are inline in o3"
chk "$($vm < tests/programs/o3copy.zc)" "520507 1005" "$l o3 copies of a loop variable read the source instead"
chk "$($vm < tests/programs/borrowmove.zc)" "6" "$l storing into a borrowed object moves it"
+ chk "$($vm < tests/programs/ownmove.zc)" "7 50 0 1" "$l an owned local moves into a released owner, and a global borrows a local until it is restored"
chk "$($vm < tests/programs/alias.zc)" "11 22 4 8" "$l aliases of a live owner: arithmetic, field, index"
chk "$($vm < tests/programs/quarantine.zc)" "0 1234" "$l quarantine: stale alias reads intact data, second free is a no-op"
chk "$($vm < tests/programs/recycle.zc)" "1 0 1" "$l recycle returns a dropped block to its size class"
@@ -160,7 +161,7 @@ ABC" "$l o3 lifts byte loads and stores"
chk "$($vm < examples/strings.zc)" "hello, zc
9 42" "$l byte string example"
chk "$(ZC_BSTR=zybyte $vm < tests/programs/bstr_io.zc)" "byte-io 7 7 1 6 122 101" "$l byte-string file and getenv"
- chk "$($vm < tests/programs/manyerrors.zc | tr '\n' '/')" "zc: line 3: expected an expression, found ';'/zc: line 4: x: m object is never used/zc: line 5: type error: initializer: expected char*, got int/zc: line 6: expected ';', found '}'/zc: 4 errors/" "$l several errors in one run"
+ chk "$($vm < tests/programs/manyerrors.zc | tr '\n' '/')" "zc: line 6: expected an expression, found ';'/zc: line 7: x: owned object is never used/zc: line 8: type error: initializer: expected char*, got int/zc: line 9: expected ';', found '}'/zc: 4 errors/" "$l several errors in one run"
chk "$($vm < tests/programs/overflow_return.zc 2>&1)" "zy: return stack overflow" "$l return stack overflow is caught"
chk "$($vm < tests/programs/overflow_data.zc 2>&1)" "zy: data stack overflow" "$l data stack overflow is caught"
chk "$($vm < tests/programs/overflow_frame.zc 2>&1)" "zc: out of heap memory" "$l frame growth stops at a configured memory limit"
@@ -489,7 +490,7 @@ s_lsp() {
if bash src/tools/mklsp.sh $T/lsp >/dev/null 2>&1; then
lsp=$T/lsp/zclsp
chk "$($lsp < examples/hello.zc)" "no errors" "lsp: a clean program"
- chk "$($lsp < tests/errors/back_to_m.zc | head -1 | cut -d' ' -f2-)" "error: $(head -1 tests/errors/back_to_m.zc | sed 's#^// expect: ##')" "lsp: the compiler's own message"
+ chk "$($lsp < tests/errors/back_to_m.zc | head -1 | cut -d' ' -f2-)" "error: $(grep -m1 '^// expect: ' tests/errors/back_to_m.zc | sed 's#^// expect: ##')" "lsp: the compiler's own message"
h=$($lsp < examples/opt_test.zc)
for w in "is never read" "is never reassigned; make it a const" "is a shift; write << 3" "unannotated numeric literal 1234" "new inside a loop" "stack buffer"; do
case "$h" in *"$w"*) chk 1 1 "lsp hint: $w";; *) chk 0 1 "lsp hint: $w";; esac