comparison python/testc3.py @ 221:848c4b15fd0b

pointers
author Windel Bouwman
date Mon, 08 Jul 2013 22:21:44 +0200
parents 3f6c30a5d234
children 1c7364bd74c7
comparison
equal deleted inserted replaced
220:3f6c30a5d234 221:848c4b15fd0b
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 = &a;
217 *pa = 22; 216 *pa = 22;
218 } 217 }
219 """ 218 """
220 self.expectOK(snippet) 219 self.expectOK(snippet)
220
221 def testPointerTypeInCorrect(self):
222 snippet = """
223 package testpointerincorrect;
224 var int* pa;
225 function void t(int a, double b)
226 {
227 pa = 2; // type conflict
228 pa = &a;
229 pa = &2;
230 &a = 3; // no valid lvalue and incorrect types.
231 &a = pa; // No valid lvalue
232 **pa = 22; // Cannot deref int
233 }
234 """
235 self.expectErrors(snippet, [6, 9, 9, 10, 11])
221 236
222 @unittest.skip 237 @unittest.skip
223 def testComplexType(self): 238 def testComplexType(self):
224 snippet = """ 239 snippet = """
225 package testpointer; 240 package testpointer;