tortoise 0.9.6 → 0.9.8

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/README.markdown CHANGED
@@ -5,10 +5,11 @@ Tortoise [![Build Status](https://secure.travis-ci.org/huntca/tortoise.png)](htt
5
5
 
6
6
  Tortoise is a [Logo][logo] interpreter for Ruby. To demonstrate the
7
7
  awesomeness of Logo, we'll draw a ruby! This example can be found in the
8
- repository at `spec/data/simple.logo`.
8
+ repository at `spec/data/ruby.logo`.
9
9
 
10
10
  > Tortoise::Interpreter.new <<-LOGO
11
11
  61
12
+ PD
12
13
  RT 135
13
14
  FD 5
14
15
  REPEAT 2 [ RT 90 FD 15 ]
@@ -59,18 +60,24 @@ any of the supported Logo commands.
59
60
  interpreter = Tortoise::Interpreter.new(canvas_size)
60
61
 
61
62
  # execute any supported commands
63
+ interpreter.pd
64
+ interpreter.setpos(1, 2)
62
65
  interpreter.rt(90)
63
66
  interpreter.fd(3)
64
67
  interpreter.lt(45)
65
68
  interpreter.bk(4)
69
+ interpreter.pu
66
70
 
67
71
  Tortoise also accepts commands as an input string:
68
72
 
69
73
  interpreter = Tortoise::Interpreter.new(11)
74
+ interpreter.draw "PD"
75
+ interpreter.draw "SETPOS 1 2"
70
76
  interpreter.draw "RT 90"
71
77
  interpreter.draw "FD 3"
72
78
  interpreter.draw "LT 45"
73
79
  interpreter.draw "BK 4"
80
+ interpreter.draw "PU"
74
81
 
75
82
  You can execute entire blocks of commands at once:
76
83
 
@@ -143,8 +150,11 @@ Supported Commands
143
150
  ------------------
144
151
  Tortoise only supports a small subset of all [Logo][logo] commands.
145
152
 
153
+ - `PU`: Lift the pen from the canvas
154
+ - `PD`: Place the pen onto the canvas
146
155
  - `RT x`: Turn the tortoise `x` degrees to the right (increments of 45)
147
156
  - `LT x`: Turn the tortoise `x` degrees to the right (increments of 45)
148
157
  - `FD x`: Move the tortoise `x` steps forward
149
158
  - `BK x`: Move the tortoise `x` steps backward
159
+ - `SETPOS x y`: Move the tortoise to position `x, y` (with pen up)
150
160
  - `REPEAT n [ x ]`: Repeat commands `x` a total of `n` times
@@ -8,12 +8,31 @@ module Tortoise
8
8
  @size = lines.shift.to_i
9
9
  @canvas = new_canvas
10
10
  @direction = 0
11
+ @pen_down = false
11
12
  center = (@size - @size/2) - 1
12
13
 
13
14
  update_position(center, center)
14
15
  draw(lines)
15
16
  end
16
17
 
18
+ def setpos(x, y)
19
+ @position = place_in_canvas_bounds(x, y)
20
+ update_canvas
21
+ end
22
+
23
+ def pu
24
+ @pen_down = false
25
+ end
26
+
27
+ def pd
28
+ @pen_down = true
29
+ update_canvas
30
+ end
31
+
32
+ def pen_down?
33
+ @pen_down
34
+ end
35
+
17
36
  def rt(degrees)
18
37
  rotate(degrees)
19
38
  end
@@ -59,14 +78,28 @@ module Tortoise
59
78
  end
60
79
 
61
80
  def execute(command)
62
- words = command.split(' ')
63
- if words.size == 2
64
- method, param = words
65
- self.send(method.downcase, param.to_i)
81
+ commands = command.split(' ')
82
+ return if commands.empty?
83
+
84
+ command = commands.shift.downcase
85
+ if command == 'repeat'
86
+ count = commands.shift.to_i
87
+ commands = commands[1..commands.size-2]
88
+ repeat(commands, count)
66
89
  else
67
- 1.upto(words[1].to_i) do
68
- commands = words[3..words.size-2]
69
- execute(commands.shift(2).join(' ')) while commands.size > 0
90
+ params = commands.map(&:to_i)
91
+ self.send(command, *params)
92
+ end
93
+ end
94
+
95
+ def repeat(commands, count)
96
+ count.times do
97
+ c = commands.dup
98
+ while c.size > 0
99
+ command = c.shift
100
+ params = []
101
+ params << c.shift while c[0].to_s.match(/[0-9]/)
102
+ execute("#{command} #{params.join(' ')}")
70
103
  end
71
104
  end
72
105
  end
@@ -92,6 +125,7 @@ module Tortoise
92
125
  end
93
126
 
94
127
  def update_canvas
128
+ return unless pen_down?
95
129
  x, y = @position
96
130
  @canvas[x][y] = true
97
131
  end
@@ -1,3 +1,3 @@
1
1
  module Tortoise
2
- VERSION = "0.9.6"
2
+ VERSION = "0.9.8"
3
3
  end
@@ -1,3 +1,4 @@
1
1
  1001
2
2
 
3
- REPEAT 4 [ FD 200 LT 45 FD 100 LT 45 FD 50 LT 45 FD 25 LT 45 FD 12 LT 45 FD 6 LT 45 RT 90 LT 45 BK 6 RT 90 FD 6 LT 45 RT 90 LT 45 BK 6 LT 45 BK 12 RT 90 FD 12 LT 45 FD 6 LT 45 RT 90 LT 45 BK 6 RT 90 FD 6 LT 45 RT 90 LT 45 BK 6 LT 45 BK 12 LT 45 BK 25 RT 90 FD 25 LT 45 FD 12 LT 45 FD 6 LT 45 RT 90 LT 45 BK 6 RT 90 FD 6 LT 45 RT 90 LT 45 BK 6 LT 45 BK 12 RT 90 FD 12 LT 45 FD 6 LT 45 RT 90 LT 45 BK 6 RT 90 FD 6 LT 45 RT 90 LT 45 BK 6 LT 45 BK 12 LT 45 BK 25 LT 45 BK 50 RT 90 FD 50 LT 45 FD 25 LT 45 FD 12 LT 45 FD 6 LT 45 RT 90 LT 45 BK 6 RT 90 FD 6 LT 45 RT 90 LT 45 BK 6 LT 45 BK 12 RT 90 FD 12 LT 45 FD 6 LT 45 RT 90 LT 45 BK 6 RT 90 FD 6 LT 45 RT 90 LT 45 BK 6 LT 45 BK 12 LT 45 BK 25 RT 90 FD 25 LT 45 FD 12 LT 45 FD 6 LT 45 RT 90 LT 45 BK 6 RT 90 FD 6 LT 45 RT 90 LT 45 BK 6 LT 45 BK 12 RT 90 FD 12 LT 45 FD 6 LT 45 RT 90 LT 45 BK 6 RT 90 FD 6 LT 45 RT 90 LT 45 BK 6 LT 45 BK 12 LT 45 BK 25 LT 45 BK 50 LT 45 BK 100 RT 90 FD 100 LT 45 FD 50 LT 45 FD 25 LT 45 FD 12 LT 45 FD 6 LT 45 RT 90 LT 45 BK 6 RT 90 FD 6 LT 45 RT 90 LT 45 BK 6 LT 45 BK 12 RT 90 FD 12 LT 45 FD 6 LT 45 RT 90 LT 45 BK 6 RT 90 FD 6 LT 45 RT 90 LT 45 BK 6 LT 45 BK 12 LT 45 BK 25 RT 90 FD 25 LT 45 FD 12 LT 45 FD 6 LT 45 RT 90 LT 45 BK 6 RT 90 FD 6 LT 45 RT 90 LT 45 BK 6 LT 45 BK 12 RT 90 FD 12 LT 45 FD 6 LT 45 RT 90 LT 45 BK 6 RT 90 FD 6 LT 45 RT 90 LT 45 BK 6 LT 45 BK 12 LT 45 BK 25 LT 45 BK 50 RT 90 FD 50 LT 45 FD 25 LT 45 FD 12 LT 45 FD 6 LT 45 RT 90 LT 45 BK 6 RT 90 FD 6 LT 45 RT 90 LT 45 BK 6 LT 45 BK 12 RT 90 FD 12 LT 45 FD 6 LT 45 RT 90 LT 45 BK 6 RT 90 FD 6 LT 45 RT 90 LT 45 BK 6 LT 45 BK 12 LT 45 BK 25 RT 90 FD 25 LT 45 FD 12 LT 45 FD 6 LT 45 RT 90 LT 45 BK 6 RT 90 FD 6 LT 45 RT 90 LT 45 BK 6 LT 45 BK 12 RT 90 FD 12 LT 45 FD 6 LT 45 RT 90 LT 45 BK 6 RT 90 FD 6 LT 45 RT 90 LT 45 BK 6 LT 45 BK 12 LT 45 BK 25 LT 45 BK 50 LT 45 BK 100 LT 45 BK 200 RT 90 ]
3
+ PD
4
+ REPEAT 4 [ FD 200 LT 45 FD 100 LT 45 FD 50 LT 45 FD 25 LT 45 FD 12 LT 45 FD 6 LT 45 RT 90 LT 45 BK 6 RT 90 FD 6 LT 45 RT 90 LT 45 BK 6 LT 45 BK 12 RT 90 FD 12 LT 45 FD 6 LT 45 RT 90 LT 45 BK 6 RT 90 FD 6 LT 45 RT 90 LT 45 BK 6 LT 45 BK 12 LT 45 BK 25 RT 90 FD 25 LT 45 FD 12 LT 45 FD 6 LT 45 RT 90 LT 45 BK 6 RT 90 FD 6 LT 45 RT 90 LT 45 BK 6 LT 45 BK 12 RT 90 FD 12 LT 45 FD 6 LT 45 RT 90 LT 45 BK 6 RT 90 FD 6 LT 45 RT 90 LT 45 BK 6 LT 45 BK 12 LT 45 BK 25 LT 45 BK 50 RT 90 FD 50 LT 45 FD 25 LT 45 FD 12 LT 45 FD 6 LT 45 RT 90 LT 45 BK 6 RT 90 FD 6 LT 45 RT 90 LT 45 BK 6 LT 45 BK 12 RT 90 FD 12 LT 45 FD 6 LT 45 RT 90 LT 45 BK 6 RT 90 FD 6 LT 45 RT 90 LT 45 BK 6 LT 45 BK 12 LT 45 BK 25 RT 90 FD 25 LT 45 FD 12 LT 45 FD 6 LT 45 RT 90 LT 45 BK 6 RT 90 FD 6 LT 45 RT 90 LT 45 BK 6 LT 45 BK 12 RT 90 FD 12 LT 45 FD 6 LT 45 RT 90 LT 45 BK 6 RT 90 FD 6 LT 45 RT 90 LT 45 BK 6 LT 45 BK 12 LT 45 BK 25 LT 45 BK 50 LT 45 BK 100 RT 90 FD 100 LT 45 FD 50 LT 45 FD 25 LT 45 FD 12 LT 45 FD 6 LT 45 RT 90 LT 45 BK 6 RT 90 FD 6 LT 45 RT 90 LT 45 BK 6 LT 45 BK 12 RT 90 FD 12 LT 45 FD 6 LT 45 RT 90 LT 45 BK 6 RT 90 FD 6 LT 45 RT 90 LT 45 BK 6 LT 45 BK 12 LT 45 BK 25 RT 90 FD 25 LT 45 FD 12 LT 45 FD 6 LT 45 RT 90 LT 45 BK 6 RT 90 FD 6 LT 45 RT 90 LT 45 BK 6 LT 45 BK 12 RT 90 FD 12 LT 45 FD 6 LT 45 RT 90 LT 45 BK 6 RT 90 FD 6 LT 45 RT 90 LT 45 BK 6 LT 45 BK 12 LT 45 BK 25 LT 45 BK 50 RT 90 FD 50 LT 45 FD 25 LT 45 FD 12 LT 45 FD 6 LT 45 RT 90 LT 45 BK 6 RT 90 FD 6 LT 45 RT 90 LT 45 BK 6 LT 45 BK 12 RT 90 FD 12 LT 45 FD 6 LT 45 RT 90 LT 45 BK 6 RT 90 FD 6 LT 45 RT 90 LT 45 BK 6 LT 45 BK 12 LT 45 BK 25 RT 90 FD 25 LT 45 FD 12 LT 45 FD 6 LT 45 RT 90 LT 45 BK 6 RT 90 FD 6 LT 45 RT 90 LT 45 BK 6 LT 45 BK 12 RT 90 FD 12 LT 45 FD 6 LT 45 RT 90 LT 45 BK 6 RT 90 FD 6 LT 45 RT 90 LT 45 BK 6 LT 45 BK 12 LT 45 BK 25 LT 45 BK 50 LT 45 BK 100 LT 45 BK 200 RT 90 ]
File without changes
File without changes
@@ -1,5 +1,6 @@
1
1
  61
2
2
 
3
+ PD
3
4
  RT 135
4
5
  FD 5
5
6
  REPEAT 2 [ RT 90 FD 15 ]
@@ -0,0 +1,20 @@
1
+ . . . . . . . . . . . . . . . . . . . .
2
+ . . . . . . . . . . . . . . . . . . . .
3
+ . . . . . . . . . . . . . . . . . . . .
4
+ . . . X X X . . . . . . . . X X X . . .
5
+ . . . X X X . . . . . . . . X X X . . .
6
+ . . . X X X . . . . . . . . X X X . . .
7
+ . . . . . . . . . . . . . . . . . . . .
8
+ . . . . . . . . . X X . . . . . . . . .
9
+ . . . . . . . . . X X . . . . . . . . .
10
+ . X . . . . . . . . . . . . . . . . X .
11
+ . . X . . . . . . . . . . . . . . X . .
12
+ . . . X . . . . . . . . . . . . X . . .
13
+ . . . . X . . . . . . . . . . X . . . .
14
+ . . . . . X . . . . . . . . X . . . . .
15
+ . . . . . . X . . . . . . X . . . . . .
16
+ . . . . . . . X . . . . X . . . . . . .
17
+ . . . . . . . . X X X X . . . . . . . .
18
+ . . . . . . . . . . . . . . . . . . . .
19
+ . . . . . . . . . . . . . . . . . . . .
20
+ . . . . . . . . . . . . . . . . . . . .
@@ -0,0 +1,25 @@
1
+ 20
2
+
3
+ SETPOS 3 16
4
+ PD
5
+ REPEAT 4 [ RT 90 FD 2 ]
6
+ REPEAT 4 [ RT 90 FD 1 ]
7
+ PU
8
+ RT 90
9
+ FD 11
10
+ LT 90
11
+ PD
12
+ REPEAT 4 [ RT 90 FD 2 ]
13
+ REPEAT 4 [ RT 90 FD 1 ]
14
+
15
+ SETPOS 9 12
16
+ REPEAT 4 [ RT 90 FD 1 ]
17
+
18
+ SETPOS 1 10
19
+ PD
20
+ RT 135
21
+ FD 7
22
+ RT 135
23
+ BK 3
24
+ LT 45
25
+ BK 7
@@ -0,0 +1,5 @@
1
+ def filled_pixels(canvas)
2
+ canvas.inject(0) do |count, column|
3
+ count += column.inject(0) { |count, pixel| count += pixel ? 1 : 0 }
4
+ end
5
+ end
@@ -1,18 +1,32 @@
1
1
  require 'tortoise'
2
2
 
3
3
  describe Tortoise::Interpreter do
4
- before do
5
- input = File.new('./spec/data/simple.logo').read
6
- @interpreter = Tortoise::Interpreter.new(input)
7
- end
4
+ context 'when rendering the ruby' do
5
+ before do
6
+ input = File.new('./spec/data/ruby.logo').read
7
+ @interpreter = Tortoise::Interpreter.new(input)
8
+ end
9
+
10
+ it 'produces the expected ascii output' do
11
+ ascii = File.new('./spec/data/ruby.ascii').read
12
+ @interpreter.to_ascii.should == ascii
13
+ end
8
14
 
9
- it 'produces the expected ascii output' do
10
- ascii = File.new('./spec/data/simple_out.ascii').read
11
- @interpreter.to_ascii.should == ascii
15
+ it 'produces the expected html output' do
16
+ html = File.new('./spec/data/ruby.html').read
17
+ @interpreter.to_html.should == html
18
+ end
12
19
  end
13
20
 
14
- it 'produces the expected html output' do
15
- html = File.new('./spec/data/simple_out.html').read
16
- @interpreter.to_html.should == html
21
+ context 'when rendering the smiley face' do
22
+ before do
23
+ input = File.new('./spec/data/smile.logo').read
24
+ @interpreter = Tortoise::Interpreter.new(input)
25
+ end
26
+
27
+ it 'produces the expected ascii output' do
28
+ ascii = File.new('./spec/data/smile.ascii').read
29
+ @interpreter.to_ascii.should == ascii
30
+ end
17
31
  end
18
32
  end
@@ -1,4 +1,5 @@
1
1
  require 'tortoise/interpreter'
2
+ require 'helpers/interpreter_helper'
2
3
 
3
4
  describe Tortoise::Interpreter do
4
5
  let(:tortoise) { Tortoise::Interpreter.new(11) }
@@ -20,12 +21,8 @@ describe Tortoise::Interpreter do
20
21
  tortoise.position.should == [3, 2]
21
22
  end
22
23
 
23
- it 'starts with a single marked pixel on the canvas' do
24
- count = 0
25
- tortoise.canvas.each do |column|
26
- column.each { |pixel| count += 1 if pixel }
27
- end
28
- count.should == 1
24
+ it 'starts with no marked pixels on the canvas' do
25
+ filled_pixels(tortoise.canvas).should == 0
29
26
  end
30
27
 
31
28
  it 'defaults tortoise position to the center of the canvas' do
@@ -36,10 +33,15 @@ describe Tortoise::Interpreter do
36
33
  tortoise.direction.should == 0
37
34
  end
38
35
 
36
+ it 'defaults with the tortoise pen up' do
37
+ tortoise.pen_down?.should == false
38
+ end
39
+
39
40
  describe '#draw' do
40
41
  it 'draws the image on the canvas when given a string' do
41
42
  tortoise = Tortoise::Interpreter.new(5)
42
43
  tortoise.draw <<-STEPS
44
+ PD
43
45
  RT 90
44
46
  FD 1
45
47
  REPEAT 2 [ RT 45 ]
@@ -60,6 +62,7 @@ describe Tortoise::Interpreter do
60
62
  it 'draws the image on the canvas when given an array' do
61
63
  tortoise = Tortoise::Interpreter.new(5)
62
64
  tortoise.draw([
65
+ 'PD',
63
66
  'RT 90',
64
67
  'FD 1',
65
68
  'REPEAT 2 [ RT 45 ]',
@@ -77,6 +80,59 @@ describe Tortoise::Interpreter do
77
80
  end
78
81
  end
79
82
 
83
+ describe '#setpos' do
84
+ it 'moves the tortoise to the specified position' do
85
+ tortoise.position.should == [5, 5]
86
+ tortoise.setpos(2, 4)
87
+ tortoise.position.should == [2, 4]
88
+ end
89
+
90
+ it 'fills in landing spot when pen is down' do
91
+ filled_pixels(tortoise.canvas).should == 0
92
+ tortoise.pd
93
+ tortoise.setpos(0, 0)
94
+ filled_pixels(tortoise.canvas).should == 2
95
+ end
96
+
97
+ it 'does not fill in landing spot when pen is up' do
98
+ filled_pixels(tortoise.canvas).should == 0
99
+ tortoise.pu
100
+ tortoise.setpos(0, 0)
101
+ filled_pixels(tortoise.canvas).should == 0
102
+ end
103
+
104
+ it 'does not set a position outside the canvas' do
105
+ tortoise.setpos(100, 100)
106
+ tortoise.position.should == [10, 10]
107
+ end
108
+ end
109
+
110
+ describe '#pu' do
111
+ it 'lifts the pen from the canvas' do
112
+ tortoise.pd
113
+ tortoise.pen_down?.should == true
114
+ tortoise.pu
115
+ tortoise.pen_down?.should == false
116
+ end
117
+ end
118
+
119
+ describe '#pd' do
120
+ it 'places the pen onto the canvas' do
121
+ tortoise.pu
122
+ tortoise.pen_down?.should == false
123
+ tortoise.pd
124
+ tortoise.pen_down?.should == true
125
+ end
126
+
127
+ it 'fills in a pixel when the pen hits the canvas' do
128
+ filled_pixels(tortoise.canvas).should == 0
129
+ tortoise.pu
130
+ tortoise.fd(2)
131
+ tortoise.pd
132
+ filled_pixels(tortoise.canvas).should == 1
133
+ end
134
+ end
135
+
80
136
  describe '#rt' do
81
137
  it 'can rotate the tortoise 45 degrees to the right' do
82
138
  tortoise.rt(45)
@@ -274,8 +330,9 @@ describe Tortoise::Interpreter do
274
330
  x.should >= 0
275
331
  end
276
332
 
277
- it 'draws on traveled areas of the canvas' do
333
+ it 'draws on traveled areas of the canvas when pen is down' do
278
334
  tortoise = Tortoise::Interpreter.new(5)
335
+ tortoise.pd
279
336
  tortoise.rt(90)
280
337
  tortoise.fd(1)
281
338
  tortoise.rt(90)
@@ -291,6 +348,13 @@ describe Tortoise::Interpreter do
291
348
  [true , true , true , false, false],
292
349
  [true , false, false, false, false]]
293
350
  end
351
+
352
+ it 'does not draw on traveled areas of the canvas when pen is up' do
353
+ tortoise = Tortoise::Interpreter.new(5)
354
+ tortoise.stub(:pen_down? => false)
355
+ tortoise.fd(2)
356
+ filled_pixels(tortoise.canvas).should == 0
357
+ end
294
358
  end
295
359
 
296
360
  describe '#bk' do
@@ -376,8 +440,9 @@ describe Tortoise::Interpreter do
376
440
  x.should < tortoise.size
377
441
  end
378
442
 
379
- it 'draws on traveled areas of the canvas' do
443
+ it 'draws on traveled areas of the canvas when pen is down' do
380
444
  tortoise = Tortoise::Interpreter.new(5)
445
+ tortoise.pd
381
446
  tortoise.lt(90)
382
447
  tortoise.bk(1)
383
448
  tortoise.rt(90)
@@ -393,6 +458,13 @@ describe Tortoise::Interpreter do
393
458
  [true , true , true , false, false],
394
459
  [true , false, false, false, false]]
395
460
  end
461
+
462
+ it 'does not draw on traveled areas of the canvas when pen is up' do
463
+ tortoise = Tortoise::Interpreter.new(5)
464
+ tortoise.stub(:pen_down? => false)
465
+ tortoise.bk(2)
466
+ filled_pixels(tortoise.canvas).should == 0
467
+ end
396
468
  end
397
469
 
398
470
  describe '#execute' do
@@ -401,6 +473,26 @@ describe Tortoise::Interpreter do
401
473
  tortoise.direction.should == 90
402
474
  end
403
475
 
476
+ it 'can execute putting the pen down' do
477
+ tortoise.pu
478
+ tortoise.pen_down?.should == false
479
+ tortoise.send(:execute, 'PD')
480
+ tortoise.pen_down?.should == true
481
+ end
482
+
483
+ it 'can execute lifting the pen up' do
484
+ tortoise.pd
485
+ tortoise.pen_down?.should == true
486
+ tortoise.send(:execute, 'PU')
487
+ tortoise.pen_down?.should == false
488
+ end
489
+
490
+ it 'can execute setpos commands' do
491
+ tortoise.position.should == [5, 5]
492
+ tortoise.send(:execute, 'SETPOS 2 4')
493
+ tortoise.position.should == [2, 4]
494
+ end
495
+
404
496
  it 'can execute right turns' do
405
497
  tortoise.send(:execute, 'RT 90')
406
498
  tortoise.direction.should == 90
@@ -429,14 +521,30 @@ describe Tortoise::Interpreter do
429
521
  end
430
522
 
431
523
  it 'can execute multi-item repeat blocks' do
432
- tortoise.send(:execute, 'REPEAT 2 [ RT 45 LT 90 ]')
524
+ tortoise.send(:execute, 'REPEAT 2 [ PD RT 45 SETPOS 0 0 LT 90 ]')
433
525
  tortoise.direction.should == 270
526
+ tortoise.position.should == [0, 0]
434
527
  end
435
528
 
436
529
  it 'can execute commands with extra whitespace' do
437
530
  tortoise.send(:execute, ' RT 90 ')
438
531
  tortoise.direction.should == 90
439
532
  end
533
+
534
+ it 'does not raise error with blank lines' do
535
+ command = lambda { tortoise.send(:execute, ' ') }
536
+ command.should_not raise_error
537
+ end
538
+
539
+ it 'does not raise error with zero params in repeat command' do
540
+ command = lambda { tortoise.send(:execute, 'REPEAT 2 [ RT 0 PD ]') }
541
+ command.should_not raise_error
542
+ end
543
+
544
+ it 'raises error with unknown commands' do
545
+ command = lambda { tortoise.send(:execute, 'UNKNOWN') }
546
+ command.should raise_error
547
+ end
440
548
  end
441
549
 
442
550
  %w(ascii html png).each do |format|
@@ -11,6 +11,7 @@ describe Tortoise::Presenter do
11
11
  before do
12
12
  interpreter = Tortoise::Interpreter.new <<-STEPS
13
13
  5
14
+ PD
14
15
  RT 90
15
16
  FD 1
16
17
  REPEAT 2 [ RT 45 ]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tortoise
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.6
4
+ version: 0.9.8
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2012-02-24 00:00:00.000000000 Z
12
+ date: 2012-02-25 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: chunky_png
16
- requirement: &70231598937120 !ruby/object:Gem::Requirement
16
+ requirement: &70206441498960 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '0'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70231598937120
24
+ version_requirements: *70206441498960
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rake
27
- requirement: &70231598933780 !ruby/object:Gem::Requirement
27
+ requirement: &70206441498060 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70231598933780
35
+ version_requirements: *70206441498060
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rspec
38
- requirement: &70231598931880 !ruby/object:Gem::Requirement
38
+ requirement: &70206441495660 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,7 +43,7 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70231598931880
46
+ version_requirements: *70206441495660
47
47
  description: Tortoise is a Logo interpreter for ruby.
48
48
  email:
49
49
  - huntca@gmail.com
@@ -63,9 +63,12 @@ files:
63
63
  - lib/tortoise/presenter.rb
64
64
  - lib/tortoise/version.rb
65
65
  - spec/data/complex.logo
66
- - spec/data/simple.logo
67
- - spec/data/simple_out.ascii
68
- - spec/data/simple_out.html
66
+ - spec/data/ruby.ascii
67
+ - spec/data/ruby.html
68
+ - spec/data/ruby.logo
69
+ - spec/data/smile.ascii
70
+ - spec/data/smile.logo
71
+ - spec/helpers/interpreter_helper.rb
69
72
  - spec/integration/tortoise_integration_spec.rb
70
73
  - spec/tortoise/interpreter_spec.rb
71
74
  - spec/tortoise/presenter_spec.rb
@@ -96,9 +99,12 @@ specification_version: 3
96
99
  summary: Tortoise is a Logo interpreter for ruby.
97
100
  test_files:
98
101
  - spec/data/complex.logo
99
- - spec/data/simple.logo
100
- - spec/data/simple_out.ascii
101
- - spec/data/simple_out.html
102
+ - spec/data/ruby.ascii
103
+ - spec/data/ruby.html
104
+ - spec/data/ruby.logo
105
+ - spec/data/smile.ascii
106
+ - spec/data/smile.logo
107
+ - spec/helpers/interpreter_helper.rb
102
108
  - spec/integration/tortoise_integration_spec.rb
103
109
  - spec/tortoise/interpreter_spec.rb
104
110
  - spec/tortoise/presenter_spec.rb