def test_mul_nimbers(): """ Test that Nimbers multiply correctly. """ a = Nimber.from_integer(2) b = Nimber.from_integer(6) c = Nimber.from_integer(11) assert a * b == c
def test_mul_nimber_game(): """ Test that Nimbers multiply with Games correctly. """ a = Nimber.from_integer(2) b = Game(Nimber.from_integer(2)) c = Game(Nimber.from_integer(3)) assert a * b == c
def test_add_nimber_game(): """ Test that Nimbers add with Games correctly. """ a = Nimber.from_integer(3) b = Game(Nimber.from_integer(2)) c = Game(Nimber.from_integer(1)) assert a + b == c
def test_add_nimbers(): """ Test that Nimbers add correctly. """ a = Nimber.from_integer(5) b = Nimber.from_integer(6) c = Nimber.from_integer(3) assert a + b == c
def test_eq_nimber_game(): """ Test that Nimbers and Games equate properly. """ a = Nimber.from_integer(3) b = 3 * one assert not a == b
def test_nimber_is_number_2(): """ Test that the Nimber 0 is a number. """ assert Nimber.from_integer(0).is_number
def test_nimber_value(n, v): """ Test that the value of a Nimber is represented correctly. """ assert Nimber.from_integer(n).value == v
def test_fail(): """ Test that Nimbers must have integral values. """ with pytest.raises(ValueError): Nimber.from_integer(0.5)
def test_neg_nimbers(): """ Test that a Nimber is its own negative. """ a = Nimber.from_integer(5) assert a == -a
def test_nimber_birthday(n): """ Test that Nimbers have the right birthdays. """ assert Nimber.from_integer(n).birthday == n
def test_nimber_is_infinitesimal_2(): """ Test that the Nimber 0 is not infinitesimal. """ assert not Nimber.from_integer(0).is_infinitesimal
@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