예제 #1
0
def test_logic_bit_equality():
    assert Logic(0) == Bit(0)
    assert Logic(1) == Bit(1)
예제 #2
0
def test_bit_conversions():
    b = Bit(0)
    assert Bit(False) == b
    assert Bit("0") == b
    assert Bit(Bit(0)) == b

    b = Bit(1)
    assert Bit(True) == b
    assert Bit("1") == b
    assert Bit(Bit(1)) == b

    for value in ("X", 2, object()):
        with pytest.raises(ValueError):
            Bit(value)
예제 #3
0
def test_bit_equality():
    assert Bit(0) == Bit(False)
    assert Bit(1) != Bit("0")
    assert Bit(1) != object()
예제 #4
0
def test_bit_invert():
    assert ~Bit(0) == Bit(1)
    assert ~Bit(1) == Bit(0)
예제 #5
0
def test_bit_identity():
    assert Bit(0) is Bit(False)
    assert Bit(Logic(1)) is Bit("1")
예제 #6
0
def test_bit_int_conversions():
    assert int(Bit("0")) == 0
    assert int(Bit("1")) == 1
예제 #7
0
def test_bit_repr():
    assert eval(repr(Bit("0"))) == Bit("0")
    assert eval(repr(Bit("1"))) == Bit("1")
예제 #8
0
def test_bit_str_conversions():
    assert str(Bit(0)) == "0"
    assert str(Bit(1)) == "1"
예제 #9
0
def test_bit_bool_conversions():
    assert bool(Bit(1)) is True
    assert bool(Bit(0)) is False
예제 #10
0
def test_bit_default_value():
    assert Bit() == Bit("0")
예제 #11
0
def test_logic_bit_hashability():
    s = {Logic("0"), Logic("1"), Logic("X"), Logic("Z"), Bit("0"), Bit("1")}
    assert len(s) == 4
예제 #12
0
def test_bit_hashability():
    s = {Bit(0), Bit(1)}
    assert len(s) == 2