annotate 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
rev   line source
300
Windel Bouwman
parents: 295
diff changeset
1 from ppci.c3 import Builder, Lexer
301
6753763d3bec merge codegen into ppci package
Windel Bouwman
parents: 300
diff changeset
2 from target import SimpleTarget
287
1c7c1e619be8 File movage
Windel Bouwman
parents: 284
diff changeset
3 import ppci
167
0b5b2ee6b435 Added 2 unit tests
Windel Bouwman
parents: 166
diff changeset
4 import unittest
287
1c7c1e619be8 File movage
Windel Bouwman
parents: 284
diff changeset
5 import io
148
e5263f74b287 Added c3 language frontend initial parser
Windel Bouwman
parents:
diff changeset
6
e5263f74b287 Added c3 language frontend initial parser
Windel Bouwman
parents:
diff changeset
7
204
de3a68f677a5 Added long comment to c3 parser
Windel Bouwman
parents: 194
diff changeset
8 class testLexer(unittest.TestCase):
293
6aa721e7b10b Try to improve build sequence
Windel Bouwman
parents: 292
diff changeset
9 def setUp(self):
6aa721e7b10b Try to improve build sequence
Windel Bouwman
parents: 292
diff changeset
10 diag = ppci.DiagnosticsManager()
300
Windel Bouwman
parents: 295
diff changeset
11 self.l = Lexer(diag)
293
6aa721e7b10b Try to improve build sequence
Windel Bouwman
parents: 292
diff changeset
12
205
d77cb5962cc5 Added some handcoded arm code generation
Windel Bouwman
parents: 204
diff changeset
13 def testUnexpectedCharacter(self):
287
1c7c1e619be8 File movage
Windel Bouwman
parents: 284
diff changeset
14 snippet = io.StringIO(""" var s \u6c34 """)
205
d77cb5962cc5 Added some handcoded arm code generation
Windel Bouwman
parents: 204
diff changeset
15 with self.assertRaises(ppci.CompilerError):
293
6aa721e7b10b Try to improve build sequence
Windel Bouwman
parents: 292
diff changeset
16 list(self.l.tokenize(snippet))
6aa721e7b10b Try to improve build sequence
Windel Bouwman
parents: 292
diff changeset
17
6aa721e7b10b Try to improve build sequence
Windel Bouwman
parents: 292
diff changeset
18 def check(self, snippet, toks):
6aa721e7b10b Try to improve build sequence
Windel Bouwman
parents: 292
diff changeset
19 toks2 = list(tok.typ for tok in self.l.tokenize(io.StringIO(snippet)))
6aa721e7b10b Try to improve build sequence
Windel Bouwman
parents: 292
diff changeset
20 self.assertSequenceEqual(toks, toks2)
205
d77cb5962cc5 Added some handcoded arm code generation
Windel Bouwman
parents: 204
diff changeset
21
204
de3a68f677a5 Added long comment to c3 parser
Windel Bouwman
parents: 194
diff changeset
22 def testBlockComment(self):
293
6aa721e7b10b Try to improve build sequence
Windel Bouwman
parents: 292
diff changeset
23 snippet = """
204
de3a68f677a5 Added long comment to c3 parser
Windel Bouwman
parents: 194
diff changeset
24 /* Demo */
de3a68f677a5 Added long comment to c3 parser
Windel Bouwman
parents: 194
diff changeset
25 var int x = 0;
293
6aa721e7b10b Try to improve build sequence
Windel Bouwman
parents: 292
diff changeset
26 """
204
de3a68f677a5 Added long comment to c3 parser
Windel Bouwman
parents: 194
diff changeset
27 toks = ['var', 'ID', 'ID', '=', 'NUMBER', ';', 'END']
293
6aa721e7b10b Try to improve build sequence
Windel Bouwman
parents: 292
diff changeset
28 self.check(snippet, toks)
205
d77cb5962cc5 Added some handcoded arm code generation
Windel Bouwman
parents: 204
diff changeset
29
204
de3a68f677a5 Added long comment to c3 parser
Windel Bouwman
parents: 194
diff changeset
30 def testBlockCommentMultiLine(self):
293
6aa721e7b10b Try to improve build sequence
Windel Bouwman
parents: 292
diff changeset
31 snippet = """
204
de3a68f677a5 Added long comment to c3 parser
Windel Bouwman
parents: 194
diff changeset
32 /* Demo
de3a68f677a5 Added long comment to c3 parser
Windel Bouwman
parents: 194
diff changeset
33 bla1
de3a68f677a5 Added long comment to c3 parser
Windel Bouwman
parents: 194
diff changeset
34 bla2
de3a68f677a5 Added long comment to c3 parser
Windel Bouwman
parents: 194
diff changeset
35 */
de3a68f677a5 Added long comment to c3 parser
Windel Bouwman
parents: 194
diff changeset
36 var int x = 0;
293
6aa721e7b10b Try to improve build sequence
Windel Bouwman
parents: 292
diff changeset
37 """
204
de3a68f677a5 Added long comment to c3 parser
Windel Bouwman
parents: 194
diff changeset
38 toks = ['var', 'ID', 'ID', '=', 'NUMBER', ';', 'END']
293
6aa721e7b10b Try to improve build sequence
Windel Bouwman
parents: 292
diff changeset
39 self.check(snippet, toks)
204
de3a68f677a5 Added long comment to c3 parser
Windel Bouwman
parents: 194
diff changeset
40
287
1c7c1e619be8 File movage
Windel Bouwman
parents: 284
diff changeset
41
204
de3a68f677a5 Added long comment to c3 parser
Windel Bouwman
parents: 194
diff changeset
42 class testBuilder(unittest.TestCase):
215
c1ccb1cb4cef Major changes in c3 frontend
Windel Bouwman
parents: 213
diff changeset
43 def setUp(self):
c1ccb1cb4cef Major changes in c3 frontend
Windel Bouwman
parents: 213
diff changeset
44 self.diag = ppci.DiagnosticsManager()
301
6753763d3bec merge codegen into ppci package
Windel Bouwman
parents: 300
diff changeset
45 self.builder = Builder(self.diag, SimpleTarget())
215
c1ccb1cb4cef Major changes in c3 frontend
Windel Bouwman
parents: 213
diff changeset
46 self.diag.clear()
c1ccb1cb4cef Major changes in c3 frontend
Windel Bouwman
parents: 213
diff changeset
47
306
b145f8e6050b Start on c3 rewrite
Windel Bouwman
parents: 303
diff changeset
48 def makeFileList(self, snippet):
b145f8e6050b Start on c3 rewrite
Windel Bouwman
parents: 303
diff changeset
49 """ Try to make a list with opened files """
b145f8e6050b Start on c3 rewrite
Windel Bouwman
parents: 303
diff changeset
50 if type(snippet) is list:
b145f8e6050b Start on c3 rewrite
Windel Bouwman
parents: 303
diff changeset
51 l2 = []
b145f8e6050b Start on c3 rewrite
Windel Bouwman
parents: 303
diff changeset
52 for s in snippet:
b145f8e6050b Start on c3 rewrite
Windel Bouwman
parents: 303
diff changeset
53 if type(s) is str:
b145f8e6050b Start on c3 rewrite
Windel Bouwman
parents: 303
diff changeset
54 l2.append(io.StringIO(s))
b145f8e6050b Start on c3 rewrite
Windel Bouwman
parents: 303
diff changeset
55 else:
b145f8e6050b Start on c3 rewrite
Windel Bouwman
parents: 303
diff changeset
56 l2.append(s)
b145f8e6050b Start on c3 rewrite
Windel Bouwman
parents: 303
diff changeset
57 return l2
b145f8e6050b Start on c3 rewrite
Windel Bouwman
parents: 303
diff changeset
58 else:
b145f8e6050b Start on c3 rewrite
Windel Bouwman
parents: 303
diff changeset
59 return [io.StringIO(snippet)]
b145f8e6050b Start on c3 rewrite
Windel Bouwman
parents: 303
diff changeset
60
215
c1ccb1cb4cef Major changes in c3 frontend
Windel Bouwman
parents: 213
diff changeset
61 def expectErrors(self, snippet, rows):
c1ccb1cb4cef Major changes in c3 frontend
Windel Bouwman
parents: 213
diff changeset
62 """ Helper to test for expected errors on rows """
287
1c7c1e619be8 File movage
Windel Bouwman
parents: 284
diff changeset
63 ircode = list(self.builder.build([io.StringIO(snippet)]))
215
c1ccb1cb4cef Major changes in c3 frontend
Windel Bouwman
parents: 213
diff changeset
64 actualErrors = [err.row for err in self.diag.diags]
c1ccb1cb4cef Major changes in c3 frontend
Windel Bouwman
parents: 213
diff changeset
65 if rows != actualErrors:
306
b145f8e6050b Start on c3 rewrite
Windel Bouwman
parents: 303
diff changeset
66 self.diag.printErrors()
215
c1ccb1cb4cef Major changes in c3 frontend
Windel Bouwman
parents: 213
diff changeset
67 self.assertSequenceEqual(rows, actualErrors)
287
1c7c1e619be8 File movage
Windel Bouwman
parents: 284
diff changeset
68 # self.assertFalse(all(ircode))
215
c1ccb1cb4cef Major changes in c3 frontend
Windel Bouwman
parents: 213
diff changeset
69
287
1c7c1e619be8 File movage
Windel Bouwman
parents: 284
diff changeset
70 def expectOK(self, snippet):
306
b145f8e6050b Start on c3 rewrite
Windel Bouwman
parents: 303
diff changeset
71 """ Expect a snippet to be OK """
b145f8e6050b Start on c3 rewrite
Windel Bouwman
parents: 303
diff changeset
72 ircode = list(self.builder.build(self.makeFileList(snippet)))
b145f8e6050b Start on c3 rewrite
Windel Bouwman
parents: 303
diff changeset
73 if len(self.diag.diags) > 0:
b145f8e6050b Start on c3 rewrite
Windel Bouwman
parents: 303
diff changeset
74 self.diag.printErrors()
287
1c7c1e619be8 File movage
Windel Bouwman
parents: 284
diff changeset
75 self.assertTrue(all(ircode))
306
b145f8e6050b Start on c3 rewrite
Windel Bouwman
parents: 303
diff changeset
76 self.assertEqual(0, len(self.diag.diags))
217
8b2e5f3cd579 Removed some stale python source files
Windel Bouwman
parents: 215
diff changeset
77 return ircode
215
c1ccb1cb4cef Major changes in c3 frontend
Windel Bouwman
parents: 213
diff changeset
78
251
6ed3d3a82a63 Added another c3 example. First import attempt
Windel Bouwman
parents: 249
diff changeset
79 def testPackage(self):
284
05184b95fa16 Moved tests to seperate folder
Windel Bouwman
parents: 280
diff changeset
80 p1 = """module p1;
251
6ed3d3a82a63 Added another c3 example. First import attempt
Windel Bouwman
parents: 249
diff changeset
81 type int A;
6ed3d3a82a63 Added another c3 example. First import attempt
Windel Bouwman
parents: 249
diff changeset
82 """
284
05184b95fa16 Moved tests to seperate folder
Windel Bouwman
parents: 280
diff changeset
83 p2 = """module p2;
251
6ed3d3a82a63 Added another c3 example. First import attempt
Windel Bouwman
parents: 249
diff changeset
84 import p1;
306
b145f8e6050b Start on c3 rewrite
Windel Bouwman
parents: 303
diff changeset
85 var p1.A b;
251
6ed3d3a82a63 Added another c3 example. First import attempt
Windel Bouwman
parents: 249
diff changeset
86 """
306
b145f8e6050b Start on c3 rewrite
Windel Bouwman
parents: 303
diff changeset
87 self.expectOK([p1, p2])
251
6ed3d3a82a63 Added another c3 example. First import attempt
Windel Bouwman
parents: 249
diff changeset
88
288
a747a45dcd78 Various styling work
Windel Bouwman
parents: 287
diff changeset
89 def testPackageMutual(self):
a747a45dcd78 Various styling work
Windel Bouwman
parents: 287
diff changeset
90 p1 = """module p1;
a747a45dcd78 Various styling work
Windel Bouwman
parents: 287
diff changeset
91 import p2;
a747a45dcd78 Various styling work
Windel Bouwman
parents: 287
diff changeset
92 type int A;
a747a45dcd78 Various styling work
Windel Bouwman
parents: 287
diff changeset
93 var p2.B b;
a747a45dcd78 Various styling work
Windel Bouwman
parents: 287
diff changeset
94 """
a747a45dcd78 Various styling work
Windel Bouwman
parents: 287
diff changeset
95 p2 = """module p2;
a747a45dcd78 Various styling work
Windel Bouwman
parents: 287
diff changeset
96 import p1;
a747a45dcd78 Various styling work
Windel Bouwman
parents: 287
diff changeset
97 var p1.A a;
a747a45dcd78 Various styling work
Windel Bouwman
parents: 287
diff changeset
98 """
306
b145f8e6050b Start on c3 rewrite
Windel Bouwman
parents: 303
diff changeset
99 self.expectOK([p1, p2])
288
a747a45dcd78 Various styling work
Windel Bouwman
parents: 287
diff changeset
100
293
6aa721e7b10b Try to improve build sequence
Windel Bouwman
parents: 292
diff changeset
101 def testPackageNotExists(self):
6aa721e7b10b Try to improve build sequence
Windel Bouwman
parents: 292
diff changeset
102 p1 = """module p1;
6aa721e7b10b Try to improve build sequence
Windel Bouwman
parents: 292
diff changeset
103 import p23;
6aa721e7b10b Try to improve build sequence
Windel Bouwman
parents: 292
diff changeset
104 """
306
b145f8e6050b Start on c3 rewrite
Windel Bouwman
parents: 303
diff changeset
105 self.expectErrors(p1, [0])
293
6aa721e7b10b Try to improve build sequence
Windel Bouwman
parents: 292
diff changeset
106
215
c1ccb1cb4cef Major changes in c3 frontend
Windel Bouwman
parents: 213
diff changeset
107 def testFunctArgs(self):
287
1c7c1e619be8 File movage
Windel Bouwman
parents: 284
diff changeset
108 snippet = """
284
05184b95fa16 Moved tests to seperate folder
Windel Bouwman
parents: 280
diff changeset
109 module testargs;
167
0b5b2ee6b435 Added 2 unit tests
Windel Bouwman
parents: 166
diff changeset
110 function void t2(int a, double b)
0b5b2ee6b435 Added 2 unit tests
Windel Bouwman
parents: 166
diff changeset
111 {
0b5b2ee6b435 Added 2 unit tests
Windel Bouwman
parents: 166
diff changeset
112 t2(2, 2);
0b5b2ee6b435 Added 2 unit tests
Windel Bouwman
parents: 166
diff changeset
113 t2(2);
0b5b2ee6b435 Added 2 unit tests
Windel Bouwman
parents: 166
diff changeset
114 t2(1, 1.2);
0b5b2ee6b435 Added 2 unit tests
Windel Bouwman
parents: 166
diff changeset
115 }
287
1c7c1e619be8 File movage
Windel Bouwman
parents: 284
diff changeset
116 """
1c7c1e619be8 File movage
Windel Bouwman
parents: 284
diff changeset
117 self.expectErrors(snippet, [5, 6])
148
e5263f74b287 Added c3 language frontend initial parser
Windel Bouwman
parents:
diff changeset
118
303
be7f60545368 Final fixups
Windel Bouwman
parents: 301
diff changeset
119 def testReturn(self):
be7f60545368 Final fixups
Windel Bouwman
parents: 301
diff changeset
120 snippet = """
be7f60545368 Final fixups
Windel Bouwman
parents: 301
diff changeset
121 module testreturn;
be7f60545368 Final fixups
Windel Bouwman
parents: 301
diff changeset
122 function void t()
be7f60545368 Final fixups
Windel Bouwman
parents: 301
diff changeset
123 {
be7f60545368 Final fixups
Windel Bouwman
parents: 301
diff changeset
124 return;
be7f60545368 Final fixups
Windel Bouwman
parents: 301
diff changeset
125 }
be7f60545368 Final fixups
Windel Bouwman
parents: 301
diff changeset
126 """
be7f60545368 Final fixups
Windel Bouwman
parents: 301
diff changeset
127 self.expectOK(snippet)
be7f60545368 Final fixups
Windel Bouwman
parents: 301
diff changeset
128
be7f60545368 Final fixups
Windel Bouwman
parents: 301
diff changeset
129 def testReturn2(self):
be7f60545368 Final fixups
Windel Bouwman
parents: 301
diff changeset
130 snippet = """
be7f60545368 Final fixups
Windel Bouwman
parents: 301
diff changeset
131 module testreturn;
be7f60545368 Final fixups
Windel Bouwman
parents: 301
diff changeset
132 function int t()
be7f60545368 Final fixups
Windel Bouwman
parents: 301
diff changeset
133 {
be7f60545368 Final fixups
Windel Bouwman
parents: 301
diff changeset
134 return 2;
be7f60545368 Final fixups
Windel Bouwman
parents: 301
diff changeset
135 }
be7f60545368 Final fixups
Windel Bouwman
parents: 301
diff changeset
136 """
be7f60545368 Final fixups
Windel Bouwman
parents: 301
diff changeset
137 self.expectOK(snippet)
be7f60545368 Final fixups
Windel Bouwman
parents: 301
diff changeset
138
215
c1ccb1cb4cef Major changes in c3 frontend
Windel Bouwman
parents: 213
diff changeset
139 def testExpressions(self):
287
1c7c1e619be8 File movage
Windel Bouwman
parents: 284
diff changeset
140 snippet = """
284
05184b95fa16 Moved tests to seperate folder
Windel Bouwman
parents: 280
diff changeset
141 module test;
167
0b5b2ee6b435 Added 2 unit tests
Windel Bouwman
parents: 166
diff changeset
142 function void t(int a, double b)
0b5b2ee6b435 Added 2 unit tests
Windel Bouwman
parents: 166
diff changeset
143 {
0b5b2ee6b435 Added 2 unit tests
Windel Bouwman
parents: 166
diff changeset
144 var int a2;
0b5b2ee6b435 Added 2 unit tests
Windel Bouwman
parents: 166
diff changeset
145 var bool c;
0b5b2ee6b435 Added 2 unit tests
Windel Bouwman
parents: 166
diff changeset
146
0b5b2ee6b435 Added 2 unit tests
Windel Bouwman
parents: 166
diff changeset
147 a2 = b * a;
0b5b2ee6b435 Added 2 unit tests
Windel Bouwman
parents: 166
diff changeset
148 c = a;
0b5b2ee6b435 Added 2 unit tests
Windel Bouwman
parents: 166
diff changeset
149 }
287
1c7c1e619be8 File movage
Windel Bouwman
parents: 284
diff changeset
150 """
307
e609d5296ee9 Massive rewrite of codegenerator
Windel Bouwman
parents: 306
diff changeset
151 self.expectErrors(snippet, [8, 9])
205
d77cb5962cc5 Added some handcoded arm code generation
Windel Bouwman
parents: 204
diff changeset
152
230
88a1e0baef65 Added some tests for IR-code
Windel Bouwman
parents: 228
diff changeset
153 def testExpression1(self):
287
1c7c1e619be8 File movage
Windel Bouwman
parents: 284
diff changeset
154 snippet = """
284
05184b95fa16 Moved tests to seperate folder
Windel Bouwman
parents: 280
diff changeset
155 module testexpr1;
230
88a1e0baef65 Added some tests for IR-code
Windel Bouwman
parents: 228
diff changeset
156 function void t()
88a1e0baef65 Added some tests for IR-code
Windel Bouwman
parents: 228
diff changeset
157 {
88a1e0baef65 Added some tests for IR-code
Windel Bouwman
parents: 228
diff changeset
158 var int a, b, c;
88a1e0baef65 Added some tests for IR-code
Windel Bouwman
parents: 228
diff changeset
159 a = 1;
88a1e0baef65 Added some tests for IR-code
Windel Bouwman
parents: 228
diff changeset
160 b = a * 2 + a * a;
88a1e0baef65 Added some tests for IR-code
Windel Bouwman
parents: 228
diff changeset
161 c = b * a - 3;
88a1e0baef65 Added some tests for IR-code
Windel Bouwman
parents: 228
diff changeset
162 }
287
1c7c1e619be8 File movage
Windel Bouwman
parents: 284
diff changeset
163 """
1c7c1e619be8 File movage
Windel Bouwman
parents: 284
diff changeset
164 self.expectOK(snippet)
230
88a1e0baef65 Added some tests for IR-code
Windel Bouwman
parents: 228
diff changeset
165
215
c1ccb1cb4cef Major changes in c3 frontend
Windel Bouwman
parents: 213
diff changeset
166 def testEmpty(self):
287
1c7c1e619be8 File movage
Windel Bouwman
parents: 284
diff changeset
167 snippet = """
1c7c1e619be8 File movage
Windel Bouwman
parents: 284
diff changeset
168 module A
1c7c1e619be8 File movage
Windel Bouwman
parents: 284
diff changeset
169 """
1c7c1e619be8 File movage
Windel Bouwman
parents: 284
diff changeset
170 self.expectErrors(snippet, [3])
205
d77cb5962cc5 Added some handcoded arm code generation
Windel Bouwman
parents: 204
diff changeset
171
215
c1ccb1cb4cef Major changes in c3 frontend
Windel Bouwman
parents: 213
diff changeset
172 def testEmpty2(self):
287
1c7c1e619be8 File movage
Windel Bouwman
parents: 284
diff changeset
173 snippet = ""
1c7c1e619be8 File movage
Windel Bouwman
parents: 284
diff changeset
174 self.expectErrors(snippet, [1])
205
d77cb5962cc5 Added some handcoded arm code generation
Windel Bouwman
parents: 204
diff changeset
175
215
c1ccb1cb4cef Major changes in c3 frontend
Windel Bouwman
parents: 213
diff changeset
176 def testRedefine(self):
287
1c7c1e619be8 File movage
Windel Bouwman
parents: 284
diff changeset
177 snippet = """
1c7c1e619be8 File movage
Windel Bouwman
parents: 284
diff changeset
178 module test;
1c7c1e619be8 File movage
Windel Bouwman
parents: 284
diff changeset
179 var int a;
1c7c1e619be8 File movage
Windel Bouwman
parents: 284
diff changeset
180 var int b;
1c7c1e619be8 File movage
Windel Bouwman
parents: 284
diff changeset
181 var int a;
1c7c1e619be8 File movage
Windel Bouwman
parents: 284
diff changeset
182 """
1c7c1e619be8 File movage
Windel Bouwman
parents: 284
diff changeset
183 self.expectErrors(snippet, [5])
205
d77cb5962cc5 Added some handcoded arm code generation
Windel Bouwman
parents: 204
diff changeset
184
215
c1ccb1cb4cef Major changes in c3 frontend
Windel Bouwman
parents: 213
diff changeset
185 def testWhile(self):
287
1c7c1e619be8 File movage
Windel Bouwman
parents: 284
diff changeset
186 snippet = """
1c7c1e619be8 File movage
Windel Bouwman
parents: 284
diff changeset
187 module tstwhile;
1c7c1e619be8 File movage
Windel Bouwman
parents: 284
diff changeset
188 function void t()
1c7c1e619be8 File movage
Windel Bouwman
parents: 284
diff changeset
189 {
306
b145f8e6050b Start on c3 rewrite
Windel Bouwman
parents: 303
diff changeset
190 var int i;
b145f8e6050b Start on c3 rewrite
Windel Bouwman
parents: 303
diff changeset
191 i = 0;
169
ee0d30533dae Added more tests and improved the diagnostic update
Windel Bouwman
parents: 168
diff changeset
192 while (i < 1054)
ee0d30533dae Added more tests and improved the diagnostic update
Windel Bouwman
parents: 168
diff changeset
193 {
ee0d30533dae Added more tests and improved the diagnostic update
Windel Bouwman
parents: 168
diff changeset
194 i = i + 3;
ee0d30533dae Added more tests and improved the diagnostic update
Windel Bouwman
parents: 168
diff changeset
195 }
307
e609d5296ee9 Massive rewrite of codegenerator
Windel Bouwman
parents: 306
diff changeset
196 }
e609d5296ee9 Massive rewrite of codegenerator
Windel Bouwman
parents: 306
diff changeset
197 """
e609d5296ee9 Massive rewrite of codegenerator
Windel Bouwman
parents: 306
diff changeset
198 self.expectOK(snippet)
205
d77cb5962cc5 Added some handcoded arm code generation
Windel Bouwman
parents: 204
diff changeset
199
307
e609d5296ee9 Massive rewrite of codegenerator
Windel Bouwman
parents: 306
diff changeset
200 def testWhile2(self):
e609d5296ee9 Massive rewrite of codegenerator
Windel Bouwman
parents: 306
diff changeset
201 snippet = """
e609d5296ee9 Massive rewrite of codegenerator
Windel Bouwman
parents: 306
diff changeset
202 module tstwhile;
e609d5296ee9 Massive rewrite of codegenerator
Windel Bouwman
parents: 306
diff changeset
203 function void t()
e609d5296ee9 Massive rewrite of codegenerator
Windel Bouwman
parents: 306
diff changeset
204 {
205
d77cb5962cc5 Added some handcoded arm code generation
Windel Bouwman
parents: 204
diff changeset
205 while(true)
d77cb5962cc5 Added some handcoded arm code generation
Windel Bouwman
parents: 204
diff changeset
206 {
d77cb5962cc5 Added some handcoded arm code generation
Windel Bouwman
parents: 204
diff changeset
207 }
d77cb5962cc5 Added some handcoded arm code generation
Windel Bouwman
parents: 204
diff changeset
208
d77cb5962cc5 Added some handcoded arm code generation
Windel Bouwman
parents: 204
diff changeset
209 while(false)
d77cb5962cc5 Added some handcoded arm code generation
Windel Bouwman
parents: 204
diff changeset
210 {
d77cb5962cc5 Added some handcoded arm code generation
Windel Bouwman
parents: 204
diff changeset
211 }
287
1c7c1e619be8 File movage
Windel Bouwman
parents: 284
diff changeset
212 }
1c7c1e619be8 File movage
Windel Bouwman
parents: 284
diff changeset
213 """
1c7c1e619be8 File movage
Windel Bouwman
parents: 284
diff changeset
214 self.expectOK(snippet)
215
c1ccb1cb4cef Major changes in c3 frontend
Windel Bouwman
parents: 213
diff changeset
215
c1ccb1cb4cef Major changes in c3 frontend
Windel Bouwman
parents: 213
diff changeset
216 def testIf(self):
c1ccb1cb4cef Major changes in c3 frontend
Windel Bouwman
parents: 213
diff changeset
217 snippet = """
287
1c7c1e619be8 File movage
Windel Bouwman
parents: 284
diff changeset
218 module tstIFF;
1c7c1e619be8 File movage
Windel Bouwman
parents: 284
diff changeset
219 function void t(int b)
1c7c1e619be8 File movage
Windel Bouwman
parents: 284
diff changeset
220 {
180
25a0753da4cf Re-organized files
Windel Bouwman
parents: 170
diff changeset
221 var int a;
169
ee0d30533dae Added more tests and improved the diagnostic update
Windel Bouwman
parents: 168
diff changeset
222 a = 2;
ee0d30533dae Added more tests and improved the diagnostic update
Windel Bouwman
parents: 168
diff changeset
223 if (a > b)
ee0d30533dae Added more tests and improved the diagnostic update
Windel Bouwman
parents: 168
diff changeset
224 {
ee0d30533dae Added more tests and improved the diagnostic update
Windel Bouwman
parents: 168
diff changeset
225 if (a > 1337)
ee0d30533dae Added more tests and improved the diagnostic update
Windel Bouwman
parents: 168
diff changeset
226 {
ee0d30533dae Added more tests and improved the diagnostic update
Windel Bouwman
parents: 168
diff changeset
227 b = 2;
ee0d30533dae Added more tests and improved the diagnostic update
Windel Bouwman
parents: 168
diff changeset
228 }
ee0d30533dae Added more tests and improved the diagnostic update
Windel Bouwman
parents: 168
diff changeset
229 }
ee0d30533dae Added more tests and improved the diagnostic update
Windel Bouwman
parents: 168
diff changeset
230 else
ee0d30533dae Added more tests and improved the diagnostic update
Windel Bouwman
parents: 168
diff changeset
231 {
ee0d30533dae Added more tests and improved the diagnostic update
Windel Bouwman
parents: 168
diff changeset
232 b = 1;
ee0d30533dae Added more tests and improved the diagnostic update
Windel Bouwman
parents: 168
diff changeset
233 }
ee0d30533dae Added more tests and improved the diagnostic update
Windel Bouwman
parents: 168
diff changeset
234
ee0d30533dae Added more tests and improved the diagnostic update
Windel Bouwman
parents: 168
diff changeset
235 return b;
287
1c7c1e619be8 File movage
Windel Bouwman
parents: 284
diff changeset
236 }
215
c1ccb1cb4cef Major changes in c3 frontend
Windel Bouwman
parents: 213
diff changeset
237 """
c1ccb1cb4cef Major changes in c3 frontend
Windel Bouwman
parents: 213
diff changeset
238 self.expectOK(snippet)
225
1c7364bd74c7 Fixed pointer deref
Windel Bouwman
parents: 221
diff changeset
239
1c7364bd74c7 Fixed pointer deref
Windel Bouwman
parents: 221
diff changeset
240 def testTypeDef(self):
1c7364bd74c7 Fixed pointer deref
Windel Bouwman
parents: 221
diff changeset
241 snippet = """
284
05184b95fa16 Moved tests to seperate folder
Windel Bouwman
parents: 280
diff changeset
242 module testtypedef;
225
1c7364bd74c7 Fixed pointer deref
Windel Bouwman
parents: 221
diff changeset
243 type int my_int;
1c7364bd74c7 Fixed pointer deref
Windel Bouwman
parents: 221
diff changeset
244 function void t()
1c7364bd74c7 Fixed pointer deref
Windel Bouwman
parents: 221
diff changeset
245 {
1c7364bd74c7 Fixed pointer deref
Windel Bouwman
parents: 221
diff changeset
246 var my_int a;
1c7364bd74c7 Fixed pointer deref
Windel Bouwman
parents: 221
diff changeset
247 var int b;
1c7364bd74c7 Fixed pointer deref
Windel Bouwman
parents: 221
diff changeset
248 a = 2;
1c7364bd74c7 Fixed pointer deref
Windel Bouwman
parents: 221
diff changeset
249 b = a + 2;
1c7364bd74c7 Fixed pointer deref
Windel Bouwman
parents: 221
diff changeset
250 }
1c7364bd74c7 Fixed pointer deref
Windel Bouwman
parents: 221
diff changeset
251 """
1c7364bd74c7 Fixed pointer deref
Windel Bouwman
parents: 221
diff changeset
252 self.expectOK(snippet)
1c7364bd74c7 Fixed pointer deref
Windel Bouwman
parents: 221
diff changeset
253
230
88a1e0baef65 Added some tests for IR-code
Windel Bouwman
parents: 228
diff changeset
254 def testLocalVariable(self):
88a1e0baef65 Added some tests for IR-code
Windel Bouwman
parents: 228
diff changeset
255 snippet = """
284
05184b95fa16 Moved tests to seperate folder
Windel Bouwman
parents: 280
diff changeset
256 module testlocalvar;
230
88a1e0baef65 Added some tests for IR-code
Windel Bouwman
parents: 228
diff changeset
257 function void t()
88a1e0baef65 Added some tests for IR-code
Windel Bouwman
parents: 228
diff changeset
258 {
88a1e0baef65 Added some tests for IR-code
Windel Bouwman
parents: 228
diff changeset
259 var int a, b;
88a1e0baef65 Added some tests for IR-code
Windel Bouwman
parents: 228
diff changeset
260 a = 2;
88a1e0baef65 Added some tests for IR-code
Windel Bouwman
parents: 228
diff changeset
261 b = a + 2;
88a1e0baef65 Added some tests for IR-code
Windel Bouwman
parents: 228
diff changeset
262 }
88a1e0baef65 Added some tests for IR-code
Windel Bouwman
parents: 228
diff changeset
263 """
268
5ec7580976d9 Op naar tree-IR
Windel Bouwman
parents: 252
diff changeset
264 self.expectOK(snippet)
230
88a1e0baef65 Added some tests for IR-code
Windel Bouwman
parents: 228
diff changeset
265
249
e41e4109addd Added current position arrow
Windel Bouwman
parents: 243
diff changeset
266 def testUnknownType(self):
284
05184b95fa16 Moved tests to seperate folder
Windel Bouwman
parents: 280
diff changeset
267 snippet = """module testlocalvar;
249
e41e4109addd Added current position arrow
Windel Bouwman
parents: 243
diff changeset
268 function void t()
e41e4109addd Added current position arrow
Windel Bouwman
parents: 243
diff changeset
269 {
e41e4109addd Added current position arrow
Windel Bouwman
parents: 243
diff changeset
270 var int2 a;
e41e4109addd Added current position arrow
Windel Bouwman
parents: 243
diff changeset
271 }
e41e4109addd Added current position arrow
Windel Bouwman
parents: 243
diff changeset
272 """
e41e4109addd Added current position arrow
Windel Bouwman
parents: 243
diff changeset
273 self.expectErrors(snippet, [4])
e41e4109addd Added current position arrow
Windel Bouwman
parents: 243
diff changeset
274
230
88a1e0baef65 Added some tests for IR-code
Windel Bouwman
parents: 228
diff changeset
275 def testStruct1(self):
88a1e0baef65 Added some tests for IR-code
Windel Bouwman
parents: 228
diff changeset
276 snippet = """
284
05184b95fa16 Moved tests to seperate folder
Windel Bouwman
parents: 280
diff changeset
277 module teststruct1;
230
88a1e0baef65 Added some tests for IR-code
Windel Bouwman
parents: 228
diff changeset
278 function void t()
88a1e0baef65 Added some tests for IR-code
Windel Bouwman
parents: 228
diff changeset
279 {
88a1e0baef65 Added some tests for IR-code
Windel Bouwman
parents: 228
diff changeset
280 var struct {int x, y;} a;
88a1e0baef65 Added some tests for IR-code
Windel Bouwman
parents: 228
diff changeset
281 a.x = 2;
88a1e0baef65 Added some tests for IR-code
Windel Bouwman
parents: 228
diff changeset
282 a.y = a.x + 2;
88a1e0baef65 Added some tests for IR-code
Windel Bouwman
parents: 228
diff changeset
283 }
88a1e0baef65 Added some tests for IR-code
Windel Bouwman
parents: 228
diff changeset
284 """
268
5ec7580976d9 Op naar tree-IR
Windel Bouwman
parents: 252
diff changeset
285 self.expectOK(snippet)
230
88a1e0baef65 Added some tests for IR-code
Windel Bouwman
parents: 228
diff changeset
286
293
6aa721e7b10b Try to improve build sequence
Windel Bouwman
parents: 292
diff changeset
287 def testStructCall(self):
6aa721e7b10b Try to improve build sequence
Windel Bouwman
parents: 292
diff changeset
288 snippet = """
6aa721e7b10b Try to improve build sequence
Windel Bouwman
parents: 292
diff changeset
289 module teststruct1;
6aa721e7b10b Try to improve build sequence
Windel Bouwman
parents: 292
diff changeset
290 function void t()
6aa721e7b10b Try to improve build sequence
Windel Bouwman
parents: 292
diff changeset
291 {
6aa721e7b10b Try to improve build sequence
Windel Bouwman
parents: 292
diff changeset
292 var struct {int x, y;} a;
307
e609d5296ee9 Massive rewrite of codegenerator
Windel Bouwman
parents: 306
diff changeset
293 a.x(9);
293
6aa721e7b10b Try to improve build sequence
Windel Bouwman
parents: 292
diff changeset
294 }
6aa721e7b10b Try to improve build sequence
Windel Bouwman
parents: 292
diff changeset
295 """
6aa721e7b10b Try to improve build sequence
Windel Bouwman
parents: 292
diff changeset
296 self.expectOK(snippet)
6aa721e7b10b Try to improve build sequence
Windel Bouwman
parents: 292
diff changeset
297
225
1c7364bd74c7 Fixed pointer deref
Windel Bouwman
parents: 221
diff changeset
298 def testPointerType1(self):
1c7364bd74c7 Fixed pointer deref
Windel Bouwman
parents: 221
diff changeset
299 snippet = """
284
05184b95fa16 Moved tests to seperate folder
Windel Bouwman
parents: 280
diff changeset
300 module testpointer1;
225
1c7364bd74c7 Fixed pointer deref
Windel Bouwman
parents: 221
diff changeset
301 var int* pa;
1c7364bd74c7 Fixed pointer deref
Windel Bouwman
parents: 221
diff changeset
302 function void t()
1c7364bd74c7 Fixed pointer deref
Windel Bouwman
parents: 221
diff changeset
303 {
1c7364bd74c7 Fixed pointer deref
Windel Bouwman
parents: 221
diff changeset
304 var int a;
1c7364bd74c7 Fixed pointer deref
Windel Bouwman
parents: 221
diff changeset
305 pa = &a;
1c7364bd74c7 Fixed pointer deref
Windel Bouwman
parents: 221
diff changeset
306 *pa = 22;
1c7364bd74c7 Fixed pointer deref
Windel Bouwman
parents: 221
diff changeset
307 }
1c7364bd74c7 Fixed pointer deref
Windel Bouwman
parents: 221
diff changeset
308 """
1c7364bd74c7 Fixed pointer deref
Windel Bouwman
parents: 221
diff changeset
309 self.expectOK(snippet)
1c7364bd74c7 Fixed pointer deref
Windel Bouwman
parents: 221
diff changeset
310
215
c1ccb1cb4cef Major changes in c3 frontend
Windel Bouwman
parents: 213
diff changeset
311 def testPointerType(self):
213
003c8a976fff Merge of semantics and parser again ..
Windel Bouwman
parents: 205
diff changeset
312 snippet = """
284
05184b95fa16 Moved tests to seperate folder
Windel Bouwman
parents: 280
diff changeset
313 module testpointer;
225
1c7364bd74c7 Fixed pointer deref
Windel Bouwman
parents: 221
diff changeset
314 var int* pa, pb;
213
003c8a976fff Merge of semantics and parser again ..
Windel Bouwman
parents: 205
diff changeset
315 function void t(int a, double b)
003c8a976fff Merge of semantics and parser again ..
Windel Bouwman
parents: 205
diff changeset
316 {
280
02385f62f250 Rework from str interface to Instruction interface
Windel Bouwman
parents: 272
diff changeset
317 var int a2;
02385f62f250 Rework from str interface to Instruction interface
Windel Bouwman
parents: 272
diff changeset
318 a2 = a; // parameters cannot be escaped for now..
02385f62f250 Rework from str interface to Instruction interface
Windel Bouwman
parents: 272
diff changeset
319 pa = &a2;
225
1c7364bd74c7 Fixed pointer deref
Windel Bouwman
parents: 221
diff changeset
320 pb = pa;
213
003c8a976fff Merge of semantics and parser again ..
Windel Bouwman
parents: 205
diff changeset
321 *pa = 22;
003c8a976fff Merge of semantics and parser again ..
Windel Bouwman
parents: 205
diff changeset
322 }
003c8a976fff Merge of semantics and parser again ..
Windel Bouwman
parents: 205
diff changeset
323 """
215
c1ccb1cb4cef Major changes in c3 frontend
Windel Bouwman
parents: 213
diff changeset
324 self.expectOK(snippet)
213
003c8a976fff Merge of semantics and parser again ..
Windel Bouwman
parents: 205
diff changeset
325
221
848c4b15fd0b pointers
Windel Bouwman
parents: 220
diff changeset
326 def testPointerTypeInCorrect(self):
848c4b15fd0b pointers
Windel Bouwman
parents: 220
diff changeset
327 snippet = """
284
05184b95fa16 Moved tests to seperate folder
Windel Bouwman
parents: 280
diff changeset
328 module testpointerincorrect;
221
848c4b15fd0b pointers
Windel Bouwman
parents: 220
diff changeset
329 var int* pa;
848c4b15fd0b pointers
Windel Bouwman
parents: 220
diff changeset
330 function void t(int a, double b)
848c4b15fd0b pointers
Windel Bouwman
parents: 220
diff changeset
331 {
848c4b15fd0b pointers
Windel Bouwman
parents: 220
diff changeset
332 pa = 2; // type conflict
848c4b15fd0b pointers
Windel Bouwman
parents: 220
diff changeset
333 pa = &a;
307
e609d5296ee9 Massive rewrite of codegenerator
Windel Bouwman
parents: 306
diff changeset
334 pa = &2; // No valid lvalue
221
848c4b15fd0b pointers
Windel Bouwman
parents: 220
diff changeset
335 &a = pa; // No valid lvalue
848c4b15fd0b pointers
Windel Bouwman
parents: 220
diff changeset
336 **pa = 22; // Cannot deref int
848c4b15fd0b pointers
Windel Bouwman
parents: 220
diff changeset
337 }
848c4b15fd0b pointers
Windel Bouwman
parents: 220
diff changeset
338 """
307
e609d5296ee9 Massive rewrite of codegenerator
Windel Bouwman
parents: 306
diff changeset
339 self.expectErrors(snippet, [6, 8, 9, 10])
221
848c4b15fd0b pointers
Windel Bouwman
parents: 220
diff changeset
340
230
88a1e0baef65 Added some tests for IR-code
Windel Bouwman
parents: 228
diff changeset
341 def testPointerTypeIr(self):
88a1e0baef65 Added some tests for IR-code
Windel Bouwman
parents: 228
diff changeset
342 snippet = """
284
05184b95fa16 Moved tests to seperate folder
Windel Bouwman
parents: 280
diff changeset
343 module testptr_ir;
230
88a1e0baef65 Added some tests for IR-code
Windel Bouwman
parents: 228
diff changeset
344 function void t()
88a1e0baef65 Added some tests for IR-code
Windel Bouwman
parents: 228
diff changeset
345 {
88a1e0baef65 Added some tests for IR-code
Windel Bouwman
parents: 228
diff changeset
346 var int* a;
88a1e0baef65 Added some tests for IR-code
Windel Bouwman
parents: 228
diff changeset
347 a = cast<int*>(40);
88a1e0baef65 Added some tests for IR-code
Windel Bouwman
parents: 228
diff changeset
348 *a = 2;
88a1e0baef65 Added some tests for IR-code
Windel Bouwman
parents: 228
diff changeset
349 }
88a1e0baef65 Added some tests for IR-code
Windel Bouwman
parents: 228
diff changeset
350 """
268
5ec7580976d9 Op naar tree-IR
Windel Bouwman
parents: 252
diff changeset
351 self.expectOK(snippet)
230
88a1e0baef65 Added some tests for IR-code
Windel Bouwman
parents: 228
diff changeset
352
88a1e0baef65 Added some tests for IR-code
Windel Bouwman
parents: 228
diff changeset
353 def testPointerTypeIr2(self):
88a1e0baef65 Added some tests for IR-code
Windel Bouwman
parents: 228
diff changeset
354 snippet = """
284
05184b95fa16 Moved tests to seperate folder
Windel Bouwman
parents: 280
diff changeset
355 module testptr_ir;
230
88a1e0baef65 Added some tests for IR-code
Windel Bouwman
parents: 228
diff changeset
356 type struct {int x,y;}* gpio;
88a1e0baef65 Added some tests for IR-code
Windel Bouwman
parents: 228
diff changeset
357 function void t()
88a1e0baef65 Added some tests for IR-code
Windel Bouwman
parents: 228
diff changeset
358 {
88a1e0baef65 Added some tests for IR-code
Windel Bouwman
parents: 228
diff changeset
359 var gpio a;
88a1e0baef65 Added some tests for IR-code
Windel Bouwman
parents: 228
diff changeset
360 a = cast<gpio>(40);
88a1e0baef65 Added some tests for IR-code
Windel Bouwman
parents: 228
diff changeset
361 a->x = 2;
88a1e0baef65 Added some tests for IR-code
Windel Bouwman
parents: 228
diff changeset
362 a->y = a->x - 14;
88a1e0baef65 Added some tests for IR-code
Windel Bouwman
parents: 228
diff changeset
363 }
88a1e0baef65 Added some tests for IR-code
Windel Bouwman
parents: 228
diff changeset
364 """
268
5ec7580976d9 Op naar tree-IR
Windel Bouwman
parents: 252
diff changeset
365 self.expectOK(snippet)
230
88a1e0baef65 Added some tests for IR-code
Windel Bouwman
parents: 228
diff changeset
366
88a1e0baef65 Added some tests for IR-code
Windel Bouwman
parents: 228
diff changeset
367 def testWrongCast(self):
88a1e0baef65 Added some tests for IR-code
Windel Bouwman
parents: 228
diff changeset
368 snippet = """
284
05184b95fa16 Moved tests to seperate folder
Windel Bouwman
parents: 280
diff changeset
369 module testptr_ir;
230
88a1e0baef65 Added some tests for IR-code
Windel Bouwman
parents: 228
diff changeset
370 type struct {int x,y;}* gpio;
88a1e0baef65 Added some tests for IR-code
Windel Bouwman
parents: 228
diff changeset
371 function void t()
88a1e0baef65 Added some tests for IR-code
Windel Bouwman
parents: 228
diff changeset
372 {
88a1e0baef65 Added some tests for IR-code
Windel Bouwman
parents: 228
diff changeset
373 var gpio a;
88a1e0baef65 Added some tests for IR-code
Windel Bouwman
parents: 228
diff changeset
374 *cast<gpio>(*a);
88a1e0baef65 Added some tests for IR-code
Windel Bouwman
parents: 228
diff changeset
375 }
88a1e0baef65 Added some tests for IR-code
Windel Bouwman
parents: 228
diff changeset
376 """
88a1e0baef65 Added some tests for IR-code
Windel Bouwman
parents: 228
diff changeset
377 self.expectErrors(snippet, [7, 7])
88a1e0baef65 Added some tests for IR-code
Windel Bouwman
parents: 228
diff changeset
378
215
c1ccb1cb4cef Major changes in c3 frontend
Windel Bouwman
parents: 213
diff changeset
379 def testComplexType(self):
213
003c8a976fff Merge of semantics and parser again ..
Windel Bouwman
parents: 205
diff changeset
380 snippet = """
284
05184b95fa16 Moved tests to seperate folder
Windel Bouwman
parents: 280
diff changeset
381 module testpointer;
213
003c8a976fff Merge of semantics and parser again ..
Windel Bouwman
parents: 205
diff changeset
382 type int my_int;
003c8a976fff Merge of semantics and parser again ..
Windel Bouwman
parents: 205
diff changeset
383
003c8a976fff Merge of semantics and parser again ..
Windel Bouwman
parents: 205
diff changeset
384 type struct {
003c8a976fff Merge of semantics and parser again ..
Windel Bouwman
parents: 205
diff changeset
385 int x, y;
003c8a976fff Merge of semantics and parser again ..
Windel Bouwman
parents: 205
diff changeset
386 } point;
003c8a976fff Merge of semantics and parser again ..
Windel Bouwman
parents: 205
diff changeset
387
003c8a976fff Merge of semantics and parser again ..
Windel Bouwman
parents: 205
diff changeset
388 type struct {
003c8a976fff Merge of semantics and parser again ..
Windel Bouwman
parents: 205
diff changeset
389 int mem1;
003c8a976fff Merge of semantics and parser again ..
Windel Bouwman
parents: 205
diff changeset
390 int memb2;
003c8a976fff Merge of semantics and parser again ..
Windel Bouwman
parents: 205
diff changeset
391 point P1;
003c8a976fff Merge of semantics and parser again ..
Windel Bouwman
parents: 205
diff changeset
392 } my_struct;
003c8a976fff Merge of semantics and parser again ..
Windel Bouwman
parents: 205
diff changeset
393
003c8a976fff Merge of semantics and parser again ..
Windel Bouwman
parents: 205
diff changeset
394 type my_struct* my_sptr;
225
1c7364bd74c7 Fixed pointer deref
Windel Bouwman
parents: 221
diff changeset
395 var int* pa;
213
003c8a976fff Merge of semantics and parser again ..
Windel Bouwman
parents: 205
diff changeset
396
227
82dfe6a32717 Fixed tests
Windel Bouwman
parents: 225
diff changeset
397 function void t(int a, int b, my_sptr x)
213
003c8a976fff Merge of semantics and parser again ..
Windel Bouwman
parents: 205
diff changeset
398 {
003c8a976fff Merge of semantics and parser again ..
Windel Bouwman
parents: 205
diff changeset
399 var my_struct *msp;
003c8a976fff Merge of semantics and parser again ..
Windel Bouwman
parents: 205
diff changeset
400
225
1c7364bd74c7 Fixed pointer deref
Windel Bouwman
parents: 221
diff changeset
401 var my_struct u, v;
1c7364bd74c7 Fixed pointer deref
Windel Bouwman
parents: 221
diff changeset
402 var point *pt;
1c7364bd74c7 Fixed pointer deref
Windel Bouwman
parents: 221
diff changeset
403
1c7364bd74c7 Fixed pointer deref
Windel Bouwman
parents: 221
diff changeset
404 pt = &msp->P1;
213
003c8a976fff Merge of semantics and parser again ..
Windel Bouwman
parents: 205
diff changeset
405 msp = x;
225
1c7364bd74c7 Fixed pointer deref
Windel Bouwman
parents: 221
diff changeset
406 *pa = 22 + u.mem1 * v.memb2 - u.P1.x;
213
003c8a976fff Merge of semantics and parser again ..
Windel Bouwman
parents: 205
diff changeset
407 x->memb2 = *pa + a * b;
003c8a976fff Merge of semantics and parser again ..
Windel Bouwman
parents: 205
diff changeset
408
225
1c7364bd74c7 Fixed pointer deref
Windel Bouwman
parents: 221
diff changeset
409 msp->P1.x = a * x->P1.y;
213
003c8a976fff Merge of semantics and parser again ..
Windel Bouwman
parents: 205
diff changeset
410 }
003c8a976fff Merge of semantics and parser again ..
Windel Bouwman
parents: 205
diff changeset
411 """
215
c1ccb1cb4cef Major changes in c3 frontend
Windel Bouwman
parents: 213
diff changeset
412 self.expectOK(snippet)
205
d77cb5962cc5 Added some handcoded arm code generation
Windel Bouwman
parents: 204
diff changeset
413
167
0b5b2ee6b435 Added 2 unit tests
Windel Bouwman
parents: 166
diff changeset
414
0b5b2ee6b435 Added 2 unit tests
Windel Bouwman
parents: 166
diff changeset
415 if __name__ == '__main__':
243
ef683881c64e Remove various files
Windel Bouwman
parents: 231
diff changeset
416 unittest.main()