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 / aienux / allen / tests / context.om

359 lines · 6557 bytes Raw Blame History
1text Who "Drake"
2text Selfname "Allen"
3text Fkey "gate code"
4text Fval "4471"
5text Note0 "Meet at noon."
6text Note1 "Old private note."
7text Note3 "Bring tools."
8text MetaWant "\tself=Allen\tname=Drake\tstarts=7\tfact gate code is 4471\tnote Bring tools.\tnote Meet at noon."
9text NewOnly "\tself=Allen\tname=Drake\tstarts=7\tfact gate code is 4471\tnote Bring tools."
10text Emptyctx "\tself=Allen\tstarts=0"
11text Lastsix "\tself=Allen\tstarts=0\tnote N9\tnote N8\tnote N7\tnote N6\tnote N5\tnote N4"
12text Plural "\tself=Allen\tname=Drake\tstarts=4294967295\tfact gate code are 4471"
13global Unitsave uchar 8192
14global Saveout uchar 8192
15global Saveos ulong 2
16fn test ok bool to void
17put Saveos 0 get Outlen 0
18put Saveos 1 get Err 0
19for i ulong get Outlen 0
20put Saveout i get Outb i
21end
22check ok add get Checks 0 1
23for i ulong get Saveos 0
24put Outb i get Saveout i
25end
26put Outlen 0 get Saveos 0
27put Err 0 get Saveos 1
28end
29fn fixture index ulong gone ulong to void
30put Ns 0 len Note0
31put Ns 1 index
32put Ns 2 7
33put Ns 3 gone
34for i ulong len Note0
35put Note i get Note0 i
36end
37if eq index 1
38put Ns 0 len Note1
39for i ulong len Note1
40put Note i get Note1 i
41end
42end
43if eq index 3
44put Ns 0 len Note3
45for i ulong len Note3
46put Note i get Note3 i
47end
48end
49test noteenc
50for i ulong 4096
51put Unit i get Enc i
52end
53end
54fn memsetup to void
55for i ulong 3692
56put Mem i 0
57end
58mset32 0 7
59mset32 32 1
60mset32 36 4
61for i ulong len Who
62put Mem add i 8 get Who i
63end
64for i ulong len Fkey
65put Mem add i 40 get Fkey i
66end
67for i ulong len Fval
68put Mem add i 88 get Fval i
69end
70for i ulong len Selfname
71put Mem add i 153 get Selfname i
72end
73end
74fn prompt to void
75put Inlen 0 2
76put In 0 104
77put In 1 105
78end
79fn main to int
80test appinit 123 0
81test ctxmeta 6
82test eq get Mx 0 len Emptyctx
83same = true
84for i ulong len Emptyctx
85if ne get Meta i get Emptyctx i
86same = false
87end
88end
89test same
90memsetup
91test memenc 100
92for i ulong 4096
93put Unit i get Enc i
94end
95loadbeg
96test loadcopy 0
97test eq get St 0 100
98test ctxbegin
99test eq get Cx 0 4
100test eq get Cx 1 0
101test eq get Cx 2 0
102test not ctxmeta 6
103prompt
104test not appask 0
105test eq get R 0 0
106test eq get Q 1 0
107appcancel
108fixture 3 0
109test eq ctxtake 3 1
110test eq get Ctxlen 3 len Note3
111test eq get Ctxstart 3 7
112test eq ctxtake 3 0
113test eq get Cx 1 1
114fixture 1 1
115test eq ctxtake 1 1
116test eq get Ctxgone 1 1
117fixture 2 0
118put Unit 64 33
119test eq ctxtake 2 2
120test eq get Cx 3 1
121test eq get Ctxgone 2 1
122test not ctxmeta 6
123fixture 0 0
124test eq ctxtake 0 1
125test eq get Cx 1 4
126test eq get Cx 2 1
127test eq get Cx 4 0
128test eq ctxtake 4 0
129test ctxmeta 6
130test eq get Mx 0 len MetaWant
131same = true
132for i ulong len MetaWant
133if ne get Meta i get MetaWant i
134same = false
135end
136end
137test same
138test ctxmeta 1
139test eq get Mx 0 len NewOnly
140same = true
141for i ulong len NewOnly
142if ne get Meta i get NewOnly i
143same = false
144end
145end
146test same
147test not ctxmeta 513
148test not ctxappend
149test ctxmeta 6
150outreset
151emitb 120
152test ctxappend
153test eq get Outlen 0 add 1 len MetaWant
154test eq get Outb 0 120
155same = true
156for i ulong len MetaWant
157if ne get Outb add i 1 get MetaWant i
158same = false
159end
160end
161test same
162note Exercise the actual appask -> qsubmit job snapshot, not only metadata helpers.
163prompt
164test appask 1
165test eq get R 0 1
166test eq get Q 1 1
167test eq get R 9 1
168n = get T 8
169test ge n len MetaWant
170same = ge n len MetaWant
171if same
172for i ulong len MetaWant
173if ne get JobOut add sub n len MetaWant i get MetaWant i
174same = false
175end
176end
177end
178test same
179test not ctxbegin
180test eq ctxtake 0 0
181appcancel
182note Exact append capacity and one byte above, preserving Outb/length/error on refusal.
183test ctxmeta 6
184n = sub ulong 4096 get Mx 0
185put Outlen 0 n
186for i ulong n
187put Outb i 90
188end
189test ctxappend
190test eq get Outlen 0 4096
191put Outlen 0 add n 1
192put Outb n 88
193test not ctxappend
194test eq get Outlen 0 add n 1
195test eq get Outb n 88
196put Err 0 5
197test not ctxappend
198test eq get Err 0 5
199outreset
200mset32 36 5
201test not ctxmeta 6
202mset32 36 4
203mset32 32 33
204prompt
205test not appask 2
206test eq get R 0 1
207test eq get Q 1 1
208mset32 32 1
209note Deliberately full valid facts make metadata fit but the whole JOB exceed4096.
210for i ulong 3692
211put Mem i 0
212end
213mset32 32 32
214for k ulong 32
215off = add 40 mul k 113
216for i ulong 47
217put Mem add off i 107
218end
219for i ulong 63
220put Mem add add off 48 i 118
221end
222end
223test ctxmeta 6
224test le get Mx 0 4096
225prompt
226test not appask 2
227test eq get R 0 1
228test eq get Q 1 1
229test eq get R 9 1
230note Catalog capacity and transaction exclusion.
231mset32 36 512
232test ctxbegin
233test eq get Cx 0 512
234test eq ctxtake 512 0
235fixture 511 0
236test eq ctxtake 511 1
237test eq get Ctxlen 511 len Note0
238test not ctxmeta 6
239put Tx 0 1
240test not ctxbegin
241test eq ctxtake 0 0
242put Tx 0 0
243put Nt 0 1
244test not ctxbegin
245test eq ctxtake 0 0
246put Nt 0 0
247mset32 36 513
248test not ctxbegin
249test eq get Cx 0 512
250note Load ten real records, select exactly the newest six, and allow zero selected.
251for i ulong 3692
252put Mem i 0
253end
254mset32 36 10
255test ctxbegin
256for k ulong 10
257put Ns 0 2
258put Ns 1 k
259put Ns 2 7
260put Ns 3 0
261put Note 0 78
262put Note 1 uchar add 48 k
263test noteenc
264for i ulong 4096
265put Unit i get Enc i
266end
267test eq ctxtake k 1
268end
269test ctxmeta 6
270test eq get Mx 0 len Lastsix
271same = true
272for i ulong len Lastsix
273if ne get Meta i get Lastsix i
274same = false
275end
276end
277test same
278test ctxmeta 0
279test eq get Mx 0 len Emptyctx
280note Context construction cannot overwrite a staged memory/note transaction image.
281for i ulong 4096
282put Unitsave i get Unit i
283put Unitsave add i 4096 get Enc i
284end
285test ctxmeta 6
286same = true
287for i ulong 4096
288if ne get Unit i get Unitsave i
289same = false
290end
291if ne get Enc i get Unitsave add i 4096
292same = false
293end
294end
295test same
296memsetup
297mset32 36 0
298mset32 0 4294967295
299put Mem 152 1
300test ctxmeta 6
301test eq get Mx 0 len Plural
302same = true
303for i ulong len Plural
304if ne get Meta i get Plural i
305same = false
306end
307end
308test same
309put Mem 40 9
310test not ctxmeta 6
311test not ctxappend
312put Mem 40 103
313for i ulong 48
314put Mem add i 40 107
315end
316test not ctxmeta 6
317note Thirty-two full facts and six full notes overflow metadata itself, not only JOB.
318for i ulong 3692
319put Mem i 0
320end
321mset32 32 32
322mset32 36 6
323for k ulong 32
324off = add 40 mul k 113
325for i ulong 47
326put Mem add off i 107
327end
328for i ulong 63
329put Mem add add off 48 i 118
330end
331end
332test ctxbegin
333for k ulong 6
334put Ns 0 127
335put Ns 1 k
336put Ns 2 7
337put Ns 3 0
338for i ulong 127
339put Note i 110
340end
341test noteenc
342for i ulong 4096
343put Unit i get Enc i
344end
345test eq ctxtake k 1
346end
347test not ctxmeta 6
348test eq get Mx 1 1
349outreset
350emitb 90
351test not ctxappend
352test eq get Outlen 0 1
353test eq get Outb 0 90
354prompt
355test not appask 2
356test eq get R 0 1
357test eq get Q 1 1
358ret int get Fails 0
359end