-
Notifications
You must be signed in to change notification settings - Fork 2
/
test-ah3.py
41 lines (36 loc) · 939 Bytes
/
test-ah3.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
from utils import Set
from autohighlight import Autohighlight
from cStringIO import StringIO
from context import Context
import unittest
test1file = \
"""
{
} {
a: 'a' .
c: 'c' .
d: 'd' .
e: 'e' .
q: 'q' .
t: 't' .
s: 's' .
x: a b c .
y: d b e .
b: q t .
b: q s .
} {
}
"""
class AhTestContexts(unittest.TestCase):
def setUp(self):
global test1file
self.ah = Autohighlight(StringIO(test1file))
self.ah.parse()
def testGetContextsForQ(self):
gsd = self.ah.GlobalSymbolDict
expected = [Context(Set([gsd['a'],gsd['d']]),gsd['q'],Set([gsd['t']])), \
Context(Set([gsd['a'],gsd['d']]),gsd['q'],Set([gsd['s']])) ]
contexts = gsd['q'].get_contexts()
self.assertEqual(contexts, expected, "Contexts for %s are not as expected:\n%s\n%s" % ('q',contexts,expected))
if __name__ == "__main__":
unittest.main()