瀏覽代碼

Make adding constraints flexible

Yentl Van Tendeloo 9 年之前
父節點
當前提交
11c2199f01
共有 1 個文件被更改,包括 22 次插入17 次删除
  1. 22 17
      integration/test_constructors_models.py

+ 22 - 17
integration/test_constructors_models.py

@@ -157,28 +157,29 @@ bottom_attributes = [
         '"exit"',
     ]
 
-add_constraints = [
-        '"model"',
-        '"add_constraint"', 1, '"Integer"',
-            '2', 10, 11,
-                '"return"', 'true',
-                    '"call"',
-                        '"access"', '"resolve"', '"is_physical_int"',
-                        '1',
+def add_constraints(model):
+    return [
+            '"model"',
+            '"add_constraint"', model, '"Integer"',
+                '2', model*100, model*100+1,
+                    '"return"', 'true',
                         '"call"',
-                            '"access"', '"resolve"', '"dict_read"',
-                            '2',
+                            '"access"', '"resolve"', '"is_physical_int"',
+                            '1',
                             '"call"',
                                 '"access"', '"resolve"', '"dict_read"',
                                 '2',
-                                '"const"', 10,
-                                '"const"', '"model"',
+                                '"call"',
+                                    '"access"', '"resolve"', '"dict_read"',
+                                    '2',
+                                    '"const"', model*100,
+                                    '"const"', '"model"',
+                                    'false',
+                                '"const"', model*100+1,
                                 'false',
-                            '"const"', 11,
                             'false',
-                        'false',
-        '"exit"',
-    ]
+            '"exit"',
+        ]
 
 instantiate_scd = [
         '"model"',
@@ -297,7 +298,11 @@ class TestConstructorsModels(unittest.TestCase):
         self.assertTrue(run_barebone(commands, ["OK"], 1))
 
     def test_constructors_constraints(self):
-        commands = bottom + action_language + bottom_attributes + add_constraints + conformance_check(1) + ['"return"', 'false']
+        commands = bottom + action_language + bottom_attributes + add_constraints(1) + conformance_check(1) + ['"return"', 'false']
+        self.assertTrue(run_barebone(commands, ["OK"], 1))
+
+    def test_constructors_constraints_executed(self):
+        commands = bottom + action_language + bottom_attributes + add_constraints(1) + instantiate_scd + add_constraints(2) + instantiate_pn + conformance_check(3) + ['"return"', 'false']
         self.assertTrue(run_barebone(commands, ["OK"], 1))
 
     def test_constructors_instantiate_scd(self):