Interplane page as plain text, for reading tools and agents. English is the reference text: translate it with your own tool. Text in backticks and in ``` blocks (commands, fingerprints, file names) and link targets in <...> are exact: copy them, never translate them. Page: /drakestapleton/omega-mv/blob/main/si/rosetta/exercises/prime-factors/test.om # 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 Sign in to star 1 stars 0 watching About Files History Releases Proposed changes Issues For developers branch `main` Branches Tags History `omega-mv / si / rosetta / exercises / prime-factors / test.om` 198 lines ยท 4055 bytes Raw Blame History 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/prime-factors/canonical-data.json at 47 note commit `650bebeb39ad40439175288042aece982b0a90a9` (2026-10-19), MIT licence, 48 note https://github.com/exercism/problem-specifications 49 note 12 cases kept, 0 skipped 50 fn tueq a view ulong * b view ulong * to bool 51 if ne len a len b 52 ret false 53 end 54 for i ulong len a 55 if ne get a i get b i 56 ret false 57 end 58 end 59 ret true 60 end 61 text c0 "factors: no factors" 62 text c1 "factors: prime number" 63 text c2 "factors: another prime number" 64 text c3 "factors: square of a prime" 65 text c4 "factors: product of first prime" 66 text c5 "factors: cube of a prime" 67 text c6 "factors: product of second prime" 68 text c7 "factors: product of third prime" 69 text c8 "factors: product of first and second prime" 70 text c9 "factors: product of primes and non-primes" 71 text c10 "factors: product of primes" 72 text c11 "factors: factors include a large prime" 73 note canonical case `924fc966`-a8f5-4288-82f2-`6b9224819ccd` 74 fn tc0 to bool 75 o = new ulong 256 0 76 n = factors 1 o 77 ret eq n 0 78 end 79 note canonical case `17e30670`-b105-4305-af53-`ddde182cb6ad` 80 fn tc1 to bool 81 o = new ulong 256 0 82 n = factors 2 o 83 a0 = new ulong 1 0 84 put a0 0 2 85 ret tueq part o 0 n a0 86 end 87 note canonical case `238d57c8`-4c12-42ef-af34-`ae4929f94789` 88 fn tc2 to bool 89 o = new ulong 256 0 90 n = factors 3 o 91 a0 = new ulong 1 0 92 put a0 0 3 93 ret tueq part o 0 n a0 94 end 95 note canonical case `f59b8350`-a180-495a-8fb1-`1712fbee1158` 96 fn tc3 to bool 97 o = new ulong 256 0 98 n = factors 9 o 99 a0 = new ulong 2 0 100 put a0 0 3 101 put a0 1 3 102 ret tueq part o 0 n a0 103 end 104 note canonical case `756949d3`-3158-4e3d-91f2-`c4f9f043ee70` 105 fn tc4 to bool 106 o = new ulong 256 0 107 n = factors 4 o 108 a0 = new ulong 2 0 109 put a0 0 2 110 put a0 1 2 111 ret tueq part o 0 n a0 112 end 113 note canonical case `bc8c113f`-9580-4516-8669-`c5fc29512ceb` 114 fn tc5 to bool 115 o = new ulong 256 0 116 n = factors 8 o 117 a0 = new ulong 3 0 118 put a0 0 2 119 put a0 1 2 120 put a0 2 2 121 ret tueq part o 0 n a0 122 end 123 note canonical case `7d6a3300`-a4cb-4065-bd33-`0ced1de6cb44` 124 fn tc6 to bool 125 o = new ulong 256 0 126 n = factors 27 o 127 a0 = new ulong 3 0 128 put a0 0 3 129 put a0 1 3 130 put a0 2 3 131 ret tueq part o 0 n a0 132 end 133 note canonical case `073ac0b2`-c915-4362-929d-`fc45f7b9a9e4` 134 fn tc7 to bool 135 o = new ulong 256 0 136 n = factors 625 o 137 a0 = new ulong 4 0 138 put a0 0 5 139 put a0 1 5 140 put a0 2 5 141 put a0 3 5 142 ret tueq part o 0 n a0 143 end 144 note canonical case `6e0e4912`-7fb6-47f3-a9ad-`dbcd79340c75` 145 fn tc8 to bool 146 o = new ulong 256 0 147 n = factors 6 o 148 a0 = new ulong 2 0 149 put a0 0 2 150 put a0 1 3 151 ret tueq part o 0 n a0 152 end 153 note canonical case `00485cd3`-a3fe-4fbe-a64a-`a4308fc1f870` 154 fn tc9 to bool 155 o = new ulong 256 0 156 n = factors 12 o 157 a0 = new ulong 3 0 158 put a0 0 2 159 put a0 1 2 160 put a0 2 3 161 ret tueq part o 0 n a0 162 end 163 note canonical case `02251d54`-3ca1-4a9b-85e1-`b38f4b0ccb91` 164 fn tc10 to bool 165 o = new ulong 256 0 166 n = factors 901255 o 167 a0 = new ulong 4 0 168 put a0 0 5 169 put a0 1 17 170 put a0 2 23 171 put a0 3 461 172 ret tueq part o 0 n a0 173 end 174 note canonical case `070cf8dc`-e202-4285-aa37-`8d775c9cd473` 175 fn tc11 to bool 176 o = new ulong 256 0 177 n = factors `93819012551` o 178 a0 = new ulong 3 0 179 put a0 0 11 180 put a0 1 9539 181 put a0 2 894119 182 ret tueq part o 0 n a0 183 end 184 fn main to int 185 tcheck tc0 c0 186 tcheck tc1 c1 187 tcheck tc2 c2 188 tcheck tc3 c3 189 tcheck tc4 c4 190 tcheck tc5 c5 191 tcheck tc6 c6 192 tcheck tc7 c7 193 tcheck tc8 c8 194 tcheck tc9 c9 195 tcheck tc10 c10 196 tcheck tc11 c11 197 ret int get tfails 0 198 end