annotate python/testc3.py @ 176:5fd02aa38b42

Added while loop code generation
author Windel Bouwman
date Sat, 20 Apr 2013 12:00:51 +0200
parents 4348da5ca307
children 25a0753da4cf
rev   line source
158
9683a4cd848f Added some functions for code generation
Windel Bouwman
parents: 157
diff changeset
1 import c3
9683a4cd848f Added some functions for code generation
Windel Bouwman
parents: 157
diff changeset
2 import time, ppci, x86, ir
167
0b5b2ee6b435 Added 2 unit tests
Windel Bouwman
parents: 166
diff changeset
3 import unittest
148
e5263f74b287 Added c3 language frontend initial parser
Windel Bouwman
parents:
diff changeset
4
162
d8c735dc31f9 Used new editor in ide
Windel Bouwman
parents: 160
diff changeset
5 testsrc = """package test;
148
e5263f74b287 Added c3 language frontend initial parser
Windel Bouwman
parents:
diff changeset
6
149
74241ca312cc Fixes on parser and semantics
Windel Bouwman
parents: 148
diff changeset
7 var u32 c, d;
163
8104fc8b5e90 Added visitor to c3
Windel Bouwman
parents: 162
diff changeset
8 var double e;
8104fc8b5e90 Added visitor to c3
Windel Bouwman
parents: 162
diff changeset
9 var int f;
8104fc8b5e90 Added visitor to c3
Windel Bouwman
parents: 162
diff changeset
10
167
0b5b2ee6b435 Added 2 unit tests
Windel Bouwman
parents: 166
diff changeset
11 const int A = 1337;
149
74241ca312cc Fixes on parser and semantics
Windel Bouwman
parents: 148
diff changeset
12
74241ca312cc Fixes on parser and semantics
Windel Bouwman
parents: 148
diff changeset
13 function void test1()
148
e5263f74b287 Added c3 language frontend initial parser
Windel Bouwman
parents:
diff changeset
14 {
163
8104fc8b5e90 Added visitor to c3
Windel Bouwman
parents: 162
diff changeset
15 var u32 bdd;
148
e5263f74b287 Added c3 language frontend initial parser
Windel Bouwman
parents:
diff changeset
16 var int a = 10;
163
8104fc8b5e90 Added visitor to c3
Windel Bouwman
parents: 162
diff changeset
17 bd = 20;
155
b28a11c01dbe Simplified IR classes
Windel Bouwman
parents: 152
diff changeset
18 var int buf;
148
e5263f74b287 Added c3 language frontend initial parser
Windel Bouwman
parents:
diff changeset
19 var int i;
e5263f74b287 Added c3 language frontend initial parser
Windel Bouwman
parents:
diff changeset
20 i = 2;
155
b28a11c01dbe Simplified IR classes
Windel Bouwman
parents: 152
diff changeset
21 var int zero = i - 2;
148
e5263f74b287 Added c3 language frontend initial parser
Windel Bouwman
parents:
diff changeset
22 if (i > 1)
e5263f74b287 Added c3 language frontend initial parser
Windel Bouwman
parents:
diff changeset
23 {
157
8f3924b6076e Added some code generator things
Windel Bouwman
parents: 155
diff changeset
24 buf = b + 22 * i - 13 + (55 * 2 *9-2) / 44 - 1;
148
e5263f74b287 Added c3 language frontend initial parser
Windel Bouwman
parents:
diff changeset
25 }
155
b28a11c01dbe Simplified IR classes
Windel Bouwman
parents: 152
diff changeset
26 else
b28a11c01dbe Simplified IR classes
Windel Bouwman
parents: 152
diff changeset
27 {
b28a11c01dbe Simplified IR classes
Windel Bouwman
parents: 152
diff changeset
28 ;;;
157
8f3924b6076e Added some code generator things
Windel Bouwman
parents: 155
diff changeset
29 }
155
b28a11c01dbe Simplified IR classes
Windel Bouwman
parents: 152
diff changeset
30
b28a11c01dbe Simplified IR classes
Windel Bouwman
parents: 152
diff changeset
31 t2(2, 3);
148
e5263f74b287 Added c3 language frontend initial parser
Windel Bouwman
parents:
diff changeset
32 }
e5263f74b287 Added c3 language frontend initial parser
Windel Bouwman
parents:
diff changeset
33
149
74241ca312cc Fixes on parser and semantics
Windel Bouwman
parents: 148
diff changeset
34 function int t2(u32 a, u32 b)
148
e5263f74b287 Added c3 language frontend initial parser
Windel Bouwman
parents:
diff changeset
35 {
157
8f3924b6076e Added some code generator things
Windel Bouwman
parents: 155
diff changeset
36 if (a > 0)
8f3924b6076e Added some code generator things
Windel Bouwman
parents: 155
diff changeset
37 {
167
0b5b2ee6b435 Added 2 unit tests
Windel Bouwman
parents: 166
diff changeset
38 a = 2 + t2(a - 1, 1.0);
157
8f3924b6076e Added some code generator things
Windel Bouwman
parents: 155
diff changeset
39 }
8f3924b6076e Added some code generator things
Windel Bouwman
parents: 155
diff changeset
40
148
e5263f74b287 Added c3 language frontend initial parser
Windel Bouwman
parents:
diff changeset
41 return a + b;
e5263f74b287 Added c3 language frontend initial parser
Windel Bouwman
parents:
diff changeset
42 }
e5263f74b287 Added c3 language frontend initial parser
Windel Bouwman
parents:
diff changeset
43
166
da0087b82fbe Improved type checking
Windel Bouwman
parents: 165
diff changeset
44 function int t3(int aap, int blah)
da0087b82fbe Improved type checking
Windel Bouwman
parents: 165
diff changeset
45 {
da0087b82fbe Improved type checking
Windel Bouwman
parents: 165
diff changeset
46 if (a > blah and blah < 45 + 33 or 33 > aap or 6 and true)
da0087b82fbe Improved type checking
Windel Bouwman
parents: 165
diff changeset
47 {
da0087b82fbe Improved type checking
Windel Bouwman
parents: 165
diff changeset
48 a = 2 + t2(a - 1);
da0087b82fbe Improved type checking
Windel Bouwman
parents: 165
diff changeset
49 }
da0087b82fbe Improved type checking
Windel Bouwman
parents: 165
diff changeset
50
da0087b82fbe Improved type checking
Windel Bouwman
parents: 165
diff changeset
51 return a + b;
da0087b82fbe Improved type checking
Windel Bouwman
parents: 165
diff changeset
52 }
da0087b82fbe Improved type checking
Windel Bouwman
parents: 165
diff changeset
53
155
b28a11c01dbe Simplified IR classes
Windel Bouwman
parents: 152
diff changeset
54 var int hahaa = 23 * 2;
150
4ae0e02599de Added type check start and analyze phase
Windel Bouwman
parents: 149
diff changeset
55
149
74241ca312cc Fixes on parser and semantics
Windel Bouwman
parents: 148
diff changeset
56
148
e5263f74b287 Added c3 language frontend initial parser
Windel Bouwman
parents:
diff changeset
57 """
e5263f74b287 Added c3 language frontend initial parser
Windel Bouwman
parents:
diff changeset
58
170
4348da5ca307 Cleanup of ir dir
Windel Bouwman
parents: 169
diff changeset
59 testsrc2 = """
4348da5ca307 Cleanup of ir dir
Windel Bouwman
parents: 169
diff changeset
60 package test2;
4348da5ca307 Cleanup of ir dir
Windel Bouwman
parents: 169
diff changeset
61
4348da5ca307 Cleanup of ir dir
Windel Bouwman
parents: 169
diff changeset
62 function void tst()
4348da5ca307 Cleanup of ir dir
Windel Bouwman
parents: 169
diff changeset
63 {
4348da5ca307 Cleanup of ir dir
Windel Bouwman
parents: 169
diff changeset
64 var int a, b;
4348da5ca307 Cleanup of ir dir
Windel Bouwman
parents: 169
diff changeset
65 a = 2 * 33 - 12;
4348da5ca307 Cleanup of ir dir
Windel Bouwman
parents: 169
diff changeset
66 b = a * 2 + 13;
4348da5ca307 Cleanup of ir dir
Windel Bouwman
parents: 169
diff changeset
67 a = b + a;
4348da5ca307 Cleanup of ir dir
Windel Bouwman
parents: 169
diff changeset
68 if (a > b and b == 3)
4348da5ca307 Cleanup of ir dir
Windel Bouwman
parents: 169
diff changeset
69 {
4348da5ca307 Cleanup of ir dir
Windel Bouwman
parents: 169
diff changeset
70 var int x = a;
4348da5ca307 Cleanup of ir dir
Windel Bouwman
parents: 169
diff changeset
71 x = b * 2 - a;
4348da5ca307 Cleanup of ir dir
Windel Bouwman
parents: 169
diff changeset
72 a = x*x;
4348da5ca307 Cleanup of ir dir
Windel Bouwman
parents: 169
diff changeset
73 }
4348da5ca307 Cleanup of ir dir
Windel Bouwman
parents: 169
diff changeset
74 else
4348da5ca307 Cleanup of ir dir
Windel Bouwman
parents: 169
diff changeset
75 {
4348da5ca307 Cleanup of ir dir
Windel Bouwman
parents: 169
diff changeset
76 a = b + a;
4348da5ca307 Cleanup of ir dir
Windel Bouwman
parents: 169
diff changeset
77 }
4348da5ca307 Cleanup of ir dir
Windel Bouwman
parents: 169
diff changeset
78 }
4348da5ca307 Cleanup of ir dir
Windel Bouwman
parents: 169
diff changeset
79
4348da5ca307 Cleanup of ir dir
Windel Bouwman
parents: 169
diff changeset
80 """
4348da5ca307 Cleanup of ir dir
Windel Bouwman
parents: 169
diff changeset
81
152
b73bc14a3aa3 Light coupling ide and c3 frontend
Windel Bouwman
parents: 151
diff changeset
82 def c3compile(src, diag):
163
8104fc8b5e90 Added visitor to c3
Windel Bouwman
parents: 162
diff changeset
83 # Structures:
165
598d3888a11c Added front class and fided AST view
Windel Bouwman
parents: 163
diff changeset
84 builder = c3.Builder(diag)
598d3888a11c Added front class and fided AST view
Windel Bouwman
parents: 163
diff changeset
85 ir = builder.build(src)
598d3888a11c Added front class and fided AST view
Windel Bouwman
parents: 163
diff changeset
86 # optional optimize here
157
8f3924b6076e Added some code generator things
Windel Bouwman
parents: 155
diff changeset
87 x86gen = x86.X86CodeGen(diag)
162
d8c735dc31f9 Used new editor in ide
Windel Bouwman
parents: 160
diff changeset
88 ok = len(diag.diags) == 0
d8c735dc31f9 Used new editor in ide
Windel Bouwman
parents: 160
diff changeset
89 if not ok:
d8c735dc31f9 Used new editor in ide
Windel Bouwman
parents: 160
diff changeset
90 return
165
598d3888a11c Added front class and fided AST view
Windel Bouwman
parents: 163
diff changeset
91 print('generating x86 code')
598d3888a11c Added front class and fided AST view
Windel Bouwman
parents: 163
diff changeset
92 x86gen.genBin(ir)
598d3888a11c Added front class and fided AST view
Windel Bouwman
parents: 163
diff changeset
93 with open('dummydummy.asm', 'w') as f:
598d3888a11c Added front class and fided AST view
Windel Bouwman
parents: 163
diff changeset
94 f.write('bits 64\n')
598d3888a11c Added front class and fided AST view
Windel Bouwman
parents: 163
diff changeset
95 for a in x86gen.asm:
598d3888a11c Added front class and fided AST view
Windel Bouwman
parents: 163
diff changeset
96 print(a)
598d3888a11c Added front class and fided AST view
Windel Bouwman
parents: 163
diff changeset
97 f.write(str(a) + '\n')
151
afc8c0207984 Added ir code generator stub
Windel Bouwman
parents: 150
diff changeset
98
afc8c0207984 Added ir code generator stub
Windel Bouwman
parents: 150
diff changeset
99 def do():
152
b73bc14a3aa3 Light coupling ide and c3 frontend
Windel Bouwman
parents: 151
diff changeset
100 diag = ppci.DiagnosticsManager()
b73bc14a3aa3 Light coupling ide and c3 frontend
Windel Bouwman
parents: 151
diff changeset
101 c3compile(testsrc, diag)
151
afc8c0207984 Added ir code generator stub
Windel Bouwman
parents: 150
diff changeset
102
167
0b5b2ee6b435 Added 2 unit tests
Windel Bouwman
parents: 166
diff changeset
103 class testA(unittest.TestCase):
0b5b2ee6b435 Added 2 unit tests
Windel Bouwman
parents: 166
diff changeset
104 def setUp(self):
0b5b2ee6b435 Added 2 unit tests
Windel Bouwman
parents: 166
diff changeset
105 self.diag = ppci.DiagnosticsManager()
0b5b2ee6b435 Added 2 unit tests
Windel Bouwman
parents: 166
diff changeset
106 self.builder = c3.Builder(self.diag)
169
ee0d30533dae Added more tests and improved the diagnostic update
Windel Bouwman
parents: 168
diff changeset
107 def testSrc(self):
ee0d30533dae Added more tests and improved the diagnostic update
Windel Bouwman
parents: 168
diff changeset
108 self.builder.build(testsrc)
167
0b5b2ee6b435 Added 2 unit tests
Windel Bouwman
parents: 166
diff changeset
109 def testFunctArgs(self):
0b5b2ee6b435 Added 2 unit tests
Windel Bouwman
parents: 166
diff changeset
110 snippet = """
0b5b2ee6b435 Added 2 unit tests
Windel Bouwman
parents: 166
diff changeset
111 package testargs;
0b5b2ee6b435 Added 2 unit tests
Windel Bouwman
parents: 166
diff changeset
112 function void t2(int a, double b)
0b5b2ee6b435 Added 2 unit tests
Windel Bouwman
parents: 166
diff changeset
113 {
0b5b2ee6b435 Added 2 unit tests
Windel Bouwman
parents: 166
diff changeset
114 t2(2, 2);
0b5b2ee6b435 Added 2 unit tests
Windel Bouwman
parents: 166
diff changeset
115 t2(2);
0b5b2ee6b435 Added 2 unit tests
Windel Bouwman
parents: 166
diff changeset
116 t2(1, 1.2);
0b5b2ee6b435 Added 2 unit tests
Windel Bouwman
parents: 166
diff changeset
117 }
0b5b2ee6b435 Added 2 unit tests
Windel Bouwman
parents: 166
diff changeset
118 """
0b5b2ee6b435 Added 2 unit tests
Windel Bouwman
parents: 166
diff changeset
119 self.diag.clear()
0b5b2ee6b435 Added 2 unit tests
Windel Bouwman
parents: 166
diff changeset
120 ir = self.builder.build(snippet)
168
49f1ab80d040 Added awesome icons
Windel Bouwman
parents: 167
diff changeset
121 assert len(self.diag.diags) == 2
49f1ab80d040 Added awesome icons
Windel Bouwman
parents: 167
diff changeset
122 assert self.diag.diags[0].loc.row == 5
49f1ab80d040 Added awesome icons
Windel Bouwman
parents: 167
diff changeset
123 assert self.diag.diags[1].loc.row == 6
148
e5263f74b287 Added c3 language frontend initial parser
Windel Bouwman
parents:
diff changeset
124
167
0b5b2ee6b435 Added 2 unit tests
Windel Bouwman
parents: 166
diff changeset
125 def testExpressions(self):
0b5b2ee6b435 Added 2 unit tests
Windel Bouwman
parents: 166
diff changeset
126 snippet = """
0b5b2ee6b435 Added 2 unit tests
Windel Bouwman
parents: 166
diff changeset
127 package test;
0b5b2ee6b435 Added 2 unit tests
Windel Bouwman
parents: 166
diff changeset
128 function void t(int a, double b)
0b5b2ee6b435 Added 2 unit tests
Windel Bouwman
parents: 166
diff changeset
129 {
0b5b2ee6b435 Added 2 unit tests
Windel Bouwman
parents: 166
diff changeset
130 var int a2;
0b5b2ee6b435 Added 2 unit tests
Windel Bouwman
parents: 166
diff changeset
131 var bool c;
0b5b2ee6b435 Added 2 unit tests
Windel Bouwman
parents: 166
diff changeset
132
0b5b2ee6b435 Added 2 unit tests
Windel Bouwman
parents: 166
diff changeset
133 a2 = b * a;
0b5b2ee6b435 Added 2 unit tests
Windel Bouwman
parents: 166
diff changeset
134 c = a;
0b5b2ee6b435 Added 2 unit tests
Windel Bouwman
parents: 166
diff changeset
135 c = b > 1;
0b5b2ee6b435 Added 2 unit tests
Windel Bouwman
parents: 166
diff changeset
136 }
0b5b2ee6b435 Added 2 unit tests
Windel Bouwman
parents: 166
diff changeset
137 """
0b5b2ee6b435 Added 2 unit tests
Windel Bouwman
parents: 166
diff changeset
138 self.diag.clear()
0b5b2ee6b435 Added 2 unit tests
Windel Bouwman
parents: 166
diff changeset
139 ir = self.builder.build(snippet)
168
49f1ab80d040 Added awesome icons
Windel Bouwman
parents: 167
diff changeset
140 assert len(self.diag.diags) == 3
49f1ab80d040 Added awesome icons
Windel Bouwman
parents: 167
diff changeset
141 assert self.diag.diags[0].loc.row == 8
49f1ab80d040 Added awesome icons
Windel Bouwman
parents: 167
diff changeset
142 assert self.diag.diags[1].loc.row == 9
49f1ab80d040 Added awesome icons
Windel Bouwman
parents: 167
diff changeset
143 assert self.diag.diags[2].loc.row == 10
49f1ab80d040 Added awesome icons
Windel Bouwman
parents: 167
diff changeset
144 assert ir == None
169
ee0d30533dae Added more tests and improved the diagnostic update
Windel Bouwman
parents: 168
diff changeset
145 def testEmpty(self):
ee0d30533dae Added more tests and improved the diagnostic update
Windel Bouwman
parents: 168
diff changeset
146 snippet = """
ee0d30533dae Added more tests and improved the diagnostic update
Windel Bouwman
parents: 168
diff changeset
147 package A
ee0d30533dae Added more tests and improved the diagnostic update
Windel Bouwman
parents: 168
diff changeset
148 """
ee0d30533dae Added more tests and improved the diagnostic update
Windel Bouwman
parents: 168
diff changeset
149 self.builder.build(snippet)
ee0d30533dae Added more tests and improved the diagnostic update
Windel Bouwman
parents: 168
diff changeset
150 def testEmpty2(self):
ee0d30533dae Added more tests and improved the diagnostic update
Windel Bouwman
parents: 168
diff changeset
151 snippet = ""
ee0d30533dae Added more tests and improved the diagnostic update
Windel Bouwman
parents: 168
diff changeset
152 self.builder.build(snippet)
ee0d30533dae Added more tests and improved the diagnostic update
Windel Bouwman
parents: 168
diff changeset
153 def testRedefine(self):
ee0d30533dae Added more tests and improved the diagnostic update
Windel Bouwman
parents: 168
diff changeset
154 snippet = """
ee0d30533dae Added more tests and improved the diagnostic update
Windel Bouwman
parents: 168
diff changeset
155 package test;
ee0d30533dae Added more tests and improved the diagnostic update
Windel Bouwman
parents: 168
diff changeset
156 var int a;
ee0d30533dae Added more tests and improved the diagnostic update
Windel Bouwman
parents: 168
diff changeset
157 var int b;
ee0d30533dae Added more tests and improved the diagnostic update
Windel Bouwman
parents: 168
diff changeset
158 var int a;
ee0d30533dae Added more tests and improved the diagnostic update
Windel Bouwman
parents: 168
diff changeset
159 """
ee0d30533dae Added more tests and improved the diagnostic update
Windel Bouwman
parents: 168
diff changeset
160 self.diag.clear()
ee0d30533dae Added more tests and improved the diagnostic update
Windel Bouwman
parents: 168
diff changeset
161 self.builder.build(snippet)
ee0d30533dae Added more tests and improved the diagnostic update
Windel Bouwman
parents: 168
diff changeset
162 assert len(self.diag.diags) == 1
ee0d30533dae Added more tests and improved the diagnostic update
Windel Bouwman
parents: 168
diff changeset
163 assert self.diag.diags[0].loc.row == 5
ee0d30533dae Added more tests and improved the diagnostic update
Windel Bouwman
parents: 168
diff changeset
164 def testWhile(self):
ee0d30533dae Added more tests and improved the diagnostic update
Windel Bouwman
parents: 168
diff changeset
165 snippet = """
ee0d30533dae Added more tests and improved the diagnostic update
Windel Bouwman
parents: 168
diff changeset
166 package tstwhile;
ee0d30533dae Added more tests and improved the diagnostic update
Windel Bouwman
parents: 168
diff changeset
167 var int a;
ee0d30533dae Added more tests and improved the diagnostic update
Windel Bouwman
parents: 168
diff changeset
168 function void t()
ee0d30533dae Added more tests and improved the diagnostic update
Windel Bouwman
parents: 168
diff changeset
169 {
ee0d30533dae Added more tests and improved the diagnostic update
Windel Bouwman
parents: 168
diff changeset
170 var int i = 0;
ee0d30533dae Added more tests and improved the diagnostic update
Windel Bouwman
parents: 168
diff changeset
171 while (i < 1054)
ee0d30533dae Added more tests and improved the diagnostic update
Windel Bouwman
parents: 168
diff changeset
172 {
ee0d30533dae Added more tests and improved the diagnostic update
Windel Bouwman
parents: 168
diff changeset
173 i = i + 3;
ee0d30533dae Added more tests and improved the diagnostic update
Windel Bouwman
parents: 168
diff changeset
174 a = a + i
ee0d30533dae Added more tests and improved the diagnostic update
Windel Bouwman
parents: 168
diff changeset
175 }
ee0d30533dae Added more tests and improved the diagnostic update
Windel Bouwman
parents: 168
diff changeset
176 }
ee0d30533dae Added more tests and improved the diagnostic update
Windel Bouwman
parents: 168
diff changeset
177 """
ee0d30533dae Added more tests and improved the diagnostic update
Windel Bouwman
parents: 168
diff changeset
178 self.builder.build(snippet)
ee0d30533dae Added more tests and improved the diagnostic update
Windel Bouwman
parents: 168
diff changeset
179 def testIf(self):
ee0d30533dae Added more tests and improved the diagnostic update
Windel Bouwman
parents: 168
diff changeset
180 snippet = """
ee0d30533dae Added more tests and improved the diagnostic update
Windel Bouwman
parents: 168
diff changeset
181 package tstIFF;
ee0d30533dae Added more tests and improved the diagnostic update
Windel Bouwman
parents: 168
diff changeset
182 var int a;
ee0d30533dae Added more tests and improved the diagnostic update
Windel Bouwman
parents: 168
diff changeset
183 function void t(int b)
ee0d30533dae Added more tests and improved the diagnostic update
Windel Bouwman
parents: 168
diff changeset
184 {
ee0d30533dae Added more tests and improved the diagnostic update
Windel Bouwman
parents: 168
diff changeset
185 a = 2;
ee0d30533dae Added more tests and improved the diagnostic update
Windel Bouwman
parents: 168
diff changeset
186 if (a > b)
ee0d30533dae Added more tests and improved the diagnostic update
Windel Bouwman
parents: 168
diff changeset
187 {
ee0d30533dae Added more tests and improved the diagnostic update
Windel Bouwman
parents: 168
diff changeset
188 if (a > 1337)
ee0d30533dae Added more tests and improved the diagnostic update
Windel Bouwman
parents: 168
diff changeset
189 {
ee0d30533dae Added more tests and improved the diagnostic update
Windel Bouwman
parents: 168
diff changeset
190 b = 2;
ee0d30533dae Added more tests and improved the diagnostic update
Windel Bouwman
parents: 168
diff changeset
191 }
ee0d30533dae Added more tests and improved the diagnostic update
Windel Bouwman
parents: 168
diff changeset
192 }
ee0d30533dae Added more tests and improved the diagnostic update
Windel Bouwman
parents: 168
diff changeset
193 else
ee0d30533dae Added more tests and improved the diagnostic update
Windel Bouwman
parents: 168
diff changeset
194 {
ee0d30533dae Added more tests and improved the diagnostic update
Windel Bouwman
parents: 168
diff changeset
195 b = 1;
ee0d30533dae Added more tests and improved the diagnostic update
Windel Bouwman
parents: 168
diff changeset
196 }
ee0d30533dae Added more tests and improved the diagnostic update
Windel Bouwman
parents: 168
diff changeset
197
ee0d30533dae Added more tests and improved the diagnostic update
Windel Bouwman
parents: 168
diff changeset
198 return b;
ee0d30533dae Added more tests and improved the diagnostic update
Windel Bouwman
parents: 168
diff changeset
199 }
ee0d30533dae Added more tests and improved the diagnostic update
Windel Bouwman
parents: 168
diff changeset
200 """
ee0d30533dae Added more tests and improved the diagnostic update
Windel Bouwman
parents: 168
diff changeset
201 self.builder.build(snippet)
170
4348da5ca307 Cleanup of ir dir
Windel Bouwman
parents: 169
diff changeset
202 def test2(self):
4348da5ca307 Cleanup of ir dir
Windel Bouwman
parents: 169
diff changeset
203 # testsrc2 is valid code:
4348da5ca307 Cleanup of ir dir
Windel Bouwman
parents: 169
diff changeset
204 self.diag.clear()
4348da5ca307 Cleanup of ir dir
Windel Bouwman
parents: 169
diff changeset
205 ir = self.builder.build(testsrc2)
4348da5ca307 Cleanup of ir dir
Windel Bouwman
parents: 169
diff changeset
206 print(self.diag.diags)
4348da5ca307 Cleanup of ir dir
Windel Bouwman
parents: 169
diff changeset
207 assert ir
4348da5ca307 Cleanup of ir dir
Windel Bouwman
parents: 169
diff changeset
208 ir.dump()
167
0b5b2ee6b435 Added 2 unit tests
Windel Bouwman
parents: 166
diff changeset
209
0b5b2ee6b435 Added 2 unit tests
Windel Bouwman
parents: 166
diff changeset
210 if __name__ == '__main__':
0b5b2ee6b435 Added 2 unit tests
Windel Bouwman
parents: 166
diff changeset
211 do()
0b5b2ee6b435 Added 2 unit tests
Windel Bouwman
parents: 166
diff changeset
212 unittest.main()
0b5b2ee6b435 Added 2 unit tests
Windel Bouwman
parents: 166
diff changeset
213
0b5b2ee6b435 Added 2 unit tests
Windel Bouwman
parents: 166
diff changeset
214