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/difference-of-squares/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 / difference-of-squares / test.om` 66 lines ยท 1304 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 text c0 "sqsum 1 is 1" 47 text c1 "sumsq 1 is 1" 48 text c2 "diffsq 1 is 0" 49 text c3 "sqsum 5 is 225" 50 text c4 "sumsq 5 is 55" 51 text c5 "diffsq 5 is 170" 52 text c6 "sqsum 100 is `25502500`" 53 text c7 "sumsq 100 is 338350" 54 text c8 "diffsq 100 is `25164150`" 55 fn main to int 56 tcheck eq sqsum 1 1 c0 57 tcheck eq sumsq 1 1 c1 58 tcheck eq diffsq 1 0 c2 59 tcheck eq sqsum 5 225 c3 60 tcheck eq sumsq 5 55 c4 61 tcheck eq diffsq 5 170 c5 62 tcheck eq sqsum 100 `25502500` c6 63 tcheck eq sumsq 100 338350 c7 64 tcheck eq diffsq 100 `25164150` c8 65 ret int get tfails 0 66 end