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 / ecosystem663 / metadata-test.om

271 lines · 3901 bytes Raw Blame History
1note Native checks plus independent element-by-element view bounds oracle.
2global EC ulong 1
3global Digits uchar 20
4text Pass "M20_METADATA_V1_PASS checks="
5text Fail "M20_METADATA_V1_FAIL check="
6text NL "\n"
7
8fn number n ulong to void
9if eq n 0
10put Digits 0 48
11w = write 1 Digits 0 1
12if ne w 1
13exit 90
14end
15ret
16end
17pos = ulong 20
18while gt n 0 bound 20
19pos = sub pos 1
20put Digits pos uchar add 48 rem n 10
21n = div n 10
22end
23w = write 1 Digits pos sub 20 pos
24if ne w long sub 20 pos
25exit 90
26end
27end
28
29fn check got int want int to void
30put EC 0 add get EC 0 1
31if ne got want
32w = write 1 Fail 0 len Fail
33number get EC 0
34w = write 1 NL 0 1
35if ne w 1
36exit 90
37end
38exit 1
39end
40end
41
42fn fixture to void
43for i ulong 24
44put ED i 0
45end
46for i ulong 8
47put ES i 0
48end
49put ED 0 1
50put ED 1 1
51put ED 2 2
52put ED 3 6
53put ED 5 4
54put ED 6 17
55put ED 8 2
56put ED 9 3
57put ED 16 3
58put ED 17 1
59put ES 0 1
60put ES 2 4
61put ES 3 17
62put ES 4 1
63put ES 5 6
64end
65
66fn direct to void
67fixture
68check emcheck 0
69put ED 0 2
70check emcheck -1
71fixture
72put ED 7 1
73check emcheck -1
74fixture
75put ES 6 1
76check emcheck -1
77fixture
78put ES 7 1
79check emcheck -1
80fixture
81put ED 1 0
82check emcheck -4
83put ED 1 4
84check emcheck -4
85fixture
86put ES 4 2
87check emcheck -4
88put ED 1 2
89check emcheck 0
90put ED 1 3
91put ES 4 3
92check emcheck 0
93fixture
94put ED 2 9
95check emcheck -2
96fixture
97put ED 8 0
98check emcheck -3
99fixture
100put ED 3 7
101check emcheck -3
102fixture
103put ED 8 1073741824
104check emcheck -8
105fixture
106put ED 8 18446744073709551615
107check emcheck -8
108fixture
109put ES 5 0
110check emcheck -8
111put ES 5 1073741825
112check emcheck -8
113fixture
114put ED 4 6
115check emcheck -6
116fixture
117put ED 4 18446744073709551615
118check emcheck -6
119fixture
120put ED 16 18446744073709551615
121check emcheck -6
122fixture
123put ED 8 1
124put ED 3 3
125put ED 16 18446744073709551615
126check emcheck 0
127fixture
128put ED 16 0
129check emcheck 0
130fixture
131put ED 16 1
132put ED 17 2
133check emcheck 0
134put ES 5 5
135check emcheck -6
136fixture
137put ED 2 0
138put ED 3 1
139put ED 4 5
140check emcheck 0
141put ED 4 6
142check emcheck -6
143fixture
144put ED 2 8
145put ED 3 1
146for i ulong 8
147put ED add 8 i 1
148put ED add 16 i 18446744073709551615
149end
150check emcheck 0
151fixture
152put ED 2 1
153put ED 8 1073741824
154put ED 3 1073741824
155put ED 16 0
156put ES 5 1
157check emcheck 0
158put ED 16 1
159put ES 5 1073741824
160check emcheck 0
161put ED 4 1
162check emcheck -6
163end
164
165fn lifetime to void
166fixture
167check emlive 4 17 0
168put ED 5 0
169put ES 2 0
170check emcheck 0
171put ED 5 4294967295
172put ES 2 4294967295
173check emcheck 0
174put ED 5 4294967296
175put ES 2 4294967296
176check emcheck -5
177fixture
178check emlive 5 17 -5
179check emlive 4 0 -5
180check emlive 4 16 -5
181check emrelease 4 16 -5
182check emlive 4 17 0
183check emrelease 4 17 0
184check int get ES 0 0
185check int get ES 3 18
186check emcheck -5
187check emrelease 4 17 -5
188put ES 0 1
189check emcheck -5
190put ED 6 18
191check emcheck 0
192check emlive 4 17 -5
193fixture
194put ES 1 1
195check emcheck -5
196fixture
197put ES 0 2
198check emcheck -5
199fixture
200put ES 1 2
201check emcheck -5
202fixture
203put ES 3 18446744073709551615
204put ED 6 18446744073709551615
205check emcheck 0
206check emrelease 4 18446744073709551615 0
207check int get ES 0 0
208check int get ES 1 1
209check emlive 4 18446744073709551615 -5
210put ES 0 1
211check emcheck -5
212if ne get ES 3 18446744073709551615
213check 1 0
214end
215fixture
216check emcheck 0
217end
218
219note Independent oracle visits every element; it never uses maximal extent.
220fn oracle a ulong b ulong s ulong t ulong off ulong cap ulong to int
221for i ulong a
222for j ulong b
223index = add off add mul i s mul j t
224if ge index cap
225ret -6
226end
227end
228end
229ret 0
230end
231
232fn enumerate to void
233fixture
234for ai ulong 3
235a = add ai 1
236put ED 8 a
237for bi ulong 3
238b = add bi 1
239put ED 9 b
240put ED 3 mul a b
241for s ulong 5
242put ED 16 s
243for t ulong 5
244put ED 17 t
245for off ulong 4
246put ED 4 off
247for ci ulong 16
248cap = add ci 1
249put ES 5 cap
250want = oracle a b s t off cap
251check emcheck want
252end
253end
254end
255end
256end
257end
258end
259
260fn main to int
261direct
262lifetime
263enumerate
264w = write 1 Pass 0 len Pass
265number get EC 0
266w = write 1 NL 0 1
267if ne w 1
268ret 90
269end
270ret 0
271end