comparison test/testc3.py @ 307:e609d5296ee9

Massive rewrite of codegenerator
author Windel Bouwman
date Thu, 12 Dec 2013 20:42:56 +0100
parents b145f8e6050b
children 2e7f55319858
comparison
equal deleted inserted replaced
306:b145f8e6050b 307:e609d5296ee9
144 var int a2; 144 var int a2;
145 var bool c; 145 var bool c;
146 146
147 a2 = b * a; 147 a2 = b * a;
148 c = a; 148 c = a;
149 c = b > 1; 149 }
150 } 150 """
151 """ 151 self.expectErrors(snippet, [8, 9])
152 self.expectErrors(snippet, [8, 9, 10])
153 152
154 def testExpression1(self): 153 def testExpression1(self):
155 snippet = """ 154 snippet = """
156 module testexpr1; 155 module testexpr1;
157 function void t() 156 function void t()
184 self.expectErrors(snippet, [5]) 183 self.expectErrors(snippet, [5])
185 184
186 def testWhile(self): 185 def testWhile(self):
187 snippet = """ 186 snippet = """
188 module tstwhile; 187 module tstwhile;
189 var int a;
190 function void t() 188 function void t()
191 { 189 {
192 var int i; 190 var int i;
193 i = 0; 191 i = 0;
194 while (i < 1054) 192 while (i < 1054)
195 { 193 {
196 i = i + 3; 194 i = i + 3;
197 a = a + i; 195 }
198 } 196 }
199 197 """
198 self.expectOK(snippet)
199
200 def testWhile2(self):
201 snippet = """
202 module tstwhile;
203 function void t()
204 {
200 while(true) 205 while(true)
201 { 206 {
202 } 207 }
203 208
204 while(false) 209 while(false)
283 snippet = """ 288 snippet = """
284 module teststruct1; 289 module teststruct1;
285 function void t() 290 function void t()
286 { 291 {
287 var struct {int x, y;} a; 292 var struct {int x, y;} a;
288 a.b.c(9); 293 a.x(9);
289 } 294 }
290 """ 295 """
291 self.expectOK(snippet) 296 self.expectOK(snippet)
292 297
293 def testPointerType1(self): 298 def testPointerType1(self):
324 var int* pa; 329 var int* pa;
325 function void t(int a, double b) 330 function void t(int a, double b)
326 { 331 {
327 pa = 2; // type conflict 332 pa = 2; // type conflict
328 pa = &a; 333 pa = &a;
329 pa = &2; 334 pa = &2; // No valid lvalue
330 &a = pa; // No valid lvalue 335 &a = pa; // No valid lvalue
331 **pa = 22; // Cannot deref int 336 **pa = 22; // Cannot deref int
332 } 337 }
333 """ 338 """
334 self.expectErrors(snippet, [6, 9, 10]) 339 self.expectErrors(snippet, [6, 8, 9, 10])
335 340
336 def testPointerTypeIr(self): 341 def testPointerTypeIr(self):
337 snippet = """ 342 snippet = """
338 module testptr_ir; 343 module testptr_ir;
339 function void t() 344 function void t()