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 / tests / searchtrace / test_st_corpus.om

414 lines · 11324 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0
2note Copyright 2026 Drake Stapleton (AIEN / aien-dev)
3note tests/searchtrace/test_st_corpus.om: Pure seeded OM-2 M23 G1 corpus unit,
4note determinism, refusal, hook API, and hook equivalence tests (port of test_st_corpus.c).
5
6text tc_ts "OMEGA-SEARCHTRACE-TASKSET v1\n# small set for unit tests\ntask add3 depth=1 max_cost=10 max_candidates=100 dedup=1 pairs=0:3,1:4,7:10\ntask affine depth=2 max_cost=10 max_candidates=500 dedup=1 pairs=0:1,1:3,2:5,10:21\ntask cut depth=3 max_cost=10 max_candidates=60 dedup=0 pairs=0:0,1:1,2:4,3:9\nend\n"
7text tc_ts_alt "OMEGA-SEARCHTRACE-TASKSET v1\n# small set for unit tests\ntask add3 depth=1 max_cost=10 max_candidates=100 dedup=1 pairs=0:4,1:4,7:10\ntask affine depth=2 max_cost=10 max_candidates=500 dedup=1 pairs=0:1,1:3,2:5,10:21\ntask cut depth=3 max_cost=10 max_candidates=60 dedup=0 pairs=0:0,1:1,2:4,3:9\nend\n"
8
9text tc_r1 "OMEGA-SEARCHTRACE-TASKSET v2\ntask a depth=1 max_cost=1 max_candidates=1 dedup=0 pairs=0:0\nend\n"
10text tc_r2 "OMEGA-SEARCHTRACE-TASKSET v1\ntask a depth=1 max_cost=1 max_candidates=1 dedup=0 pairs=0:0\n"
11text tc_r3 "OMEGA-SEARCHTRACE-TASKSET v1\nend\n"
12text tc_r4 "OMEGA-SEARCHTRACE-TASKSET v1\ntask a depth=4 max_cost=1 max_candidates=1 dedup=0 pairs=0:0\nend\n"
13text tc_r5 "OMEGA-SEARCHTRACE-TASKSET v1\ntask a depth=1 max_cost=1 max_candidates=1 dedup=0 pairs=00:0\nend\n"
14text tc_r6 "OMEGA-SEARCHTRACE-TASKSET v1\ntask a max_cost=1 depth=1 max_candidates=1 dedup=0 pairs=0:0\nend\n"
15text tc_r7 "OMEGA-SEARCHTRACE-TASKSET v1\ntask a depth=1 max_cost=1 max_candidates=1 dedup=0 pairs=0:0,\nend\n"
16text tc_r8 "OMEGA-SEARCHTRACE-TASKSET v1\ntask a depth=1 max_cost=1 max_candidates=1 dedup=0 pairs=0:0\ntask a depth=1 max_cost=1 max_candidates=1 dedup=0 pairs=0:0\nend\n"
17text tc_r9 "OMEGA-SEARCHTRACE-TASKSET v1\ntask a depth=1 max_cost=1 max_candidates=1 dedup=0 pairs=0:0\nend\nextra\n"
18text tc_r11 "OMEGA-SEARCHTRACE-TASKSET v1\ntask a depth=1 max_cost=1 max_candidates=1 dedup=0 pairs=0:18446744073709551616\nend\n"
19
20text tc_s_bud "prune=budget"
21text tc_s_sol "verdict=solved"
22text tc_s_eqv "prune=equiv"
23text tc_s_rrc "rrc=0 "
24text tc_s_pr "prune="
25text tc_s_prw "prune=wrong"
26text tc_s_ch "child="
27text tc_s_v2 "OMEGA-SEARCHTRACE v2"
28
29text tc_fail "FAIL "
30text tc_nl "\n"
31text tc_sum1 "st_corpus: "
32text tc_sum2 "/"
33text tc_sum3 " PASS\n"
34
35text tc_n1 "taskset parses"
36text tc_n2 "generate run 1"
37text tc_n3 "generate run 2"
38text tc_n4 "two runs byte-identical"
39text tc_n5 "corpus verifies against its task set"
40text tc_n6 "corpus verifies standalone"
41text tc_n7 "budget cutoff recorded"
42text tc_n8 "solved step recorded"
43text tc_n9 "equivalence prune recorded"
44text tc_n10 "realization cost recorded"
45text tc_n11 "every truncated prefix refused"
46text tc_n12 "missing final newline refused"
47text tc_n13 "bytes after end refused"
48text tc_n14 "CR refused"
49text tc_n15 "NUL refused"
50text tc_n16 "single-byte mutations refused"
51text tc_n17 "dropped step line refused"
52text tc_n18 "unknown prune value refused"
53text tc_n19 "uppercase hex refused"
54text tc_n20 "wrong version refused"
55text tc_n21 "alt taskset parses"
56text tc_n22 "corpus for another task set refused"
57text tc_n23 "taskset wrong version"
58text tc_n24 "taskset without end"
59text tc_n25 "taskset with no tasks"
60text tc_n26 "taskset depth 4"
61text tc_n27 "taskset leading zero"
62text tc_n28 "taskset reordered fields"
63text tc_n29 "taskset trailing comma"
64text tc_n30 "taskset duplicate name"
65text tc_n31 "taskset bytes after end"
66text tc_n32 "taskset CR"
67text tc_n33 "taskset u64 overflow"
68text tc_n34 "synth hook install"
69text tc_n35 "second synth hook refused"
70text tc_n36 "clear with wrong ctx refused"
71text tc_n37 "generate refused while a hook is installed"
72text tc_n38 "synth hook clear"
73text tc_n39 "realize hook install"
74text tc_n40 "generate refused while realize hook is installed"
75text tc_n41 "synth hook free after refused generate"
76text tc_n42 "synth hook clear 2"
77text tc_n43 "realize hook clear"
78text tc_n44 "null hook refused"
79text tc_n45 "hook equivalence on unit set"
80
81global tc_pass ulong 1
82global tc_fail_c ulong 1
83global tc_a uchar 524288
84global tc_an ulong 1
85global tc_c uchar 524288
86
87fn tc_num v ulong to void
88 b = new uchar 24 0
89 p = ulong 24
90 x = v
91 while true bound 24
92 p = sub p 1
93 put b p uchar add 48 rem x 10
94 x = div x 10
95 if eq x 0
96 break
97 end
98 end
99 r = write 1 b p sub 24 p
100end
101
102fn tc_chk ok bool name view uchar * to void
103 if ok
104 put tc_pass 0 add get tc_pass 0 1
105 else
106 put tc_fail_c 0 add get tc_fail_c 0 1
107 sth_wr 1 tc_fail
108 sth_wr 1 name
109 sth_wr 1 tc_nl
110 end
111end
112
113fn tc_verify_c clen ulong check_ts ulong to long
114 buf = new uchar 524288 0
115 for i ulong clen bound 524288
116 put buf i get tc_c i
117 end
118 ret stc_corpus_verify buf clen check_ts
119end
120
121fn tc_verify_a alen ulong check_ts ulong to long
122 buf = new uchar 524288 0
123 for i ulong alen bound 524288
124 put buf i get tc_a i
125 end
126 ret stc_corpus_verify buf alen check_ts
127end
128
129fn tc_has_sub ndl view uchar * to bool
130 an = get tc_an 0
131 nl = len ndl
132 if gt nl an
133 ret false
134 end
135 lim = add sub an nl 1
136 for i ulong lim bound 524288
137 m = ulong 1
138 for j ulong nl bound 64
139 if ne get tc_a add i j get ndl j
140 m = 0
141 break
142 end
143 end
144 if eq m 1
145 ret true
146 end
147 end
148 ret false
149end
150
151fn tc_copy_repl on ulong repl view uchar * rlen ulong to ulong
152 for i ulong rlen bound 2048
153 put tc_c add on i get repl i
154 end
155 put tc_c add on rlen 10
156 ret add add on rlen 1
157end
158
159fn tc_copy_orig on ulong p ulong ln ulong to ulong
160 for i ulong ln bound 4096
161 put tc_c add on i get tc_a add p i
162 end
163 ret add on ln
164end
165
166fn tc_edit_line which ulong has_repl ulong repl view uchar * rlen ulong to ulong
167 an = get tc_an 0
168 on = ulong 0
169 line = ulong 0
170 p = ulong 0
171 while lt p an bound 10000
172 nl = p
173 while lt nl an bound 4096
174 if eq ulong get tc_a nl 10
175 break
176 end
177 nl = add nl 1
178 end
179 if eq line which
180 if ne has_repl 0
181 on = tc_copy_repl on repl rlen
182 end
183 else
184 on = tc_copy_orig on p add sub nl p 1
185 end
186 p = add nl 1
187 line = add line 1
188 end
189 ret on
190end
191
192fn tc_get_line which ulong dst edit uchar 2048 to ulong
193 an = get tc_an 0
194 line = ulong 0
195 p = ulong 0
196 while lt p an bound 10000
197 nl = p
198 while lt nl an bound 4096
199 if eq ulong get tc_a nl 10
200 break
201 end
202 nl = add nl 1
203 end
204 if eq line which
205 ln = sub nl p
206 for i ulong ln bound 2048
207 put dst i get tc_a add p i
208 end
209 ret ln
210 end
211 p = add nl 1
212 line = add line 1
213 end
214 ret 0
215end
216
217fn tc_find_in_line line view uchar 2048 ln ulong ndl view uchar * to long
218 nl = len ndl
219 if gt nl ln
220 ret -1
221 end
222 lim = add sub ln nl 1
223 for i ulong lim bound 2048
224 m = ulong 1
225 for j ulong nl bound 32
226 if ne get line add i j get ndl j
227 m = 0
228 break
229 end
230 end
231 if eq m 1
232 ret long i
233 end
234 end
235 ret -1
236end
237
238fn tc_test_gen_and_verify to void
239 tc_chk eq stc_taskset_parse tc_ts len tc_ts 0 tc_n1
240 tc_chk eq stc_corpus_generate 0 tc_n2
241 an = get stc_out_len 0
242 put tc_an 0 an
243 for i ulong an bound 524288
244 put tc_a i get stc_out i
245 end
246 tc_chk eq stc_corpus_generate 0 tc_n3
247 same = eq an get stc_out_len 0
248 if same
249 for i ulong an bound 524288
250 if ne get tc_a i get stc_out i
251 same = false
252 break
253 end
254 end
255 end
256 tc_chk same tc_n4
257 tc_chk eq tc_verify_a an 1 0 tc_n5
258 tc_chk eq tc_verify_a an 0 0 tc_n6
259 tc_chk tc_has_sub tc_s_bud tc_n7
260 tc_chk tc_has_sub tc_s_sol tc_n8
261 tc_chk tc_has_sub tc_s_eqv tc_n9
262 tc_chk tc_has_sub tc_s_rrc tc_n10
263end
264
265fn tc_test_mutations to void
266 an = get tc_an 0
267 pok = true
268 k = ulong 0
269 while lt k an bound 10000
270 if eq tc_verify_a k 1 0
271 pok = false
272 break
273 end
274 if lt k 4096
275 k = add k 1
276 else
277 k = add k 97
278 end
279 end
280 tc_chk pok tc_n11
281 tc_chk ne tc_verify_a sub an 1 1 0 tc_n12
282
283 for i ulong an bound 524288
284 put tc_c i get tc_a i
285 end
286 put tc_c an 120
287 put tc_c add an 1 10
288 tc_chk ne tc_verify_c add an 2 1 0 tc_n13
289 put tc_c 10 13
290 tc_chk ne tc_verify_c an 1 0 tc_n14
291 put tc_c 10 get tc_a 10
292 put tc_c div an 2 0
293 tc_chk ne tc_verify_c an 1 0 tc_n15
294
295 all = true
296 k = ulong 0
297 while lt k an bound 50000
298 for i ulong an bound 524288
299 put tc_c i get tc_a i
300 end
301 orig = ulong get tc_a k
302 if eq orig 48
303 put tc_c k 49
304 else
305 if eq orig 10
306 put tc_c k 32
307 else
308 put tc_c k 48
309 end
310 end
311 if eq tc_verify_c an 1 0
312 all = false
313 break
314 end
315 k = add k 13
316 end
317 tc_chk all tc_n16
318end
319
320fn tc_test_line_edits to void
321 emp = new uchar 1 0
322 n2 = tc_edit_line 6 0 emp 0
323 tc_chk ne tc_verify_c n2 1 0 tc_n17
324
325 l5 = new uchar 2048 0
326 ln = tc_get_line 5 l5
327 po = tc_find_in_line l5 ln tc_s_pr
328 if ge po 0
329 for i ulong 11
330 put l5 add ulong po i get tc_s_prw i
331 end
332 end
333 n2 = tc_edit_line 5 1 l5 ln
334 tc_chk ne tc_verify_c n2 1 0 tc_n18
335
336 ln = tc_get_line 5 l5
337 co = tc_find_in_line l5 ln tc_s_ch
338 if ge co 0
339 for i ulong 64
340 c = ulong get l5 add add ulong co 6 i
341 if and ge c 97 le c 102
342 put l5 add add ulong co 6 i uchar sub c 32
343 break
344 end
345 end
346 end
347 n2 = tc_edit_line 5 1 l5 ln
348 tc_chk ne tc_verify_c n2 1 0 tc_n19
349
350 n2 = tc_edit_line 0 1 tc_s_v2 len tc_s_v2
351 tc_chk ne tc_verify_c n2 1 0 tc_n20
352
353 tc_chk eq stc_taskset_parse tc_ts_alt len tc_ts_alt 0 tc_n21
354 tc_chk ne tc_verify_a get tc_an 0 1 0 tc_n22
355end
356
357fn tc_test_ts_refusals to void
358 tc_chk ne stc_taskset_parse tc_r1 len tc_r1 0 tc_n23
359 tc_chk ne stc_taskset_parse tc_r2 len tc_r2 0 tc_n24
360 tc_chk ne stc_taskset_parse tc_r3 len tc_r3 0 tc_n25
361 tc_chk ne stc_taskset_parse tc_r4 len tc_r4 0 tc_n26
362 tc_chk ne stc_taskset_parse tc_r5 len tc_r5 0 tc_n27
363 tc_chk ne stc_taskset_parse tc_r6 len tc_r6 0 tc_n28
364 tc_chk ne stc_taskset_parse tc_r7 len tc_r7 0 tc_n29
365 tc_chk ne stc_taskset_parse tc_r8 len tc_r8 0 tc_n30
366 tc_chk ne stc_taskset_parse tc_r9 len tc_r9 0 tc_n31
367 cr = new uchar 128 0
368 rl = len tc_r2
369 p = ulong 0
370 for i ulong rl bound 128
371 c = get tc_r2 i
372 if eq ulong c 10
373 put cr p 13
374 p = add p 1
375 end
376 put cr p c
377 p = add p 1
378 end
379 tc_chk ne stc_taskset_parse cr p 0 tc_n32
380 tc_chk ne stc_taskset_parse tc_r11 len tc_r11 0 tc_n33
381end
382
383fn tc_test_hooks to void
384 r = stc_taskset_parse tc_ts len tc_ts
385 tc_chk eq stc_synth_set_hook 1 101 0 tc_n34
386 tc_chk ne stc_synth_set_hook 1 102 0 tc_n35
387 tc_chk ne stc_synth_clear_hook 102 0 tc_n36
388 tc_chk ne stc_corpus_generate 0 tc_n37
389 tc_chk eq stc_synth_clear_hook 101 0 tc_n38
390 tc_chk eq stc_real_set_hook 1 101 0 tc_n39
391 tc_chk ne stc_corpus_generate 0 tc_n40
392 tc_chk eq stc_synth_set_hook 1 102 0 tc_n41
393 tc_chk eq stc_synth_clear_hook 102 0 tc_n42
394 tc_chk eq stc_real_clear_hook 101 0 tc_n43
395 tc_chk ne stc_synth_set_hook 0 101 0 tc_n44
396 tc_chk eq stc_hook_equivalence 0 tc_n45
397end
398
399fn main to int
400 tc_test_gen_and_verify
401 tc_test_mutations
402 tc_test_line_edits
403 tc_test_ts_refusals
404 tc_test_hooks
405 sth_wr 1 tc_sum1
406 tc_num get tc_pass 0
407 sth_wr 1 tc_sum2
408 tc_num add get tc_pass 0 get tc_fail_c 0
409 sth_wr 1 tc_sum3
410 if eq get tc_fail_c 0 0
411 ret 0
412 end
413 ret 1
414end