Skip to content

Commit

Permalink
robot-simulator: ensure mutating functions return robot (JuliaLang#259)
Browse files Browse the repository at this point in the history
  • Loading branch information
cmcaine authored Sep 28, 2020
1 parent d86b8b8 commit 6adc8ef
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
2 changes: 1 addition & 1 deletion exercises/robot-simulator/robot-simulator.ipynb

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 8 additions & 0 deletions exercises/robot-simulator/runtests.jl
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,14 @@ include("robot-simulator.jl")
@test heading(r) == SOUTH
end

@testset "mutating functions should return robot" begin
r = Robot((0, 0), NORTH)
@test r == turn_right!(r)
@test r == turn_left!(r)
@test r == advance!(r)
@test r == move!(r, "A")
end

@testset "rotate +π/2" begin
r = Robot((0, 0), NORTH)
turn_right!(r)
Expand Down

0 comments on commit 6adc8ef

Please sign in to comment.