|
@@ -16,46 +16,30 @@ def flatten(lst):
|
|
|
bottom = [
|
|
|
'"model"',
|
|
|
'"instantiate_bottom"', 1,
|
|
|
- '"add_node"', 1, '"Class"',
|
|
|
+ '"add_node"', 1, '"Class"',
|
|
|
'"add_node"', 1, '"Any"',
|
|
|
'"add_node"', 1, '"String"',
|
|
|
- '"add_node"', 1, '"Integer"',
|
|
|
- '"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"', '"String"', '"Any"',
|
|
|
- '"add_edge"', 1, '"Inheritance"', '"Any"', '"Any"',
|
|
|
- '"add_edge"', 1, '"l4"', '"Inheritance"', '"inheritance"',
|
|
|
- '"add_edge"', 1, '"Association"', '"Any"', '"Any"',
|
|
|
- '"add_edge"', 1, '"l6"', '"Association"', '"Any"',
|
|
|
- '"add_edge"', 1, '"l7"', '"Association"', '"link"',
|
|
|
- '"add_edge"', 1, '"l8"', '"Association"', '"String"',
|
|
|
- '"add_edge"', 1, '"l9"', '"l8"', '"name"',
|
|
|
- '"add_edge"', 1, '"l10"', '"Integer"', '"Any"',
|
|
|
- '"exit"',
|
|
|
- ]
|
|
|
-
|
|
|
-retype = [
|
|
|
- '"model"',
|
|
|
+ '"add_edge"', 1, '"Association"', '"Class"', '"Any"',
|
|
|
+ '"add_edge"', 1, '"Inheritance"', '"Class"', '"Class"',
|
|
|
+ '"add_edge"', 1, '"Association_attribute"', '"Association"', '"String"',
|
|
|
+ '"add_edge"', 1, '"Association_name"', '"Association_attribute"', '"name"',
|
|
|
+ '"add_edge"', 1, '"assoc_inh_class"', '"Association"', '"Class"',
|
|
|
+ '"add_edge"', 1, '"class_inh_any"', '"Class"', '"Any"',
|
|
|
+ '"add_edge"', 1, '"string_inh_any"', '"String"', '"Any"',
|
|
|
'"retype_model"', 1, 1,
|
|
|
'"define_inheritance"', 1, '"Inheritance"',
|
|
|
'"retype"', 1, '"Class"', '"Class"',
|
|
|
- '"retype"', 1, '"String"', '"Class"',
|
|
|
'"retype"', 1, '"Any"', '"Class"',
|
|
|
- '"retype"', 1, '"Integer"', '"Class"',
|
|
|
- '"retype"', 1, '"inheritance"', '"String"',
|
|
|
- '"retype"', 1, '"link"', '"String"',
|
|
|
+ '"retype"', 1, '"String"', '"Class"',
|
|
|
'"retype"', 1, '"name"', '"String"',
|
|
|
- '"retype"', 1, '"l1"', '"Inheritance"',
|
|
|
- '"retype"', 1, '"l2"', '"Inheritance"',
|
|
|
- '"retype"', 1, '"Inheritance"', '"Association"',
|
|
|
- '"retype"', 1, '"l4"', '"l8"',
|
|
|
'"retype"', 1, '"Association"', '"Association"',
|
|
|
- '"retype"', 1, '"l6"', '"Inheritance"',
|
|
|
- '"retype"', 1, '"l7"', '"l8"',
|
|
|
- '"retype"', 1, '"l8"', '"Association"',
|
|
|
- '"retype"', 1, '"l9"', '"l8"',
|
|
|
+ '"retype"', 1, '"Inheritance"', '"Association"',
|
|
|
+ '"retype"', 1, '"Association_attribute"', '"Association"',
|
|
|
+ '"retype"', 1, '"Association_name"', '"Association_attribute"',
|
|
|
+ '"retype"', 1, '"assoc_inh_class"', '"Inheritance"',
|
|
|
+ '"retype"', 1, '"class_inh_any"', '"Inheritance"',
|
|
|
+ '"retype"', 1, '"string_inh_any"', '"Inheritance"',
|
|
|
'"exit"',
|
|
|
]
|
|
|
|
|
@@ -148,11 +132,16 @@ action_language = [
|
|
|
'"instantiate_attribute"', 1, '"call_params"', '"name"', '"params"',
|
|
|
'"instantiate_link"', 1, '"Association"', '"call_last_param"', '"call"', '"param"',
|
|
|
'"instantiate_attribute"', 1, '"call_last_param"', '"name"', '"last_param"',
|
|
|
+
|
|
|
+ '"instantiate_link"', 1, '"Association"', '"constraint"', '"Any"', '"funcdef"',
|
|
|
+ '"instantiate_attribute"', 1, '"constraint"', '"name"', '"constraint"',
|
|
|
'"exit"',
|
|
|
]
|
|
|
|
|
|
bottom_attributes = [
|
|
|
'"model"',
|
|
|
+ '"instantiate_node"', 1, '"Class"', '"Integer"',
|
|
|
+ '"instantiate_link"', 1, '"Inheritance"', '"integer_inh_any"', '"Integer"', '"Any"',
|
|
|
'"instantiate_link"', 1, '"Association"', '"lc"', '"Class"', '"Integer"',
|
|
|
'"instantiate_attribute"', 1, '"lc"', '"name"', '"lower_cardinality"',
|
|
|
'"instantiate_link"', 1, '"Association"', '"uc"', '"Class"', '"Integer"',
|
|
@@ -165,8 +154,6 @@ bottom_attributes = [
|
|
|
'"instantiate_attribute"', 1, '"tlc"', '"name"', '"target_lower_cardinality"',
|
|
|
'"instantiate_link"', 1, '"Association"', '"tuc"', '"Association"', '"Integer"',
|
|
|
'"instantiate_attribute"', 1, '"tuc"', '"name"', '"target_upper_cardinality"',
|
|
|
- '"instantiate_link"', 1, '"Association"', '"constraint"', '"Any"', '"funcdef"',
|
|
|
- '"instantiate_attribute"', 1, '"constraint"', '"name"', '"constraint"',
|
|
|
'"exit"',
|
|
|
]
|
|
|
|
|
@@ -302,38 +289,38 @@ def conformance_check(node):
|
|
|
|
|
|
class TestConstructorsModels(unittest.TestCase):
|
|
|
def test_constructors_instantiate_bottom(self):
|
|
|
- commands = bottom + retype + bottom_attributes + conformance_check(1) + ['"return"', 'false']
|
|
|
+ commands = bottom + bottom_attributes + conformance_check(1) + ['"return"', 'false']
|
|
|
self.assertTrue(run_barebone(commands, ["OK"], 1))
|
|
|
|
|
|
def test_constructors_action_language(self):
|
|
|
- commands = bottom + retype + action_language + bottom_attributes + conformance_check(1) + ['"return"', 'false']
|
|
|
+ commands = bottom + action_language + bottom_attributes + conformance_check(1) + ['"return"', 'false']
|
|
|
self.assertTrue(run_barebone(commands, ["OK"], 1))
|
|
|
|
|
|
def test_constructors_constraints(self):
|
|
|
- commands = bottom + retype + action_language + bottom_attributes + add_constraints + conformance_check(1) + ['"return"', 'false']
|
|
|
+ commands = bottom + action_language + bottom_attributes + add_constraints + conformance_check(1) + ['"return"', 'false']
|
|
|
self.assertTrue(run_barebone(commands, ["OK"], 1))
|
|
|
|
|
|
def test_constructors_instantiate_scd(self):
|
|
|
- commands = bottom + retype + bottom_attributes + instantiate_scd + conformance_check(2) + ['"return"', 'false']
|
|
|
+ commands = bottom + bottom_attributes + instantiate_scd + conformance_check(2) + ['"return"', 'false']
|
|
|
self.assertTrue(run_barebone(commands, ["OK"], 1))
|
|
|
|
|
|
def test_constructors_instantiate_pn(self):
|
|
|
- commands = bottom + retype + bottom_attributes + instantiate_scd + instantiate_pn + conformance_check(3) + ['"return"', 'false']
|
|
|
+ commands = bottom + bottom_attributes + instantiate_scd + instantiate_pn + conformance_check(3) + ['"return"', 'false']
|
|
|
self.assertTrue(run_barebone(commands, ["OK"], 1))
|
|
|
|
|
|
def test_constructors_instantiate_example(self):
|
|
|
- commands = bottom + retype + bottom_attributes + instantiate_example + conformance_check(2) + conformance_check(3) + ['"return"', 'false']
|
|
|
+ commands = bottom + bottom_attributes + instantiate_example + conformance_check(2) + conformance_check(3) + ['"return"', 'false']
|
|
|
self.assertTrue(run_barebone(commands, ["OK", "OK"], 1))
|
|
|
|
|
|
def test_constructors_is_direct_instance(self):
|
|
|
- commands = bottom + retype + bottom_attributes + instantiate_example + is_direct_instance + ['"return"', 'false']
|
|
|
+ commands = bottom + bottom_attributes + instantiate_example + is_direct_instance + ['"return"', 'false']
|
|
|
expected = ['True', 'False', 'False',
|
|
|
'False', 'True', 'False',
|
|
|
'False', 'False', 'True']
|
|
|
self.assertTrue(run_barebone(commands, expected, 1))
|
|
|
|
|
|
def test_constructors_is_nominal_instance(self):
|
|
|
- commands = bottom + retype + bottom_attributes + instantiate_example + is_nominal_instance + ['"return"', 'false']
|
|
|
+ commands = bottom + bottom_attributes + instantiate_example + is_nominal_instance + ['"return"', 'false']
|
|
|
expected = ['True', 'True', 'False',
|
|
|
'False', 'True', 'False',
|
|
|
'False', 'False', 'True']
|