Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Sign in
Toggle navigation
Menu
Open sidebar
TASTE
OpenGEODE
Commits
e0897e45
Commit
e0897e45
authored
May 19, 2016
by
Maxime Perrotin
Browse files
Format testcases to run with py.test
parent
db23ae92
Changes
1
Hide whitespace changes
Inline
Side-by-side
tests/parser/aggreg.py
View file @
e0897e45
#!/usr/bin/env python
import
opengeode
from
opengeode
.ogParser
import
parser_init
# detect syntax errors (missing semi after "entry")
print
(
'composite_state_body:'
)
test
=
opengeode
.
ogParser
.
parser_init
(
string
=
'''state ENTRYA;
substructure
procedure entry EXTERNAL;
endsubstructure ENTRYA;
'''
)
test
.
composite_state_body
()
print
(
'composite_state:'
)
test
=
opengeode
.
ogParser
.
parser_init
(
string
=
'''state CHECKING;
substructure
state ENTRYA;
substructure
procedure entry EXTERNAL;
endsubstructure ENTRYA;
endsubstructure CHECKING;
'''
)
test
.
composite_state
()
print
(
'composite_state (should have no error)'
)
test
=
opengeode
.
ogParser
.
parser_init
(
string
=
'''state CHECKING;
substructure
state ENTRYA;
endstate ENTRYA;
endsubstructure CHECKING;
'''
)
test
.
composite_state
()
print
(
'composite_state_body 2:'
)
test
=
opengeode
.
ogParser
.
parser_init
(
string
=
'''state ENTRYA;
endstate;
'''
)
test
.
composite_state_body
()
print
(
'from rm - reports that start must be before state:'
)
test
=
opengeode
.
ogParser
.
parser_init
(
string
=
'''
STATE AGGREGATION DemoDeviceDACPStates;
SUBSTRUCTURE
STATE INTERNAL_MAPPINGS;
SUBSTRUCTURE
STATE STATELESS;
ENDSTATE STATELESS;
START;
NEXTSTATE STATELESS;
ENDSUBSTRUCTURE INTERNAL_MAPPINGS;
ENDSUBSTRUCTURE DemoDeviceDACPStates;
'''
)
test
.
composite_state
()
print
(
'from rm(2) - reports that start must be before state:'
)
test
=
opengeode
.
ogParser
.
parser_init
(
string
=
'''
process hello;
STATE AGGREGATION DemoDeviceDACPStates;
SUBSTRUCTURE
STATE INTERNAL_MAPPINGS;
SUBSTRUCTURE
STATE STATELESS;
ENDSTATE STATELESS;
START;
NEXTSTATE STATELESS;
ENDSUBSTRUCTURE INTERNAL_MAPPINGS;
ENDSUBSTRUCTURE DemoDeviceDACPStates;
end hello;
'''
)
def
test_composite_state_body_1
():
test
=
parser_init
(
string
=
'''state ENTRYA;
substructure
procedure entry EXTERNAL;
endsubstructure ENTRYA;
'''
)
test
.
composite_state_body
()
def
test_composite_state_1
():
test
=
parser_init
(
string
=
'''state CHECKING;
substructure
state ENTRYA;
substructure
procedure entry EXTERNAL;
endsubstructure ENTRYA;
endsubstructure CHECKING;
'''
)
test
.
composite_state
()
def
test_composite_state_2
():
print
(
'composite_state (should have no error)'
)
test
.
process_definition
()
test
=
parser_init
(
string
=
'''state CHECKING;
substructure
state ENTRYA;
endstate ENTRYA;
endsubstructure CHECKING;
'''
)
test
.
composite_state
()
def
test_composite_state_body_1
():
print
(
'composite_state_body 2:'
)
test
=
parser_init
(
string
=
'''state ENTRYA;
endstate;
'''
)
test
.
composite_state_body
()
def
test_composite_state_3
():
print
(
'from rm - reports that start must be before state:'
)
test
=
parser_init
(
string
=
'''
STATE AGGREGATION DemoDeviceDACPStates;
SUBSTRUCTURE
STATE INTERNAL_MAPPINGS;
SUBSTRUCTURE
STATE STATELESS;
ENDSTATE STATELESS;
START;
NEXTSTATE STATELESS;
ENDSUBSTRUCTURE INTERNAL_MAPPINGS;
ENDSUBSTRUCTURE DemoDeviceDACPStates;
'''
)
test
.
composite_state
()
def
test_composite_state_4
():
print
(
'from rm(2) - reports that start must be before state:'
)
test
=
parser_init
(
string
=
'''
process hello;
STATE AGGREGATION DemoDeviceDACPStates;
SUBSTRUCTURE
STATE INTERNAL_MAPPINGS;
SUBSTRUCTURE
STATE STATELESS;
ENDSTATE STATELESS;
START;
NEXTSTATE STATELESS;
ENDSUBSTRUCTURE INTERNAL_MAPPINGS;
ENDSUBSTRUCTURE DemoDeviceDACPStates;
end hello;
'''
)
test
.
process_definition
()
if
__name__
==
'__main__'
:
for
name
,
value
in
dict
(
globals
()).
viewitems
():
if
name
.
startswith
(
'test_'
):
print
(
'---- Executing {} ----'
.
format
(
name
))
value
()
print
(
'---- Done - {} ----
\n
'
.
format
(
name
))
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment