|
@@ -2,6 +2,11 @@ import unittest
|
|
|
|
|
|
from utils import run_file, get_constructor
|
|
|
|
|
|
+set_inheritance = [
|
|
|
+ "Which link in the metamodel is the inheritance link?",
|
|
|
+ "Set inheritance link!",
|
|
|
+ ]
|
|
|
+
|
|
|
do_instantiate_simple = [
|
|
|
'"new"', '"PetriNets"', '"abc"',
|
|
|
'"instantiate"', '"Transition"', '"t1"',
|
|
@@ -408,10 +413,6 @@ include "primitives.alh"
|
|
|
include "object_operations.alh"
|
|
|
|
|
|
Element function constraint(model : Element, name : String):
|
|
|
-\treturn "OK"
|
|
|
- """
|
|
|
-
|
|
|
- """
|
|
|
\tElement associations
|
|
|
\tElement back_associations
|
|
|
\tElement association
|
|
@@ -419,30 +420,31 @@ Element function constraint(model : Element, name : String):
|
|
|
\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\tdestination = reverseKeyLookup(model["model"], read_edge_dst(model["model"][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\t\treturn "Left link does not have a right link back at "
|
|
|
\t\telse:
|
|
|
-\t\t\tassociation = list_read(back_associations, 0)
|
|
|
-\t\t\tdestination = reverseKeyLookup(model["model"], read_edge_dst(association))
|
|
|
+\t\t\tassociation = set_pop(back_associations)
|
|
|
+\t\t\tdestination = reverseKeyLookup(model["model"], read_edge_dst(model["model"][association]))
|
|
|
\t\t\tif (destination != name):
|
|
|
-\t\t\t\treturn "Left link does not have a right link back to the same node"
|
|
|
- """
|
|
|
+\t\t\t\treturn "Left link does not have a right link back to the same node at "
|
|
|
+\tlog("All OK for " + name)
|
|
|
+\treturn "OK"
|
|
|
+ """
|
|
|
|
|
|
constructors = get_constructor(constraint_code)
|
|
|
print(constructors)
|
|
|
|
|
|
self.assertTrue(run_file(all_files,
|
|
|
['"new"', '"SimpleClassDiagrams"', '"RPGame"',
|
|
|
+ '"set_inheritance"', '"Inheritance"',
|
|
|
'"instantiate"', '"Class"', '"Scene"',
|
|
|
'"instantiate"', '"Class"', '"Tile"',
|
|
|
'"instantiate"', '"Class"', '"Item"',
|
|
|
'"instantiate"', '"Class"', '"Goal"',
|
|
|
'"instantiate"', '"Class"', '"Character"',
|
|
|
'"instantiate"', '"Class"', '"Hero"',
|
|
|
- '"instantiate"', '"Class"', '"String"',
|
|
|
- '"instantiate"', '"Association"', '"scene_name"', '"Scene"', '"String"',
|
|
|
'"instantiate"', '"Association"', '"scene_has_tiles"', '"Scene"', '"Tile"',
|
|
|
'"instantiate"', '"Association"', '"tile_left"', '"Tile"', '"Tile"',
|
|
|
'"instantiate"', '"Association"', '"tile_right"', '"Tile"', '"Tile"',
|
|
@@ -458,8 +460,6 @@ Element function constraint(model : Element, name : String):
|
|
|
'"attr_add"', '"scene_has_tiles"', '"source_lower_cardinality"', '1',
|
|
|
'"attr_add"', '"scene_has_tiles"', '"source_upper_cardinality"', '1',
|
|
|
'"attr_add"', '"scene_has_tiles"', '"target_lower_cardinality"', '1',
|
|
|
- '"attr_add"', '"scene_name"', '"target_lower_cardinality"', '1',
|
|
|
- '"attr_add"', '"scene_name"', '"target_upper_cardinality"', '1',
|
|
|
'"attr_add"', '"item_on"', '"target_lower_cardinality"', '1',
|
|
|
'"attr_add"', '"item_on"', '"target_upper_cardinality"', '1',
|
|
|
'"attr_add"', '"item_on"', '"source_upper_cardinality"', '1',
|
|
@@ -475,8 +475,43 @@ Element function constraint(model : Element, name : String):
|
|
|
'"attr_add"', '"tile_bottom"', '"source_upper_cardinality"', '1',
|
|
|
'"attr_add"', '"tile_bottom"', '"target_upper_cardinality"', '1',
|
|
|
'"constrain"', '"Tile"',
|
|
|
- ] + constructors + [
|
|
|
+ ] + constructors + ['"verify"'] + ['"exit"'] + [
|
|
|
+ '"new"', '"RPGame"', '"my_game"',
|
|
|
+ '"instantiate"', '"Scene"', '"scene"',
|
|
|
+ '"instantiate"', '"Hero"', '"Link"',
|
|
|
+ '"instantiate"', '"Goal"', '"goal"',
|
|
|
+ '"instantiate"', '"Tile"', '"tile_00"',
|
|
|
+ '"instantiate"', '"Tile"', '"tile_01"',
|
|
|
+ '"instantiate"', '"Tile"', '"tile_10"',
|
|
|
+ '"instantiate"', '"Tile"', '"tile_11"',
|
|
|
+ '"instantiate"', '"scene_has_tiles"', '""', '"scene"', '"tile_00"',
|
|
|
+ '"instantiate"', '"scene_has_tiles"', '""', '"scene"', '"tile_01"',
|
|
|
+ '"instantiate"', '"scene_has_tiles"', '""', '"scene"', '"tile_10"',
|
|
|
+ '"instantiate"', '"scene_has_tiles"', '""', '"scene"', '"tile_11"',
|
|
|
+ '"instantiate"', '"character_on"', '""', '"Link"', '"tile_00"',
|
|
|
+ '"instantiate"', '"item_on"', '""', '"goal"', '"tile_11"',
|
|
|
+ '"instantiate"', '"tile_left"', '""', '"tile_01"', '"tile_00"',
|
|
|
+ '"instantiate"', '"tile_left"', '""', '"tile_11"', '"tile_10"',
|
|
|
+ '"instantiate"', '"tile_right"', '""', '"tile_00"', '"tile_01"',
|
|
|
+ '"instantiate"', '"tile_right"', '""', '"tile_10"', '"tile_11"',
|
|
|
+ '"instantiate"', '"tile_top"', '""', '"tile_10"', '"tile_00"',
|
|
|
+ '"instantiate"', '"tile_top"', '""', '"tile_11"', '"tile_01"',
|
|
|
+ '"instantiate"', '"tile_bottom"', '""', '"tile_00"', '"tile_10"',
|
|
|
+ '"instantiate"', '"tile_bottom"', '""', '"tile_01"', '"tile_11"',
|
|
|
'"verify"',
|
|
|
],
|
|
|
- init + new + loaded + (instantiate_node + prompt) * 7 + (instantiate_edge + prompt) * 10 + (attr_add + prompt) * 22 + ["Element to constrain (empty for global)?", "Give input to function constructors for LOCAL constraint!", "Added constraint to model!"] + prompt + ["OK"] + prompt,
|
|
|
+ init + new + loaded + \
|
|
|
+ set_inheritance + prompt + \
|
|
|
+ (instantiate_node + prompt) * 6 + \
|
|
|
+ (instantiate_edge + prompt) * 9 + \
|
|
|
+ (attr_add + prompt) * 20 + \
|
|
|
+ ["Element to constrain (empty for global)?",
|
|
|
+ "Give input to function constructors for LOCAL constraint!",
|
|
|
+ "Added constraint to model!"] + \
|
|
|
+ prompt + \
|
|
|
+ ["OK"] + \
|
|
|
+ prompt + prompt + new + loaded + \
|
|
|
+ (instantiate_node + prompt) * 7 + \
|
|
|
+ (instantiate_edge + prompt) * 14 + \
|
|
|
+ ["OK"],
|
|
|
mode))
|