Ejemplo n.º 1
0
def test_reference_counter(int_: AlternativeInt) -> None:
    int_refcount_before = sys.getrefcount(int_)

    result = int_.bit_length()

    int_refcount_after = sys.getrefcount(int_)
    assert int_refcount_after == int_refcount_before
Ejemplo n.º 2
0
def test_basic(int_: AlternativeInt) -> None:
    result = int_.bit_length()

    assert isinstance(result, AlternativeInt)
Ejemplo n.º 3
0
def test_product(first: AlternativeInt, second: AlternativeInt) -> None:
    result = (first * second).bit_length()

    assert result <= first.bit_length() + second.bit_length()
Ejemplo n.º 4
0
def test_evenness(int_: AlternativeInt) -> None:
    result = int_.bit_length()

    assert result == (-int_).bit_length()
Ejemplo n.º 5
0
def test_positive_definiteness(int_: AlternativeInt) -> None:
    result = int_.bit_length()

    assert equivalence(not result, not int_)