Mercurial > lcfOS
diff test/testc3.py @ 293:6aa721e7b10b
Try to improve build sequence
author | Windel Bouwman |
---|---|
date | Thu, 28 Nov 2013 20:39:37 +0100 |
parents | 534b94b40aa8 |
children | 917eab04b8b7 |
line wrap: on
line diff
--- a/test/testc3.py Wed Nov 27 08:06:42 2013 +0100 +++ b/test/testc3.py Thu Nov 28 20:39:37 2013 +0100 @@ -66,29 +66,37 @@ """ class testLexer(unittest.TestCase): + def setUp(self): + diag = ppci.DiagnosticsManager() + self.l = c3.Lexer(diag) + def testUnexpectedCharacter(self): snippet = io.StringIO(""" var s \u6c34 """) with self.assertRaises(ppci.CompilerError): - list(c3.lexer.tokenize(snippet)) + list(self.l.tokenize(snippet)) + + def check(self, snippet, toks): + toks2 = list(tok.typ for tok in self.l.tokenize(io.StringIO(snippet))) + self.assertSequenceEqual(toks, toks2) def testBlockComment(self): - snippet = io.StringIO(""" + snippet = """ /* Demo */ var int x = 0; - """) + """ toks = ['var', 'ID', 'ID', '=', 'NUMBER', ';', 'END'] - self.assertSequenceEqual([tok.typ for tok in c3.lexer.tokenize(snippet)], toks) + self.check(snippet, toks) def testBlockCommentMultiLine(self): - snippet = io.StringIO(""" + snippet = """ /* Demo bla1 bla2 */ var int x = 0; - """) + """ toks = ['var', 'ID', 'ID', '=', 'NUMBER', ';', 'END'] - self.assertSequenceEqual([tok.typ for tok in c3.lexer.tokenize(snippet)], toks) + self.check(snippet, toks) class testBuilder(unittest.TestCase): @@ -141,6 +149,12 @@ """ self.expectOK([io.StringIO(s) for s in (p1, p2)]) + def testPackageNotExists(self): + p1 = """module p1; + import p23; + """ + self.expectOK([io.StringIO(p1)]) + def testFunctArgs(self): snippet = """ module testargs; @@ -295,6 +309,17 @@ """ self.expectOK(snippet) + def testStructCall(self): + snippet = """ + module teststruct1; + function void t() + { + var struct {int x, y;} a; + a.b.c(9); + } + """ + self.expectOK(snippet) + def testPointerType1(self): snippet = """ module testpointer1;