Exemplo n.º 1
0
def test_upcast_BinaryOp_nested_casting():
    outer_expr = BinaryOp(op=ArithmeticOperator.ADD,
                          left=A_BOOL_LITERAL,
                          right=A_INT64_LITERAL)
    testee = BinaryOp(op=ArithmeticOperator.ADD,
                      left=outer_expr,
                      right=A_FLOAT64_LITERAL)
    expected = [
        Cast(dtype=DataType.INT64, expr=A_BOOL_LITERAL),
        Cast(dtype=DataType.FLOAT64, expr=Placeholder()),
    ]
    upcast_and_validate(testee, expected)
Exemplo n.º 2
0
def test_upcast_TernaryOp():
    testee = TernaryOp(
        cond=A_BOOL_LITERAL,
        true_expr=A_INT64_LITERAL,
        false_expr=A_FLOAT64_LITERAL,
    )
    upcast_and_validate(testee,
                        [Cast(dtype=DataType.FLOAT64, expr=A_INT64_LITERAL)])
Exemplo n.º 3
0
def test_upcast_in_cond_of_TernaryOp():
    testee = TernaryOp(
        cond=BinaryOp(op=ComparisonOperator.GE,
                      left=A_INT64_LITERAL,
                      right=A_FLOAT64_LITERAL),
        true_expr=AN_UNIMPORTANT_LITERAL,
        false_expr=AN_UNIMPORTANT_LITERAL,
    )
    upcast_and_validate(testee,
                        [Cast(dtype=DataType.FLOAT64, expr=A_INT64_LITERAL)])
Exemplo n.º 4
0
def test_upcast_ParAssignStmt():
    testee = ParAssignStmt(left=FieldAccessBuilder("out").dtype(
        DataType.FLOAT64).build(),
                           right=A_INT64_LITERAL)
    upcast_and_validate(testee,
                        [Cast(dtype=DataType.FLOAT64, expr=A_INT64_LITERAL)])
Exemplo n.º 5
0
def test_upcast_NativeFuncCall():
    testee = NativeFuncCall(func=NativeFunction.MAX,
                            args=[A_INT64_LITERAL, A_FLOAT64_LITERAL])
    upcast_and_validate(testee,
                        [Cast(dtype=DataType.FLOAT64, expr=A_INT64_LITERAL)])
Exemplo n.º 6
0
def test_upcast_BinaryOp_INT_to_FLOAT():
    testee = BinaryOp(op=ArithmeticOperator.ADD,
                      left=A_INT64_LITERAL,
                      right=A_FLOAT64_LITERAL)
    upcast_and_validate(testee,
                        [Cast(dtype=DataType.FLOAT64, expr=A_INT64_LITERAL)])
Exemplo n.º 7
0
def test_upcast_ParAssignStmt():
    testee = ParAssignStmt(left=FieldAccessFactory(dtype=DataType.FLOAT64),
                           right=A_INT64_LITERAL)
    upcast_and_validate(testee,
                        [Cast(dtype=DataType.FLOAT64, expr=A_INT64_LITERAL)])