コード例 #1
0
ファイル: parser_tests.py プロジェクト: mwilliamson/nope
def test_parse_chained_boolean_operators():
    _assert_expression_parse(
        nodes.bool_and(
            nodes.bool_and(nodes.ref("a"), nodes.ref("b")),
            nodes.ref("c"),
        ),
        "a and b and c"
    )
コード例 #2
0
ファイル: desugar_tests.py プロジェクト: mwilliamson/nope
 def test_transform_boolean_and(self):
     _assert_transform(
         nodes.bool_and(nodes.ref("x"), nodes.ref("y")),
         cc.ternary_conditional(
             cc.call(cc.builtin("bool"), [cc.ref("x")]),
             cc.ref("y"),
             cc.ref("x")
         ),
     )
コード例 #3
0
ファイル: operators_tests.py プロジェクト: mwilliamson/nope
def type_of_boolean_and_operation_is_unification_of_operand_types():
    type_bindings = {"x": types.int_type, "y": types.int_type}
    operation = nodes.bool_and(nodes.ref("x"), nodes.ref("y"))
    assert_equal(types.int_type, infer(operation, type_bindings=type_bindings))
コード例 #4
0
ファイル: parser_tests.py プロジェクト: mwilliamson/nope
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")