Mercurial > lcfOS
comparison test/testc3.py @ 393:6ae782a085e0
Added init program
author | Windel Bouwman |
---|---|
date | Sat, 17 May 2014 21:17:40 +0200 |
parents | 2ec730e45ea1 |
children | fb3c1f029b30 |
comparison
equal
deleted
inserted
replaced
392:bb4289c84907 | 393:6ae782a085e0 |
---|---|
390 def testArrayFail3(self): | 390 def testArrayFail3(self): |
391 snippet = """ | 391 snippet = """ |
392 module testarray; | 392 module testarray; |
393 function void t() | 393 function void t() |
394 { | 394 { |
395 int c[20]; | 395 var int c[20]; |
396 } | 396 } |
397 """ | 397 """ |
398 self.expectErrors(snippet, [7]) | 398 self.expectErrors(snippet, [7]) |
399 | 399 |
400 def testStructCall(self): | 400 def testStructCall(self): |
416 var string a; | 416 var string a; |
417 a = "Hello world"; | 417 a = "Hello world"; |
418 print(a); | 418 print(a); |
419 print("Moi"); | 419 print("Moi"); |
420 } | 420 } |
421 | |
421 function void print(string a) | 422 function void print(string a) |
422 { | 423 { |
424 } | |
425 """ | |
426 self.expectOK(snippet) | |
427 | |
428 def testSizeof1(self): | |
429 snippet = """ | |
430 module testsizeof; | |
431 | |
432 function void t() | |
433 { | |
434 var int a; | |
435 a = sizeof(int*); | |
436 } | |
437 """ | |
438 self.expectOK(snippet) | |
439 | |
440 def testSizeof2(self): | |
441 snippet = """ | |
442 module testsizeof2; | |
443 | |
444 function void t() | |
445 { | |
446 sizeof(int*) = 2; | |
447 } | |
448 """ | |
449 self.expectErrors(snippet, [6]) | |
450 | |
451 @unittest.skip('TODO: Too hard') | |
452 def testWrongVarUse(self): | |
453 snippet = """ | |
454 module testsizeof; | |
455 | |
456 function void t() | |
457 { | |
458 int a = 1; | |
423 } | 459 } |
424 """ | 460 """ |
425 self.expectOK(snippet) | 461 self.expectOK(snippet) |
426 | 462 |
427 def testPointerType1(self): | 463 def testPointerType1(self): |
492 a->y = a->x - 14; | 528 a->y = a->x - 14; |
493 } | 529 } |
494 """ | 530 """ |
495 self.expectOK(snippet) | 531 self.expectOK(snippet) |
496 | 532 |
533 def testPointerArithmatic(self): | |
534 snippet = """ | |
535 module testpointerarithmatic; | |
536 function void t() | |
537 { | |
538 var int* pa; | |
539 *(pa+2) = 2; | |
540 } | |
541 """ | |
542 self.expectOK(snippet) | |
543 | |
497 def testWrongCast(self): | 544 def testWrongCast(self): |
498 snippet = """ | 545 snippet = """ |
499 module testptr_ir; | 546 module testptr_ir; |
500 type struct {int x,y;}* gpio; | 547 type struct {int x,y;}* gpio; |
501 function void t() | 548 function void t() |