Mercurial > lcfOS
diff test/testc3.py @ 300:158068af716c
yafm
author | Windel Bouwman |
---|---|
date | Tue, 03 Dec 2013 18:00:22 +0100 |
parents | 917eab04b8b7 |
children | 6753763d3bec |
line wrap: on
line diff
--- a/test/testc3.py Sun Dec 01 18:37:23 2013 +0100 +++ b/test/testc3.py Tue Dec 03 18:00:22 2013 +0100 @@ -1,74 +1,13 @@ -import c3 -import time +from ppci.c3 import Builder, Lexer import ppci -import ir import unittest -import glob import io -testsrc = """module test; - -/* - demo of the source that is correct :) -*/ -var int c, d; -var double e; -var int f; - -const int A = 1337; - -function void test1() -{ - var int bdd; - var int a = 10; - bdd = 20; - var int buf; - var int i; - i = 2; - var int zero = i - 2; - if (i > 1) - { - buf = b + 22 * i - 13 + (55 * 2 *9-2) / 44 - 1; - } - else - { - ;;; - } - - t2(2, 3); -} - -function int t2(int a, int b) -{ - if (a > 0) - { - a = 2 + t2(a - 1, 10); - } - - return a + b; -} - -var int a, b; - -function int t3(int aap, int blah) -{ - if (a > blah and blah < 45 + 33 or 33 > aap or 6 > 2 and true) - { - a = 2 + t2(a - 1, 0); - } - - return a + b; -} - -var int hahaa = 23 * 2; - - -""" class testLexer(unittest.TestCase): def setUp(self): diag = ppci.DiagnosticsManager() - self.l = c3.Lexer(diag) + self.l = Lexer(diag) def testUnexpectedCharacter(self): snippet = io.StringIO(""" var s \u6c34 """) @@ -102,12 +41,9 @@ class testBuilder(unittest.TestCase): def setUp(self): self.diag = ppci.DiagnosticsManager() - self.builder = c3.Builder(self.diag) + self.builder = Builder(self.diag) self.diag.clear() - def testSrc(self): - self.expectOK(testsrc) - def expectErrors(self, snippet, rows): """ Helper to test for expected errors on rows """ ircode = list(self.builder.build([io.StringIO(snippet)])) @@ -309,7 +245,6 @@ """ self.expectOK(snippet) - @unittest.skip('Too strange to handle') def testStructCall(self): snippet = """ module teststruct1; @@ -437,41 +372,6 @@ """ self.expectOK(snippet) - @unittest.skip('To be rewritten') - def testExamples(self): - """ Test all examples in the c3/examples directory """ - example_filenames = glob.glob('./c3examples/*.c3') - for filename in example_filenames: - with open(filename, 'r') as f: - self.expectOK(f) - - def test2(self): - # testsrc2 is valid code: - snippet = """ - module test2; - - function void tst() - { - var int a, b; - a = 2 * 33 - 12; - b = a * 2 + 13; - a = b + a; - if (a > b and b == 3) - { - var int x = a; - x = b * 2 - a; - a = x*x; - } - else - { - a = b + a; - } - } - - """ - self.expectOK(snippet) if __name__ == '__main__': unittest.main() - -