interplane.Get Omega
Read in your language

omega-mv

Omega: a language for verified programs, semantic identity and machine realization. Seed-born work and existing implementations have distinct provenance.

Brought by drakestapleton

branch main Branches Tags History

omega-mv / seed / omc / gate7.sh

75 lines · 1997 bytes Raw Blame History
1#!/bin/sh
2# gate7.sh -- break, continue and trap (OMEGESE 9.8). The compiler under test is seed/out/omc, which
3# seed/omega-from-seed.sh has already built and proved self-identical. om4 refuses all three words
4# (they are omc-only), and that refusal is checked here too. RC=0 only when every case passed.
5set -eu
6R=$(CDPATH= cd -- "$(dirname "$0")/../.." && pwd)
7cd "$R"
8B=build/seed/r7
9T=seed/omc/tests/loop
10S=seed/out/omc
11OM4=seed/rung4/om4.bin
12mkdir -p "$B"
13[ -x "$S" ] || { printf 'FAIL: %s missing; run sh seed/omega-from-seed.sh first\n' "$S" >&2; exit 1; }
14bad() { printf 'FAIL: %s\n' "$*" >&2; exit 1; }
15say() { printf '%s\n' "$*"; }
16
17# om4 has neither word: each such line must be refused, never compiled.
18for f in w1.om c2.om t1.om; do
19 set +e
20 "$OM4" < "$T/$f" > "$B/om4-$f.bin" 2> "$B/om4-$f.err"
21 orc=$?
22 set -e
23 [ "$orc" != 0 ] || bad "om4 accepted $f (break/trap are omc-only)"
24done
25say "PASS om4 refuses break and trap"
26
27n=0
28run_exit() { # name expect
29 n=$((n+1))
30 set +e
31 "$S" < "$T/$1.om" > "$B/$1.bin" 2> "$B/$1.err"
32 crc=$?
33 set -e
34 [ "$crc" = 0 ] || bad "$1: compiler exit $crc ($(cat "$B/$1.err"))"
35 chmod +x "$B/$1.bin"
36 set +e
37 "$B/$1.bin" > /dev/null
38 rrc=$?
39 set -e
40 [ "$rrc" = "$2" ] || bad "$1: ran $rrc, wanted $2"
41 say "PASS $1 exit $rrc"
42}
43
44refuse() { # name expect-error
45 n=$((n+1))
46 set +e
47 "$S" < "$T/$1.om" > "$B/$1.bin" 2> "$B/$1.err"
48 crc=$?
49 set -e
50 [ "$crc" = "$2" ] || bad "$1: compiler exit $crc, wanted $2 ($(cat "$B/$1.err"))"
51 grep -q "error $2" "$B/$1.err" || bad "$1: diagnostic does not name error $2"
52 say "PASS $1 error $2"
53}
54
55run_exit w1 6
56run_exit f1 3
57run_exit n1 33
58run_exit n2 4
59run_exit n3 3
60run_exit c1 18
61run_exit c2 12
62run_exit c3 36
63run_exit c4 0
64run_exit c5 104
65run_exit t1 105
66run_exit t2 107
67refuse bad_outside 9
68refuse bad_after 17
69refuse bad_continue 9
70refuse bad_after_continue 17
71refuse bad_trap0 8
72refuse bad_trap15 8
73
74say "PASS gate7 $n cases"
75exit 0