def test_transform_boolean_or(self): _assert_transform( nodes.bool_or(nodes.ref("x"), nodes.ref("y")), cc.ternary_conditional( cc.call(cc.builtin("bool"), [cc.ref("x")]), cc.ref("x"), cc.ref("y") ), )
def type_of_boolean_or_operation_is_unification_of_operand_types(): type_bindings = {"x": types.int_type, "y": types.int_type} operation = nodes.bool_or(nodes.ref("x"), nodes.ref("y")) assert_equal(types.int_type, infer(operation, type_bindings=type_bindings))
def test_parse_simple_boolean_operators(): x = nodes.ref("x") y = nodes.ref("y") _assert_expression_parse(nodes.bool_and(x, y), "x and y") _assert_expression_parse(nodes.bool_or(x, y), "x or y") _assert_expression_parse(nodes.bool_not(x), "not x")