OILS / core / ui_test.py View on Github | oilshell.org

29 lines, 17 significant
1#!/usr/bin/env python2
2from __future__ import print_function
3
4import unittest
5
6from core import test_lib
7from core import ui # module under test
8
9
10class 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
28if __name__ == '__main__':
29 unittest.main()