Mercurial > lcfOS
comparison python/testc3.py @ 220:3f6c30a5d234
Major change in expression parsing to enable pointers and structs
author | Windel Bouwman |
---|---|
date | Sat, 06 Jul 2013 21:32:20 +0200 |
parents | 8b2e5f3cd579 |
children | 848c4b15fd0b |
comparison
equal
deleted
inserted
replaced
219:1fa3e0050b49 | 220:3f6c30a5d234 |
---|---|
1 import c3 | 1 import c3 |
2 import time, ppci, x86, ir | 2 import time, ppci, x86, ir |
3 import unittest | 3 import unittest |
4 import glob | |
4 | 5 |
5 testsrc = """package test; | 6 testsrc = """package test; |
6 | 7 |
7 /* | 8 /* |
8 demo of the source that is correct :) | 9 demo of the source that is correct :) |
203 return b; | 204 return b; |
204 } | 205 } |
205 """ | 206 """ |
206 self.expectOK(snippet) | 207 self.expectOK(snippet) |
207 | 208 |
208 @unittest.skip | |
209 def testPointerType(self): | 209 def testPointerType(self): |
210 snippet = """ | 210 snippet = """ |
211 package testpointer; | 211 package testpointer; |
212 var int* pa; | 212 var int* pa; |
213 function void t(int a, double b) | 213 function void t(int a, double b) |
214 { | 214 { |
215 pa = 2; | |
216 pa = &a; | |
215 *pa = 22; | 217 *pa = 22; |
216 } | 218 } |
217 """ | 219 """ |
218 self.expectOK(snippet) | 220 self.expectOK(snippet) |
219 | 221 |
245 | 247 |
246 mxp->P1.x = a * x->P1.y; | 248 mxp->P1.x = a * x->P1.y; |
247 } | 249 } |
248 """ | 250 """ |
249 self.expectOK(snippet) | 251 self.expectOK(snippet) |
252 | |
253 def testExamples(self): | |
254 """ Test all examples in the c3/examples directory """ | |
255 example_filenames = glob.glob('./c3/examples/*.c3') | |
256 for filename in example_filenames: | |
257 with open(filename, 'r') as f: | |
258 src = f.read() | |
259 self.expectOK(src) | |
250 | 260 |
251 def test2(self): | 261 def test2(self): |
252 # testsrc2 is valid code: | 262 # testsrc2 is valid code: |
253 snippet = """ | 263 snippet = """ |
254 package test2; | 264 package test2; |