comparison python/testc3.py @ 168:49f1ab80d040

Added awesome icons
author Windel Bouwman
date Fri, 22 Mar 2013 19:09:38 +0100
parents 0b5b2ee6b435
children ee0d30533dae
comparison
equal deleted inserted replaced
167:0b5b2ee6b435 168:49f1ab80d040
62 ir = builder.build(src) 62 ir = builder.build(src)
63 # optional optimize here 63 # optional optimize here
64 x86gen = x86.X86CodeGen(diag) 64 x86gen = x86.X86CodeGen(diag)
65 ok = len(diag.diags) == 0 65 ok = len(diag.diags) == 0
66 if not ok: 66 if not ok:
67 print('Not generating code')
68 return 67 return
69 print('generating x86 code') 68 print('generating x86 code')
70 x86gen.genBin(ir) 69 x86gen.genBin(ir)
71 with open('dummydummy.asm', 'w') as f: 70 with open('dummydummy.asm', 'w') as f:
72 f.write('bits 64\n') 71 f.write('bits 64\n')
92 t2(1, 1.2); 91 t2(1, 1.2);
93 } 92 }
94 """ 93 """
95 self.diag.clear() 94 self.diag.clear()
96 ir = self.builder.build(snippet) 95 ir = self.builder.build(snippet)
97 print(self.diag.diags) 96 assert len(self.diag.diags) == 2
97 assert self.diag.diags[0].loc.row == 5
98 assert self.diag.diags[1].loc.row == 6
98 99
99 def testExpressions(self): 100 def testExpressions(self):
100 snippet = """ 101 snippet = """
101 package test; 102 package test;
102 function void t(int a, double b) 103 function void t(int a, double b)
109 c = b > 1; 110 c = b > 1;
110 } 111 }
111 """ 112 """
112 self.diag.clear() 113 self.diag.clear()
113 ir = self.builder.build(snippet) 114 ir = self.builder.build(snippet)
114 print(self.diag.diags) 115 assert len(self.diag.diags) == 3
116 assert self.diag.diags[0].loc.row == 8
117 assert self.diag.diags[1].loc.row == 9
118 assert self.diag.diags[2].loc.row == 10
119 assert ir == None
115 120
116 if __name__ == '__main__': 121 if __name__ == '__main__':
117 do() 122 do()
118 unittest.main() 123 unittest.main()
119 124