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 / delegate.om

198 lines · 3397 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 "delegate 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 parent p edit ulong 24 to void
13for i ulong 24
14put p i 0
15end
16put p 0 1
17put p 1 7
18put p 2 1024
19put p 3 200
20put p 4 100
21put p 5 4
22for i ulong 16
23put p add i 8 add i 100
24end
25end
26fn child c edit ulong 24 to void
27parent c
28put c 1 3
29put c 2 512
30put c 3 100
31put c 4 90
32put c 5 3
33put c 16 200
34put c 20 300
35end
36fn summary to int
37for i ulong len title
38put report i get title i
39end
40n = get checks 0
41at = len title
42put report at uchar add 48 div n 100
43put report add at 1 uchar add 48 rem div n 10 10
44put report add at 2 uchar add 48 rem n 10
45put report add at 3 32
46put report add at 4 uchar add 48 div get fails 0 100
47put report add at 5 uchar add 48 rem div get fails 0 10 10
48put report add at 6 uchar add 48 rem get fails 0 10
49put report add at 7 10
50w = write 1 report 0 add at 8
51if ne w long add at 8
52ret 2
53end
54if ne get fails 0 0
55ret 1
56end
57ret 0
58end
59fn main to int
60p = new ulong 24 0
61c = new ulong 24 0
62parent p
63child c
64check capchild p c 50 0
65put c 1 8
66check capchild p c 50 66
67child c
68put c 2 1025
69check capchild p c 50 67
70child c
71put c 3 201
72check capchild p c 50 68
73child c
74put c 4 101
75check capchild p c 50 69
76child c
77put c 5 4
78check capchild p c 50 73
79child c
80put p 5 0
81check capchild p c 50 72
82parent p
83child c
84put c 4 50
85check capchild p c 50 65
86child c
87put c 4 100
88check capchild p c 50 0
89note Rights are a bit subset: a numerically smaller child is still refused if it has a bit the parent lacks.
90child c
91put p 1 5
92put c 1 2
93check capchild p c 50 66
94put p 1 6
95put c 1 1
96check capchild p c 50 66
97put p 1 9223372036854775808
98check capchild p c 50 66
99parent p
100child c
101check capchild p c 100 64
102child c
103put c 1 0
104put c 2 0
105put c 3 0
106put c 5 0
107check capchild p c 50 0
108put p 1 0
109put p 2 0
110put p 3 0
111check capchild p c 50 0
112put c 1 1
113check capchild p c 50 66
114
115for i ulong 8
116parent p
117child c
118put c add i 8 add get c add i 8 1
119check capchild p c 50 add 70 div i 4
120end
121parent p
122child c
123for i ulong 4
124put c add i 16 get p add i 16
125end
126check capchild p c 50 74
127child c
128for i ulong 4
129put c add i 20 get p add i 20
130end
131check capchild p c 50 75
132for group ulong 4
133parent p
134child c
135for j ulong 4
136put p add 8 add mul group 4 j 0
137end
138check capchild p c 50 62
139parent p
140for j ulong 4
141put c add 8 add mul group 4 j 0
142end
143check capchild p c 50 62
144end
145
146parent p
147child c
148put p 0 2
149check capchild p c 50 61
150parent p
151put c 0 2
152check capchild p c 50 61
153child c
154put c 1 512
155check capchild p c 50 66
156child c
157put c 6 1
158check capchild p c 50 62
159child c
160put c 7 1
161check capchild p c 50 62
162child c
163put c 5 18446744073709551615
164check capchild p c 50 62
165child c
166put p 5 65
167check capchild p c 50 62
168parent p
169child c
170put p 5 1
171put c 5 0
172check capchild p c 50 0
173put p 2 18446744073709551615
174put c 2 18446744073709551615
175check capchild p c 50 0
176put p 2 18446744073709551614
177check capchild p c 50 67
178parent p
179child c
180put p 1 9223372036854775808
181put c 1 9223372036854775808
182check capchild p c 50 0
183put c 1 9223372036854775809
184check capchild p c 50 66
185
186note Exhaust all subsets of the small rights profile, not only one happy case.
187for rights ulong 32
188parent p
189child c
190put c 1 rights
191want = ulong 66
192if lt rights 8
193want = 0
194end
195check capchild p c 50 want
196end
197ret summary
198end