Explorar el Código

Added simple class diagrams test

Yentl Van Tendeloo hace 9 años
padre
commit
7772cc9352

+ 0 - 9
integration/test_constructors_models.py

@@ -4,15 +4,6 @@ import os
 
 from utils import execute, kill, run_file, run_barebone
 
-def flatten(lst):
-    new_lst = []
-    for f in lst:
-        if isinstance(f, (list, tuple)):
-            new_lst.extend(flatten(f))
-        else:
-            new_lst.append(f)
-    return new_lst
-
 bottom = [
         '"model"',
         '"instantiate_bottom"', '"1"',

+ 2 - 0
interface/HUTN/hutn_compiler/model_visitor.py

@@ -70,11 +70,13 @@ class ModelVisitor(Visitor):
         is_definition = bool(tree.get_children("COLON"))
 
         if is_definition:
+            # is definition
             attr_name = children[0].get_text()
             attr_type = children[1].get_text()
             self.constructors.extend(['"instantiate_link"', jsonstr("Association"), jsonstr(self.current_element + "_" + attr_name), jsonstr(self.current_element), jsonstr(attr_type)])
             self.constructors.extend(['"instantiate_attribute"', jsonstr(self.current_element + "_" + attr_name), jsonstr("name"), jsonstr(attr_name)])
         else:
+            # is assign
             attr_name = children[0].get_text()
             attr_value = children[1]
             self.constructors.extend(['"instantiate_attribute"', jsonstr(self.current_element), jsonstr(attr_name), jsonstr(attr_value.get_text()) if attr_value.head == "STRVALUE" else attr_value.get_text()])

+ 21 - 0
interface/HUTN/test/modelling_language/code/simpleclassdiagrams.mvc

@@ -0,0 +1,21 @@
+import /formalisms/SimpleClassDiagrams as SCD
+
+SCD SimpleClassDiagrams{
+    Class Any {}
+    Class Natural {}
+    Class String {}
+    Class Class{
+        lower_cardinality : Natural
+        upper_cardinality : Natural
+    }
+    Association Association (Class, Class){
+        name : String
+        source_lower_cardinality : Natural
+        source_upper_cardinality : Natural
+        target_lower_cardinality : Natural
+        target_upper_cardinality : Natural
+    }
+    Association Inheritance (Class, Class){}
+    Inheritance assoc_inh_class (Association, Class) {}
+    Inheritance class_inh_any (Class, Any) {}
+}

La diferencia del archivo ha sido suprimido porque es demasiado grande
+ 1 - 0
interface/HUTN/test/modelling_language/expected/simpleclassdiagrams


+ 3 - 0
interface/HUTN/test/modelling_language/test_compile.py

@@ -18,3 +18,6 @@ def compile_file(obj, filename):
 class TestCompile(unittest.TestCase):
     def test_PetriNets(self):
         compile_file(self, "petrinets.mvc")
+
+    def test_SimpleClassDiagrams(self):
+        compile_file(self, "simpleclassdiagrams.mvc")