smalruby-editor 0.1.6-x86-mingw32 → 0.1.7-x86-mingw32

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of smalruby-editor might be problematic. Click here for more details.

Files changed (98) hide show
  1. checksums.yaml +4 -4
  2. data/app/assets/javascripts/blocks/hardware.js.coffee.erb +40 -3
  3. data/app/assets/stylesheets/toolbox.css.scss.erb +1 -6
  4. data/app/controllers/source_codes_controller.rb +5 -1
  5. data/app/models/concerns/ruby_to_block/block/base.rb +251 -0
  6. data/app/models/concerns/ruby_to_block/block/character.rb +42 -0
  7. data/app/models/concerns/ruby_to_block/block/character_event.rb +27 -0
  8. data/app/models/concerns/ruby_to_block/block/character_method_call.rb +29 -0
  9. data/app/models/concerns/ruby_to_block/block/character_new.rb +7 -0
  10. data/app/models/concerns/ruby_to_block/block/character_operation.rb +80 -0
  11. data/app/models/concerns/ruby_to_block/block/control_if.rb +45 -0
  12. data/app/models/concerns/ruby_to_block/block/control_loop.rb +19 -0
  13. data/app/models/concerns/ruby_to_block/block/control_sleep.rb +18 -0
  14. data/app/models/concerns/ruby_to_block/block/do.rb +24 -0
  15. data/app/models/concerns/ruby_to_block/block/else.rb +12 -0
  16. data/app/models/concerns/ruby_to_block/block/end.rb +26 -0
  17. data/app/models/concerns/ruby_to_block/block/events_on_click.rb +14 -0
  18. data/app/models/concerns/ruby_to_block/block/events_on_key_push_or_down.rb +17 -0
  19. data/app/models/concerns/ruby_to_block/block/events_on_start.rb +14 -0
  20. data/app/models/concerns/ruby_to_block/block/hardware_init_hardware.rb +14 -0
  21. data/app/models/concerns/ruby_to_block/block/hardware_led_off.rb +16 -0
  22. data/app/models/concerns/ruby_to_block/block/hardware_led_on.rb +16 -0
  23. data/app/models/concerns/ruby_to_block/block/hardware_on_sensor_change.rb +17 -0
  24. data/app/models/concerns/ruby_to_block/block/hardware_rgb_led_off.rb +18 -0
  25. data/app/models/concerns/ruby_to_block/block/hardware_rgb_led_on.rb +23 -0
  26. data/app/models/concerns/ruby_to_block/block/hardware_sensor_value.rb +23 -0
  27. data/app/models/concerns/ruby_to_block/block/hardware_two_wheel_drive_car.rb +26 -0
  28. data/app/models/concerns/ruby_to_block/block/looks_hide.rb +8 -0
  29. data/app/models/concerns/ruby_to_block/block/looks_say.rb +20 -0
  30. data/app/models/concerns/ruby_to_block/block/looks_show.rb +8 -0
  31. data/app/models/concerns/ruby_to_block/block/looks_vanish.rb +8 -0
  32. data/app/models/concerns/ruby_to_block/block/math_number.rb +14 -0
  33. data/app/models/concerns/ruby_to_block/block/motion_change_x_by.rb +20 -0
  34. data/app/models/concerns/ruby_to_block/block/motion_change_y_by.rb +20 -0
  35. data/app/models/concerns/ruby_to_block/block/motion_move.rb +15 -0
  36. data/app/models/concerns/ruby_to_block/block/motion_point_towards_character.rb +24 -0
  37. data/app/models/concerns/ruby_to_block/block/motion_point_towards_mouse.rb +9 -0
  38. data/app/models/concerns/ruby_to_block/block/motion_reach_wall.rb +24 -0
  39. data/app/models/concerns/ruby_to_block/block/motion_rotate_left.rb +20 -0
  40. data/app/models/concerns/ruby_to_block/block/motion_rotate_right.rb +20 -0
  41. data/app/models/concerns/ruby_to_block/block/motion_self_angle.rb +23 -0
  42. data/app/models/concerns/ruby_to_block/block/motion_self_x.rb +23 -0
  43. data/app/models/concerns/ruby_to_block/block/motion_self_y.rb +23 -0
  44. data/app/models/concerns/ruby_to_block/block/motion_set_angle.rb +15 -0
  45. data/app/models/concerns/ruby_to_block/block/motion_set_x.rb +38 -0
  46. data/app/models/concerns/ruby_to_block/block/motion_set_y.rb +15 -0
  47. data/app/models/concerns/ruby_to_block/block/motion_turn.rb +8 -0
  48. data/app/models/concerns/ruby_to_block/block/motion_turn_if_reach_wall.rb +8 -0
  49. data/app/models/concerns/ruby_to_block/block/null.rb +17 -0
  50. data/app/models/concerns/ruby_to_block/block/operators_compare.rb +36 -0
  51. data/app/models/concerns/ruby_to_block/block/operators_false.rb +8 -0
  52. data/app/models/concerns/ruby_to_block/block/operators_true.rb +8 -0
  53. data/app/models/concerns/ruby_to_block/block/require_smalruby.rb +7 -0
  54. data/app/models/concerns/ruby_to_block/block/ruby_comment.rb +16 -0
  55. data/app/models/concerns/ruby_to_block/block/ruby_expression.rb +14 -0
  56. data/app/models/concerns/ruby_to_block/block/ruby_statement.rb +23 -0
  57. data/app/models/concerns/ruby_to_block/block/sensing_hit.rb +23 -0
  58. data/app/models/concerns/ruby_to_block/block/sound_play.rb +15 -0
  59. data/app/models/concerns/ruby_to_block/block/sound_preset_sounds.rb +31 -0
  60. data/app/models/concerns/ruby_to_block/block/text.rb +15 -0
  61. data/app/models/concerns/ruby_to_block/block/value.rb +12 -0
  62. data/app/models/concerns/ruby_to_block/block.rb +97 -0
  63. data/app/models/concerns/ruby_to_block/context.rb +97 -0
  64. data/app/models/concerns/ruby_to_block/formatter.rb +26 -0
  65. data/app/models/concerns/ruby_to_block.rb +17 -360
  66. data/app/models/source_code.rb +3 -1
  67. data/app/views/editor/_toolbox.html.haml +16 -0
  68. data/lib/smalruby_editor/version.rb +3 -3
  69. data/public/assets/{application-64a390efe879c386a5950515064f062d.css → application-28b7bed56c5389dfa372e972c75b6676.css} +17 -10
  70. data/public/assets/application-28b7bed56c5389dfa372e972c75b6676.css.gz +0 -0
  71. data/public/assets/{application-8bfffad1222d4e198f3c7ccc1cbd774f.js → application-4f747690ebc8ec4815ae36021fdb2c44.js} +135 -0
  72. data/public/assets/{application-8bfffad1222d4e198f3c7ccc1cbd774f.js.gz → application-4f747690ebc8ec4815ae36021fdb2c44.js.gz} +0 -0
  73. data/public/assets/manifest-332a5a1668194028b55103e0ea45c054.json +1 -1
  74. data/smalruby-editor.gemspec +1 -1
  75. data/spec/acceptance/block_mode/blocks/hardware/two_wheel_drive_car.feature +69 -0
  76. data/spec/acceptance/ruby_mode/translate.feature +1 -1
  77. data/spec/controllers/source_codes_controller_spec.rb +14 -11
  78. data/spec/models/concerns/ruby_to_block/block/character_method_call_spec.rb +175 -0
  79. data/spec/models/concerns/ruby_to_block/block/control_if_spec.rb +75 -0
  80. data/spec/models/concerns/ruby_to_block/block/control_loop_spec.rb +68 -0
  81. data/spec/models/concerns/ruby_to_block/block/events_on_start_spec.rb +120 -0
  82. data/spec/models/concerns/ruby_to_block/block/hardware_spec.rb +120 -0
  83. data/spec/models/concerns/ruby_to_block/block/looks_say_spec.rb +79 -0
  84. data/spec/models/concerns/ruby_to_block/block/looks_spec.rb +74 -0
  85. data/spec/models/concerns/ruby_to_block/block/motion_move_spec.rb +63 -0
  86. data/spec/models/concerns/ruby_to_block/block/motion_reach_wall_spec.rb +67 -0
  87. data/spec/models/concerns/ruby_to_block/block/motion_spec.rb +392 -0
  88. data/spec/models/concerns/ruby_to_block/block/motion_turn_spec.rb +54 -0
  89. data/spec/models/concerns/ruby_to_block/block/require_smalruby_spec.rb +39 -0
  90. data/spec/models/concerns/ruby_to_block/block/ruby_comment_spec.rb +55 -0
  91. data/spec/models/concerns/ruby_to_block/block/ruby_statement_spec.rb +113 -0
  92. data/spec/models/concerns/ruby_to_block/block/shared/block_examples.rb +44 -0
  93. data/spec/models/concerns/ruby_to_block/block/sound_spec.rb +46 -0
  94. data/spec/models/concerns/ruby_to_block/block_spec.rb +49 -0
  95. data/spec/models/concerns/ruby_to_block_spec.rb +421 -217
  96. data/spec/support/ruby_to_block.rb +10 -0
  97. metadata +108 -10
  98. data/public/assets/application-64a390efe879c386a5950515064f062d.css.gz +0 -0
@@ -0,0 +1,79 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'spec_helper'
3
+ require_relative 'shared/block_examples'
4
+
5
+ # rubocop:disable EmptyLines, LineLength
6
+
7
+ describe RubyToBlock::Block::LooksSay, to_blocks: true do
8
+ parts = <<-EOS
9
+ say(message: "こんにちは")
10
+ EOS
11
+ describe compact_source_code(parts), on_start_data: true do
12
+ _parts = parts
13
+ let(:parts) { _parts }
14
+
15
+ it '結果が正しいこと' do
16
+ should eq_block_xml(<<-XML)
17
+ <block type="looks_say" inline="true">
18
+ <value name="TEXT">
19
+ <block type="text">
20
+ <field name="TEXT">こんにちは</field>
21
+ </block>
22
+ </value>
23
+ </block>
24
+ XML
25
+ end
26
+ end
27
+
28
+ parts = <<-EOS
29
+ car1.say(message: "こんにちは")
30
+ EOS
31
+ describe compact_source_code(parts), character_new_data: true do
32
+ _parts = parts
33
+ let(:parts) { _parts }
34
+
35
+ it '結果が正しいこと' do
36
+ should eq_block_xml(<<-XML)
37
+ <block type="looks_say" inline="true">
38
+ <value name="TEXT">
39
+ <block type="text">
40
+ <field name="TEXT">こんにちは</field>
41
+ </block>
42
+ </value>
43
+ </block>
44
+ XML
45
+ end
46
+ end
47
+
48
+ parts = <<-EOS
49
+ say(message: "こんにちは")
50
+ EOS
51
+ describe compact_source_code(parts) do
52
+ _parts = parts
53
+ let(:data) { _parts }
54
+
55
+ it '結果が正しいこと' do
56
+ should eq_block_xml(<<-XML)
57
+ <block type="ruby_statement">
58
+ <field name="STATEMENT">say(message: &quot;こんにちは&quot;)</field>
59
+ </block>
60
+ XML
61
+ end
62
+ end
63
+
64
+ parts = <<-EOS
65
+ self.say(message: "こんにちは")
66
+ EOS
67
+ describe compact_source_code(parts) do
68
+ _parts = parts
69
+ let(:data) { _parts }
70
+
71
+ it '結果が正しいこと' do
72
+ should eq_block_xml(<<-XML)
73
+ <block type="ruby_statement">
74
+ <field name="STATEMENT">self.say(message: &quot;こんにちは&quot;)</field>
75
+ </block>
76
+ XML
77
+ end
78
+ end
79
+ end
@@ -0,0 +1,74 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'spec_helper'
3
+ require_relative 'shared/block_examples'
4
+
5
+ # rubocop:disable EmptyLines, LineLength
6
+
7
+ describe RubyToBlock::Block, '見た目ジャンル', to_blocks: true do
8
+ parts = <<-EOS
9
+ car1.on(:start) do
10
+ say(message: "こんにちは!")
11
+ self.visible = true
12
+ self.visible = false
13
+ vanish
14
+ end
15
+ car1.say(message: "こんにちは!")
16
+ car1.visible = true
17
+ car1.visible = false
18
+ car1.vanish
19
+ EOS
20
+ describe compact_source_code(parts), character_new_data: true do
21
+ _parts = parts
22
+ let(:parts) { _parts }
23
+
24
+ it '結果が正しいこと' do
25
+ should eq_block_xml(<<-XML)
26
+ <field name="NAME">car1</field>
27
+ <statement name="DO">
28
+ <block type="events_on_start">
29
+ <statement name="DO">
30
+ <block type="looks_say" inline="true">
31
+ <value name="TEXT">
32
+ <block type="text">
33
+ <field name="TEXT">こんにちは!</field>
34
+ </block>
35
+ </value>
36
+ <next>
37
+ <block type="looks_show">
38
+ <next>
39
+ <block type="looks_hide">
40
+ <next>
41
+ <block type="looks_vanish" />
42
+ </next>
43
+ </block>
44
+ </next>
45
+ </block>
46
+ </next>
47
+ </block>
48
+ </statement>
49
+ <next>
50
+ <block type="looks_say" inline="true">
51
+ <value name="TEXT">
52
+ <block type="text">
53
+ <field name="TEXT">こんにちは!</field>
54
+ </block>
55
+ </value>
56
+ <next>
57
+ <block type="looks_show">
58
+ <next>
59
+ <block type="looks_hide">
60
+ <next>
61
+ <block type="looks_vanish" />
62
+ </next>
63
+ </block>
64
+ </next>
65
+ </block>
66
+ </next>
67
+ </block>
68
+ </next>
69
+ </block>
70
+ </statement>
71
+ XML
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,63 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'spec_helper'
3
+ require_relative 'shared/block_examples'
4
+
5
+ # rubocop:disable EmptyLines, LineLength
6
+
7
+ describe RubyToBlock::Block::MotionMove, to_blocks: true do
8
+ parts = <<-EOS
9
+ move(6)
10
+ EOS
11
+ describe compact_source_code(parts), on_start_data: true do
12
+ _parts = parts
13
+ let(:parts) { _parts }
14
+
15
+ it '結果が正しいこと' do
16
+ should eq_block_xml(<<-XML)
17
+ <block type="motion_move" inline="true">
18
+ <value name="STEP">
19
+ <block type="math_number">
20
+ <field name="NUM">6</field>
21
+ </block>
22
+ </value>
23
+ </block>
24
+ XML
25
+ end
26
+ end
27
+
28
+ parts = <<-EOS
29
+ car1.move(6)
30
+ EOS
31
+ describe compact_source_code(parts), character_new_data: true do
32
+ _parts = parts
33
+ let(:parts) { _parts }
34
+
35
+ it '結果が正しいこと' do
36
+ should eq_block_xml(<<-XML)
37
+ <block type="motion_move" inline="true">
38
+ <value name="STEP">
39
+ <block type="math_number">
40
+ <field name="NUM">6</field>
41
+ </block>
42
+ </value>
43
+ </block>
44
+ XML
45
+ end
46
+ end
47
+
48
+ parts = <<-EOS
49
+ move(6)
50
+ EOS
51
+ describe compact_source_code(parts) do
52
+ _parts = parts
53
+ let(:data) { _parts }
54
+
55
+ it '結果が正しいこと' do
56
+ should eq_block_xml(<<-XML)
57
+ <block type="ruby_statement">
58
+ <field name="STATEMENT">move(6)</field>
59
+ </block>
60
+ XML
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,67 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'spec_helper'
3
+ require_relative 'shared/block_examples'
4
+
5
+ # rubocop:disable EmptyLines, LineLength
6
+
7
+ describe RubyToBlock::Block::MotionReachWall, to_blocks: true do
8
+ parts = <<-EOS
9
+ if reach_wall?
10
+
11
+ end
12
+ EOS
13
+ describe compact_source_code(parts), on_start_data: true do
14
+ _parts = parts
15
+ let(:parts) { _parts }
16
+
17
+ it '結果が正しいこと' do
18
+ should eq_block_xml(<<-XML)
19
+ <block type="control_if" inline="true">
20
+ <value name="COND">
21
+ <block type="motion_reach_wall" />
22
+ </value>
23
+ </block>
24
+ XML
25
+ end
26
+ end
27
+
28
+ parts = <<-EOS
29
+ if car1.reach_wall?
30
+
31
+ end
32
+ EOS
33
+ describe compact_source_code(parts), character_new_data: true do
34
+ _parts = parts
35
+ let(:parts) { _parts }
36
+
37
+ it '結果が正しいこと' do
38
+ should eq_block_xml(<<-XML)
39
+ <block type="ruby_expression">
40
+ <field name="EXP">car1.reach_wall?</field>
41
+ </block>
42
+ XML
43
+ end
44
+ end
45
+
46
+ parts = <<-EOS
47
+ if reach_wall?
48
+
49
+ end
50
+ EOS
51
+ describe compact_source_code(parts) do
52
+ _parts = parts
53
+ let(:data) { _parts }
54
+
55
+ it '結果が正しいこと' do
56
+ should eq_block_xml(<<-XML)
57
+ <block type="control_if" inline="true">
58
+ <value name="COND">
59
+ <block type="ruby_expression">
60
+ <field name="EXP">reach_wall?</field>
61
+ </block>
62
+ </value>
63
+ </block>
64
+ XML
65
+ end
66
+ end
67
+ end
@@ -0,0 +1,392 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'spec_helper'
3
+ require_relative 'shared/block_examples'
4
+
5
+ # rubocop:disable EmptyLines, LineLength
6
+
7
+ describe RubyToBlock::Block, '移動・回転ジャンル', to_blocks: true do
8
+ parts = <<-EOS
9
+ car1.on(:start) do
10
+ move(10)
11
+ self.x = 0
12
+ self.y = 0
13
+ self.x += 10
14
+ self.x = 0
15
+ self.y += 10
16
+ self.y = 0
17
+ if x < 300
18
+ if y < 300
19
+
20
+ end
21
+ end
22
+ end
23
+ car1.move(10)
24
+ car1.x = 0
25
+ car1.y = 0
26
+ car1.x += 10
27
+ car1.x = 0
28
+ car1.y += 10
29
+ car1.y = 0
30
+ EOS
31
+ describe compact_source_code(parts), character_new_data: true do
32
+ _parts = parts
33
+ let(:parts) { _parts }
34
+
35
+ it '結果が正しいこと' do
36
+ should eq_block_xml(<<-XML)
37
+ <field name="NAME">car1</field>
38
+ <statement name="DO">
39
+ <block type="events_on_start">
40
+ <statement name="DO">
41
+ <block type="motion_move" inline="true">
42
+ <value name="STEP">
43
+ <block type="math_number">
44
+ <field name="NUM">10</field>
45
+ </block>
46
+ </value>
47
+ <next>
48
+ <block type="motion_set_x_y" inline="true">
49
+ <value name="X">
50
+ <block type="math_number">
51
+ <field name="NUM">0</field>
52
+ </block>
53
+ </value>
54
+ <value name="Y">
55
+ <block type="math_number">
56
+ <field name="NUM">0</field>
57
+ </block>
58
+ </value>
59
+ <next>
60
+ <block type="motion_change_x_by" inline="true">
61
+ <value name="X">
62
+ <block type="math_number">
63
+ <field name="NUM">10</field>
64
+ </block>
65
+ </value>
66
+ <next>
67
+ <block type="motion_set_x" inline="true">
68
+ <value name="X">
69
+ <block type="math_number">
70
+ <field name="NUM">0</field>
71
+ </block>
72
+ </value>
73
+ <next>
74
+ <block type="motion_change_y_by" inline="true">
75
+ <value name="Y">
76
+ <block type="math_number">
77
+ <field name="NUM">10</field>
78
+ </block>
79
+ </value>
80
+ <next>
81
+ <block type="motion_set_y" inline="true">
82
+ <value name="Y">
83
+ <block type="math_number">
84
+ <field name="NUM">0</field>
85
+ </block>
86
+ </value>
87
+ <next>
88
+ <block type="control_if" inline="true">
89
+ <value name="COND">
90
+ <block type="operators_compare_lt" inline="true">
91
+ <value name="A">
92
+ <block type="motion_self_x" />
93
+ </value>
94
+ <value name="B">
95
+ <block type="math_number">
96
+ <field name="NUM">300</field>
97
+ </block>
98
+ </value>
99
+ </block>
100
+ </value>
101
+ <statement name="THEN">
102
+ <block type="control_if" inline="true">
103
+ <value name="COND">
104
+ <block type="operators_compare_lt" inline="true">
105
+ <value name="A">
106
+ <block type="motion_self_y" />
107
+ </value>
108
+ <value name="B">
109
+ <block type="math_number">
110
+ <field name="NUM">300</field>
111
+ </block>
112
+ </value>
113
+ </block>
114
+ </value>
115
+ </block>
116
+ </statement>
117
+ </block>
118
+ </next>
119
+ </block>
120
+ </next>
121
+ </block>
122
+ </next>
123
+ </block>
124
+ </next>
125
+ </block>
126
+ </next>
127
+ </block>
128
+ </next>
129
+ </block>
130
+ </statement>
131
+ <next>
132
+ <block type="motion_move" inline="true">
133
+ <value name="STEP">
134
+ <block type="math_number">
135
+ <field name="NUM">10</field>
136
+ </block>
137
+ </value>
138
+ <next>
139
+ <block type="motion_set_x_y" inline="true">
140
+ <value name="X">
141
+ <block type="math_number">
142
+ <field name="NUM">0</field>
143
+ </block>
144
+ </value>
145
+ <value name="Y">
146
+ <block type="math_number">
147
+ <field name="NUM">0</field>
148
+ </block>
149
+ </value>
150
+ <next>
151
+ <block type="motion_change_x_by" inline="true">
152
+ <value name="X">
153
+ <block type="math_number">
154
+ <field name="NUM">10</field>
155
+ </block>
156
+ </value>
157
+ <next>
158
+ <block type="motion_set_x" inline="true">
159
+ <value name="X">
160
+ <block type="math_number">
161
+ <field name="NUM">0</field>
162
+ </block>
163
+ </value>
164
+ <next>
165
+ <block type="motion_change_y_by" inline="true">
166
+ <value name="Y">
167
+ <block type="math_number">
168
+ <field name="NUM">10</field>
169
+ </block>
170
+ </value>
171
+ <next>
172
+ <block type="motion_set_y" inline="true">
173
+ <value name="Y">
174
+ <block type="math_number">
175
+ <field name="NUM">0</field>
176
+ </block>
177
+ </value>
178
+ </block>
179
+ </next>
180
+ </block>
181
+ </next>
182
+ </block>
183
+ </next>
184
+ </block>
185
+ </next>
186
+ </block>
187
+ </next>
188
+ </block>
189
+ </next>
190
+ </block>
191
+ </statement>
192
+ XML
193
+ end
194
+ end
195
+
196
+ parts = <<-EOS
197
+ car1.move(10)
198
+ car1.x = 0
199
+ car1.y = 0
200
+ car1.x += 10
201
+ EOS
202
+ describe compact_source_code(parts), character_new_data: true do
203
+ _parts = parts
204
+ let(:parts) { _parts }
205
+
206
+ it '結果が正しいこと' do
207
+ should eq_block_xml(<<-XML)
208
+ <field name="NAME">car1</field>
209
+ <statement name="DO">
210
+ <block type="motion_move" inline="true">
211
+ <value name="STEP">
212
+ <block type="math_number">
213
+ <field name="NUM">10</field>
214
+ </block>
215
+ </value>
216
+ <next>
217
+ <block type="motion_set_x_y" inline="true">
218
+ <value name="X">
219
+ <block type="math_number">
220
+ <field name="NUM">0</field>
221
+ </block>
222
+ </value>
223
+ <value name="Y">
224
+ <block type="math_number">
225
+ <field name="NUM">0</field>
226
+ </block>
227
+ </value>
228
+ <next>
229
+ <block type="motion_change_x_by" inline="true">
230
+ <value name="X">
231
+ <block type="math_number">
232
+ <field name="NUM">10</field>
233
+ </block>
234
+ </value>
235
+ </block>
236
+ </next>
237
+ </block>
238
+ </next>
239
+ </block>
240
+ </statement>
241
+ XML
242
+ end
243
+ end
244
+
245
+ parts = <<-EOS
246
+ car1.on(:start) do
247
+ turn_if_reach_wall
248
+ if reach_wall?
249
+ turn
250
+ end
251
+ rotate(15)
252
+ rotate(-15)
253
+ self.angle = 90
254
+ point_towards(:mouse)
255
+ point_towards(car1)
256
+ if angle < 90
257
+
258
+ end
259
+ end
260
+ car1.turn_if_reach_wall
261
+ car1.turn
262
+ car1.rotate(15)
263
+ car1.rotate(-15)
264
+ car1.angle = 90
265
+ car1.point_towards(:mouse)
266
+ car1.point_towards(car1)
267
+ EOS
268
+ describe compact_source_code(parts), character_new_data: true do
269
+ _parts = parts
270
+ let(:parts) { _parts }
271
+
272
+ it '結果が正しいこと' do
273
+ should eq_block_xml(<<-XML)
274
+ <field name="NAME">car1</field>
275
+ <statement name="DO">
276
+ <block type="events_on_start">
277
+ <statement name="DO">
278
+ <block type="motion_turn_if_reach_wall">
279
+ <next>
280
+ <block type="control_if" inline="true">
281
+ <value name="COND">
282
+ <block type="motion_reach_wall" />
283
+ </value>
284
+ <statement name="THEN">
285
+ <block type="motion_turn" />
286
+ </statement>
287
+ <next>
288
+ <block type="motion_rotate_right" inline="true">
289
+ <value name="ANGLE">
290
+ <block type="math_number">
291
+ <field name="NUM">15</field>
292
+ </block>
293
+ </value>
294
+ <next>
295
+ <block type="motion_rotate_left" inline="true">
296
+ <value name="ANGLE">
297
+ <block type="math_number">
298
+ <field name="NUM">15</field>
299
+ </block>
300
+ </value>
301
+ <next>
302
+ <block type="motion_set_angle" inline="true">
303
+ <value name="ANGLE">
304
+ <block type="math_number">
305
+ <field name="NUM">90</field>
306
+ </block>
307
+ </value>
308
+ <next>
309
+ <block type="motion_point_towards_mouse">
310
+ <next>
311
+ <block type="motion_point_towards_character">
312
+ <field name="CHAR">car1</field>
313
+ <next>
314
+ <block type="control_if" inline="true">
315
+ <value name="COND">
316
+ <block type="operators_compare_lt" inline="true">
317
+ <value name="A">
318
+ <block type="motion_self_angle" />
319
+ </value>
320
+ <value name="B">
321
+ <block type="math_number">
322
+ <field name="NUM">90</field>
323
+ </block>
324
+ </value>
325
+ </block>
326
+ </value>
327
+ </block>
328
+ </next>
329
+ </block>
330
+ </next>
331
+ </block>
332
+ </next>
333
+ </block>
334
+ </next>
335
+ </block>
336
+ </next>
337
+ </block>
338
+ </next>
339
+ </block>
340
+ </next>
341
+ </block>
342
+ </statement>
343
+ <next>
344
+ <block type="motion_turn_if_reach_wall">
345
+ <next>
346
+ <block type="motion_turn">
347
+ <next>
348
+ <block type="motion_rotate_right" inline="true">
349
+ <value name="ANGLE">
350
+ <block type="math_number">
351
+ <field name="NUM">15</field>
352
+ </block>
353
+ </value>
354
+ <next>
355
+ <block type="motion_rotate_left" inline="true">
356
+ <value name="ANGLE">
357
+ <block type="math_number">
358
+ <field name="NUM">15</field>
359
+ </block>
360
+ </value>
361
+ <next>
362
+ <block type="motion_set_angle" inline="true">
363
+ <value name="ANGLE">
364
+ <block type="math_number">
365
+ <field name="NUM">90</field>
366
+ </block>
367
+ </value>
368
+ <next>
369
+ <block type="motion_point_towards_mouse">
370
+ <next>
371
+ <block type="motion_point_towards_character">
372
+ <field name="CHAR">car1</field>
373
+ </block>
374
+ </next>
375
+ </block>
376
+ </next>
377
+ </block>
378
+ </next>
379
+ </block>
380
+ </next>
381
+ </block>
382
+ </next>
383
+ </block>
384
+ </next>
385
+ </block>
386
+ </next>
387
+ </block>
388
+ </statement>
389
+ XML
390
+ end
391
+ end
392
+ end