Skip to content

Commit

Permalink
Cancel incomplete fill before drawing stamps.
Browse files Browse the repository at this point in the history
  • Loading branch information
donkirkby committed Feb 5, 2016
1 parent 5ebfc69 commit d7e8f86
Show file tree
Hide file tree
Showing 2 changed files with 128 additions and 0 deletions.
1 change: 1 addition & 0 deletions plugin/PySrc/mock_turtle.py
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,7 @@ def _goto(self, end):

def __getattr__(self, name):
if name == 'report':
self._path = None # Cancel incomplete fill.
self._newLine()
self._flush_lines()
self._draw_stamps()
Expand Down
127 changes: 127 additions & 0 deletions test/PySrc/tests/mock_turtle_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -318,3 +318,130 @@ def test_forgotten_end_fill(self):

# VERIFY
self.assertEqual(expected_report.splitlines(), report)

def test_stamp(self):
# SETUP
expected_report = """\
create_polygon
0
0
-9
-5
-7
0
-9
5
0
0
fill='#000000'
outline=''
create_line
0
0
-9
-5
fill='#000000'
pensize=1
create_line
-9
-5
-7
0
fill='#000000'
pensize=1
create_line
-7
0
-9
5
fill='#000000'
pensize=1
create_line
-9
5
0
0
fill='#000000'
pensize=1
"""

# EXEC
t = MockTurtle()
t.stamp()
report = t.report

# VERIFY
self.assertEqual(expected_report.splitlines(), report)

def test_forgotten_end_fill_with_stamp(self):
# SETUP
expected_report = """\
create_line
0
0
100
0
fill='#ff0000'
pensize=1
create_line
100
0
100
100
fill='#ff0000'
pensize=1
create_polygon
0
0
-9
-5
-7
0
-9
5
0
0
fill='#000000'
outline=''
create_line
0
0
-9
-5
fill='#000000'
pensize=1
create_line
-9
-5
-7
0
fill='#000000'
pensize=1
create_line
-7
0
-9
5
fill='#000000'
pensize=1
create_line
-9
5
0
0
fill='#000000'
pensize=1
"""

# EXEC
t = MockTurtle()
t.stamp()
t.color('red', 'blue')
t.begin_fill()
for _ in range(2):
t.fd(100)
t.right(90)
report = t.report

# VERIFY
self.assertEqual(expected_report.splitlines(), report)

0 comments on commit d7e8f86

Please sign in to comment.