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 / om / quantity / demo.om

94 lines · 2078 bytes Raw Blame History
1note Concatenate quantity.om then demo.om. No parser or service is simulated.
2text db "PASS modular baseline8 checked add status3 unchanged output effects0\n"
3text dm "PASS multiply status3 narrow status3 negative status2 unchanged output\n"
4text da "PASS reused object identity changed version status4 unchanged slice\n"
5
6fn demoadd to bool
7out = new bqty ulong 17 ulong 19
8a = new bqty ulong 18446744073709551608 ulong 18446744073709551615
9b = new bqty ulong 16 ulong 18446744073709551615
10effects = int 0
11rc = qadd out a b
12if eq rc int 0
13effects = add effects int 1
14end
15if ne effects int 0
16ret bool 0
17end
18if ne add get a val get b val ulong 8
19ret bool 0
20end
21if ne rc int 3
22ret bool 0
23end
24ret and eq get out val ulong 17 eq get out cap ulong 19
25end
26
27fn demomul to bool
28out = new bqty ulong 17 ulong 19
29a = new bqty ulong 18446744073709551615 ulong 18446744073709551615
30b = new bqty ulong 2 ulong 18446744073709551615
31rc = qmul out a b
32if ne rc int 3
33ret bool 0
34end
35if not and eq get out val ulong 17 eq get out cap ulong 19
36ret bool 0
37end
38rc = qnarrow out a ulong 255
39if ne rc int 3
40ret bool 0
41end
42if not and eq get out val ulong 17 eq get out cap ulong 19
43ret bool 0
44end
45rc = qsigned out long -1 ulong 18446744073709551615
46if ne rc int 2
47ret bool 0
48end
49ret and eq get out val ulong 17 eq get out cap ulong 19
50end
51
52fn demoaba to bool
53out = new qslic ulong 91 ulong 92 ulong 93 ulong 94
54off = new bqty ulong 0 ulong 8
55count = new bqty ulong 1 ulong 8
56expect = new qobj ulong 5 ulong 7 ulong 8
57current = new qobj ulong 5 ulong 8 ulong 8
58rc = qtyslice out off count expect current
59if ne rc int 4
60ret bool 0
61end
62if ne get out ident ulong 91
63ret bool 0
64end
65if ne get out ver ulong 92
66ret bool 0
67end
68ret and eq get out off ulong 93 eq get out count ulong 94
69end
70
71fn main to int
72if not demoadd
73ret int 1
74end
75n = write int 1 db ulong 0 len db
76if ne n long len db
77ret int 2
78end
79if not demomul
80ret int 3
81end
82n = write int 1 dm ulong 0 len dm
83if ne n long len dm
84ret int 4
85end
86if not demoaba
87ret int 5
88end
89n = write int 1 da ulong 0 len da
90if ne n long len da
91ret int 6
92end
93ret int 0
94end