Ejemplo n.º 1
0
def test_repr():

    s1 = to_abstract_test(1)
    assert repr(s1) == "AbstractScalar(Int[64] = 1)"

    s2 = to_abstract_test(f32)
    assert repr(s2) == "AbstractScalar(Float[32])"

    t1 = to_abstract_test((1, f32))
    assert repr(t1) == f"AbstractTuple((Int[64] = 1, Float[32]))"

    a1 = to_abstract_test(af32_of(4, 5))
    assert repr(a1) == f"AbstractArray(Float[32] x 4 x 5)"

    p1 = to_abstract_test(Point(1, f32))
    assert repr(
        p1) == f"AbstractClass(Point(x :: Int[64] = 1, y :: Float[32]))"

    j1 = AbstractJTagged(to_abstract_test(1))
    assert repr(j1) == f"AbstractJTagged(J(Int[64] = 1))"

    h1 = AbstractHandle(to_abstract_test(1))
    assert repr(h1) == f"AbstractHandle(H(Int[64] = 1))"

    kw1 = AbstractKeywordArgument("bucket", to_abstract_test(1))
    assert repr(kw1) == f"AbstractKeywordArgument(KW(bucket :: Int[64] = 1))"

    ty1 = Ty(f32)
    assert repr(ty1) == "AbstractType(Ty(AbstractScalar(Float[32])))"

    e1 = AbstractError(DEAD)
    assert repr(e1) == "AbstractError(E(DEAD))"

    f1 = AbstractFunction(P.scalar_mul)
    assert repr(f1) == "AbstractFunction(scalar_mul)"

    fa = AbstractFunction(value=ANYTHING)
    assert repr(fa) == "AbstractFunction(ANYTHING)"

    tu1 = AbstractTaggedUnion([[13, s2], [4, to_abstract_test(i16)]])
    assert repr(tu1) == "AbstractTaggedUnion(U(4 :: Int[16], 13 :: Float[32]))"

    bot = AbstractBottom()
    assert repr(bot) == "AbstractBottom(⊥)"
Ejemplo n.º 2
0
def test_repr():

    s1 = to_abstract_test(1)
    assert repr(s1) == 'AbstractScalar(Int[64] = 1)'

    s2 = to_abstract_test(f32)
    assert repr(s2) == 'AbstractScalar(Float[32])'

    t1 = to_abstract_test((1, f32))
    assert repr(t1) == f'AbstractTuple((Int[64] = 1, Float[32]))'

    a1 = to_abstract_test(af32_of(4, 5))
    assert repr(a1) == f'AbstractArray(Float[32] x 4 x 5)'

    p1 = to_abstract_test(Point(1, f32))
    assert repr(p1) == \
        f'AbstractClass(Point(x :: Int[64] = 1, y :: Float[32]))'

    j1 = AbstractJTagged(to_abstract_test(1))
    assert repr(j1) == f'AbstractJTagged(J(Int[64] = 1))'

    kw1 = AbstractKeywordArgument('bucket', to_abstract_test(1))
    assert repr(kw1) == f'AbstractKeywordArgument(KW(bucket :: Int[64] = 1))'

    ty1 = Ty(f32)
    assert repr(ty1) == 'AbstractType(Ty(Float[32]))'

    e1 = AbstractError(DEAD)
    assert repr(e1) == 'AbstractError(E(DEAD))'

    f1 = AbstractFunction(P.scalar_mul)
    assert repr(f1) == 'AbstractFunction(scalar_mul)'

    tu1 = AbstractTaggedUnion([[13, s2], [4, to_abstract_test(i16)]])
    assert repr(tu1) == \
        'AbstractTaggedUnion(U(4 :: Int[16], 13 :: Float[32]))'

    @macro
    def mackerel(info):
        pass

    assert repr(mackerel) == '<Macro mackerel>'