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 / train / omega-llm / tools / combined / test.sh

134 lines · 4773 bytes Raw Blame History
1#!/bin/sh
2# Synthetic routing tests. The real symbolic engines and compiler execute every checked case.
3set -eu
4umask 077
5[ "$#" = 1 ] || { echo 'usage: test.sh BUILT_KIT' >&2; exit 2; }
6installed=$(CDPATH= cd -- "$1" && pwd)
7d=$(mktemp -d)
8trap 'rm -rf -- "$d"' EXIT
9trap 'exit 1' HUP INT TERM
10cd "$d"
11mkdir kit
12for name in solve combined omc om_formalize om_sketch om_synth; do
13 ln -s "$installed/$name" "kit/$name"
14done
15touch kit/r6.ck kit/r3.ck kit/base.ck kit/trace.ck kit/merges.bin kit/S2_fold.sp
16cat > kit/ollm <<'MOCK'
17#!/bin/sh
18set -eu
19REPLAY=$(dirname -- "$0")/../replay
20test -f "$2"
21name=$(basename "$2")
22case "$1" in
23sample)
24 test "$#" = 7 && test "$3/$4/$5" = "42/128/0" && test -s "$REPLAY/$name" && test -f "$7" || exit 2
25 cat "$REPLAY/$name";;
26spsamp)
27 test "$#" = 8 && test "$4/$5" = "64/700" && test "$name" = r3.ck && test -f "$3" && test -f "$8" || exit 2
28 cat "$REPLAY/strand-$7";;
29*) exit 2;;
30esac
31MOCK
32chmod 700 kit/ollm
33mkdir replay
34for ck in r6.ck r3.ck base.ck trace.ck; do printf 'ret 0\nend\n' > "replay/$ck"; done
35for s in 1100 1101 1102 1103; do cp replay/r6.ck "replay/strand-$s"; done
36prompt() { printf 'note %s\nfn solve %s\n' "$1" "$2" > prompt; }
37answer() { kit/solve "$@" > got 2> route; }
38route_is() { grep -Fx "route $1" route >/dev/null; }
39refuse() {
40 rc=0
41 kit/solve "$@" > got 2> route || rc=$?
42 [ "$rc" = "$want" ] && [ ! -s got ] || { echo "expected $want, got $rc" >&2; exit 1; }
43}
44prompt 'return the argument rounded down to a multiple of 14' 'a ulong to ulong'
45answer prompt
46route_is om_synth
47printf '41 28\n70 70\n0 0\n13 0\n' > examples
48answer prompt examples
49route_is om_synth
50prompt 'demo operation' 'a ulong b ulong to ulong'
51printf '2 3 5\n7 11 18\n5 0 5\n21 3 24\n' > examples
52answer prompt examples
53grep -Eq '^route om_(sketch|synth)$' route
54prompt 'demo operation' 'a view ulong 8 n ulong to ulong'
55printf '4 1 3 9 4 0 0 0 0 17\n2 1 1 7 2 0 0 0 0 2\n' > examples
56answer prompt examples
57route_is om_sketch
58# Historical r-030, including tails after the active length.
59prompt 'return the sum of the items at even indexes minus the sum of the items at odd indexes among the first n items, or zero when the odd sum is larger' 'a view ulong 8 n ulong to ulong'
60cat > examples <<'ROWS'
610 7 0 3 11 3 2 9 13 0
622 7 0 3 11 3 2 9 13 7
635 7 0 3 11 3 2 9 13 2
648 7 0 3 11 3 2 9 13 0
650 9 2 3 2 1 12 0 9 0
662 9 2 3 2 1 12 0 9 7
675 9 2 3 2 1 12 0 9 9
688 9 2 3 2 1 12 0 9 0
69ROWS
70answer prompt examples
71route_is om_sketch
72prompt 'demo operation' 'a edit ulong 8 n ulong to void'
73printf '2 1 3 0 0 0 0 0 0 3 1 0 0 0 0 0 0\n3 7 5 9 0 0 0 0 0 9 5 7 0 0 0 0 0\n' > examples
74answer prompt examples
75route_is om_sketch
76prompt 'demo operation' 'a ulong to ulong'
77answer prompt
78route_is r6.ck
79cmp got replay/r6.ck
80# Nine cases force checking beyond the eight lanes used to propose a symbolic program.
81n=1
82: > examples
83while [ "$n" -le 9 ]; do
84 expected=$((n * 937 + 417))
85 printf '%s %s\n' "$n" "$expected" >> examples
86 n=$((n + 1))
87done
88printf 'if eq a 9\nret 0\nend\nret add mul a 937 417\nend\n' > replay/r6.ck
89printf 'ret add mul a 937 417\nend\n' > good
90cp good replay/trace.ck
91answer prompt examples
92route_is trace.ck
93cmp good got
94cp replay/base.ck replay/trace.ck
95cp good replay/strand-1102
96answer prompt examples
97route_is S2_fold.sp
98cmp good got
99cp replay/base.ck replay/strand-1102
100want=1
101refuse prompt examples
102# Every candidate below would satisfy all nine rows if its invalid line were ignored.
103for local in se so runningTotal local_with_underscores; do
104 printf '%s = mul a 937\nret add %s 417\nend\n' "$local" "$local" > replay/r3.ck
105 answer prompt examples
106 route_is r3.ck
107 cmp got replay/r3.ck
108done
109printf 'subtotal = ulong 0\nfor position ulong a bound 9\nsubtotal = add subtotal 937\nend\nret add subtotal 417\nend\n' > replay/r3.ck
110answer prompt examples
111route_is r3.ck
112cmp got replay/r3.ck
113for body in 'ret add mul missing 937 417' 'ret add mul z 937 417' 'for add ulong 0' 'for note ulong 0' 'for getpid ulong 0'; do
114 { printf '%s\n' "$body"; case "$body" in 'for '*) printf 'end\n';; esac; cat good; } > replay/r3.ck
115 refuse prompt examples
116done
117{ printf 'unused = getpid\n'; cat good; } > replay/r3.ck
118refuse prompt examples
119{ cat good; printf 'fn extra to int\nret 0\nend\n'; } > replay/r3.ck
120refuse prompt examples
121printf '18446744073709551616 2\n' > invalid
122want=65
123refuse prompt invalid
124: > invalid
125refuse prompt invalid
126printf 'note demo\nfn solve a ulong to ulong\nend\n' > invalid-prompt
127refuse invalid-prompt
128printf '9 0 0 0 0 0 0 0 0 0\n' > invalid
129prompt 'demo' 'a view ulong 8 n ulong to ulong'
130refuse prompt invalid
131rm kit/om_formalize
132want=70
133refuse prompt
134echo 'PASS symbolic, checked scalar and array, neural fallback, trace, specialist, rejection, setup error'