コード例 #1
0
def test_consistent():
    assert consistent([A], [A])
    assert consistent([B], [B])
    assert not consistent([A], [C])
    assert consistent([A, B], [A, B])
    assert consistent([B, A], [A, B])
    assert not consistent([B, A], [B])
    assert not consistent([B, A], [B, C])
コード例 #2
0
def test_consistent():
    assert consistent([A], [A])
    assert consistent([B], [B])
    assert not consistent([A], [C])
    assert consistent([A, B], [A, B])
    assert consistent([B, A], [A, B])
    assert not consistent([B, A], [B])
    assert not consistent([B, A], [B, C])
コード例 #3
0
def test_consistent_variadic():
    # basic check
    assert consistent((Variadic[A],), (Variadic[A],))
    assert consistent((Variadic[B],), (Variadic[B],))
    assert not consistent((Variadic[C],), (Variadic[A],))

    # union types
    assert consistent((Variadic[(A, C)],), (Variadic[A],))
    assert consistent((Variadic[(A, C)],), (Variadic[(C, A)],))
    assert consistent((Variadic[(A, B, C)],), (Variadic[(C, B, A)],))
    assert consistent((A, B, C), (Variadic[(A, B, C)],))
    assert consistent((A, B, C), (A, Variadic[(B, C)]))

    # more complex examples
    assert consistent(tuple([]), (Variadic[object],))
    assert consistent((A, A, B), (A, A, Variadic[B]))
    assert consistent((A, A, B), (A, A, Variadic[A]))
    assert consistent((A, B, Variadic[C]), (B, A, Variadic[C]))
    assert consistent((A, B, Variadic[C]), (B, A, Variadic[(C, B)]))

    # not consistent
    assert not consistent((C,), (Variadic[A],))
    assert not consistent((A, A, Variadic[C]), (A, Variadic[C]))
    assert not consistent((A, B, Variadic[C]), (C, B, Variadic[C]))