Browse Source

Add corner cases for instantiate

Yentl Van Tendeloo 7 years ago
parent
commit
2c6d374906
2 changed files with 16 additions and 16 deletions
  1. 0 16
      bootstrap/mini_modify.alc
  2. 16 0
      unit/test_all.py

+ 0 - 16
bootstrap/mini_modify.alc

@@ -40,20 +40,6 @@ String function cmd_help_m(write : Boolean):
 
 	return result!
 
-String function cmd_upload(write : Boolean, model : Element):
-	Element new_model
-	if (write):
-		output("Waiting for model constructors...")
-		new_model = compile_model(input(), model["metamodel"])
-		if (is_physical_string(new_model)):
-			return "Compilation error: " + cast_string(new_model)!
-
-		dict_overwrite(model, "model", new_model["model"])
-		set_type_mapping(model, get_type_mapping(new_model))
-		return "Success"!
-	else:
-		return "Write permission denied"!
-
 String function cmd_instantiate_node(write : Boolean, model : Element, mm_type_name : String, element_name : String):
 	if (write):
 		if (dict_in(model["metamodel"]["model"], mm_type_name)):
@@ -495,8 +481,6 @@ Boolean function modify(model : Element, write : Boolean):
 			output(cmd_help_m(write))
 		elif (cmd == "exit"):
 			return True!
-		elif (cmd == "upload"):
-			output(cmd_upload(write, model))
 		elif (cmd == "instantiate_node"):
 			output(cmd_instantiate_node(write, model, single_input("Type?"), single_input("Name?")))
 		elif (cmd == "instantiate_edge"):

+ 16 - 0
unit/test_all.py

@@ -1694,6 +1694,22 @@ class TestModelverse(unittest.TestCase):
         except UnknownElement:
             assert element_list("users/user/test/a") == before
 
+        # Test instantiating node as edge
+        before = element_list("users/user/test/a")
+        try:
+            instantiate("users/user/test/a", "Class", edge=("a", "b"))
+            self.fail()
+        except IncorrectFormat:
+            assert element_list("users/user/test/a") == before
+
+        # Test instantiating edge as node
+        before = element_list("users/user/test/a")
+        try:
+            instantiate("users/user/test/a", "Association")
+            self.fail()
+        except IncorrectFormat:
+            assert element_list("users/user/test/a") == before
+
     def test_op_delete_element(self):
         model_add("users/user/test/a", "formalisms/SimpleClassDiagrams", """
             Class A {}