Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-mv/blob/main/seed/omc/gate14.sh # 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 Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / seed / omc / gate14.sh` 78 lines ยท 4170 bytes Raw Blame History 1 #!/bin/sh 2 # gate14.sh -- numeric conformance. Expected values were computed exactly in Wolfram Language through 3 # the Wolfram MCP server (agenttools.wolfram.com, Wolfram 2026.09.15); the table and the exact 4 # expressions are in evidence/SEED-0/num-conformance/wolfram.txt. The gate is independent of the 5 # compiler: it only compares exit statuses. 6 # 7 # Value rows return the low byte of the exact result (main's value mod 256). Trap rows must stop with 8 # 100 + trap code: 1 signed overflow, 2 divide/remainder by zero, 3 bounds, 4 loop bound, 9 # 5 conversion, 7 shift. A compile refusal or a timeout is a failure. 10 set -eu 11 R=$(CDPATH= cd -- "$(dirname "$0")/../.." && pwd) 12 cd "$R" 13 S=seed/out/omc 14 [ -x "$S" ] || { printf 'FAIL: %s missing; run sh seed/omega-from-seed.sh first\n' "$S" >&2; exit 1; } 15 mkdir -p build/seed/r14 16 T=$(mktemp -d build/seed/r14/num.XXXXXX) 17 trap 'rm -rf "$T"' EXIT HUP INT TERM 18 bad() { printf 'FAIL: %s\n' "$*" >&2; exit 1; } 19 say() { printf '%s\n' "$*"; } 20 21 n=0 22 while IFS='|' read -r name want src; do 23 [ -n "$name" ] || continue 24 n=$((n + 1)) 25 printf '%b\n' "$src" > "$T/p.om" 26 set +e 27 "$S" < "$T/p.om" > "$T/p.bin" 2> "$T/p.err" 28 rc=$? 29 set -e 30 [ "$rc" = 0 ] || bad "$name: compile exit $rc: $(cat "$T/p.err")" 31 chmod +x "$T/p.bin" 32 set +e 33 timeout 5 "$T/p.bin" > /dev/null 2>&1 34 got=$? 35 set -e 36 [ "$got" != 124 ] || bad "$name: timeout" 37 [ "$got" = "$want" ] || bad "$name: exit $got, wanted $want" 38 done <<'CASES' 39 u8_add|0|fn main to int\nx = add uchar 255 1\nret int x\nend 40 u8_sub|255|fn main to int\nx = sub uchar 0 1\nret int x\nend 41 u16_add|1|fn main to int\nx = add ushort 65535 2\nret int x\nend 42 u32_add|0|fn main to int\nx = add uint `4294967295` 1\nret int x\nend 43 u64_add|0|fn main to int\nx = add ulong `18446744073709551615` 1\nret int x\nend 44 u8_shl7|128|fn main to int\nx = shl uchar 1 uchar 7\nret int x\nend 45 u64_shl63_hi|128|fn main to int\nx = shl ulong 1 ulong 63\ny = shr x ulong 56\nret int y\nend 46 i32_shr_neg8|252|fn main to int\nx = shr int -8 int 1\nret int x\nend 47 i32_div_neg7_2|253|fn main to int\nx = div int -7 int 2\nret int x\nend 48 i32_rem_neg7_2|255|fn main to int\nx = rem int -7 int 2\nret int x\nend 49 i32_div_7_neg2|253|fn main to int\nx = div int 7 int -2\nret int x\nend 50 i32_rem_7_neg2|1|fn main to int\nx = rem int 7 int -2\nret int x\nend 51 i32_min_rem_neg1|0|fn main to int\nx = rem int -`2147483648` int -1\nret int x\nend 52 u64_max_div10|153|fn main to int\nx = div ulong `18446744073709551615` ulong 10\ny = rem x ulong 256\nret int y\nend 53 u64_max_rem10|5|fn main to int\nx = rem ulong `18446744073709551615` ulong 10\nret int x\nend 54 i32_min|0|fn main to int\nx = int -`2147483648`\nret int x\nend 55 i32_max|255|fn main to int\nx = int `2147483647`\nret int x\nend 56 conv_u8_255|255|fn main to int\nx = uchar 255\nret int x\nend 57 conv_byte_neg128|128|fn main to int\nx = byte -128\nret int x\nend 58 byte_add_ovf|101|fn main to int\nx = add byte 127 1\nret int x\nend 59 byte_sub_ovf|101|fn main to int\nx = sub byte -128 1\nret int x\nend 60 byte_neg_ovf|101|fn main to int\nx = neg byte -128\nret int x\nend 61 short_add_ovf|101|fn main to int\nx = add short 32767 1\nret int x\nend 62 int_add_ovf|101|fn main to int\nx = add int `2147483647` 1\nret int x\nend 63 long_add_ovf|101|fn main to int\nx = add long `9223372036854775807` 1\nret int x\nend 64 int_min_div|101|fn main to int\nx = div int -`2147483648` int -1\nret int x\nend 65 int_shl31|101|fn main to int\nx = shl int 1 int 31\nret int x\nend 66 conv_300|105|fn main to int\nx = uchar int 300\nret int x\nend 67 conv_m129|105|fn main to int\nx = byte int -129\nret int x\nend 68 conv_2p31|105|fn main to int\nx = int long `2147483648`\nret int x\nend 69 shift8|107|fn main to int\nx = shl uchar 1 uchar 8\nret int x\nend 70 div0|102|fn main to int\nx = div int 1 int 0\nret int x\nend 71 rem0|102|fn main to int\nx = rem int 1 int 0\nret int x\nend 72 index|103|fn main to int\na = new uint 4 0\ni = ulong 4\nx = get a i\nret int x\nend 73 bound|104|fn main to int\na = new uint 1 0\nwhile eq int 1 int 1 bound 3\nput a 0 1\nend\nret 0\nend 74 CASES 75 76 [ "$n" = 35 ] || bad "ran $n of 35 cases" 77 say "PASS gate14 35 numeric cases (19 values, 16 traps; Wolfram-derived expectations)" 78 exit 0