interplane.Get Omega
Read in your language

omega-rosetta

aien-dev/omega-rosetta

Brought by drakestapleton

branch main Branches Tags History

omega-rosetta / exercises / protein-translation / test.om

438 lines · 9591 bytes Raw Blame History
1note ---- test harness (appended after the solution by exercise.sh) ----
2text tok "ok "
3text tnok "not ok "
4text tsep " - "
5text tnl "\n"
6global tfails ulong 1
7global tnum ulong 1
8fn temit a view uchar * to void
9o = ulong 0
10while lt o len a bound 4096
11k = write 1 a o sub len a o
12if le k 0
13exit 2
14end
15o = add o ulong k
16end
17end
18fn temitu n ulong to void
19d = new uchar 20 0
20i = ulong 20
21v = n
22while true bound 20
23i = sub i 1
24put d i uchar add rem v 10 48
25v = div v 10
26if eq v 0
27break
28end
29end
30temit part d i sub 20 i
31end
32note one TAP-style line per case; main returns the number of failed cases
33fn tcheck c bool what view uchar * to void
34put tnum 0 add get tnum 0 1
35if c
36temit tok
37else
38temit tnok
39put tfails 0 add get tfails 0 1
40end
41temitu get tnum 0
42temit tsep
43temit what
44temit tnl
45end
46note cases: exercism/problem-specifications exercises/protein-translation/canonical-data.json at
47note commit 650bebeb39ad40439175288042aece982b0a90a9 (2026-10-19), MIT licence,
48note https://github.com/exercism/problem-specifications
49note 30 cases kept, 0 skipped, 1 superseded (reimplemented) cases omitted
50fn tbeq a view uchar * b view uchar * to bool
51if ne len a len b
52ret false
53end
54for i ulong len a
55if ne get a i get b i
56ret false
57end
58end
59ret true
60end
61text z0 "z"
62text c1 "proteins: Empty RNA sequence results in no proteins"
63text s2 "AUG"
64text e3 "Methionine"
65text c4 "proteins: Methionine RNA sequence"
66text s5 "UUU"
67text e6 "Phenylalanine"
68text c7 "proteins: Phenylalanine RNA sequence 1"
69text s8 "UUC"
70text e9 "Phenylalanine"
71text c10 "proteins: Phenylalanine RNA sequence 2"
72text s11 "UUA"
73text e12 "Leucine"
74text c13 "proteins: Leucine RNA sequence 1"
75text s14 "UUG"
76text e15 "Leucine"
77text c16 "proteins: Leucine RNA sequence 2"
78text s17 "UCU"
79text e18 "Serine"
80text c19 "proteins: Serine RNA sequence 1"
81text s20 "UCC"
82text e21 "Serine"
83text c22 "proteins: Serine RNA sequence 2"
84text s23 "UCA"
85text e24 "Serine"
86text c25 "proteins: Serine RNA sequence 3"
87text s26 "UCG"
88text e27 "Serine"
89text c28 "proteins: Serine RNA sequence 4"
90text s29 "UAU"
91text e30 "Tyrosine"
92text c31 "proteins: Tyrosine RNA sequence 1"
93text s32 "UAC"
94text e33 "Tyrosine"
95text c34 "proteins: Tyrosine RNA sequence 2"
96text s35 "UGU"
97text e36 "Cysteine"
98text c37 "proteins: Cysteine RNA sequence 1"
99text s38 "UGC"
100text e39 "Cysteine"
101text c40 "proteins: Cysteine RNA sequence 2"
102text s41 "UGG"
103text e42 "Tryptophan"
104text c43 "proteins: Tryptophan RNA sequence"
105text s44 "UAA"
106text c45 "proteins: STOP codon RNA sequence 1"
107text s46 "UAG"
108text c47 "proteins: STOP codon RNA sequence 2"
109text s48 "UGA"
110text c49 "proteins: STOP codon RNA sequence 3"
111text s50 "UUUUUU"
112text e51 "Phenylalanine,Phenylalanine"
113text c52 "proteins: Sequence of two protein codons translates into proteins"
114text s53 "UUAUUG"
115text e54 "Leucine,Leucine"
116text c55 "proteins: Sequence of two different protein codons translates into proteins"
117text s56 "AUGUUUUGG"
118text e57 "Methionine,Phenylalanine,Tryptophan"
119text c58 "proteins: Translate RNA strand into correct protein list"
120text s59 "UAGUGG"
121text c60 "proteins: Translation stops if STOP codon at beginning of sequence"
122text s61 "UGGUAG"
123text e62 "Tryptophan"
124text c63 "proteins: Translation stops if STOP codon at end of two-codon sequence"
125text s64 "AUGUUUUAA"
126text e65 "Methionine,Phenylalanine"
127text c66 "proteins: Translation stops if STOP codon at end of three-codon sequence"
128text s67 "UGGUAGUGG"
129text e68 "Tryptophan"
130text c69 "proteins: Translation stops if STOP codon in middle of three-codon sequence"
131text s70 "UGGUGUUAUUAAUGGUUU"
132text e71 "Tryptophan,Cysteine,Tyrosine"
133text c72 "proteins: Translation stops if STOP codon in middle of six-codon sequence"
134text s73 "AUGAUG"
135text e74 "Methionine,Methionine"
136text c75 "proteins: Sequence of two non-STOP codons does not translate to a STOP codon"
137text s76 "XYZ"
138text c77 "proteins: Unknown amino acids, not part of a codon, can't translate"
139text s78 "AUGU"
140text c79 "proteins: Incomplete RNA sequence can't translate"
141text s80 "UUCUUCUAAUGGU"
142text e81 "Phenylalanine,Phenylalanine"
143text c82 "proteins: Incomplete RNA sequence can translate if valid until a STOP codon"
144note canonical case 2c44f7bf-ba20-43f7-a3bf-f2219c0c3f98
145fn tc0 to bool
146o = new uchar 1024 0
147n = proteins part z0 0 0 o
148if lt n 0
149ret false
150end
151ret eq ulong n 0
152end
153note canonical case 96d3d44f-34a2-4db4-84cd-fff523e069be
154fn tc1 to bool
155o = new uchar 1024 0
156n = proteins s2 o
157if lt n 0
158ret false
159end
160ret tbeq part o 0 ulong n e3
161end
162note canonical case 1b4c56d8-d69f-44eb-be0e-7b17546143d9
163fn tc2 to bool
164o = new uchar 1024 0
165n = proteins s5 o
166if lt n 0
167ret false
168end
169ret tbeq part o 0 ulong n e6
170end
171note canonical case 81b53646-bd57-4732-b2cb-6b1880e36d11
172fn tc3 to bool
173o = new uchar 1024 0
174n = proteins s8 o
175if lt n 0
176ret false
177end
178ret tbeq part o 0 ulong n e9
179end
180note canonical case 42f69d4f-19d2-4d2c-a8b0-f0ae9ee1b6b4
181fn tc4 to bool
182o = new uchar 1024 0
183n = proteins s11 o
184if lt n 0
185ret false
186end
187ret tbeq part o 0 ulong n e12
188end
189note canonical case ac5edadd-08ed-40a3-b2b9-d82bb50424c4
190fn tc5 to bool
191o = new uchar 1024 0
192n = proteins s14 o
193if lt n 0
194ret false
195end
196ret tbeq part o 0 ulong n e15
197end
198note canonical case 8bc36e22-f984-44c3-9f6b-ee5d4e73f120
199fn tc6 to bool
200o = new uchar 1024 0
201n = proteins s17 o
202if lt n 0
203ret false
204end
205ret tbeq part o 0 ulong n e18
206end
207note canonical case 5c3fa5da-4268-44e5-9f4b-f016ccf90131
208fn tc7 to bool
209o = new uchar 1024 0
210n = proteins s20 o
211if lt n 0
212ret false
213end
214ret tbeq part o 0 ulong n e21
215end
216note canonical case 00579891-b594-42b4-96dc-7ff8bf519606
217fn tc8 to bool
218o = new uchar 1024 0
219n = proteins s23 o
220if lt n 0
221ret false
222end
223ret tbeq part o 0 ulong n e24
224end
225note canonical case 08c61c3b-fa34-4950-8c4a-133945570ef6
226fn tc9 to bool
227o = new uchar 1024 0
228n = proteins s26 o
229if lt n 0
230ret false
231end
232ret tbeq part o 0 ulong n e27
233end
234note canonical case 54e1e7d8-63c0-456d-91d2-062c72f8eef5
235fn tc10 to bool
236o = new uchar 1024 0
237n = proteins s29 o
238if lt n 0
239ret false
240end
241ret tbeq part o 0 ulong n e30
242end
243note canonical case 47bcfba2-9d72-46ad-bbce-22f7666b7eb1
244fn tc11 to bool
245o = new uchar 1024 0
246n = proteins s32 o
247if lt n 0
248ret false
249end
250ret tbeq part o 0 ulong n e33
251end
252note canonical case 3a691829-fe72-43a7-8c8e-1bd083163f72
253fn tc12 to bool
254o = new uchar 1024 0
255n = proteins s35 o
256if lt n 0
257ret false
258end
259ret tbeq part o 0 ulong n e36
260end
261note canonical case 1b6f8a26-ca2f-43b8-8262-3ee446021767
262fn tc13 to bool
263o = new uchar 1024 0
264n = proteins s38 o
265if lt n 0
266ret false
267end
268ret tbeq part o 0 ulong n e39
269end
270note canonical case 1e91c1eb-02c0-48a0-9e35-168ad0cb5f39
271fn tc14 to bool
272o = new uchar 1024 0
273n = proteins s41 o
274if lt n 0
275ret false
276end
277ret tbeq part o 0 ulong n e42
278end
279note canonical case e547af0b-aeab-49c7-9f13-801773a73557
280fn tc15 to bool
281o = new uchar 1024 0
282n = proteins s44 o
283if lt n 0
284ret false
285end
286ret eq ulong n 0
287end
288note canonical case 67640947-ff02-4f23-a2ef-816f8a2ba72e
289fn tc16 to bool
290o = new uchar 1024 0
291n = proteins s46 o
292if lt n 0
293ret false
294end
295ret eq ulong n 0
296end
297note canonical case 9c2ad527-ebc9-4ace-808b-2b6447cb54cb
298fn tc17 to bool
299o = new uchar 1024 0
300n = proteins s48 o
301if lt n 0
302ret false
303end
304ret eq ulong n 0
305end
306note canonical case f4d9d8ee-00a8-47bf-a1e3-1641d4428e54
307fn tc18 to bool
308o = new uchar 1024 0
309n = proteins s50 o
310if lt n 0
311ret false
312end
313ret tbeq part o 0 ulong n e51
314end
315note canonical case dd22eef3-b4f1-4ad6-bb0b-27093c090a9d
316fn tc19 to bool
317o = new uchar 1024 0
318n = proteins s53 o
319if lt n 0
320ret false
321end
322ret tbeq part o 0 ulong n e54
323end
324note canonical case d0f295df-fb70-425c-946c-ec2ec185388e
325fn tc20 to bool
326o = new uchar 1024 0
327n = proteins s56 o
328if lt n 0
329ret false
330end
331ret tbeq part o 0 ulong n e57
332end
333note canonical case e30e8505-97ec-4e5f-a73e-5726a1faa1f4
334fn tc21 to bool
335o = new uchar 1024 0
336n = proteins s59 o
337if lt n 0
338ret false
339end
340ret eq ulong n 0
341end
342note canonical case 5358a20b-6f4c-4893-bce4-f929001710f3
343fn tc22 to bool
344o = new uchar 1024 0
345n = proteins s61 o
346if lt n 0
347ret false
348end
349ret tbeq part o 0 ulong n e62
350end
351note canonical case ba16703a-1a55-482f-bb07-b21eef5093a3
352fn tc23 to bool
353o = new uchar 1024 0
354n = proteins s64 o
355if lt n 0
356ret false
357end
358ret tbeq part o 0 ulong n e65
359end
360note canonical case 4089bb5a-d5b4-4e71-b79e-b8d1f14a2911
361fn tc24 to bool
362o = new uchar 1024 0
363n = proteins s67 o
364if lt n 0
365ret false
366end
367ret tbeq part o 0 ulong n e68
368end
369note canonical case 2c2a2a60-401f-4a80-b977-e0715b23b93d
370fn tc25 to bool
371o = new uchar 1024 0
372n = proteins s70 o
373if lt n 0
374ret false
375end
376ret tbeq part o 0 ulong n e71
377end
378note canonical case f6f92714-769f-4187-9524-e353e8a41a80
379fn tc26 to bool
380o = new uchar 1024 0
381n = proteins s73 o
382if lt n 0
383ret false
384end
385ret tbeq part o 0 ulong n e74
386end
387note canonical case 9eac93f3-627a-4c90-8653-6d0a0595bc6f
388fn tc27 to bool
389o = new uchar 1024 0
390ret eq proteins s76 o -1
391end
392note canonical case 9d73899f-e68e-4291-b1e2-7bf87c00f024
393fn tc28 to bool
394o = new uchar 1024 0
395ret eq proteins s78 o -1
396end
397note canonical case 43945cf7-9968-402d-ab9f-b8a28750b050
398fn tc29 to bool
399o = new uchar 1024 0
400n = proteins s80 o
401if lt n 0
402ret false
403end
404ret tbeq part o 0 ulong n e81
405end
406fn main to int
407tcheck tc0 c1
408tcheck tc1 c4
409tcheck tc2 c7
410tcheck tc3 c10
411tcheck tc4 c13
412tcheck tc5 c16
413tcheck tc6 c19
414tcheck tc7 c22
415tcheck tc8 c25
416tcheck tc9 c28
417tcheck tc10 c31
418tcheck tc11 c34
419tcheck tc12 c37
420tcheck tc13 c40
421tcheck tc14 c43
422tcheck tc15 c45
423tcheck tc16 c47
424tcheck tc17 c49
425tcheck tc18 c52
426tcheck tc19 c55
427tcheck tc20 c58
428tcheck tc21 c60
429tcheck tc22 c63
430tcheck tc23 c66
431tcheck tc24 c69
432tcheck tc25 c72
433tcheck tc26 c75
434tcheck tc27 c77
435tcheck tc28 c79
436tcheck tc29 c82
437ret int get tfails 0
438end