|
@@ -1,10 +1,6 @@
|
|
|
import unittest
|
|
|
-import sys
|
|
|
-sys.path.append("interface/HUTN")
|
|
|
|
|
|
-from hutn_compiler.compiler import main as do_compile
|
|
|
-
|
|
|
-from utils import run_file
|
|
|
+from utils import run_file, get_constructor
|
|
|
|
|
|
do_instantiate_simple = [
|
|
|
'"new"', '"PetriNets"', '"abc"',
|
|
@@ -408,28 +404,30 @@ class TestPetrinetInterface(unittest.TestCase):
|
|
|
|
|
|
constraint_code = \
|
|
|
"""
|
|
|
- include "primitives.alh"
|
|
|
- include "object_operations.alh"
|
|
|
-
|
|
|
- Element function constraint(model : Element, name : String):
|
|
|
- Element associations
|
|
|
- Element back_associations
|
|
|
- Element association
|
|
|
-
|
|
|
- associations = allOutgoingAssociationInstances(model, name, "tile_left")
|
|
|
- while (0 < list_len(associations)):
|
|
|
- association = set_pop(associations)
|
|
|
- destination = reverseKeyLookup(model["model"], read_edge_dst(association))
|
|
|
- back_associations = allOutgoingAssociationInstances(model, destination, "tile_right")
|
|
|
- if (list_len(back_associations) < 1):
|
|
|
- return "Left link does not have a right link back"
|
|
|
- else:
|
|
|
- association = list_get(back_associations, 0)
|
|
|
- destination = reverseKeyLookup(model["model"], read_edge_dst(association))
|
|
|
- if (destination != name):
|
|
|
- return "Left link does not have a right link back to the same node"
|
|
|
+include "primitives.alh"
|
|
|
+include "object_operations.alh"
|
|
|
+
|
|
|
+Element function constraint(model : Element, name : String):
|
|
|
+\tElement associations
|
|
|
+\tElement back_associations
|
|
|
+\tElement association
|
|
|
+\tString destination
|
|
|
+\tassociations = allOutgoingAssociationInstances(model, name, "tile_left")
|
|
|
+\twhile (0 < list_len(associations)):
|
|
|
+\t\tassociation = set_pop(associations)
|
|
|
+\t\tdestination = reverseKeyLookup(model["model"], read_edge_dst(association))
|
|
|
+\t\tback_associations = allOutgoingAssociationInstances(model, destination, "tile_right")
|
|
|
+\t\tif (list_len(back_associations) < 1):
|
|
|
+\t\t\treturn "Left link does not have a right link back"
|
|
|
+\t\telse:
|
|
|
+\t\t\tassociation = list_read(back_associations, 0)
|
|
|
+\t\t\tdestination = reverseKeyLookup(model["model"], read_edge_dst(association))
|
|
|
+\t\t\tif (destination != name):
|
|
|
+\t\t\t\treturn "Left link does not have a right link back to the same node"
|
|
|
"""
|
|
|
|
|
|
+ constructors = get_constructor(constraint_code)
|
|
|
+
|
|
|
self.assertTrue(run_file(all_files,
|
|
|
['"new"', '"SimpleClassDiagrams"', '"RPGame"',
|
|
|
'"instantiate"', '"Class"', '"Scene"',
|
|
@@ -471,6 +469,7 @@ class TestPetrinetInterface(unittest.TestCase):
|
|
|
'"attr_add"', '"tile_top"', '"target_upper_cardinality"', '1',
|
|
|
'"attr_add"', '"tile_bottom"', '"source_upper_cardinality"', '1',
|
|
|
'"attr_add"', '"tile_bottom"', '"target_upper_cardinality"', '1',
|
|
|
+ ] + constructors + [
|
|
|
'"verify"',
|
|
|
],
|
|
|
init + new + loaded + (instantiate_node + prompt) * 7 + (instantiate_edge + prompt) * 10 + (attr_add + prompt) * 22 + ["OK"] + prompt,
|