Esempio n. 1
0
def test_mul_nimbers():
    """
    Test that Nimbers multiply correctly.
    """
    a = Nimber(2)
    b = Nimber(6)
    c = Nimber(11)
    assert a * b == c
Esempio n. 2
0
def test_mul_nimber_game():
    """
    Test that Nimbers multiply with Games correctly.
    """
    a = Nimber(2)
    b = Game(Nimber(2))
    c = Game(Nimber(3))
    assert a * b == c
Esempio n. 3
0
def test_add_nimbers():
    """
    Test that Nimbers add correctly.
    """
    a = Nimber(5)
    b = Nimber(6)
    c = Nimber(3)
    assert a + b == c
Esempio n. 4
0
def test_add_nimber_game():
    """
    Test that Nimbers add with Games correctly.
    """
    a = Nimber(3)
    b = Game(Nimber(2))
    c = Game(Nimber(1))
    assert a + b == c
Esempio n. 5
0
def test_eq_nimber_game():
    """
    Test that Nimbers and Games equate properly.
    """
    a = Nimber(3)
    b = 3 * one
    assert not a == b
Esempio n. 6
0
def test_remoteness(G, H):
    """
    Tests for remoteness.
    """
    G_plus_H = conjunctive(G, H)
    G_plus_H = Nimber(left=G_plus_H.left, right=G_plus_H.right)
    assert remoteness(G_plus_H) == min([remoteness(G), remoteness(H)])
Esempio n. 7
0
def test_nimber_is_number_2():
    """
    Test that the Nimber 0 is a number.
    """
    assert Nimber(0).is_number
Esempio n. 8
0
def test_nimber_value(n, v):
    """
    Test that the value of a Nimber is represented correctly.
    """
    assert Nimber(n).value == v
Esempio n. 9
0
def test_fail():
    """
    Test that Nimbers must have integral values.
    """
    with pytest.raises(ValueError):
        Nimber(0.5)
Esempio n. 10
0
def test_neg_nimbers():
    """
    Test that a Nimber is its own negative.
    """
    a = Nimber(5)
    assert a == -a
Esempio n. 11
0
def test_nimber_birthday(n):
    """
    Test that Nimbers have the right birthdays.
    """
    assert Nimber(n).birthday == n
Esempio n. 12
0
def test_nimber_is_infinitesimal_2():
    """
    Test that the Nimber 0 is not infinitesimal.
    """
    assert not Nimber(0).is_infinitesimal
Esempio n. 13
0

@pytest.mark.parametrize(['n', 'v'], [
    (0, '0'),
    (1, '*'),
    (6, '*6'),
])
def test_nimber_value(n, v):
    """
    Test that the value of a Nimber is represented correctly.
    """
    assert Nimber(n).value == v


@pytest.mark.parametrize('n', [
    Nimber(3),
    Nimber(4),
    Nimber(7),
])
def test_nimber_is_number(n):
    """
    Test that Nimbers (other than 0) are not numbers.
    """
    assert not n.is_number


def test_nimber_is_number_2():
    """
    Test that the Nimber 0 is a number.
    """
    assert Nimber(0).is_number
Esempio n. 14
0

@pytest.mark.parametrize(('n', 'v'), [
    (0, '0'),
    (1, '∗'),
    (6, '∗6'),
])
def test_nimber_value(n, v):
    """
    Test that the value of a Nimber is represented correctly.
    """
    assert Nimber.from_integer(n).value == v


@pytest.mark.parametrize('n', [
    Nimber.from_integer(3),
    Nimber.from_integer(4),
    Nimber.from_integer(7),
])
def test_nimber_is_number(n):
    """
    Test that Nimbers (other than 0) are not numbers.
    """
    assert not n.is_number


def test_nimber_is_number_2():
    """
    Test that the Nimber 0 is a number.
    """
    assert Nimber.from_integer(0).is_number