|
@@ -13,89 +13,88 @@ def flatten(lst):
|
|
|
new_lst.append(f)
|
|
|
return new_lst
|
|
|
|
|
|
-bottom = ['"instantiate_bottom"',
|
|
|
- '"node"', '"Class"', 'true',
|
|
|
- '"node"', '"Type"', 'true',
|
|
|
- '"node"', '"__String"', 'true',
|
|
|
- '"value"', '"__name"', '"name"', 'true',
|
|
|
- '"edge"', '"Attribute"', '"Class"', '"Type"', 'true',
|
|
|
- '"edge"', '"__Name"', '"Attribute"', '"__String"', 'true',
|
|
|
- '"edge"', '"Association"', '"Class"', '"Class"', 'true',
|
|
|
- '"edge"', '"Inheritance"', '"Class"', '"Class"', 'true',
|
|
|
- '"edge"', '"__name_edge"', '"__Name"', '"__name"', 'true',
|
|
|
- '"edge"', '"__inh_1"', '"Association"', '"Class"', 'true',
|
|
|
- '"edge"', '"__inh_2"', '"Attribute"', '"Class"', 'true',
|
|
|
- '"value"', '"__attribute"', '"attribute"', 'true',
|
|
|
- '"edge"', '"__attribute_edge"', '"Attribute"', '"__attribute"', 'false',
|
|
|
- 1,
|
|
|
- ]
|
|
|
+bottom = [
|
|
|
+ '"model"',
|
|
|
+ '"instantiate_bottom"', 1,
|
|
|
+ '"add_node"', 1, '"Class"',
|
|
|
+ '"add_node"', 1, '"Type"',
|
|
|
+ '"add_node"', 1, '"Any"',
|
|
|
+ '"add_node"', 1, '"String"',
|
|
|
+ '"add_value"', 1, '"inheritance"', '"inheritance"',
|
|
|
+ '"add_value"', 1, '"link"', '"link"',
|
|
|
+ '"add_value"', 1, '"name"', '"name"',
|
|
|
+ '"add_edge"', 1, '"l1"', '"Class"', '"Any"',
|
|
|
+ '"add_edge"', 1, '"l2"', '"Type"', '"Any"',
|
|
|
+ '"add_edge"', 1, '"l3"', '"Any"', '"Any"',
|
|
|
+ '"add_edge"', 1, '"l4"', '"l3"', '"inheritance"',
|
|
|
+ '"add_edge"', 1, '"l5"', '"Any"', '"Any"',
|
|
|
+ '"add_edge"', 1, '"l6"', '"l5"', '"Any"',
|
|
|
+ '"add_edge"', 1, '"l7"', '"l5"', '"link"',
|
|
|
+ '"add_edge"', 1, '"l8"', '"l5"', '"String"',
|
|
|
+ '"add_edge"', 1, '"l9"', '"l8"', '"name"',
|
|
|
+ '"exit"',
|
|
|
+ ]
|
|
|
|
|
|
-retype = ['"retype_model"',
|
|
|
- 1,
|
|
|
- 1,
|
|
|
- 1, '"Inheritance"',
|
|
|
- 'true',
|
|
|
- '"Class"', '"Class"', 'true',
|
|
|
- '"Type"', '"Type"', 'true',
|
|
|
- '"__String"', '"Type"', 'true',
|
|
|
- '"Attribute"', '"Attribute"', 'true',
|
|
|
- '"__Name"', '"Attribute"', 'true',
|
|
|
- '"Association"', '"Association"', 'true',
|
|
|
- '"Inheritance"', '"Association"', 'true',
|
|
|
- '"__inh_1"', '"Inheritance"', 'true',
|
|
|
- '"__inh2"', '"Inheritance"', 'true',
|
|
|
- '"__name"', '"__String"', 'true',
|
|
|
- '"__name_edge"', '"__Name"', 'true',
|
|
|
- '"__attribute"', '"__String"', 'true',
|
|
|
- '"__attribute_edge"', '"__Name"', 'false',
|
|
|
- ]
|
|
|
+retype = [
|
|
|
+ '"model"',
|
|
|
+ '"retype_model"', 1, 1,
|
|
|
+ '"retype"', 1, '"Class"', '"Class"',
|
|
|
+ '"retype"', 1, '"Type"', '"Class"',
|
|
|
+ '"retype"', 1, '"Any"', '"Class"',
|
|
|
+ '"retype"', 1, '"String"', '"Type"',
|
|
|
+ '"retype"', 1, '"inheritance"', '"String"',
|
|
|
+ '"retype"', 1, '"link"', '"String"',
|
|
|
+ '"retype"', 1, '"name"', '"String"',
|
|
|
+ '"retype"', 1, '"l1"', '"l3"',
|
|
|
+ '"retype"', 1, '"l2"', '"l3"',
|
|
|
+ '"retype"', 1, '"l3"', '"l5"',
|
|
|
+ '"retype"', 1, '"l4"', '"l8"',
|
|
|
+ '"retype"', 1, '"l5"', '"l5"',
|
|
|
+ '"retype"', 1, '"l6"', '"l3"',
|
|
|
+ '"retype"', 1, '"l7"', '"l8"',
|
|
|
+ '"retype"', 1, '"l8"', '"l5"',
|
|
|
+ '"retype"', 1, '"l9"', '"l8"',
|
|
|
+ '"define_inheritance"', 1, '"l3"',
|
|
|
+ '"exit"',
|
|
|
+ ]
|
|
|
|
|
|
-def function_call(func, paramA, paramB):
|
|
|
- return ['"output"', '"call"',
|
|
|
- '"access"',
|
|
|
- '"resolve"', '"%s"' % func,
|
|
|
- '3',
|
|
|
- '"const"', 3,
|
|
|
- '"call"',
|
|
|
- '"access"',
|
|
|
- '"resolve"', '"dict_read"',
|
|
|
- '2',
|
|
|
- '"call"',
|
|
|
- '"access"',
|
|
|
- '"resolve"', '"dict_read"',
|
|
|
- '2',
|
|
|
- '"const"', 3,
|
|
|
- '"const"', '"model"',
|
|
|
- 'false',
|
|
|
- '"const"', '"%s"' % paramA,
|
|
|
- 'false',
|
|
|
- '"call"',
|
|
|
- '"access"',
|
|
|
- '"resolve"', '"dict_read"',
|
|
|
- '2',
|
|
|
- '"call"',
|
|
|
- '"access"',
|
|
|
- '"resolve"', '"dict_read"',
|
|
|
- '2',
|
|
|
- '"const"', 2,
|
|
|
- '"const"', '"model"',
|
|
|
- 'false',
|
|
|
- '"const"', '"%s"' % paramB,
|
|
|
- 'false',
|
|
|
- 'false',
|
|
|
+instantiate_pn = [
|
|
|
+ '"model"',
|
|
|
+ '"instantiate_model"', 1, 2,
|
|
|
+ '"instantiate_node"', 1, '"Class"', '"Place"',
|
|
|
+ '"instantiate_node"', 1, '"Class"', '"Transition"',
|
|
|
+ '"instantiate_node"', 1, '"Type"', '"Integer"',
|
|
|
+ '"instantiate_named"', 1, '"l5"', '"P2T"', '"Place"', '"Transition"',
|
|
|
+ '"instantiate_named"', 1, '"l5"', '"T2P"', '"Transition"', '"Place"',
|
|
|
+ '"instantiate_named"', 1, '"l5"', '"tokens"', '"Place"', '"Integer"',
|
|
|
+ '"instantiate_named"', 1, '"l5"', '"weight"', '"P2T"', '"Integer"',
|
|
|
+ '"instantiate_named"', 1, '"l5"', '"weight"', '"T2P"', '"Integer"',
|
|
|
+ '"exit"',
|
|
|
+ ]
|
|
|
+
|
|
|
+def conformance_check(node):
|
|
|
+ return [
|
|
|
+ '"output"',
|
|
|
+ '"call"',
|
|
|
+ '"access"', '"resolve"', '"conformance_scd"',
|
|
|
+ '1',
|
|
|
+ '"const"', node,
|
|
|
+ 'false',
|
|
|
'true',
|
|
|
+ '"return"',
|
|
|
+ 'false',
|
|
|
]
|
|
|
-
|
|
|
+
|
|
|
class TestConstructorsModels(unittest.TestCase):
|
|
|
def test_constructors_instantiate_bottom(self):
|
|
|
- commands = bottom + [
|
|
|
- '"output"', '"const"', '3',
|
|
|
- 'true',
|
|
|
- '"return"', 'true',
|
|
|
- '"const"', 'true',
|
|
|
- ]
|
|
|
- self.assertTrue(run_barebone(flatten(commands), ['3'], 1))
|
|
|
+ commands = bottom + retype + conformance_check(1)
|
|
|
+ self.assertTrue(run_barebone(commands, ["OK"], 1))
|
|
|
+
|
|
|
+ def test_constructors_instantiate_petrinet(self):
|
|
|
+ commands = bottom + retype + instantiate_pn + conformance_check(2)
|
|
|
+ self.assertTrue(run_barebone(commands, ["OK"], 1))
|
|
|
|
|
|
+ """
|
|
|
def test_constructors_instantiate_model(self):
|
|
|
commands = bottom + [
|
|
|
'"instantiate_model"',
|
|
@@ -815,3 +814,4 @@ class TestConstructorsModels(unittest.TestCase):
|
|
|
'"const"', 'true',
|
|
|
]
|
|
|
self.assertTrue(run_barebone(flatten(commands), ['5', '1', '2', '10', '16', '30'], 1))
|
|
|
+ """
|