Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add test: revert to cell where direction changed #5

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 78 additions & 0 deletions test/snake/reverse/ReverseTests.scala
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,84 @@ class ReverseTests extends SnakeTestSuiteBase {
)
}

test("testReverseToDirectionChange") {
checkGame(
List(
TestFrame(2,
"""OO>..
|A....
|....."""),
TestFrame(2,
""".OO>.
|A....
|....."""),
TestFrame(2, List(ChangeDir(South())),
"""..OO.
|A..v.
|....."""),
TestFrame(2,
"""...O.
|A..O.
|...v."""),
TestFrame(2, List(ChangeDir(East()), ChangeDir(West())),
""".....
|A..O.
|..<O."""),
TestFrame(2,
""".....
|A....
|.<OO."""),
TestFrame(2,
""".....
|A....
|<OO.."""),
TestFrame(2, List(ReverseGame(true)),
""".....
|A....
|.<OO."""),
TestFrame(2,
""".....
|A..O.
|..<O."""),
TestFrame(2,
"""...O.
|A..O.
|...v."""),
TestFrame(2, List(ReverseGame(false)),
"""...v.
|A..O.
|...O."""),
TestFrame(2,
"""...O.
|A..v.
|...O."""),
TestFrame(2, List(ReverseGame(true)),
"""...v.
|A..O.
|...O."""),
TestFrame(2,
"""...O.
|A..O.
|...v."""),
TestFrame(2,
"""..OO.
|A..v.
|....."""),
TestFrame(2,
""".OO>.
|A....
|....."""),
TestFrame(2, List(ReverseGame(false)),
"""..OO>
|A....
|.....""")
),
hint = "After reversing to a GameState where the snake changed direction, " +
"the snake should keep going in the direction it is pointing to (if user does not input anything), " +
"and not perform automatically the same turn it performed the previous time"
)
}

test("testReverseGameOver") {
checkGame(
List(
Expand Down