1 | #!/usr/bin/env python2
|
2 | from __future__ import print_function
|
3 |
|
4 | import unittest
|
5 |
|
6 | from core import test_lib
|
7 | from core import ui # module under test
|
8 |
|
9 |
|
10 | class UiTest(unittest.TestCase):
|
11 |
|
12 | def testErrorFormatter(self):
|
13 | arena = test_lib.MakeArena('')
|
14 | line_id = arena.AddLine('[line one]', 1)
|
15 | tok1 = arena.NewToken(-1, 0, 2, line_id)
|
16 | tok2 = arena.NewToken(-1, 2, 2, line_id)
|
17 |
|
18 | errfmt = ui.ErrorFormatter()
|
19 |
|
20 | # no location info
|
21 | errfmt.Print_('hello')
|
22 |
|
23 | with ui.ctx_Location(errfmt, tok1):
|
24 | errfmt.Print_('zero')
|
25 | errfmt.Print_('zero', tok2)
|
26 |
|
27 |
|
28 | if __name__ == '__main__':
|
29 | unittest.main()
|