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

309 lines · 6638 bytes Raw Blame History
1note Surface tests: removing clipping, using constant background or bypassing drawing must fail.
2note The surface draws packed 0x00RRGGBB words into the native frame Nfrm (look-paint.om) with
3note Lg 0..1 as the native size. A 32 x 32 native frame gives scale 1 and no offset, so the
4note logical geometry equals the former Canvas tests; 70 x 66 and 3840 x 2160 check the scale.
5global Csave uint 1024
6global Cmeta ulong 16
7const CNIGHT ulong 395282
8fn test ok bool to void
9check ok add get Checks 0 1
10end
11fn cvframe w ulong h ulong to void
12note The native size and the night background the look leaves; one sentinel word past it.
13put Lg 0 long w
14put Lg 1 long h
15for i ulong mul w h
16put Nfrm i uint CNIGHT
17end
18put Nfrm mul w h 0
19end
20fn cvat x ulong y ulong to ulong
21ret ulong get Nfrm add mul y 32 x
22end
23fn cvkeep to void
24for i ulong 1024
25put Csave i get Nfrm i
26end
27for i ulong 8
28put Cmeta i get Cv i
29put Cmeta add i 8 get Cvs i
30end
31end
32fn cvsame to bool
33for i ulong 1024
34if ne get Nfrm i get Csave i
35ret false
36end
37end
38for i ulong 8
39if ne get Cv i get Cmeta i
40ret false
41end
42if ne get Cvs i get Cmeta add i 8
43ret false
44end
45end
46ret true
47end
48fn cvink to ulong
49ink = ulong 0
50for i ulong 1024
51if ne ulong get Nfrm i CNIGHT
52ink = add ink 1
53end
54end
55ret ink
56end
57fn cvrefclip to bool
58ink = ulong 0
59for y ulong 32
60for x ulong 32
61at = add mul y 32 x
62inside = and ge x 8 lt x 16
63inside = and inside and ge y 8 lt y 16
64v = ulong get Nfrm at
65if inside
66if ne v ulong get Csave at
67ret false
68end
69if ne v CNIGHT
70ink = add ink 1
71end
72else
73if ne v CNIGHT
74ret false
75end
76end
77end
78end
79ret gt ink 0
80end
81fn cvfrac to bool
82cvframe 32 32
83b = cvinit 32 32
84b = afinit 14 900
85for i ulong 3
86put Dtext i 65
87end
88if not cvspan 0 3 -1 20 15528188
89ret false
90end
91one = get Af 5
92if ne get Cv 7 mul one 3
93ret false
94end
95cvkeep
96cvframe 32 32
97b = cvinit 32 32
98for i ulong 3
99x = affloor add long -256 long mul one i
100if not cvglyph 65 x 20 15528188
101ret false
102end
103end
104for i ulong 1024
105if ne get Nfrm i get Csave i
106ret false
107end
108end
109ret true
110end
111fn cvfills to void
112note A logical fill blends from the current pixel, clamps alpha, refuses an oversized rectangle
113note and stays inside the clip.
114cvframe 32 32
115test cvinit 32 32
116cvfill 1 1 2 2 15528188 128
117test eq cvat 1 1 7961735
118test eq cvat 2 2 7961735
119test eq cvat 0 0 CNIGHT
120test eq cvat 3 3 CNIGHT
121test eq cvat 1 3 CNIGHT
122test eq cvat 3 1 CNIGHT
123cvfill 1 1 2 2 15528188 128
124test eq cvat 1 1 11712193
125cvfill 1 1 2 2 0 999
126test eq cvat 2 2 0
127cvfill 31 0 2 1 15528188 255
128test eq cvat 31 0 CNIGHT
129test cvclip 8 8 8 8
130cvfill 0 0 32 32 15528188 255
131test eq cvat 7 7 CNIGHT
132test eq cvat 8 8 15528188
133test eq cvat 15 15 15528188
134test eq cvat 16 16 CNIGHT
135end
136fn cvscale to void
137note 70 x 66 native pixels hold the 32 x 32 surface at scale 2, centred at (3, 1).
138cvframe 70 66
139test cvinit 32 32
140test eq get Cvs 0 2
141test eq get Cvs 2 3
142test eq get Cvs 3 1
143test eq get Cvs 4 3
144test eq get Cvs 5 1
145test eq get Cvs 6 64
146test eq get Cvs 7 64
147cvfill 0 0 1 1 15528188 255
148test eq get Nfrm 73 15528188
149test eq get Nfrm 74 15528188
150test eq get Nfrm 143 15528188
151test eq get Nfrm 144 15528188
152test eq ulong get Nfrm 72 CNIGHT
153test eq ulong get Nfrm 75 CNIGHT
154test eq ulong get Nfrm 3 CNIGHT
155test eq ulong get Nfrm 213 CNIGHT
156test cvfont 10 900
157test eq get Cvs 1 10
158cvpixel 2 0 255 0
159test eq ulong get Nfrm 2 CNIGHT
160cvpixel 3 1 255 0
161test eq get Nfrm 73 0
162put Lg 0 3840
163put Lg 1 2160
164test cvinit 768 384
165test eq get Cv 0 768
166test eq get Cv 1 384
167test eq get Cvs 0 5
168test eq get Cvs 2 0
169test eq get Cvs 3 120
170test eq get Cvs 6 3840
171test eq get Cvs 7 1920
172end
173fn main to int
174test not cvglyph 65 0 0 15528188
175test not cvinit 0 32
176test not cvinit 32 0
177test not cvinit 769 32
178test not cvinit 32 385
179cvframe 32 32
180test cvinit 32 32
181test eq get Cv 0 32
182test eq get Cv 1 32
183test eq get Cv 4 32
184test eq get Cv 5 32
185test eq get Cvs 0 1
186test eq get Cvs 2 0
187test eq get Cvs 3 0
188test eq get Cvs 6 32
189test eq get Cvs 7 32
190test eq cvat 0 0 CNIGHT
191test eq cvat 31 31 CNIGHT
192test eq get Nfrm 1024 0
193test not cvglyph 65 0 0 15528188
194test afinit 20 1000
195note Exact alpha arithmetic and repeated overlap must use current destination.
196cvpixel 0 0 0 15528188
197test eq cvat 0 0 CNIGHT
198cvpixel 0 0 128 15528188
199test eq cvat 0 0 7961735
200cvpixel 0 0 128 15528188
201test eq cvat 0 0 11712193
202cvpixel 0 0 255 15528188
203test eq cvat 0 0 15528188
204cvkeep
205cvpixel -1 0 255 0
206cvpixel 0 -1 255 0
207cvpixel 32 0 255 0
208cvpixel 0 32 255 0
209test cvsame
210test not cvinit 18446744073709551615 1
211test cvsame
212test not cvclip 33 0 0 0
213test not cvclip 0 33 0 0
214test not cvclip 0 0 33 1
215test not cvclip 0 0 1 33
216test not cvclip 1 1 18446744073709551615 1
217test cvsame
218test not cvglyph 65 -4097 0 15528188
219test not cvglyph 65 4097 0 15528188
220test not cvglyph 65 0 -4097 15528188
221test not cvglyph 65 0 4097 15528188
222test not cvglyph 65 0 0 16777216
223test cvsame
224note Independent reference crop of the already rendered glyph.
225cvframe 32 32
226test cvinit 32 32
227test cvglyph 65 4 24 15528188
228test gt get Cv 7 0
229cvkeep
230cvframe 32 32
231test cvinit 32 32
232test cvclip 8 8 8 8
233put Nfrm 1024 165
234test cvglyph 65 4 24 15528188
235test cvrefclip
236test eq get Nfrm 1024 165
237note Zero-area and edge clips cannot draw any pixel.
238cvframe 32 32
239test cvinit 32 32
240test cvclip 32 32 0 0
241cvkeep
242test cvglyph 65 -8 6 15528188
243put Cmeta 7 get Cv 7
244test cvsame
245note A negative origin that intersects the surface must draw without wrapping.
246test cvclip 0 0 32 32
247test cvglyph 65 -8 6 15528188
248test gt cvink 0
249test eq get Nfrm 1024 0
250note Explicit retained-text span agrees with two separately positioned glyphs.
251put Dtext 0 65
252put Dtext 1 65
253cvframe 32 32
254test cvinit 32 32
255put Outb 0 88
256put Outlen 0 1
257put Err 0 7
258put In 8191 99
259ok = cvspan 0 2 1 24 15528188
260clean = and eq get Outb 0 88 eq get Outlen 0 1
261clean = and clean eq get Err 0 7
262test ok
263test clean
264test eq get In 8191 99
265advance = get Cv 7
266cvkeep
267cvframe 32 32
268test cvinit 32 32
269test cvglyph 65 1 24 15528188
270one = get Cv 7
271x = add long 1 long div one 256
272test cvglyph 65 x 24 15528188
273test eq advance mul one 2
274same = true
275for i ulong 1024
276if ne get Nfrm i get Csave i
277same = false
278end
279end
280test same
281note Refused spans and extreme offsets preserve pixels and all surface metadata.
282cvkeep
283test not cvspan 2305 0 0 0 0
284test not cvspan 2304 1 0 0 0
285test not cvspan 1 18446744073709551615 0 0 0
286test not cvspan 0 1 0 0 18446744073709551615
287test not cvspan 0 1 -4097 0 0
288test cvsame
289test cvspan 2304 0 0 0 0
290test eq get Cv 7 0
291test eq get Dtext 0 65
292test eq get Dtext 1 65
293test cvfrac
294for i ulong 2304
295put Dtext i 65
296end
297cvframe 32 32
298test cvinit 32 32
299cvkeep
300test cvspan 0 2304 4096 0 15528188
301put Cmeta 7 get Cv 7
302test cvsame
303cvfills
304cvscale
305if ne get Fails 0 0
306ret 1
307end
308ret 0
309end