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