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 / si / rosetta / exercises / nth-prime / test.om
| 1 | note ---- test harness (appended after the solution by exercise.sh) ---- |
| 2 | text tok "ok " |
| 3 | text tnok "not ok " |
| 4 | text tsep " - " |
| 5 | text tnl "\n" |
| 6 | global tfails ulong 1 |
| 7 | global tnum ulong 1 |
| 8 | fn temit a view uchar * to void |
| 9 | o = ulong 0 |
| 10 | while lt o len a bound 4096 |
| 11 | k = write 1 a o sub len a o |
| 12 | if le k 0 |
| 13 | exit 2 |
| 14 | end |
| 15 | o = add o ulong k |
| 16 | end |
| 17 | end |
| 18 | fn temitu n ulong to void |
| 19 | d = new uchar 20 0 |
| 20 | i = ulong 20 |
| 21 | v = n |
| 22 | while true bound 20 |
| 23 | i = sub i 1 |
| 24 | put d i uchar add rem v 10 48 |
| 25 | v = div v 10 |
| 26 | if eq v 0 |
| 27 | break |
| 28 | end |
| 29 | end |
| 30 | temit part d i sub 20 i |
| 31 | end |
| 32 | note one TAP-style line per case; main returns the number of failed cases |
| 33 | fn tcheck c bool what view uchar * to void |
| 34 | put tnum 0 add get tnum 0 1 |
| 35 | if c |
| 36 | temit tok |
| 37 | else |
| 38 | temit tnok |
| 39 | put tfails 0 add get tfails 0 1 |
| 40 | end |
| 41 | temitu get tnum 0 |
| 42 | temit tsep |
| 43 | temit what |
| 44 | temit tnl |
| 45 | end |
| 46 | note cases: exercism/problem-specifications exercises/nth-prime/canonical-data.json at |
| 47 | note commit 650bebeb39ad40439175288042aece982b0a90a9 (2026-10-19), MIT licence, |
| 48 | note https://github.com/exercism/problem-specifications |
| 49 | note 5 cases kept, 0 skipped |
| 50 | text c0 "prime: first prime" |
| 51 | text c1 "prime: second prime" |
| 52 | text c2 "prime: sixth prime" |
| 53 | text c3 "prime: big prime" |
| 54 | text c4 "prime: there is no zeroth prime" |
| 55 | note canonical case 75c65189-8aef-471a-81de-0a90c728160c |
| 56 | fn tc0 to bool |
| 57 | ret eq prime 1 2 |
| 58 | end |
| 59 | note canonical case 2c38804c-295f-4701-b728-56dea34fd1a0 |
| 60 | fn tc1 to bool |
| 61 | ret eq prime 2 3 |
| 62 | end |
| 63 | note canonical case 56692534-781e-4e8c-b1f9-3e82c1640259 |
| 64 | fn tc2 to bool |
| 65 | ret eq prime 6 13 |
| 66 | end |
| 67 | note canonical case fce1e979-0edb-412d-93aa-2c744e8f50ff |
| 68 | fn tc3 to bool |
| 69 | ret eq prime 10001 104743 |
| 70 | end |
| 71 | note canonical case bd0a9eae-6df7-485b-a144-80e13c7d55b2 |
| 72 | fn tc4 to bool |
| 73 | ret eq prime 0 0 |
| 74 | end |
| 75 | fn main to int |
| 76 | tcheck tc0 c0 |
| 77 | tcheck tc1 c1 |
| 78 | tcheck tc2 c2 |
| 79 | tcheck tc3 c3 |
| 80 | tcheck tc4 c4 |
| 81 | ret int get tfails 0 |
| 82 | end |