-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathtest_token_freq.py
118 lines (111 loc) · 2.34 KB
/
test_token_freq.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
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
import unittest
import token_freq
test_stock = [
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
]
assert_dict = {
None: 35,
'ID:summary': 3,
'ID:BUGNUMBER': 2,
'ID:actual': 2,
'LIT:': 2,
'ID:expect': 2,
'ID:test': 2,
'LIT:test': 2,
'ID:jit': 2,
'ID:f': 2,
'ID:gTestfile': 1,
'LIT:regress-472450-04.js': 1,
'LIT:472450': 1,
'LIT:TM: Do not assert: StackBase(fp) + blockDepth == regs.sp': 1,
'ID:enterFunc': 1,
'ID:printBugNumber': 1,
'ID:printStatus': 1,
'LIT:true': 1,
'ID:__proto__': 1,
'ID:✖': 1,
'LIT:1': 1,
'ID:eval': 1,
"LIT:for (var y = 0; y < 1; ++y) { for each (let z in [null, function(){}, null, '', null, '', null]) { let x = 1, c = []; } }": 1,
'LIT:false': 1,
'ID:reportCompare': 1,
'ID:exitFunc': 1
}
class TestTester(unittest.TestCase):
def test_function(self):
tf = token_freq.TokenFrequency(test_stock)
self.assertEqual(tf.get_frequency(), assert_dict)
self.assertEqual(tf.get_most_freq_token(), None)
self.assertEqual(tf.get_most_freq_token_not_none(), 'ID:summary')
self.run(tf.clear_list())
self.assertEqual(tf.add_token('a'), {'a':1})
self.assertEqual(tf.add_token('a'), {'a':2})