1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
|
project('number arithmetic')
if 6 + 4 != 10
error('Number addition is broken')
endif
if 6 - 4 != 2
error('Number subtraction is broken')
endif
if 6 * 4 != 24
error('Number multiplication is broken')
endif
if 16 / 4 != 4
error('Number division is broken')
endif
#if (1 / 3) * 3 != 1
# error('Float interconversion broken')
#endif
if (5 / 3) * 3 != 3
error('Integer division is broken')
endif
assert((5 % 2) == 1, 'Integer modulo (odd) is broken')
assert((4 % 2) == 0, 'Integer modulo (even) is broken')
if 2 * 1 % 2 != 0
error('Modulo precedence with multiplication is broken')
endif
if 2 + 1 % 2 != 3
error('Modulo precedence with addition is broken')
endif
if 9 / 9 % 2 != 1
error('Modulo precedence with division is broken')
endif
if 9 - 9 % 2 != 8
error('Modulo precedence with subtraction is broken')
endif
assert(2.is_even(), 'int is_even() broken for even value')
assert(not(2.is_odd()), 'int is_odd() broken for even value')
assert(not(3.is_even()), 'int is_even() broken for odd value')
assert(3.is_odd(), 'int is_odd() broken for odd value')
assert(3 < 4, 'Lt broken')
assert(not(4 < 3), 'Lt broken')
assert(3 <= 4, 'Lte broken')
assert(not(4 <= 3), 'Lte broken')
assert(3 <= 3, 'Lte broken')
assert(4 > 3, 'Gt broken')
assert(not(3 > 4), 'Gt broken')
assert(4 >= 3, 'Gte broken')
assert(not(3 >= 4), 'Gte broken')
assert(3 >= 3, 'Gte broken')
assert(true.to_int() == 1,'bool to_int() broken')
assert(false.to_int() == 0,'bool to_int() broken')
hex_255 = 0xff
hex2_255 = 0XFF
assert(hex_255 == 255, 'Hex parsing is broken.')
assert(hex2_255 == 255, 'Uppercase hex parsing is broken.')
bin_123 = 0b1111011
bin2_123 = 0B1111011
assert(bin_123 == 123, 'Bin number parsing is broken.')
assert(bin2_123 == 123, 'Uppercase bin number parsing is broken.')
oct_493 = 0o755
oct2_493 = 0O755
assert(oct_493 == 493, 'Oct number parsing is broken.')
assert(oct2_493 == 493, 'Uppercase oct number parsing is broken.')
|