-
-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy patherror_test.py
executable file
·72 lines (54 loc) · 1.64 KB
/
error_test.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
#!/usr/bin/env python
import angle
from parser_test_helper import *
class ErrorTest(ParserBaseTest):
def setUp(self):
parser.clear()
def test_type(self):
assert_has_error('x=1,2,y;')
assert_has_error('x=1,2,y;')
def test_variable_type_safety_errors2(self):
assert_has_no_error("char i='c'")
assert_has_no_error("char i;i='c'")
def test_variable_type_safety_no_errors(self):
assert_has_no_error('an integer i;i=3')
def test_variable_type_safety_no_errors2(self):
assert_has_no_error('int i=3')
assert_has_no_error('int i;i=3')
def test_variable_type_safety_errors(self):
assert_has_error('const i=1;i=2')
assert_has_error('string i=3')
assert_has_error("int i='hi'")
assert_has_error("integer i='hi'")
assert_has_error("an integer i;i='hi'")
assert_has_error("const i=1;i='hi'")
assert_has_error("const i='hi';i='ho'")
def test_assert_has_error(self):
try:
assert_has_no_error('dfsafdsa ewdfsa}{P}{P;@#%')
except:
puts("OK")
def test_type3(self):
assert_has_error('x be 1,2,3y= class of x')
assert_has_error('x be 1,2,3y= class of x')
def test_map(self):
assert_has_error('square 1,2 andy 3')
assert_has_error('square 1,2 andy 3')
@unittest.expectedFailure
def test_x(self):
parse('x')
def test_endNode_as(self):
init('as')
try:
parser.arg()
except: assert_has_error("as")
def test_rollback(self):
assert_has_error('if 1>0 then else')
assert_has_error('if 1>0 then else')
def test_endNode(self):
assert_has_error('of')
assert_has_error('of')
def test_list_concatenation_unknownVariable(self):
variables['x'] = ['hi', ]
variables['y'] = ['world', ]
assert_has_error("z=x ' ' w")