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