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
omega-mv / seed / omc / gate10.sh
| 1 | #!/bin/sh |
| 2 | # gate10.sh -- compile-time layout queries (OMEGESE 9.11): sizeof T / sizeof S and offsetof S f. |
| 3 | # Both are constants of type ulong over the same 8-byte-cell struct layout that new/get/put use. |
| 4 | # RC=0 only when every case below ran and passed. |
| 5 | set -eu |
| 6 | R=$(CDPATH= cd -- "$(dirname "$0")/../.." && pwd) |
| 7 | cd "$R" |
| 8 | B=build/seed/r10 |
| 9 | T=seed/omc/tests/layout |
| 10 | S=seed/out/omc |
| 11 | mkdir -p "$B" |
| 12 | [ -x "$S" ] || { printf 'FAIL: %s missing; run sh seed/omega-from-seed.sh first\n' "$S" >&2; exit 1; } |
| 13 | bad() { printf 'FAIL: %s\n' "$*" >&2; exit 1; } |
| 14 | say() { printf '%s\n' "$*"; } |
| 15 | |
| 16 | n=0 |
| 17 | run_exit() { # name expect |
| 18 | n=$((n+1)) |
| 19 | set +e |
| 20 | "$S" < "$T/$1.om" > "$B/$1.bin" 2> "$B/$1.err" |
| 21 | crc=$? |
| 22 | set -e |
| 23 | [ "$crc" = 0 ] || bad "$1: compiler exit $crc ($(cat "$B/$1.err"))" |
| 24 | chmod +x "$B/$1.bin" |
| 25 | set +e |
| 26 | "$B/$1.bin" > /dev/null |
| 27 | rrc=$? |
| 28 | set -e |
| 29 | [ "$rrc" = "$2" ] || bad "$1: ran $rrc, wanted $2" |
| 30 | say "PASS $1 exit $rrc" |
| 31 | } |
| 32 | |
| 33 | refuse() { # name expect-error |
| 34 | n=$((n+1)) |
| 35 | set +e |
| 36 | "$S" < "$T/$1.om" > "$B/$1.bin" 2> "$B/$1.err" |
| 37 | crc=$? |
| 38 | set -e |
| 39 | [ "$crc" = "$2" ] || bad "$1: compiler exit $crc, wanted $2 ($(cat "$B/$1.err"))" |
| 40 | grep -q "error $2" "$B/$1.err" || bad "$1: diagnostic does not name error $2" |
| 41 | say "PASS $1 error $2" |
| 42 | } |
| 43 | |
| 44 | run_exit sizes 0 |
| 45 | refuse neg_type 16 |
| 46 | refuse neg_field 3 |
| 47 | refuse neg_struct 3 |
| 48 | refuse neg_void 9 |
| 49 | |
| 50 | say "PASS gate10 $n cases" |
| 51 | exit 0 |