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 | spid1 = arena.NewToken(-1, 0, 2, line_id, '').span_id
|
17 | spid2 = arena.NewToken(-1, 2, 2, line_id, '').span_id
|
18 |
|
19 | tok1 = arena.GetToken(spid1)
|
20 | tok2 = arena.GetToken(spid2)
|
21 |
|
22 | errfmt = ui.ErrorFormatter()
|
23 |
|
24 | # no location info
|
25 | errfmt.Print_('hello')
|
26 |
|
27 | with ui.ctx_Location(errfmt, tok1):
|
28 | errfmt.Print_('zero')
|
29 | errfmt.Print_('zero', tok2)
|
30 |
|
31 |
|
32 | if __name__ == '__main__':
|
33 | unittest.main()
|