208
|
1 import unittest
|
237
|
2 import glob
|
208
|
3 import zcc
|
250
|
4 import outstream
|
|
5 import ppci
|
208
|
6
|
286
|
7
|
208
|
8 class ZccTestCase(unittest.TestCase):
|
|
9 """ Tests the compiler driver """
|
|
10
|
237
|
11 def do(self, fn):
|
208
|
12 """ Compile blink.c3 """
|
286
|
13 args = zcc.parser.parse_args([fn, '--package_dir', './c3examples/'])
|
|
14 self.assertEqual(0, zcc.main(args))
|
208
|
15
|
237
|
16 def testExamples(self):
|
|
17 """ Test all examples in the c3/examples directory """
|
284
|
18 example_filenames = glob.glob('./c3examples/*.c3')
|
237
|
19 for filename in example_filenames:
|
|
20 self.do(filename)
|
|
21
|
250
|
22 def testSectionAddress(self):
|
284
|
23 src = "module tst; function void t2() {var int t3; t3 = 2;}"
|
250
|
24 diag = ppci.DiagnosticsManager()
|
|
25 outs = outstream.TextOutputStream()
|
|
26 self.assertTrue(zcc.zcc(src, outs, diag))
|
|
27 code = outs.getSection('code')
|
|
28 self.assertEqual(0x08000000, code.address)
|
|
29 data = outs.getSection('data')
|
|
30 self.assertEqual(0x20000000, data.address)
|
|
31
|
|
32
|
208
|
33 if __name__ == '__main__':
|
|
34 unittest.main()
|
|
35
|