-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest_ast_token_extractor.py
99 lines (93 loc) · 1.93 KB
/
test_ast_token_extractor.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
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
import unittest
from ast_token_extractor import ast2id_or_lit
# manually checked outs, regression style test
json0_tokens = [
None,
None,
"ID:gTestfile",
"LIT:regress-472450-04.js",
None,
"ID:BUGNUMBER",
"LIT:472450",
None,
"ID:summary",
"LIT:TM: Do not assert: StackBase(fp) + blockDepth == regs.sp",
None,
"ID:actual",
"LIT:",
None,
"ID:expect",
"LIT:",
None,
None,
"ID:test",
None,
"ID:test",
None,
None,
None,
"ID:enterFunc",
"LIT:test",
None,
None,
"ID:printBugNumber",
"ID:BUGNUMBER",
None,
None,
"ID:printStatus",
"ID:summary",
None,
None,
"ID:jit",
"LIT:true",
None,
None,
"ID:__proto__",
None,
"ID:✖",
None,
"LIT:1",
None,
"ID:f",
None,
None,
None,
"ID:eval",
"LIT:for (var y = 0; y < 1; ++y) { for each (let z in [null, function(){}, null, '', null, '', null]) { let x = 1, c = []; } }",
None,
None,
"ID:f",
None,
None,
"ID:jit",
"LIT:false",
None,
None,
"ID:reportCompare",
"ID:expect",
"ID:actual",
"ID:summary",
None,
None,
"ID:exitFunc",
"LIT:test",
None
]
class TestTester(unittest.TestCase):
def test_function(self):
# test file -> json (python hash table)
File = open("data/ast_for_prototyping/ast_0.json",'r')
lines = File.readlines()
File.close()
file_str = ''
for l in lines :
file_str += l
file_str.replace('\n','')
nodes = eval(file_str) # json is legal python
# run test function over all hash tables
test_outputs = []
for node in nodes :
test_outputs.append(ast2id_or_lit(node))
# check if output matches manual check
for i in range(len(json0_tokens)) :
self.assertEqual(test_outputs[i], json0_tokens[i])