return ExprNodes.BoolNode(node.pos, value=bool_result,
constant_result=bool_result)
+ def visit_CondExprNode(self, node):
+ self._calculate_const(node)
+ if node.test.constant_result is ExprNodes.not_a_constant:
+ return node
+ if node.test.constant_result:
+ return node.true_val
+ else:
+ return node.false_val
+
def visit_IfStatNode(self, node):
self.visitchildren(node)
# eliminate dead code based on constant condition results
"""
return 1 if x == 1 else (2 if x == 2 else 3)
+@cython.test_fail_if_path_exists('//CondExprNode')
def const_true():
"""
>>> const_true()
"""
return 1 if 1 == 1 else 2
+@cython.test_fail_if_path_exists('//CondExprNode')
def const_false():
"""
>>> const_false()