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 / gate9.sh

50 lines · 1392 bytes Raw Blame History
1#!/bin/sh
2# gate9.sh -- grouping parentheses (OMEGESE 3). The lexer splits '(' and ')' even when they touch a
3# value, and a group returns exactly the value inside it. seed/out/omc is the compiler under test.
4# RC=0 only when every case below ran and passed.
5set -eu
6R=$(CDPATH= cd -- "$(dirname "$0")/../.." && pwd)
7cd "$R"
8B=build/seed/r9
9T=seed/omc/tests/paren
10S=seed/out/omc
11mkdir -p "$B"
12[ -x "$S" ] || { printf 'FAIL: %s missing; run sh seed/omega-from-seed.sh first\n' "$S" >&2; exit 1; }
13bad() { printf 'FAIL: %s\n' "$*" >&2; exit 1; }
14say() { printf '%s\n' "$*"; }
15
16n=0
17run_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
33refuse() { # 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
44run_exit basic 0
45run_exit float 4
46refuse neg_ambiguous 11
47refuse neg_unclosed 16
48
49say "PASS gate9 $n cases"
50exit 0