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 / native / control / tests / reuse.om

154 lines · 2595 bytes Raw Blame History
1note SPDX-License-Identifier: Apache-2.0
2global checks ulong 1
3global fails ulong 1
4global report uchar 64
5text title "reuse checks="
6fn check got ulong want ulong to void
7put checks 0 add get checks 0 1
8if ne got want
9put fails 0 add get fails 0 1
10end
11end
12fn profile p edit ulong 40 to void
13for i ulong 40
14put p i 0
15end
16put p 0 1
17put p 1 1
18put p 2 32
19put p 3 4096
20put p 4 1
21put p 5 2
22put p 6 1
23for i ulong 28
24put p add i 8 add i 100
25end
26end
27fn saved s edit ulong 40 to void
28profile s
29for i ulong 4
30put s add i 36 add i 200
31end
32end
33fn payload h edit ulong 4 to void
34for i ulong 4
35put h i add i 200
36end
37end
38fn summary to int
39for i ulong len title
40put report i get title i
41end
42n = get checks 0
43at = len title
44put report at uchar add 48 div n 100
45put report add at 1 uchar add 48 rem div n 10 10
46put report add at 2 uchar add 48 rem n 10
47put report add at 3 32
48put report add at 4 uchar add 48 div get fails 0 100
49put report add at 5 uchar add 48 rem div get fails 0 10 10
50put report add at 6 uchar add 48 rem get fails 0 10
51put report add at 7 10
52w = write 1 report 0 add at 8
53if ne w long add at 8
54ret 2
55end
56if ne get fails 0 0
57ret 1
58end
59ret 0
60end
61fn main to int
62s = new ulong 40 0
63w = new ulong 40 0
64h = new ulong 4 0
65saved s
66profile w
67payload h
68check kvmatch s w h 0
69for i ulong 6
70saved s
71put s add i 1 add get s add i 1 1
72check kvmatch s w h add 111 i
73end
74for i ulong 28
75saved s
76put s add i 8 add get s add i 8 1
77check kvmatch s w h add 120 div i 4
78end
79for i ulong 4
80saved s
81payload h
82put h i add get h i 1
83check kvmatch s w h 127
84end
85payload h
86for g ulong 7
87saved s
88profile w
89for j ulong 4
90put s add 8 add mul g 4 j 0
91end
92check kvmatch s w h 104
93saved s
94for j ulong 4
95put w add 8 add mul g 4 j 0
96end
97check kvmatch s w h 104
98end
99profile w
100saved s
101put s 0 2
102check kvmatch s w h 100
103saved s
104put w 0 2
105check kvmatch s w h 100
106profile w
107put s 7 1
108check kvmatch s w h 102
109saved s
110put w 7 1
111check kvmatch s w h 102
112profile w
113for i ulong 6
114saved s
115put s add i 1 0
116check kvmatch s w h 103
117end
118saved s
119put s 2 4097
120check kvmatch s w h 103
121saved s
122put s 5 5
123check kvmatch s w h 103
124saved s
125for i ulong 4
126put s add i 36 0
127end
128check kvmatch s w h 104
129saved s
130for i ulong 4
131profile w
132put w add i 36 1
133check kvmatch s w h 128
134end
135profile w
136saved s
137check kvmatch s w h 0
138note Whole-token prefix identity is required even if lengths match.
139put w 28 999
140check kvmatch s w h 125
141profile w
142put w 24 999
143check kvmatch s w h 124
144profile w
145put w 16 999
146check kvmatch s w h 122
147note A prefix that fills the whole context is admitted.
148profile w
149saved s
150put s 2 4096
151put w 2 4096
152check kvmatch s w h 0
153ret summary
154end