File tree Expand file tree Collapse file tree 6 files changed +108
-18
lines changed Expand file tree Collapse file tree 6 files changed +108
-18
lines changed Original file line number Diff line number Diff line change @@ -210,6 +210,9 @@ RUN(NAME expr_13 LABELS llvm c
210
210
EXTRAFILES expr_13b.c )
211
211
RUN (NAME expr_14 LABELS cpython llvm c )
212
212
RUN (NAME loop_01 LABELS cpython llvm c )
213
+ RUN (NAME loop_02 LABELS cpython llvm wasm wasm_x86 )
214
+ RUN (NAME if_01 LABELS cpython llvm wasm wasm_x86 )
215
+ RUN (NAME if_02 LABELS cpython llvm wasm wasm_x86 )
213
216
RUN (NAME print_02 LABELS cpython llvm )
214
217
RUN (NAME test_types_01 LABELS cpython llvm c )
215
218
RUN (NAME test_str_01 LABELS cpython llvm c )
Original file line number Diff line number Diff line change 1
1
def Test_if_01 ():
2
+ z : i32 = 0
2
3
if True :
3
- print ( 1 )
4
+ assert True
4
5
5
6
if False :
6
- print ( 0 )
7
+ assert False
7
8
8
9
if 1 < 0 :
9
- print ( 0 )
10
+ assert False
10
11
else :
11
- print ( 1 )
12
+ assert True
12
13
13
14
if 1 > 0 :
14
- print ( 1 )
15
+ assert True
15
16
else :
16
- print ( 0 )
17
+ assert False
17
18
18
19
if 1 < 0 :
19
- print ( 1 )
20
+ assert False
20
21
elif 1 > 0 :
21
- print ( 1 )
22
+ assert True
22
23
else :
23
- print ( 0 )
24
+ assert False
24
25
25
26
def Test_if_02 ():
26
27
if True :
27
28
print (1 )
28
29
if True :
29
30
print (2 )
30
31
if False :
31
- print ( 3 )
32
+ assert False
32
33
elif True :
33
34
print (4 )
34
35
else :
35
- print ( 5 )
36
+ assert False
36
37
else :
37
- print ( 6 )
38
+ assert False
38
39
39
40
if True :
40
41
print (7 )
41
42
if False :
42
- print ( 8 )
43
+ assert False
43
44
if False :
44
45
print (9 )
45
46
else :
@@ -48,7 +49,7 @@ def Test_if_02():
48
49
if True :
49
50
print (11 )
50
51
else :
51
- print ( 12 )
52
+ assert False
52
53
print (13 )
53
54
print (14 )
54
55
Original file line number Diff line number Diff line change 1
- from ltypes import bool , i32
1
+ from ltypes import i32
2
2
3
3
def test_if_01 ():
4
4
x : bool = True
@@ -33,8 +33,7 @@ def test_if_01():
33
33
if y >= 2 :
34
34
z += 1
35
35
36
- # TODO: replace this an assert statement
37
- print (z )
36
+ assert z == 9
38
37
39
38
def verify ():
40
39
test_if_01 ()
Original file line number Diff line number Diff line change
1
+ from ltypes import i32
2
+ def test_loop_01 ():
3
+ i : i32 = 0
4
+ j : i32 = 0
5
+
6
+ while False :
7
+ assert False
8
+
9
+ while i < 0 :
10
+ assert False
11
+
12
+ while i < 10 :
13
+ i += 1
14
+ assert i == 10
15
+
16
+ while i < 20 :
17
+ while i < 15 :
18
+ i += 1
19
+ i += 1
20
+ assert i == 20
21
+
22
+ for i in range (5 ):
23
+ assert i == j
24
+ j += 1
25
+
26
+ def test_loop_02 ():
27
+ i : i32 = 0
28
+ j : i32 = 0
29
+
30
+ j = 0
31
+ for i in range (10 , 0 , - 1 ):
32
+ j = j + i
33
+ assert j == 55
34
+
35
+ for i in range (5 ):
36
+ if i == 3 :
37
+ break
38
+ assert i == 3
39
+
40
+ j = 0
41
+ for i in range (5 ):
42
+ if i == 3 :
43
+ continue
44
+ j += 1
45
+ assert j == 4
46
+
47
+ def test_loop_03 ():
48
+ i : i32 = 0
49
+ j : i32 = 0
50
+ k : i32 = 0
51
+ while i < 10 :
52
+ j = 0
53
+ while j < 10 :
54
+ k += 1
55
+ if i == 0 :
56
+ if j == 3 :
57
+ continue
58
+ else :
59
+ j += 1
60
+ j += 1
61
+ i += 1
62
+ assert k == 95
63
+
64
+ i = 0 ; j = 0 ; k = 0
65
+ while i < 10 :
66
+ j = 0
67
+ while j < 10 :
68
+ k += i + j
69
+ if i == 5 :
70
+ if j == 4 :
71
+ break
72
+ else :
73
+ j += 1
74
+ j += 1
75
+ i += 1
76
+ assert k == 826
77
+
78
+
79
+ def verify ():
80
+ test_loop_01 ()
81
+ test_loop_02 ()
82
+ test_loop_03 ()
83
+
84
+ verify ()
Original file line number Diff line number Diff line change 6
6
"outfile" : null ,
7
7
"outfile_hash" : null ,
8
8
"stdout" : " wat-loop1-e0046d4.stdout" ,
9
- "stdout_hash" : " 72c18793b437f96f1f96c9f8fc8cc253601fb360929216a4de1cb2f1 " ,
9
+ "stdout_hash" : " f2518c3df21a94fba3afb27274ecfae56de7beaaaa8b54b4c1fd84fa " ,
10
10
"stderr" : null ,
11
11
"stderr_hash" : null ,
12
12
"returncode" : 0
Original file line number Diff line number Diff line change 48
48
i32.sub
49
49
local.set 0
50
50
br 1
51
+ else
51
52
end
52
53
end
53
54
local.get 2
83
84
i32.mul
84
85
local.set 3
85
86
br 1
87
+ else
86
88
end
87
89
end
88
90
local.get 3
121
123
i32.sub
122
124
local.set 0
123
125
br 1
126
+ else
124
127
end
125
128
end
126
129
local.get 2
You can’t perform that action at this time.
0 commit comments