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

184 lines · 3087 bytes Raw Blame History
1note SPDX-License-Identifier: AGPL-3.0-only
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
87check capchild p c 100 64
88child c
89put c 1 0
90put c 2 0
91put c 3 0
92put c 5 0
93check capchild p c 50 0
94put p 1 0
95put p 2 0
96put p 3 0
97check capchild p c 50 0
98put c 1 1
99check capchild p c 50 66
100
101for i ulong 8
102parent p
103child c
104put c add i 8 add get c add i 8 1
105check capchild p c 50 add 70 div i 4
106end
107parent p
108child c
109for i ulong 4
110put c add i 16 get p add i 16
111end
112check capchild p c 50 74
113child c
114for i ulong 4
115put c add i 20 get p add i 20
116end
117check capchild p c 50 75
118for group ulong 4
119parent p
120child c
121for j ulong 4
122put p add 8 add mul group 4 j 0
123end
124check capchild p c 50 62
125parent p
126for j ulong 4
127put c add 8 add mul group 4 j 0
128end
129check capchild p c 50 62
130end
131
132parent p
133child c
134put p 0 2
135check capchild p c 50 61
136parent p
137put c 0 2
138check capchild p c 50 61
139child c
140put c 1 512
141check capchild p c 50 66
142child c
143put c 6 1
144check capchild p c 50 62
145child c
146put c 7 1
147check capchild p c 50 62
148child c
149put c 5 18446744073709551615
150check capchild p c 50 62
151child c
152put p 5 65
153check capchild p c 50 62
154parent p
155child c
156put p 5 1
157put c 5 0
158check capchild p c 50 0
159put p 2 18446744073709551615
160put c 2 18446744073709551615
161check capchild p c 50 0
162put p 2 18446744073709551614
163check capchild p c 50 67
164parent p
165child c
166put p 1 9223372036854775808
167put c 1 9223372036854775808
168check capchild p c 50 0
169put c 1 9223372036854775809
170check capchild p c 50 66
171
172note Exhaust all subsets of the small rights profile, not only one happy case.
173for rights ulong 32
174parent p
175child c
176put c 1 rights
177want = ulong 66
178if lt rights 8
179want = 0
180end
181check capchild p c 50 want
182end
183ret summary
184end