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