-
Notifications
You must be signed in to change notification settings - Fork 11
/
test_pluspy.py
73 lines (58 loc) · 2.48 KB
/
test_pluspy.py
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
64
65
66
67
68
69
70
71
import pluspy
import unittest
class TestLexer(unittest.TestCase):
def test_ignore_preamble(self):
cases = [
{
"name": "preamble",
"input": '''
This is some prose preceding the module definition.
\* WORKAROUND: Comment prose before the module definition.
---- MODULE AsyncGameOfLifeDistributed -----
VARIABLE x
Spec == x = TRUE /\ [][x'\in BOOLEAN]_x
====
''',
},
{
"name": "preamble with four dashes",
"input": '''
---- What is this
\* A comment
And more preamble there is.
------------------------------- MODULE Somename -------------------------------
''',
},
{
"name": "preamble with commented module",
"input": ''''
---- What is this
\* A comment
\* ---- MODULE foo ----
And more preamble there is.
------------------------------- MODULE Foo -------------------------------
================================ =============================================
'''
},
]
for case in cases:
results = pluspy.lexer(case["input"], "nofile.tla")
a, b, _, d = results[0], results[1], results[2], results[3]
self.assertEqual(
"----", pluspy.lexeme(a),
"failed test {} expected {}, actual {}".format(
case["name"], "----", a
),
)
self.assertEqual(
"MODULE", pluspy.lexeme(b),
"failed test {} expected {}, actual {}".format(
case["name"], "MODULE", b
),
)
self.assertEqual(
"----", pluspy.lexeme(d),
"failed test {} expected {}, actual {}".format(
case["name"], "----", a
),
)