History

Merged in basic_tests_raise (pull request #5)

Update limbo tests to raise exception on failure rather than call 'exit'.

Aaron R Robinson committed 9 years ago

Commit e5f12522 parents c55b47f 63ba7151 file · +227 −225Browse files

Unified · Split

limbo/basic_limbo_tests.b+227−225
@@ -6,6 +6,8 @@ include "external_module.m"; · 5 unmodified lines
6 6
7sys : Sys;7sys : Sys;
8 8
9TEST_FAILED : exception;
10
9init(args: list of string)11init(args: list of string)
10{12{
11 a := "foobar!";13 a := "foobar!";
@@ -56,7 +58,7 @@ test_function_refs() · 44 unmodified lines
56 s1 := "abcdefg";58 s1 := "abcdefg";
57 s2 := "ABCDEFG";59 s2 := "ABCDEFG";
58 60
59 if (f(s1, s2) != 1) exit;61 if (f(s1, s2) != 1) raise TEST_FAILED();
60}62}
61 63
62test_alt()64test_alt()
@@ -74,9 +76,9 @@ test_alt() · 11 unmodified lines
74 alt76 alt
75 {77 {
76 r1 := <- int_chan_10 =>78 r1 := <- int_chan_10 =>
77 if (r1 != 10) exit;79 if (r1 != 10) raise TEST_FAILED();
78 r2 := <- int_chan_20 =>80 r2 := <- int_chan_20 =>
79 if (r2 != 20) exit;81 if (r2 != 20) raise TEST_FAILED();
80 d = <- int_chan_done =>82 d = <- int_chan_done =>
81 ;83 ;
82 }84 }
@@ -94,9 +96,9 @@ test_alt() · 11 unmodified lines
94 alt96 alt
95 {97 {
96 unused =<- int_chan_unused1 =>98 unused =<- int_chan_unused1 =>
97 exit;99 raise TEST_FAILED();
98 int_chan_unused2 <-= unused =>100 int_chan_unused2 <-= unused =>
99 exit;101 raise TEST_FAILED();
100 * =>102 * =>
101 ;103 ;
102 }104 }
@@ -114,9 +116,9 @@ test_alt() · 11 unmodified lines
114 alt116 alt
115 {117 {
116 unused =<- int_chan_unused1 =>118 unused =<- int_chan_unused1 =>
117 exit;119 raise TEST_FAILED();
118 int_chan_unused2 <-= unused =>120 int_chan_unused2 <-= unused =>
119 exit;121 raise TEST_FAILED();
120 * =>122 * =>
121 ;123 ;
122 }124 }
@@ -136,17 +138,17 @@ alt2(ten : chan of int, twenty : chan of int, done : chan of int) · 13 unmodified lines
136{138{
137 v : int;139 v : int;
138 v =<- twenty;140 v =<- twenty;
139 if (v != 20) exit;141 if (v != 20) raise TEST_FAILED();
140 v =<- ten;142 v =<- ten;
141 if (v != 10) exit;143 if (v != 10) raise TEST_FAILED();
142 v =<- twenty;144 v =<- twenty;
143 if (v != 20) exit;145 if (v != 20) raise TEST_FAILED();
144 v =<- twenty;146 v =<- twenty;
145 if (v != 20) exit;147 if (v != 20) raise TEST_FAILED();
146 v =<- ten;148 v =<- ten;
147 if (v != 10) exit;149 if (v != 10) raise TEST_FAILED();
148 v =<- ten;150 v =<- ten;
149 if (v != 10) exit;151 if (v != 10) raise TEST_FAILED();
150 done <-= 1;152 done <-= 1;
151}153}
152 154
@@ -171,7 +173,7 @@ test_channel_int(c : chan of int) · 18 unmodified lines
171 spawn test_channel_int(c_l);173 spawn test_channel_int(c_l);
172 174
173 m := <- c_l;175 m := <- c_l;
174 if (m != 10) exit;176 if (m != 10) raise TEST_FAILED();
175 177
176 c_l <-= 20;178 c_l <-= 20;
177 }179 }
@@ -180,7 +182,7 @@ test_channel_int(c : chan of int) · 2 unmodified lines
180 c <-= 10;182 c <-= 10;
181 m := <- c;183 m := <- c;
182 184
183 if (m != 20) exit;185 if (m != 20) raise TEST_FAILED();
184 }186 }
185}187}
186 188
@@ -193,15 +195,15 @@ test_channel_int_buffered(c : chan of int, r : chan of int) · 6 unmodified lines
193 spawn test_channel_int_buffered(c_l, r_l);195 spawn test_channel_int_buffered(c_l, r_l);
194 196
195 m := <- c_l;197 m := <- c_l;
196 if (m != 10) exit;198 if (m != 10) raise TEST_FAILED();
197 m += <- c_l;199 m += <- c_l;
198 if (m != 20) exit;200 if (m != 20) raise TEST_FAILED();
199 m += <- c_l;201 m += <- c_l;
200 if (m != 30) exit;202 if (m != 30) raise TEST_FAILED();
201 m += <- c_l;203 m += <- c_l;
202 if (m != 40) exit;204 if (m != 40) raise TEST_FAILED();
203 m += <- c_l;205 m += <- c_l;
204 if (m != 50) exit;206 if (m != 50) raise TEST_FAILED();
205 207
206 r_l <-= m;208 r_l <-= m;
207 }209 }
@@ -214,7 +216,7 @@ test_channel_int_buffered(c : chan of int, r : chan of int) · 6 unmodified lines
214 c <-= 10;216 c <-= 10;
215 m := <- r;217 m := <- r;
216 218
217 if (m != 50) exit;219 if (m != 50) raise TEST_FAILED();
218 }220 }
219}221}
220 222
@@ -232,8 +234,8 @@ test_channel_adt(c : chan of ChannelAdt) · 11 unmodified lines
232 spawn test_channel_adt(c_l);234 spawn test_channel_adt(c_l);
233 235
234 m := <- c_l;236 m := <- c_l;
235 if (m.s != "from") exit;237 if (m.s != "from") raise TEST_FAILED();
236 if (m.d != 1.0) exit;238 if (m.d != 1.0) raise TEST_FAILED();
237 239
238 c_l <-= ("to", 2.0);240 c_l <-= ("to", 2.0);
239 }241 }
@@ -242,8 +244,8 @@ test_channel_adt(c : chan of ChannelAdt) · 2 unmodified lines
242 c <-= ("from", 1.0);244 c <-= ("from", 1.0);
243 m := <- c;245 m := <- c;
244 246
245 if (m.s != "to") exit;247 if (m.s != "to") raise TEST_FAILED();
246 if (m.d != 2.0) exit;248 if (m.d != 2.0) raise TEST_FAILED();
247 }249 }
248}250}
249 251
@@ -256,14 +258,14 @@ test_channel_adt_buffered(c : chan of ChannelAdt, r : chan of ChannelAdt) · 6 unmodified lines
256 spawn test_channel_adt_buffered(c_l, r_l);258 spawn test_channel_adt_buffered(c_l, r_l);
257 259
258 m := <- c_l;260 m := <- c_l;
259 if (m.s != "from") exit;261 if (m.s != "from") raise TEST_FAILED();
260 if (m.d != 1.0) exit;262 if (m.d != 1.0) raise TEST_FAILED();
261 m = <- c_l;263 m = <- c_l;
262 if (m.s != "from") exit;264 if (m.s != "from") raise TEST_FAILED();
263 if (m.d != 1.0) exit;265 if (m.d != 1.0) raise TEST_FAILED();
264 m = <- c_l;266 m = <- c_l;
265 if (m.s != "from") exit;267 if (m.s != "from") raise TEST_FAILED();
266 if (m.d != 1.0) exit;268 if (m.d != 1.0) raise TEST_FAILED();
267 269
268 r_l <-= ("to", 2.0);270 r_l <-= ("to", 2.0);
269 }271 }
@@ -274,8 +276,8 @@ test_channel_adt_buffered(c : chan of ChannelAdt, r : chan of ChannelAdt) · 4 unmodified lines
274 c <-= ("from", 1.0);276 c <-= ("from", 1.0);
275 m := <- r;277 m := <- r;
276 278
277 if (m.s != "to") exit;279 if (m.s != "to") raise TEST_FAILED();
278 if (m.d != 2.0) exit;280 if (m.d != 2.0) raise TEST_FAILED();
279 }281 }
280}282}
281 283
@@ -287,8 +289,8 @@ test_channel_ref_adt(c : chan of ref ChannelAdt) · 5 unmodified lines
287 spawn test_channel_ref_adt(c_l);289 spawn test_channel_ref_adt(c_l);
288 290
289 m := <- c_l;291 m := <- c_l;
290 if (m.s != "from") exit;292 if (m.s != "from") raise TEST_FAILED();
291 if (m.d != 1.0) exit;293 if (m.d != 1.0) raise TEST_FAILED();
292 294
293 c_l <-= ref ("to", 2.0);295 c_l <-= ref ("to", 2.0);
294 }296 }
@@ -297,8 +299,8 @@ test_channel_ref_adt(c : chan of ref ChannelAdt) · 2 unmodified lines
297 c <-= ref ("from", 1.0);299 c <-= ref ("from", 1.0);
298 m := <- c;300 m := <- c;
299 301
300 if (m.s != "to") exit;302 if (m.s != "to") raise TEST_FAILED();
301 if (m.d != 2.0) exit;303 if (m.d != 2.0) raise TEST_FAILED();
302 }304 }
303}305}
304 306
@@ -311,14 +313,14 @@ test_channel_ref_adt_buffered(c : chan of ref ChannelAdt, r : chan of ref Channe · 6 unmodified lines
311 spawn test_channel_ref_adt_buffered(c_l, r_l);313 spawn test_channel_ref_adt_buffered(c_l, r_l);
312 314
313 m := <- c_l;315 m := <- c_l;
314 if (m.s != "from") exit;316 if (m.s != "from") raise TEST_FAILED();
315 if (m.d != 1.0) exit;317 if (m.d != 1.0) raise TEST_FAILED();
316 m = <- c_l;318 m = <- c_l;
317 if (m.s != "from") exit;319 if (m.s != "from") raise TEST_FAILED();
318 if (m.d != 1.0) exit;320 if (m.d != 1.0) raise TEST_FAILED();
319 m = <- c_l;321 m = <- c_l;
320 if (m.s != "from") exit;322 if (m.s != "from") raise TEST_FAILED();
321 if (m.d != 1.0) exit;323 if (m.d != 1.0) raise TEST_FAILED();
322 324
323 r_l <-= ref ("to", 2.0);325 r_l <-= ref ("to", 2.0);
324 }326 }
@@ -329,8 +331,8 @@ test_channel_ref_adt_buffered(c : chan of ref ChannelAdt, r : chan of ref Channe · 4 unmodified lines
329 c <-= ref ("from", 1.0);331 c <-= ref ("from", 1.0);
330 m := <- r;332 m := <- r;
331 333
332 if (m.s != "to") exit;334 if (m.s != "to") raise TEST_FAILED();
333 if (m.d != 2.0) exit;335 if (m.d != 2.0) raise TEST_FAILED();
334 }336 }
335}337}
336 338
@@ -345,7 +347,7 @@ th1() · 8 unmodified lines
345 a := 9;347 a := 9;
346 b := 11;348 b := 11;
347 c := a + b;349 c := a + b;
348 if (c != 20) exit;350 if (c != 20) raise TEST_FAILED();
349}351}
350 352
351TESTEXCEPTION : exception(int, int);353TESTEXCEPTION : exception(int, int);
@@ -358,16 +360,16 @@ test_exceptions() · 6 unmodified lines
358 } exception e {360 } exception e {
359 TESTEXCEPTION =>361 TESTEXCEPTION =>
360 (a,b) := e;362 (a,b) := e;
361 if (a != 5 || b != 10) exit;363 if (a != 5 || b != 10) raise TEST_FAILED();
362 364
363 * => exit;365 * => raise TEST_FAILED();
364 }366 }
365 367
366 {368 {
367 raise "bad time";369 raise "bad time";
368 } exception e {370 } exception e {
369 "bad time" => ;371 "bad time" => ;
370 * => exit;372 * => raise TEST_FAILED();
371 }373 }
372 374
373 s := 0;375 s := 0;
@@ -377,7 +379,7 @@ test_exceptions() · 3 unmodified lines
377 TESTEXCEPTION => s = 1;379 TESTEXCEPTION => s = 1;
378 * => ;380 * => ;
379 }381 }
380 if (s != 1) exit;382 if (s != 1) raise TEST_FAILED();
381 383
382 s = 0;384 s = 0;
383 {385 {
@@ -386,7 +388,7 @@ test_exceptions() · 2 unmodified lines
386 "exception string" => s = 1;388 "exception string" => s = 1;
387 * => ;389 * => ;
388 }390 }
389 if (s != 1) exit;391 if (s != 1) raise TEST_FAILED();
390 392
391 s = 0;393 s = 0;
392 {394 {
@@ -394,11 +396,11 @@ test_exceptions() · 1 unmodified line
394 } exception e {396 } exception e {
395 TESTEXCEPTION =>397 TESTEXCEPTION =>
396 (a,b) := e;398 (a,b) := e;
397 if (a != 0) exit;399 if (a != 0) raise TEST_FAILED();
398 s = 1;400 s = 1;
399 * => ;401 * => ;
400 }402 }
401 if (s != 1) exit;403 if (s != 1) raise TEST_FAILED();
402}404}
403 405
404raise_exception_1(v : int)406raise_exception_1(v : int)
@@ -406,10 +408,10 @@ raise_exception_1(v : int) · 1 unmodified line
406 {408 {
407 raise_exception_2(v);409 raise_exception_2(v);
408 } exception e {410 } exception e {
409 "do not catch" => exit;411 "do not catch" => raise TEST_FAILED();
410 }412 }
411 413
412 exit;414 raise TEST_FAILED();
413}415}
414 416
415raise_exception_2(v : int)417raise_exception_2(v : int)
@@ -444,7 +446,7 @@ test_case() · 28 unmodified lines
444 * => s = 0;446 * => s = 0;
445 }447 }
446 448
447 if (s != 1) exit;449 if (s != 1) raise TEST_FAILED();
448 }450 }
449 451
450 {452 {
@@ -457,7 +459,7 @@ test_case() · 6 unmodified lines
457 * => s = 0;459 * => s = 0;
458 }460 }
459 461
460 if (s != 1) exit;462 if (s != 1) raise TEST_FAILED();
461 }463 }
462 464
463 {465 {
@@ -471,7 +473,7 @@ test_case() · 7 unmodified lines
471 * => s = 0;473 * => s = 0;
472 }474 }
473 475
474 if (s != 1) exit;476 if (s != 1) raise TEST_FAILED();
475 }477 }
476}478}
477 479
@@ -494,12 +496,12 @@ test_discriminated_union() · 16 unmodified lines
494 pick x := c496 pick x := c
495 {497 {
496 Str =>498 Str =>
497 exit;499 raise TEST_FAILED();
498 Real =>500 Real =>
499 ;501 ;
500 };502 };
501 503
502 if (tagof(c) != tagof(Constant.Real)) exit;504 if (tagof(c) != tagof(Constant.Real)) raise TEST_FAILED();
503}505}
504 506
505test_external_module()507test_external_module()
@@ -509,12 +511,12 @@ test_external_module() · 3 unmodified lines
509 511
510 {512 {
511 module_int := ext_mod->return_int();513 module_int := ext_mod->return_int();
512 if (module_int != ext_mod->module_constant) exit;514 if (module_int != ext_mod->module_constant) raise TEST_FAILED();
513 }515 }
514 516
515 {517 {
516 thirty_four := ext_mod->double_int(17);518 thirty_four := ext_mod->double_int(17);
517 if (thirty_four != 34) exit;519 if (thirty_four != 34) raise TEST_FAILED();
518 }520 }
519 521
520 {522 {
@@ -534,7 +536,7 @@ test_fixed_point() · 13 unmodified lines
534 a := fpt(1.5);536 a := fpt(1.5);
535 b := fpt(2.5);537 b := fpt(2.5);
536 c := a * b;538 c := a * b;
537 if (c != fpt(3.75)) exit;539 if (c != fpt(3.75)) raise TEST_FAILED();
538}540}
539 541
540test_exponent()542test_exponent()
@@ -544,34 +546,34 @@ test_exponent() · 3 unmodified lines
544 base := 2;546 base := 2;
545 power := 3;547 power := 3;
546 result := base ** power;548 result := base ** power;
547 if (result != 8) exit;549 if (result != 8) raise TEST_FAILED();
548 base **= power;550 base **= power;
549 if (result != base) exit;551 if (result != base) raise TEST_FAILED();
550 }552 }
551 553
552 {554 {
553 base := big 2;555 base := big 2;
554 power := 3;556 power := 3;
555 result := base ** power;557 result := base ** power;
556 if (result != big 8) exit;558 if (result != big 8) raise TEST_FAILED();
557 base **= power;559 base **= power;
558 if (result != base) exit;560 if (result != base) raise TEST_FAILED();
559 }561 }
560 562
561 {563 {
562 base := real 2.0;564 base := real 2.0;
563 power := 3;565 power := 3;
564 result := base ** power;566 result := base ** power;
565 if (result != real 8.0) exit;567 if (result != real 8.0) raise TEST_FAILED();
566 base **= power;568 base **= power;
567 if (result != base) exit;569 if (result != base) raise TEST_FAILED();
568 }570 }
569 571
570 {572 {
571 base := 2;573 base := 2;
572 power := 0;574 power := 0;
573 result := base ** power;575 result := base ** power;
574 if (result != 1) exit;576 if (result != 1) raise TEST_FAILED();
575 }577 }
576 578
577 # Integer exponent rules579 # Integer exponent rules
@@ -579,12 +581,12 @@ test_exponent() · 1 unmodified line
579 base := 2;581 base := 2;
580 power := 0;582 power := 0;
581 result := base ** power;583 result := base ** power;
582 if (result != 1) exit;584 if (result != 1) raise TEST_FAILED();
583 585
584 base = 2;586 base = 2;
585 power = -1;587 power = -1;
586 result = base ** power;588 result = base ** power;
587 if (result != 0) exit; # Non integer result (i.e. 0)589 if (result != 0) raise TEST_FAILED(); # Non integer result (i.e. 0)
588 }590 }
589 591
590 # Real exponent rules592 # Real exponent rules
@@ -592,12 +594,12 @@ test_exponent() · 1 unmodified line
592 base := 2.0;594 base := 2.0;
593 power := 0;595 power := 0;
594 result := base ** power;596 result := base ** power;
595 if (result != 1.0) exit;597 if (result != 1.0) raise TEST_FAILED();
596 598
597 base = 2.0;599 base = 2.0;
598 power = -1;600 power = -1;
599 result = base ** power;601 result = base ** power;
600 if (result != 0.5) exit;602 if (result != 0.5) raise TEST_FAILED();
601 }603 }
602}604}
603 605
@@ -605,28 +607,28 @@ test_string() · 1 unmodified line
605{607{
606 sys->print("test_string()\n");608 sys->print("test_string()\n");
607 count4 := "abcd";609 count4 := "abcd";
608 if (len count4 != 4) exit;610 if (len count4 != 4) raise TEST_FAILED();
609 611
610 array4 := array of byte count4;612 array4 := array of byte count4;
611 if (len array4 != 4) exit;613 if (len array4 != 4) raise TEST_FAILED();
612 614
613 count6 := "わがよたれぞ";615 count6 := "わがよたれぞ";
614 if (len count6 != 6) exit;616 if (len count6 != 6) raise TEST_FAILED();
615 617
616 array18 := array of byte count6;618 array18 := array of byte count6;
617 if (len array18 != 18) exit;619 if (len array18 != 18) raise TEST_FAILED();
618 620
619 count6_2 := string array18;621 count6_2 := string array18;
620 if (count6 != count6_2) exit;622 if (count6 != count6_2) raise TEST_FAILED();
621 623
622 count7 := "खा सकता";624 count7 := "खा सकता";
623 if (len count7 != 7) exit;625 if (len count7 != 7) raise TEST_FAILED();
624 626
625 array19 := array of byte count7;627 array19 := array of byte count7;
626 if (len array19 != 19) exit;628 if (len array19 != 19) raise TEST_FAILED();
627 629
628 count36 := "abcdefghijklmnopqrstuvwxyz0123456789";630 count36 := "abcdefghijklmnopqrstuvwxyz0123456789";
629 if (len count36 != 36) exit;631 if (len count36 != 36) raise TEST_FAILED();
630 632
631 # Grow string633 # Grow string
632 {634 {
@@ -637,12 +639,12 @@ test_string() · 4 unmodified lines
637 str[len str] = ch + 2;639 str[len str] = ch + 2;
638 str[len str] = ch + 3;640 str[len str] = ch + 3;
639 str[len str] = ch + 4;641 str[len str] = ch + 4;
640 if (len str != 5) exit;642 if (len str != 5) raise TEST_FAILED();
641 if (str[2] != 'c') exit;643 if (str[2] != 'c') raise TEST_FAILED();
642 644
643 str[2] = 'よ';645 str[2] = 'よ';
644 if (len str != 5) exit;646 if (len str != 5) raise TEST_FAILED();
645 if (str[2] != 'よ') exit;647 if (str[2] != 'よ') raise TEST_FAILED();
646 }648 }
647 649
648 # Compare (ascii)650 # Compare (ascii)
@@ -651,27 +653,27 @@ test_string() · 2 unmodified lines
651 str_l2 := "a";653 str_l2 := "a";
652 str_g := "z";654 str_g := "z";
653 655
654 if (!(str_l == str_l)) exit;656 if (!(str_l == str_l)) raise TEST_FAILED();
655 if (!(str_l == str_l2)) exit;657 if (!(str_l == str_l2)) raise TEST_FAILED();
656 if (!(str_l <= str_l2)) exit;658 if (!(str_l <= str_l2)) raise TEST_FAILED();
657 if (!(str_l >= str_l2)) exit;659 if (!(str_l >= str_l2)) raise TEST_FAILED();
658 if (!(str_l < str_g)) exit;660 if (!(str_l < str_g)) raise TEST_FAILED();
659 if (!(str_g > str_l)) exit;661 if (!(str_g > str_l)) raise TEST_FAILED();
660 662
661 str_e : string;663 str_e : string;
662 if (str_l == str_e) exit;664 if (str_l == str_e) raise TEST_FAILED();
663 if (!(str_l != str_e)) exit;665 if (!(str_l != str_e)) raise TEST_FAILED();
664 if (str_l <= str_e) exit;666 if (str_l <= str_e) raise TEST_FAILED();
665 if (!(str_l >= str_e)) exit;667 if (!(str_l >= str_e)) raise TEST_FAILED();
666 if (str_l < str_e) exit;668 if (str_l < str_e) raise TEST_FAILED();
667 if (!(str_g > str_e)) exit;669 if (!(str_g > str_e)) raise TEST_FAILED();
668 670
669 if (str_e == str_l) exit;671 if (str_e == str_l) raise TEST_FAILED();
670 if (!(str_e != str_l)) exit;672 if (!(str_e != str_l)) raise TEST_FAILED();
671 if (!(str_e <= str_l)) exit;673 if (!(str_e <= str_l)) raise TEST_FAILED();
672 if (str_e >= str_l) exit;674 if (str_e >= str_l) raise TEST_FAILED();
673 if (!(str_e < str_l)) exit;675 if (!(str_e < str_l)) raise TEST_FAILED();
674 if (str_e > str_g) exit;676 if (str_e > str_g) raise TEST_FAILED();
675 }677 }
676 678
677 # Compare (multi-byte)679 # Compare (multi-byte)
@@ -680,27 +682,27 @@ test_string() · 2 unmodified lines
680 str_l2 := "Α";682 str_l2 := "Α";
681 str_g := "Ω";683 str_g := "Ω";
682 684
683 if (!(str_l == str_l)) exit;685 if (!(str_l == str_l)) raise TEST_FAILED();
684 if (!(str_l == str_l2)) exit;686 if (!(str_l == str_l2)) raise TEST_FAILED();
685 if (!(str_l <= str_l2)) exit;687 if (!(str_l <= str_l2)) raise TEST_FAILED();
686 if (!(str_l >= str_l2)) exit;688 if (!(str_l >= str_l2)) raise TEST_FAILED();
687 if (!(str_l < str_g)) exit;689 if (!(str_l < str_g)) raise TEST_FAILED();
688 if (!(str_g > str_l)) exit;690 if (!(str_g > str_l)) raise TEST_FAILED();
689 691
690 str_e : string;692 str_e : string;
691 if (str_l == str_e) exit;693 if (str_l == str_e) raise TEST_FAILED();
692 if (!(str_l != str_e)) exit;694 if (!(str_l != str_e)) raise TEST_FAILED();
693 if (str_l <= str_e) exit;695 if (str_l <= str_e) raise TEST_FAILED();
694 if (!(str_l >= str_e)) exit;696 if (!(str_l >= str_e)) raise TEST_FAILED();
695 if (str_l < str_e) exit;697 if (str_l < str_e) raise TEST_FAILED();
696 if (!(str_g > str_e)) exit;698 if (!(str_g > str_e)) raise TEST_FAILED();
697 699
698 if (str_e == str_l) exit;700 if (str_e == str_l) raise TEST_FAILED();
699 if (!(str_e != str_l)) exit;701 if (!(str_e != str_l)) raise TEST_FAILED();
700 if (!(str_e <= str_l)) exit;702 if (!(str_e <= str_l)) raise TEST_FAILED();
701 if (str_e >= str_l) exit;703 if (str_e >= str_l) raise TEST_FAILED();
702 if (!(str_e < str_l)) exit;704 if (!(str_e < str_l)) raise TEST_FAILED();
703 if (str_e > str_g) exit;705 if (str_e > str_g) raise TEST_FAILED();
704 }706 }
705 707
706 # Compare (multi-byte/ascii mix)708 # Compare (multi-byte/ascii mix)
@@ -709,27 +711,27 @@ test_string() · 2 unmodified lines
709 str_l2 := "a";711 str_l2 := "a";
710 str_g := "Ω";712 str_g := "Ω";
711 713
712 if (!(str_l == str_l)) exit;714 if (!(str_l == str_l)) raise TEST_FAILED();
713 if (!(str_l == str_l2)) exit;715 if (!(str_l == str_l2)) raise TEST_FAILED();
714 if (!(str_l <= str_l2)) exit;716 if (!(str_l <= str_l2)) raise TEST_FAILED();
715 if (!(str_l >= str_l2)) exit;717 if (!(str_l >= str_l2)) raise TEST_FAILED();
716 if (!(str_l < str_g)) exit;718 if (!(str_l < str_g)) raise TEST_FAILED();
717 if (!(str_g > str_l)) exit;719 if (!(str_g > str_l)) raise TEST_FAILED();
718 720
719 str_e : string;721 str_e : string;
720 if (str_l == str_e) exit;722 if (str_l == str_e) raise TEST_FAILED();
721 if (!(str_l != str_e)) exit;723 if (!(str_l != str_e)) raise TEST_FAILED();
722 if (str_l <= str_e) exit;724 if (str_l <= str_e) raise TEST_FAILED();
723 if (!(str_l >= str_e)) exit;725 if (!(str_l >= str_e)) raise TEST_FAILED();
724 if (str_l < str_e) exit;726 if (str_l < str_e) raise TEST_FAILED();
725 if (!(str_g > str_e)) exit;727 if (!(str_g > str_e)) raise TEST_FAILED();
726 728
727 if (str_e == str_l) exit;729 if (str_e == str_l) raise TEST_FAILED();
728 if (!(str_e != str_l)) exit;730 if (!(str_e != str_l)) raise TEST_FAILED();
729 if (!(str_e <= str_l)) exit;731 if (!(str_e <= str_l)) raise TEST_FAILED();
730 if (str_e >= str_l) exit;732 if (str_e >= str_l) raise TEST_FAILED();
731 if (!(str_e < str_l)) exit;733 if (!(str_e < str_l)) raise TEST_FAILED();
732 if (str_e > str_g) exit;734 if (str_e > str_g) raise TEST_FAILED();
733 }735 }
734 736
735 # Concat737 # Concat
@@ -739,10 +741,10 @@ test_string() · 3 unmodified lines
739 s3 : string;741 s3 : string;
740 742
741 s4 := s1 + s2;743 s4 := s1 + s2;
742 if (s4 != "12") exit;744 if (s4 != "12") raise TEST_FAILED();
743 745
744 s1 += s2;746 s1 += s2;
745 if (s1 != "12") exit;747 if (s1 != "12") raise TEST_FAILED();
746 748
747 s5 := s3 + s1;749 s5 := s3 + s1;
748 s6 := s3 + s3;750 s6 := s3 + s3;
@@ -752,41 +754,41 @@ test_string() · 3 unmodified lines
752 {754 {
753 s1 := "01234567";755 s1 := "01234567";
754 r1 := s1[2:6];756 r1 := s1[2:6];
755 if (r1 != "2345") exit;757 if (r1 != "2345") raise TEST_FAILED();
756 758
757 s2 : string;759 s2 : string;
758 r2 := s2[0:0];760 r2 := s2[0:0];
759 if (r2 != nil) exit;761 if (r2 != nil) raise TEST_FAILED();
760 }762 }
761 763
762 # Convert number => string764 # Convert number => string
763 {765 {
764 w_val := 12345;766 w_val := 12345;
765 s_w := string w_val;767 s_w := string w_val;
766 if (s_w != "12345") exit;768 if (s_w != "12345") raise TEST_FAILED();
767 769
768 r_val := 3.14;770 r_val := 3.14;
769 s_r := string r_val;771 s_r := string r_val;
770 if (s_r != "3.14") exit;772 if (s_r != "3.14") raise TEST_FAILED();
771 773
772 b_val := big 987532;774 b_val := big 987532;
773 s_b := string b_val;775 s_b := string b_val;
774 if (s_b != "987532") exit;776 if (s_b != "987532") raise TEST_FAILED();
775 }777 }
776 778
777 # Convert string => number779 # Convert string => number
778 {780 {
779 s_w := "12345";781 s_w := "12345";
780 w_val := int s_w;782 w_val := int s_w;
781 if (w_val != 12345) exit;783 if (w_val != 12345) raise TEST_FAILED();
782 784
783 s_r := "3.14";785 s_r := "3.14";
784 r_val := real s_r;786 r_val := real s_r;
785 if (r_val != 3.14) exit;787 if (r_val != 3.14) raise TEST_FAILED();
786 788
787 s_b := "987532";789 s_b := "987532";
788 b_val := big s_b;790 b_val := big s_b;
789 if (b_val != big 987532) exit;791 if (b_val != big 987532) raise TEST_FAILED();
790 }792 }
791}793}
792 794
@@ -795,7 +797,7 @@ test_array() · 2 unmodified lines
795 sys->print("test_array()\n");797 sys->print("test_array()\n");
796 arr : array of int;798 arr : array of int;
797 a := len arr;799 a := len arr;
798 if (a != 0) exit;800 if (a != 0) raise TEST_FAILED();
799 801
800 test_array_byte();802 test_array_byte();
801 test_array_int();803 test_array_int();
@@ -808,21 +810,21 @@ test_array_byte() · 6 unmodified lines
808 arr := array [] of { byte 1, byte 2, byte 3, byte 4, byte 5, byte 6 };810 arr := array [] of { byte 1, byte 2, byte 3, byte 4, byte 5, byte 6 };
809 811
810 sl1 := arr[2:5];812 sl1 := arr[2:5];
811 if (len sl1 != 3) exit;813 if (len sl1 != 3) raise TEST_FAILED();
812 if (sl1[0] != byte 3) exit;814 if (sl1[0] != byte 3) raise TEST_FAILED();
813 if (sl1[2] != byte 5) exit;815 if (sl1[2] != byte 5) raise TEST_FAILED();
814 816
815 sl2 := sl1[1:];817 sl2 := sl1[1:];
816 if (len sl2 != 2) exit;818 if (len sl2 != 2) raise TEST_FAILED();
817 if (sl2[0] != byte 4) exit;819 if (sl2[0] != byte 4) raise TEST_FAILED();
818 if (sl2[1] != byte 5) exit;820 if (sl2[1] != byte 5) raise TEST_FAILED();
819 821
820 sl3 := array[4] of byte;822 sl3 := array[4] of byte;
821 sl3[0] = byte 16ree;823 sl3[0] = byte 16ree;
822 sl3[1:] = arr[3:5];824 sl3[1:] = arr[3:5];
823 sl3[3] = byte 16ree;825 sl3[3] = byte 16ree;
824 if (sl3[1] != byte 4) exit;826 if (sl3[1] != byte 4) raise TEST_FAILED();
825 if (sl3[2] != byte 5) exit;827 if (sl3[2] != byte 5) raise TEST_FAILED();
826}828}
827 829
828test_array_int()830test_array_int()
@@ -830,21 +832,21 @@ test_array_int() · 1 unmodified line
830 arr := array [] of { 1, 2, 3, 4, 5, 6 };832 arr := array [] of { 1, 2, 3, 4, 5, 6 };
831 833
832 sl1 := arr[2:5];834 sl1 := arr[2:5];
833 if (len sl1 != 3) exit;835 if (len sl1 != 3) raise TEST_FAILED();
834 if (sl1[0] != 3) exit;836 if (sl1[0] != 3) raise TEST_FAILED();
835 if (sl1[2] != 5) exit;837 if (sl1[2] != 5) raise TEST_FAILED();
836 838
837 sl2 := sl1[1:];839 sl2 := sl1[1:];
838 if (len sl2 != 2) exit;840 if (len sl2 != 2) raise TEST_FAILED();
839 if (sl2[0] != 4) exit;841 if (sl2[0] != 4) raise TEST_FAILED();
840 if (sl2[1] != 5) exit;842 if (sl2[1] != 5) raise TEST_FAILED();
841 843
842 sl3 := array[4] of int;844 sl3 := array[4] of int;
843 sl3[0] = 16reeee;845 sl3[0] = 16reeee;
844 sl3[1:] = arr[3:5];846 sl3[1:] = arr[3:5];
845 sl3[3] = 16reeee;847 sl3[3] = 16reeee;
846 if (sl3[1] != 4) exit;848 if (sl3[1] != 4) raise TEST_FAILED();
847 if (sl3[2] != 5) exit;849 if (sl3[2] != 5) raise TEST_FAILED();
848}850}
849 851
850test_array_big()852test_array_big()
@@ -852,21 +854,21 @@ test_array_big() · 1 unmodified line
852 arr := array [] of { 16r100000001, 16r100000002, 16r100000003, 16r100000004, 16r100000005, 16r100000006 };854 arr := array [] of { 16r100000001, 16r100000002, 16r100000003, 16r100000004, 16r100000005, 16r100000006 };
853 855
854 sl1 := arr[2:5];856 sl1 := arr[2:5];
855 if (len sl1 != 3) exit;857 if (len sl1 != 3) raise TEST_FAILED();
856 if (sl1[0] != 16r100000003) exit;858 if (sl1[0] != 16r100000003) raise TEST_FAILED();
857 if (sl1[2] != 16r100000005) exit;859 if (sl1[2] != 16r100000005) raise TEST_FAILED();
858 860
859 sl2 := sl1[1:];861 sl2 := sl1[1:];
860 if (len sl2 != 2) exit;862 if (len sl2 != 2) raise TEST_FAILED();
861 if (sl2[0] != 16r100000004) exit;863 if (sl2[0] != 16r100000004) raise TEST_FAILED();
862 if (sl2[1] != 16r100000005) exit;864 if (sl2[1] != 16r100000005) raise TEST_FAILED();
863 865
864 sl3 := array[4] of big;866 sl3 := array[4] of big;
865 sl3[0] = 16reeeeeeeeeeeeeeee;867 sl3[0] = 16reeeeeeeeeeeeeeee;
866 sl3[1:] = arr[3:5];868 sl3[1:] = arr[3:5];
867 sl3[3] = 16reeeeeeeeeeeeeeee;869 sl3[3] = 16reeeeeeeeeeeeeeee;
868 if (sl3[1] != 16r100000004) exit;870 if (sl3[1] != 16r100000004) raise TEST_FAILED();
869 if (sl3[2] != 16r100000005) exit;871 if (sl3[2] != 16r100000005) raise TEST_FAILED();
870}872}
871 873
872test_array_real()874test_array_real()
@@ -874,21 +876,21 @@ test_array_real() · 1 unmodified line
874 arr := array [] of { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 };876 arr := array [] of { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 };
875 877
876 sl1 := arr[2:5];878 sl1 := arr[2:5];
877 if (len sl1 != 3) exit;879 if (len sl1 != 3) raise TEST_FAILED();
878 if (sl1[0] != 3.0) exit;880 if (sl1[0] != 3.0) raise TEST_FAILED();
879 if (sl1[2] != 5.0) exit;881 if (sl1[2] != 5.0) raise TEST_FAILED();
880 882
881 sl2 := sl1[1:];883 sl2 := sl1[1:];
882 if (len sl2 != 2) exit;884 if (len sl2 != 2) raise TEST_FAILED();
883 if (sl2[0] != 4.0) exit;885 if (sl2[0] != 4.0) raise TEST_FAILED();
884 if (sl2[1] != 5.0) exit;886 if (sl2[1] != 5.0) raise TEST_FAILED();
885 887
886 sl3 := array[4] of real;888 sl3 := array[4] of real;
887 sl3[0] = 1.1111111;889 sl3[0] = 1.1111111;
888 sl3[1:] = arr[3:5];890 sl3[1:] = arr[3:5];
889 sl3[3] = 1.1111111;891 sl3[3] = 1.1111111;
890 if (sl3[1] != 4.0) exit;892 if (sl3[1] != 4.0) raise TEST_FAILED();
891 if (sl3[2] != 5.0) exit;893 if (sl3[2] != 5.0) raise TEST_FAILED();
892}894}
893 895
894test_list()896test_list()
@@ -896,7 +898,7 @@ test_list() · 1 unmodified line
896 sys->print("test_list()\n");898 sys->print("test_list()\n");
897 lst : list of int;899 lst : list of int;
898 l := len lst;900 l := len lst;
899 if (l != 0) exit;901 if (l != 0) raise TEST_FAILED();
900 902
901 test_list_byte();903 test_list_byte();
902 test_list_int();904 test_list_int();
@@ -912,9 +914,9 @@ test_list_byte() · 9 unmodified lines
912 lst2 := byte 16rfe :: lst1;914 lst2 := byte 16rfe :: lst1;
913 lst3 := byte 16rfd :: lst2;915 lst3 := byte 16rfd :: lst2;
914 916
915 if (len lst3 != 3) exit;917 if (len lst3 != 3) raise TEST_FAILED();
916 if (hd lst3 != byte 16rfd) exit;918 if (hd lst3 != byte 16rfd) raise TEST_FAILED();
917 if (hd tl tl lst3 != byte 16rff) exit;919 if (hd tl tl lst3 != byte 16rff) raise TEST_FAILED();
918}920}
919 921
920test_list_int()922test_list_int()
@@ -924,9 +926,9 @@ test_list_int() · 3 unmodified lines
924 lst2 := 16rfe00 :: lst1;926 lst2 := 16rfe00 :: lst1;
925 lst3 := 16rfd00 :: lst2;927 lst3 := 16rfd00 :: lst2;
926 928
927 if (len lst3 != 3) exit;929 if (len lst3 != 3) raise TEST_FAILED();
928 if (hd lst3 != 16rfd00) exit;930 if (hd lst3 != 16rfd00) raise TEST_FAILED();
929 if (hd tl tl lst3 != 16rff00) exit;931 if (hd tl tl lst3 != 16rff00) raise TEST_FAILED();
930}932}
931 933
932test_list_big()934test_list_big()
@@ -936,9 +938,9 @@ test_list_big() · 3 unmodified lines
936 lst2 := 16rfe000000ff000000 :: lst1;938 lst2 := 16rfe000000ff000000 :: lst1;
937 lst3 := 16rfd000000ff000000 :: lst2;939 lst3 := 16rfd000000ff000000 :: lst2;
938 940
939 if (len lst3 != 3) exit;941 if (len lst3 != 3) raise TEST_FAILED();
940 if (hd lst3 != 16rfd000000ff000000) exit;942 if (hd lst3 != 16rfd000000ff000000) raise TEST_FAILED();
941 if (hd tl tl lst3 != 16rff000000ff000000) exit;943 if (hd tl tl lst3 != 16rff000000ff000000) raise TEST_FAILED();
942}944}
943 945
944test_list_real()946test_list_real()
@@ -948,9 +950,9 @@ test_list_real() · 3 unmodified lines
948 lst2 := 2.0 :: lst1;950 lst2 := 2.0 :: lst1;
949 lst3 := 1.0 :: lst2;951 lst3 := 1.0 :: lst2;
950 952
951 if (len lst3 != 3) exit;953 if (len lst3 != 3) raise TEST_FAILED();
952 if (hd lst3 != 1.0) exit;954 if (hd lst3 != 1.0) raise TEST_FAILED();
953 if (hd tl tl lst3 != 3.0) exit;955 if (hd tl tl lst3 != 3.0) raise TEST_FAILED();
954}956}
955 957
956ListAdt : adt958ListAdt : adt
@@ -967,9 +969,9 @@ test_list_adt() · 10 unmodified lines
967 lst2 := ( "two", 2.0 ) :: lst1;969 lst2 := ( "two", 2.0 ) :: lst1;
968 lst3 := ( "one", 1.0 ) :: lst2;970 lst3 := ( "one", 1.0 ) :: lst2;
969 971
970 if (len lst3 != 3) exit;972 if (len lst3 != 3) raise TEST_FAILED();
971 if ((hd lst3).r != 1.0) exit;973 if ((hd lst3).r != 1.0) raise TEST_FAILED();
972 if ((hd tl tl lst3).r != 3.0) exit;974 if ((hd tl tl lst3).r != 3.0) raise TEST_FAILED();
973 }975 }
974 976
975 {977 {
@@ -981,9 +983,9 @@ test_list_adt() · 5 unmodified lines
981 lst2 := e2 :: lst1;983 lst2 := e2 :: lst1;
982 lst3 := e1 :: lst2;984 lst3 := e1 :: lst2;
983 985
984 if (len lst3 != 3) exit;986 if (len lst3 != 3) raise TEST_FAILED();
985 if ((hd lst3).r != 1.0) exit;987 if ((hd lst3).r != 1.0) raise TEST_FAILED();
986 if ((hd tl tl lst3).r != 3.0) exit;988 if ((hd tl tl lst3).r != 3.0) raise TEST_FAILED();
987 }989 }
988}990}
989 991
@@ -1000,40 +1002,40 @@ test_branch_byte() · 10 unmodified lines
1000{1002{
1001 a := byte 16rff;1003 a := byte 16rff;
1002 b := byte 16rff;1004 b := byte 16rff;
1003 if (a < b) exit;1005 if (a < b) raise TEST_FAILED();
1004 if (a > b) exit;1006 if (a > b) raise TEST_FAILED();
1005 if (a != b) exit;1007 if (a != b) raise TEST_FAILED();
1006 if (!(a == b)) exit;1008 if (!(a == b)) raise TEST_FAILED();
1007}1009}
1008 1010
1009test_branch_int()1011test_branch_int()
1010{1012{
1011 a := 1024;1013 a := 1024;
1012 b := 1024;1014 b := 1024;
1013 if (a < b) exit;1015 if (a < b) raise TEST_FAILED();
1014 if (a > b) exit;1016 if (a > b) raise TEST_FAILED();
1015 if (a != b) exit;1017 if (a != b) raise TEST_FAILED();
1016 if (!(a == b)) exit;1018 if (!(a == b)) raise TEST_FAILED();
1017}1019}
1018 1020
1019test_branch_big()1021test_branch_big()
1020{1022{
1021 a := 16r10000000FFFFFFFF;1023 a := 16r10000000FFFFFFFF;
1022 b := 16r10000000FFFFFFFF;1024 b := 16r10000000FFFFFFFF;
1023 if (a < b) exit;1025 if (a < b) raise TEST_FAILED();
1024 if (a > b) exit;1026 if (a > b) raise TEST_FAILED();
1025 if (a != b) exit;1027 if (a != b) raise TEST_FAILED();
1026 if (!(a == b)) exit;1028 if (!(a == b)) raise TEST_FAILED();
1027}1029}
1028 1030
1029test_branch_real()1031test_branch_real()
1030{1032{
1031 a := 1.0;1033 a := 1.0;
1032 b := 1.0;1034 b := 1.0;
1033 if (a < b) exit;1035 if (a < b) raise TEST_FAILED();
1034 if (a > b) exit;1036 if (a > b) raise TEST_FAILED();
1035 if (a != b) exit;1037 if (a != b) raise TEST_FAILED();
1036 if (!(a == b)) exit;1038 if (!(a == b)) raise TEST_FAILED();
1037}1039}
1038 1040
1039test_for_loop_function_call()1041test_for_loop_function_call()
@@ -1046,13 +1048,13 @@ test_for_loop_function_call() · 6 unmodified lines
1046 1048
1047 if (j % 2 == 0)1049 if (j % 2 == 0)
1048 {1050 {
1049 if (is_odd != 0) exit;1051 if (is_odd != 0) raise TEST_FAILED();
1050 if (is_even != 1) exit;1052 if (is_even != 1) raise TEST_FAILED();
1051 }1053 }
1052 else1054 else
1053 {1055 {
1054 if (is_odd != 1) exit;1056 if (is_odd != 1) raise TEST_FAILED();
1055 if (is_even != 0) exit;1057 if (is_even != 0) raise TEST_FAILED();
1056 }1058 }
1057 }1059 }
1058}1060}