diff --git a/test_gol.py b/test_gol.py index 3f1a24ccf955bc9236a825bf750b6ea5c35ac345..bad4330d759a0726d48829c50ef49b6eaeea0799 100644 --- a/test_gol.py +++ b/test_gol.py @@ -21,23 +21,28 @@ def oscillators(): def test_gol_still_lifes(): - gol = GameOfLife() for l in still_lifes(): - if np.any(l != gol.next(l)): + gol = GameOfLife(l) + gol.update() + if not np.all(l == gol.board()): assert False,"Still life was not still." def test_gol_oscillators(): - gol=GameOfLife() for l_i,l_o in oscillators(): - if np.any(l_o != gol.next(l_i)): + gol=GameOfLife(l_i) + gol.update() + if not np.all(l_o == gol.board()): assert False,"Oscillators did not work." def test_gol_benchmark(benchmark): - gol=GameOfLife() board = np.ones((50,50)) - benchmark(gol.next,board) + def gol_next(board): + gol=GameOfLife(board) + gol.update() + return gol.board() + benchmark(gol_next, board) if __name__ == "__main__": test_gol_still_lifes() - test_gol_oscillators() \ No newline at end of file + test_gol_oscillators()