Skip to content

Commit

Permalink
Elaborate: add real list and path
Browse files Browse the repository at this point in the history
  • Loading branch information
fr2d9y2 authored and fr2d9y2 committed Apr 6, 2017
1 parent cb7d1d7 commit 191927b
Show file tree
Hide file tree
Showing 2 changed files with 14 additions and 1 deletion.
3 changes: 2 additions & 1 deletion mars-rover/src/rover.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ def __init__(self, x, y, orientation):
self.orientation = orientation

def move(self, commands):
self.moveBy(commands[0])
for command in commands:
self.moveBy(command)

# use command pattern and lookup to avoid switch statements :)
def moveBy(self, commandKey):
Expand Down
12 changes: 12 additions & 0 deletions mars-rover/test/test_rover.py
Original file line number Diff line number Diff line change
Expand Up @@ -113,3 +113,15 @@ def test_move_right(self):
def test_move_left(self):
r.move(list('l'));
assert_equals('S', r.orientation)

class TestMovePath:

def setup(self):
global r
r = rover.Rover(10, 21, 'N')

def test_simple_path(self):
r.move(list("ffrff"))
assert_equal('E', r.orientation)
assert_equal(12, r.x)
assert_equal(23, r.y)

0 comments on commit 191927b

Please sign in to comment.