-
-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathproperty_test.py
More file actions
executable file
·67 lines (51 loc) · 1.61 KB
/
Copy pathproperty_test.py
File metadata and controls
executable file
·67 lines (51 loc) · 1.61 KB
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
#!/usr/bin/env python
from parser_test_helper import *
class PropertyTest(ParserBaseTest):
def test_property_of_known(self):
parse("a={}")
init("a.b=3")
parser.property()
assert_result_is("a.b",3)
def test_property_of_unknown_forbidden(self):
assert_has_error("z.b=3", exception.UndeclaredVariable)
def test_property_of_unknown_allowed(self):
skip()
init("z.b=3")
parser.property()
assert_result_is("z.b", 3)
def test_property(self):
assert_result_is("x={};x.a=7;x.a", 7)
def test_property_index(self):
assert_result_is("x={};x.a=7;x['a']", 7)
assert_result_is("x={};x.a=7;x[a]", 7)
def test_property_from_type(self):
init("x is a map")
x=parser.setter()
assert x.type == dict
assert_result_is("x is a map;x.a=7;x.a", 7)
def test_property_from_empty_declaration(self):
x=parse("map x")
assert x=={} # variable results return resolved!
# assert x.type == dict
# assert x.value == {}
def test_property_from_type2(self):
assert_result_is("map y;y.a=7;y.a", 7)
def test_property_of_object(self):
init("x is an object") # 'object' object has no attribute 'a' :(
x = parser.setter()
assert x.type == object
assert_result_is("x is an object;x.a=7;x.a", 7)
def test_property3(self):
assert_result_is("x={};a of x is 7;x.a", 7)
def test_property_s(self):
assert_result_is("x={};x's a is 7;x.a", 7)
def test_relations(self):
bill, mary = parse(" bill's parent is mary ")
assert_equals(bill.parent, mary)
def test_relations(self):
bill, mary, john = parse("""
bill's parent is mary
parent or mary is john
[bill,mary,john]
""")
assert_equals(bill.parent,mary)