node.iterator.sequence = sequence.as_tuple()
return node
+ def visit_WhileStatNode(self, node):
+ self.visitchildren(node)
+ if node.condition.has_constant_result():
+ if node.condition.constant_result:
+ node.else_clause = None
+ else:
+ return node.else_clause
+ return node
+
def _find_genexpr_yield_stat(self, node):
body_node_types = (Nodes.ForInStatNode, Nodes.IfStatNode)
while isinstance(node, body_node_types):
"""
if 'a' in 'abc' and 'b' in 'abc' and 'c' in 'abc' and 'd' not in 'abc': return True
else: return False
+
+
+@cython.test_fail_if_path_exists(
+ "//WhileStatNode",
+)
+def while_false():
+ """
+ >>> while_false()
+ """
+ while 1 == 0:
+ return False
+
+
+@cython.test_fail_if_path_exists(
+ "//WhileStatNode",
+ )
+def while_false_else():
+ """
+ >>> while_false_else()
+ True
+ """
+ while 1 == 0:
+ return False
+ else:
+ return True
+
+
+@cython.test_fail_if_path_exists(
+ "//WhileStatNode//PrintStatNode",
+)
+@cython.test_assert_path_exists(
+ "//WhileStatNode",
+)
+def while_true():
+ """
+ >>> while_true()
+ True
+ """
+ while 1 == 1:
+ return True
+ else:
+ print("FAIL")