Skip to content

Commit 2480a28

Browse files
committed
[test_OMTypedParser] rename file / use om_parser_typed()
1 parent cfa3c12 commit 2480a28

2 files changed

Lines changed: 65 additions & 53 deletions

File tree

tests/test_OMTypedParser.py

Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
import OMPython
2+
3+
parser = OMPython.OMTypedParser.om_parser_typed
4+
5+
6+
def test_newline_behaviour():
7+
pass
8+
9+
10+
def test_boolean():
11+
# TODO: why does these fail?
12+
# assert parser('TRUE') is True
13+
# assert parser('True') is True
14+
assert parser('true') is True
15+
# TODO: why does these fail?
16+
# assert parser('FALSE') is False
17+
# assert parser('False') is False
18+
assert parser('false') is False
19+
20+
21+
def test_int():
22+
assert parser('2') == 2
23+
assert type(parser('1')) == int
24+
assert type(parser('123123123123123123232323')) == int
25+
assert type(parser('9223372036854775808')) == int
26+
27+
28+
def test_float():
29+
assert type(parser('1.2e3')) == float
30+
31+
32+
def test_dict():
33+
# TODO: why does it fail?
34+
# assert type(parser('{"a": "b"}')) == dict
35+
pass
36+
37+
38+
def test_ident():
39+
assert parser('blabla2') == "blabla2"
40+
41+
42+
def test_empty():
43+
assert parser('') is None
44+
45+
46+
def test_str():
47+
pass
48+
49+
50+
def test_UnStringable():
51+
pass
52+
53+
54+
def test_everything():
55+
# this test used to be in OMTypedParser.py's main()
56+
testdata = """
57+
(1.0,{{1,true,3},{"4\\"
58+
",5.9,6,NONE ( )},record ABC
59+
startTime = ErrorLevel.warning,
60+
'stop*Time' = SOME(1.0)
61+
end ABC;})
62+
"""
63+
expected = (1.0, ((1, True, 3), ('4"\n', 5.9, 6, None), {"'stop*Time'": 1.0, 'startTime': 'ErrorLevel.warning'}))
64+
results = parser(testdata)
65+
assert results == expected

tests/test_typedParser.py

Lines changed: 0 additions & 53 deletions
This file was deleted.

0 commit comments

Comments
 (0)