extended test case
authorStefan Behnel <scoder@users.berlios.de>
Thu, 29 Apr 2010 06:35:35 +0000 (08:35 +0200)
committerStefan Behnel <scoder@users.berlios.de>
Thu, 29 Apr 2010 06:35:35 +0000 (08:35 +0200)
tests/run/if_const.pyx

index 00c14f4d591efe44fd63131e59bd37ad144d9294..b8ca34ad12a3ba03b06964e01aec6779122269b9 100644 (file)
@@ -3,6 +3,11 @@ cimport cython
 
 DEF INT_VAL = 1
 
+def _not_constant_but_False():
+    return False
+
+@cython.test_fail_if_path_exists("//PrimaryCmpNode",
+                                 "//IfStatNode")
 def int_bool_result():
     """
     >>> int_bool_result()
@@ -13,6 +18,61 @@ def int_bool_result():
     else:
         return False
 
+@cython.test_fail_if_path_exists("//IfStatNode")
+def constant_if_elif_else():
+    """
+    >>> constant_if_elif_else()
+    True
+    """
+    if 0:
+        return False
+    elif 5:
+        return True
+    else:
+        return False
+
+@cython.test_fail_if_path_exists("//PrintStatNode")
+@cython.test_assert_path_exists("//IfStatNode",
+                                "//IfClauseNode")
+def non_constant_if_elif_else1():
+    """
+    >>> non_constant_if_elif_else1()
+    True
+    """
+    if _not_constant_but_False():
+        return False
+    elif 5:
+        return True
+    else:
+        print(False)
+
+@cython.test_fail_if_path_exists("//PrintStatNode")
+@cython.test_assert_path_exists("//IfStatNode",
+                                "//IfClauseNode")
+def non_constant_if_elif_else2():
+    """
+    >>> non_constant_if_elif_else2()
+    True
+    """
+    if _not_constant_but_False():
+        return False
+    elif 0:
+        print(False)
+    else:
+        return True
+
+@cython.test_fail_if_path_exists("//PrimaryCmpNode",
+                                 "//IfStatNode")
+def if_not_compare_true():
+    """
+    >>> if_not_compare_true()
+    False
+    """
+    if not 0 == 0:
+        return True
+    else:
+        return False
+
 @cython.test_fail_if_path_exists("//PrimaryCmpNode",
                                  "//IfStatNode")
 def if_compare_true():