Ejemplo n.º 1
0
def test_convert_result():

    # Leaves

    assert convert_result(True, Bool, Bool) is True
    assert convert_result(False, Bool, Bool) is False
    assert convert_result(10, i64, i64) == 10
    assert convert_result(1.5, f64, f64) == 1.5

    # Tuple -> Class conversion

    pt = Point(1, 2)
    assert convert_result(pt, Point_t, Point_t) == pt
    assert convert_result((1, 2), Point_t, Tuple[i64, i64]) == pt

    assert convert_result(((1, 2), (1, 2)),
                          Tuple[Point_t, Point_t],
                          Tuple[Tuple[i64, i64], Tuple[i64, i64]]) == \
        (pt, pt)

    assert convert_result([(1, 2), (1, 2), (1, 2)],
                          List[Point_t],
                          List[Tuple[i64, i64]]) == \
        [pt, pt, pt]
Ejemplo n.º 2
0
 def _convert(data, typ1, typ2):
     return convert_result(data, to_abstract_test(typ1),
                           to_abstract_test(typ2), backend, _return_backend)
Ejemplo n.º 3
0
 def _convert(data, typ1, typ2):
     return convert_result(data, to_abstract_test(typ1),
                           to_abstract_test(typ2))