Пример #1
0
def test_nan():
    z = nint32('nan')
    assert math.isnan(float(z))
    assert math.isnan(z + 1.5)

    z = nint32(math.nan)
    assert math.isnan(float(z))
    assert z != z
Пример #2
0
def test_comparison():
    x = nint32(100)
    y = nint32(-500)
    assert x > 0
    assert x < 200
    assert x < 123.4
    assert x <= 200
    assert 200 >= x
    assert x == 100
    assert x > y
    assert x >= y
    assert y < x
    assert y <= x
    assert x != y
Пример #3
0
def test_init_bad_arg(arg):
    with pytest.raises(TypeError, match='argument must be'):
        nint32(arg)
Пример #4
0
def test_init_arg_too_big(value):
    with pytest.raises(OverflowError, match='int too big to convert'):
        nint32(value)
Пример #5
0
def test_other():
    z = 1.0 + 2.0j
    a = nint32(2)
    w = z / a
    assert w == z / 2
Пример #6
0
def test_basic():
    x = nint32(3)
    assert x == 3
    assert int(x) == 3
Пример #7
0
def test_bool():
    assert bool(nint32(123))
    assert bool(nint32('nan'))
    assert not bool(nint32(0))
Пример #8
0
def test_nan():
    z = nint32(math.nan)
    assert math.isnan(float(z))
    assert z != z
Пример #9
0
def test_nan_str(nanstr):
    z = nint32(nanstr)
    assert math.isnan(float(z))
    assert math.isnan(z + 1.5)
Пример #10
0
def test_true_division():
    x = nint32(20)
    y = nint32(10)
    z = x / y
    assert isinstance(z, float)
    assert z == 2.0
Пример #11
0
def test_init_str_type():
    x = nint32("123")
    assert x == 123
Пример #12
0
def test_init_np_types(typ):
    x = nint32(typ(123))
    assert x == 123