forked from OpenModelica/OMPython
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathtest_typedParser.py
More file actions
53 lines (34 loc) · 1.06 KB
/
test_typedParser.py
File metadata and controls
53 lines (34 loc) · 1.06 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
from OMPython import OMTypedParser
typeCheck = OMTypedParser.om_parser_typed
def test_newline_behaviour():
pass
def test_boolean():
assert typeCheck('true') is True
assert typeCheck('false') is False
def test_int():
assert typeCheck('2') == 2
assert type(typeCheck('1')) == int
assert type(typeCheck('123123123123123123232323')) == int
assert type(typeCheck('9223372036854775808')) == int
def test_float():
assert type(typeCheck('1.2e3')) == float
def test_ident():
assert typeCheck('blabla2') == "blabla2"
def test_empty():
assert typeCheck('') is None
def test_str():
pass
def test_UnStringable():
pass
def test_everything():
# this test used to be in OMTypedParser.py's main()
testdata = """
(1.0,{{1,true,3},{"4\\"
",5.9,6,NONE ( )},record ABC
startTime = ErrorLevel.warning,
'stop*Time' = SOME(1.0)
end ABC;})
"""
expected = (1.0, ((1, True, 3), ('4"\n', 5.9, 6, None), {"'stop*Time'": 1.0, 'startTime': 'ErrorLevel.warning'}))
results = typeCheck(testdata)
assert results == expected