1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
|
| import unittest
|
| import antlr3
|
|
| class TestDFA(unittest.TestCase):
| """Test case for the DFA class."""
|
| def setUp(self):
| """Setup test fixure.
|
| We need a Recognizer in order to instanciate a DFA.
|
| """
|
| class TRecognizer(antlr3.BaseRecognizer):
| api_version = 'HEAD'
|
| self.recog = TRecognizer()
|
|
| def testInit(self):
| """DFA.__init__()
|
| Just a smoke test.
|
| """
|
| dfa = antlr3.DFA(
| self.recog, 1,
| eot=[],
| eof=[],
| min=[],
| max=[],
| accept=[],
| special=[],
| transition=[]
| )
|
|
| def testUnpack(self):
| """DFA.unpack()"""
|
| self.failUnlessEqual(
| antlr3.DFA.unpack(
| u"\1\3\1\4\2\uffff\1\5\22\uffff\1\2\31\uffff\1\6\6\uffff"
| u"\32\6\4\uffff\1\6\1\uffff\32\6"
| ),
| [ 3, 4, -1, -1, 5, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
| -1, -1, -1, -1, -1, -1, 2, -1, -1, -1, -1, -1, -1, -1, -1, -1,
| -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1,
| 6, -1, -1, -1, -1, -1, -1, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
| 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, -1, -1, -1, -1, 6, -1,
| 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6, 6,
| 6, 6, 6, 6, 6
| ]
| )
|
|
|
| if __name__ == "__main__":
| unittest.main(testRunner=unittest.TextTestRunner(verbosity=2))
|
|