sashite-ggn 0.0.1 → 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (69) hide show
  1. checksums.yaml +4 -4
  2. data/README.md +523 -521
  3. data/VERSION.semver +1 -1
  4. data/lib/sashite/ggn.rb +3 -2
  5. data/lib/sashite/ggn/ability.rb +11 -19
  6. data/lib/sashite/ggn/actor.rb +5 -13
  7. data/lib/sashite/ggn/ally.rb +6 -14
  8. data/lib/sashite/ggn/area.rb +6 -14
  9. data/lib/sashite/ggn/attacked.rb +6 -14
  10. data/lib/sashite/ggn/boolean.rb +6 -14
  11. data/lib/sashite/ggn/digit.rb +6 -14
  12. data/lib/sashite/ggn/digit_excluding_zero.rb +6 -14
  13. data/lib/sashite/ggn/direction.rb +6 -14
  14. data/lib/sashite/ggn/gameplay.rb +8 -28
  15. data/lib/sashite/ggn/gameplay_into_base64.rb +7 -14
  16. data/lib/sashite/ggn/integer.rb +6 -14
  17. data/lib/sashite/ggn/last_moved_actor.rb +6 -14
  18. data/lib/sashite/ggn/maximum_magnitude.rb +6 -14
  19. data/lib/sashite/ggn/name.rb +6 -14
  20. data/lib/sashite/ggn/negative_integer.rb +6 -14
  21. data/lib/sashite/ggn/null.rb +7 -9
  22. data/lib/sashite/ggn/object.rb +11 -19
  23. data/lib/sashite/ggn/occupied.rb +12 -20
  24. data/lib/sashite/ggn/pattern.rb +7 -16
  25. data/lib/sashite/ggn/previous_moves_counter.rb +6 -14
  26. data/lib/sashite/ggn/promotable_into_actors.rb +8 -17
  27. data/lib/sashite/ggn/required.rb +6 -14
  28. data/lib/sashite/ggn/self.rb +7 -9
  29. data/lib/sashite/ggn/square.rb +11 -19
  30. data/lib/sashite/ggn/state.rb +9 -17
  31. data/lib/sashite/ggn/subject.rb +11 -19
  32. data/lib/sashite/ggn/unsigned_integer.rb +6 -14
  33. data/lib/sashite/ggn/unsigned_integer_excluding_zero.rb +5 -13
  34. data/lib/sashite/ggn/verb.rb +15 -24
  35. data/lib/sashite/ggn/zero.rb +7 -9
  36. data/sashite-ggn.gemspec +2 -4
  37. data/test/test_ggn.rb +501 -495
  38. data/test/test_ggn_ability.rb +10 -10
  39. data/test/test_ggn_actor.rb +516 -536
  40. data/test/test_ggn_ally.rb +13 -29
  41. data/test/test_ggn_area.rb +9 -67
  42. data/test/test_ggn_attacked.rb +13 -29
  43. data/test/test_ggn_boolean.rb +10 -26
  44. data/test/test_ggn_digit.rb +10 -10
  45. data/test/test_ggn_digit_excluding_zero.rb +10 -11
  46. data/test/test_ggn_direction.rb +10 -10
  47. data/test/test_ggn_gameplay.rb +22 -38
  48. data/test/test_ggn_gameplay_into_base64.rb +511 -501
  49. data/test/test_ggn_integer.rb +19 -21
  50. data/test/test_ggn_last_moved_actor.rb +13 -29
  51. data/test/test_ggn_maximum_magnitude.rb +18 -16
  52. data/test/test_ggn_name.rb +9 -39
  53. data/test/test_ggn_negative_integer.rb +10 -10
  54. data/test/test_ggn_null.rb +10 -10
  55. data/test/test_ggn_object.rb +22 -24
  56. data/test/test_ggn_occupied.rb +40 -64
  57. data/test/test_ggn_pattern.rb +12 -10
  58. data/test/test_ggn_previous_moves_counter.rb +18 -20
  59. data/test/test_ggn_promotable_into_actors.rb +529 -549
  60. data/test/test_ggn_required.rb +10 -26
  61. data/test/test_ggn_self.rb +10 -10
  62. data/test/test_ggn_square.rb +14 -16
  63. data/test/test_ggn_state.rb +15 -19
  64. data/test/test_ggn_subject.rb +17 -19
  65. data/test/test_ggn_unsigned_integer.rb +30 -12
  66. data/test/test_ggn_unsigned_integer_excluding_zero.rb +14 -10
  67. data/test/test_ggn_verb.rb +16 -15
  68. data/test/test_ggn_zero.rb +10 -10
  69. metadata +4 -18
@@ -1,13 +1,16 @@
1
1
  require_relative '_test_helper'
2
2
 
3
3
  describe Sashite::GGN::Pattern do
4
- describe '.new' do
4
+ subject { Sashite::GGN::Pattern }
5
+
6
+ describe '.load' do
5
7
  before do
6
- @pattern = Sashite::GGN::Pattern.new('t<self>_&_^shift[-1,0]_/t=_@f+all~_@f+all%self; t<self>_&_^remove[-1,0]1/t=_@f+all~_@an_enemy_actor+all%self')
8
+ @ggn_obj = 't<self>_&_^shift[-1,0]_/t=_@f+all~_@f+all%self; ' +
9
+ 't<self>_&_^remove[-1,0]1/t=_@f+all~_@an_enemy_actor+all%self'
7
10
  end
8
11
 
9
- it 'returns the GGN as a JSON' do
10
- @pattern.as_json.hash.must_equal(
12
+ it 'loads a document from the current io stream' do
13
+ subject.load(@ggn_obj).hash.must_equal(
11
14
  [
12
15
  {
13
16
  :"subject" => {
@@ -71,12 +74,11 @@ describe Sashite::GGN::Pattern do
71
74
  )
72
75
  end
73
76
 
74
- it 'returns the GGN as a string' do
75
- @pattern.to_s.must_equal 't<self>_&_^shift[-1,0]_/t=_@f+all~_@f+all%self; t<self>_&_^remove[-1,0]1/t=_@f+all~_@an_enemy_actor+all%self'
77
+ describe 'errors' do
78
+ it 'raises with several identical patterns' do
79
+ -> { subject.load 't<self>_&_^shift[-1,0]_/t=_@f+all~_@f+all%self; ' +
80
+ 't<self>_&_^shift[-1,0]_/t=_@f+all~_@f+all%self' }.must_raise ArgumentError
81
+ end
76
82
  end
77
83
  end
78
-
79
- it 'raises an error' do
80
- -> { Sashite::GGN::Pattern.new('foobar') }.must_raise ArgumentError
81
- end
82
84
  end
@@ -1,40 +1,38 @@
1
1
  require_relative '_test_helper'
2
2
 
3
3
  describe Sashite::GGN::PreviousMovesCounter do
4
- describe '.new' do
4
+ subject { Sashite::GGN::PreviousMovesCounter }
5
+
6
+ describe '.load' do
5
7
  describe 'null' do
6
8
  before do
7
- @previous_moves_counter = Sashite::GGN::PreviousMovesCounter.new('_')
8
- end
9
-
10
- it 'returns the GGN as a JSON' do
11
- @previous_moves_counter.as_json.must_equal nil
9
+ @ggn_obj = '_'
12
10
  end
13
11
 
14
- it 'returns the GGN as a string' do
15
- @previous_moves_counter.to_s.must_equal '_'
12
+ it 'loads a document from the current io stream' do
13
+ subject.load(@ggn_obj).must_equal nil
16
14
  end
17
15
 
18
- it 'raises an error' do
19
- -> { Sashite::GGN::PreviousMovesCounter.new('foobar') }.must_raise ArgumentError
16
+ describe 'errors' do
17
+ it 'raises without null' do
18
+ -> { subject.load '' }.must_raise ArgumentError
19
+ end
20
20
  end
21
21
  end
22
22
 
23
- describe 'unsigned integer' do
23
+ describe 'an unsigned integer' do
24
24
  before do
25
- @previous_moves_counter = Sashite::GGN::PreviousMovesCounter.new('42')
26
- end
27
-
28
- it 'returns the GGN as a JSON' do
29
- @previous_moves_counter.as_json.must_equal 42
25
+ @ggn_obj = '0'
30
26
  end
31
27
 
32
- it 'returns the GGN as a string' do
33
- @previous_moves_counter.to_s.must_equal '42'
28
+ it 'loads a document from the current io stream' do
29
+ subject.load(@ggn_obj).must_equal 0
34
30
  end
35
31
 
36
- it 'raises an error' do
37
- -> { Sashite::GGN::PreviousMovesCounter.new('-42') }.must_raise ArgumentError
32
+ describe 'errors' do
33
+ it 'raises with a negative integer' do
34
+ -> { subject.load '-4' }.must_raise ArgumentError
35
+ end
38
36
  end
39
37
  end
40
38
  end
@@ -1,598 +1,578 @@
1
1
  require_relative '_test_helper'
2
2
 
3
3
  describe Sashite::GGN::PromotableIntoActors do
4
- describe '.new' do
5
- describe 'self' do
6
- before do
7
- @promotable_into_actors = Sashite::GGN::PromotableIntoActors.new('self')
8
- end
9
-
10
- it 'returns the GGN as a JSON' do
11
- @promotable_into_actors.as_json.hash.must_equal [:self].hash
12
- end
13
-
14
- it 'returns the GGN as a string' do
15
- @promotable_into_actors.to_s.must_equal 'self'
16
- end
17
-
18
- it 'raises an error' do
19
- -> { Sashite::GGN::PromotableIntoActors.new('foobar') }.must_raise ArgumentError
20
- end
21
- end
4
+ subject { Sashite::GGN::PromotableIntoActors }
22
5
 
6
+ describe '.load' do
23
7
  describe 'gameplay into base64 and self' do
24
8
  before do
25
- @promotable_into_actors = Sashite::GGN::PromotableIntoActors.new(
26
- 'dDxzZWxmPl8mX15yZW1vdmVbLTEsMF0xL3Q9X0BmK2FsbH5fQGFu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2hpZnRbMCwxXV8vdD1fQGYrYWxsfl9AZith' +
19
+ 'bGwlc2VsZi4gdDxzZWxmPl8mX15zaGlmdFswLDFdXy90PV9AZithbGx+X0BmK2FsbCVzZWxmOyB0PHNl' +
20
+ 'bGY+XyZfXnJlbW92ZVswLDFdMS90PV9AZithbGx+X0Bhbl9lbmVteV9hY3RvcithbGwlc2VsZi4gdDxz' +
21
+ 'ZWxmPl8mX15zaGlmdFsxLDBdXy90PV9AZithbGx+X0BmK2FsbCVzZWxmLiB0PHNlbGY+XyZfXnNoaWZ0' +
22
+ 'WzEsMF1fL3Q9X0BmK2FsbH5fQGYrYWxsJXNlbGY7IHQ8c2VsZj5fJl9ecmVtb3ZlWzEsMF0xL3Q9X0Bm' +
23
+ 'K2FsbH5fQGFuX2VuZW15X2FjdG9yK2FsbCVzZWxmLg==,self'
41
24
  end
42
25
 
43
- it 'returns the GGN as a JSON' do
44
- @promotable_into_actors.as_json.hash.must_equal(
26
+ it 'loads a document from the current io stream' do
27
+ subject.load(@ggn_obj).hash.must_equal [
45
28
  [
46
29
  [
47
- [
48
- {
49
- :"subject" => {
50
- :"...ally?" => true,
51
- :"actor" => :self,
52
- :"state" => {
53
- :"...last_moved_actor?" => nil,
54
- :"...previous_moves_counter" => nil
55
- }
56
- },
57
-
58
- :"verb" => {
59
- :"name" => :remove,
60
- :"vector" => {:"...maximum_magnitude" => 1, direction: [-1,0]}
61
- },
62
-
63
- :"object" => {
64
- :"src_square" => {
65
- :"...attacked?" => nil,
66
- :"...occupied!" => false,
67
- :"area" => :all
68
- },
69
- :"dst_square" => {
70
- :"...attacked?" => nil,
71
- :"...occupied!" => :an_enemy_actor,
72
- :"area" => :all
73
- },
74
- :"promotable_into_actors" => [:self]
30
+ {
31
+ :"subject" => {
32
+ :"...ally?" => true,
33
+ :"actor" => :self,
34
+ :"state" => {
35
+ :"...last_moved_actor?" => nil,
36
+ :"...previous_moves_counter" => nil
75
37
  }
38
+ },
39
+
40
+ :"verb" => {
41
+ :"name" => :remove,
42
+ :"vector" => {:"...maximum_magnitude" => 1, direction: [-1,0]}
43
+ },
44
+
45
+ :"object" => {
46
+ :"src_square" => {
47
+ :"...attacked?" => nil,
48
+ :"...occupied!" => false,
49
+ :"area" => :all
50
+ },
51
+ :"dst_square" => {
52
+ :"...attacked?" => nil,
53
+ :"...occupied!" => :an_enemy_actor,
54
+ :"area" => :all
55
+ },
56
+ :"promotable_into_actors" => [:self]
76
57
  }
77
- ],
78
-
79
-
80
-
81
- [
82
- {
83
- :"subject" => {
84
- :"...ally?" => true,
85
- :"actor" => :self,
86
- :"state" => {
87
- :"...last_moved_actor?" => nil,
88
- :"...previous_moves_counter" => nil
89
- }
90
- },
91
-
92
- :"verb" => {
93
- :"name" => :remove,
94
- :"vector" => {:"...maximum_magnitude" => 1, direction: [0,-1]}
95
- },
96
-
97
- :"object" => {
98
- :"src_square" => {
99
- :"...attacked?" => nil,
100
- :"...occupied!" => false,
101
- :"area" => :all
102
- },
103
- :"dst_square" => {
104
- :"...attacked?" => nil,
105
- :"...occupied!" => :an_enemy_actor,
106
- :"area" => :all
107
- },
108
- :"promotable_into_actors" => [:self]
58
+ }
59
+ ],
60
+
61
+
62
+
63
+ [
64
+ {
65
+ :"subject" => {
66
+ :"...ally?" => true,
67
+ :"actor" => :self,
68
+ :"state" => {
69
+ :"...last_moved_actor?" => nil,
70
+ :"...previous_moves_counter" => nil
109
71
  }
72
+ },
73
+
74
+ :"verb" => {
75
+ :"name" => :remove,
76
+ :"vector" => {:"...maximum_magnitude" => 1, direction: [0,-1]}
77
+ },
78
+
79
+ :"object" => {
80
+ :"src_square" => {
81
+ :"...attacked?" => nil,
82
+ :"...occupied!" => false,
83
+ :"area" => :all
84
+ },
85
+ :"dst_square" => {
86
+ :"...attacked?" => nil,
87
+ :"...occupied!" => :an_enemy_actor,
88
+ :"area" => :all
89
+ },
90
+ :"promotable_into_actors" => [:self]
110
91
  }
111
- ],
112
-
113
-
114
-
115
- [
116
- {
117
- :"subject" => {
118
- :"...ally?" => true,
119
- :"actor" => :self,
120
- :"state" => {
121
- :"...last_moved_actor?" => nil,
122
- :"...previous_moves_counter" => nil
123
- }
124
- },
125
-
126
- :"verb" => {
127
- :"name" => :remove,
128
- :"vector" => {:"...maximum_magnitude" => 1, direction: [0,1]}
129
- },
130
-
131
- :"object" => {
132
- :"src_square" => {
133
- :"...attacked?" => nil,
134
- :"...occupied!" => false,
135
- :"area" => :all
136
- },
137
- :"dst_square" => {
138
- :"...attacked?" => nil,
139
- :"...occupied!" => :an_enemy_actor,
140
- :"area" => :all
141
- },
142
- :"promotable_into_actors" => [:self]
92
+ }
93
+ ],
94
+
95
+
96
+
97
+ [
98
+ {
99
+ :"subject" => {
100
+ :"...ally?" => true,
101
+ :"actor" => :self,
102
+ :"state" => {
103
+ :"...last_moved_actor?" => nil,
104
+ :"...previous_moves_counter" => nil
143
105
  }
106
+ },
107
+
108
+ :"verb" => {
109
+ :"name" => :remove,
110
+ :"vector" => {:"...maximum_magnitude" => 1, direction: [0,1]}
111
+ },
112
+
113
+ :"object" => {
114
+ :"src_square" => {
115
+ :"...attacked?" => nil,
116
+ :"...occupied!" => false,
117
+ :"area" => :all
118
+ },
119
+ :"dst_square" => {
120
+ :"...attacked?" => nil,
121
+ :"...occupied!" => :an_enemy_actor,
122
+ :"area" => :all
123
+ },
124
+ :"promotable_into_actors" => [:self]
144
125
  }
145
- ],
146
-
147
-
148
-
149
- [
150
- {
151
- :"subject" => {
152
- :"...ally?" => true,
153
- :"actor" => :self,
154
- :"state" => {
155
- :"...last_moved_actor?" => nil,
156
- :"...previous_moves_counter" => nil
157
- }
158
- },
159
-
160
- :"verb" => {
161
- :"name" => :remove,
162
- :"vector" => {:"...maximum_magnitude" => 1, direction: [1,0]}
163
- },
164
-
165
- :"object" => {
166
- :"src_square" => {
167
- :"...attacked?" => nil,
168
- :"...occupied!" => false,
169
- :"area" => :all
170
- },
171
- :"dst_square" => {
172
- :"...attacked?" => nil,
173
- :"...occupied!" => :an_enemy_actor,
174
- :"area" => :all
175
- },
176
- :"promotable_into_actors" => [:self]
126
+ }
127
+ ],
128
+
129
+
130
+
131
+ [
132
+ {
133
+ :"subject" => {
134
+ :"...ally?" => true,
135
+ :"actor" => :self,
136
+ :"state" => {
137
+ :"...last_moved_actor?" => nil,
138
+ :"...previous_moves_counter" => nil
177
139
  }
140
+ },
141
+
142
+ :"verb" => {
143
+ :"name" => :remove,
144
+ :"vector" => {:"...maximum_magnitude" => 1, direction: [1,0]}
145
+ },
146
+
147
+ :"object" => {
148
+ :"src_square" => {
149
+ :"...attacked?" => nil,
150
+ :"...occupied!" => false,
151
+ :"area" => :all
152
+ },
153
+ :"dst_square" => {
154
+ :"...attacked?" => nil,
155
+ :"...occupied!" => :an_enemy_actor,
156
+ :"area" => :all
157
+ },
158
+ :"promotable_into_actors" => [:self]
178
159
  }
179
- ],
180
-
181
-
182
-
183
- [
184
- {
185
- :"subject" => {
186
- :"...ally?" => true,
187
- :"actor" => :self,
188
- :"state" => {
189
- :"...last_moved_actor?" => nil,
190
- :"...previous_moves_counter" => nil
191
- }
192
- },
193
-
194
- :"verb" => {
195
- :"name" => :shift,
196
- :"vector" => {:"...maximum_magnitude" => nil, direction: [-1,0]}
197
- },
198
-
199
- :"object" => {
200
- :"src_square" => {
201
- :"...attacked?" => nil,
202
- :"...occupied!" => false,
203
- :"area" => :all
204
- },
205
- :"dst_square" => {
206
- :"...attacked?" => nil,
207
- :"...occupied!" => false,
208
- :"area" => :all
209
- },
210
- :"promotable_into_actors" => [:self]
160
+ }
161
+ ],
162
+
163
+
164
+
165
+ [
166
+ {
167
+ :"subject" => {
168
+ :"...ally?" => true,
169
+ :"actor" => :self,
170
+ :"state" => {
171
+ :"...last_moved_actor?" => nil,
172
+ :"...previous_moves_counter" => nil
211
173
  }
174
+ },
175
+
176
+ :"verb" => {
177
+ :"name" => :shift,
178
+ :"vector" => {:"...maximum_magnitude" => nil, direction: [-1,0]}
179
+ },
180
+
181
+ :"object" => {
182
+ :"src_square" => {
183
+ :"...attacked?" => nil,
184
+ :"...occupied!" => false,
185
+ :"area" => :all
186
+ },
187
+ :"dst_square" => {
188
+ :"...attacked?" => nil,
189
+ :"...occupied!" => false,
190
+ :"area" => :all
191
+ },
192
+ :"promotable_into_actors" => [:self]
212
193
  }
213
- ],
214
-
215
-
216
-
217
- [
218
- {
219
- :"subject" => {
220
- :"...ally?" => true,
221
- :"actor" => :self,
222
- :"state" => {
223
- :"...last_moved_actor?" => nil,
224
- :"...previous_moves_counter" => nil
225
- }
226
- },
227
-
228
- :"verb" => {
229
- :"name" => :shift,
230
- :"vector" => {:"...maximum_magnitude" => nil, direction: [-1,0]}
231
- },
232
-
233
- :"object" => {
234
- :"src_square" => {
235
- :"...attacked?" => nil,
236
- :"...occupied!" => false,
237
- :"area" => :all
238
- },
239
- :"dst_square" => {
240
- :"...attacked?" => nil,
241
- :"...occupied!" => false,
242
- :"area" => :all
243
- },
244
- :"promotable_into_actors" => [:self]
194
+ }
195
+ ],
196
+
197
+
198
+
199
+ [
200
+ {
201
+ :"subject" => {
202
+ :"...ally?" => true,
203
+ :"actor" => :self,
204
+ :"state" => {
205
+ :"...last_moved_actor?" => nil,
206
+ :"...previous_moves_counter" => nil
245
207
  }
246
208
  },
247
- {
248
- :"subject" => {
249
- :"...ally?" => true,
250
- :"actor" => :self,
251
- :"state" => {
252
- :"...last_moved_actor?" => nil,
253
- :"...previous_moves_counter" => nil
254
- }
255
- },
256
-
257
- :"verb" => {
258
- :"name" => :remove,
259
- :"vector" => {:"...maximum_magnitude" => 1, direction: [-1,0]}
260
- },
261
-
262
- :"object" => {
263
- :"src_square" => {
264
- :"...attacked?" => nil,
265
- :"...occupied!" => false,
266
- :"area" => :all
267
- },
268
- :"dst_square" => {
269
- :"...attacked?" => nil,
270
- :"...occupied!" => :an_enemy_actor,
271
- :"area" => :all
272
- },
273
- :"promotable_into_actors" => [:self]
209
+
210
+ :"verb" => {
211
+ :"name" => :shift,
212
+ :"vector" => {:"...maximum_magnitude" => nil, direction: [-1,0]}
213
+ },
214
+
215
+ :"object" => {
216
+ :"src_square" => {
217
+ :"...attacked?" => nil,
218
+ :"...occupied!" => false,
219
+ :"area" => :all
220
+ },
221
+ :"dst_square" => {
222
+ :"...attacked?" => nil,
223
+ :"...occupied!" => false,
224
+ :"area" => :all
225
+ },
226
+ :"promotable_into_actors" => [:self]
227
+ }
228
+ },
229
+ {
230
+ :"subject" => {
231
+ :"...ally?" => true,
232
+ :"actor" => :self,
233
+ :"state" => {
234
+ :"...last_moved_actor?" => nil,
235
+ :"...previous_moves_counter" => nil
274
236
  }
237
+ },
238
+
239
+ :"verb" => {
240
+ :"name" => :remove,
241
+ :"vector" => {:"...maximum_magnitude" => 1, direction: [-1,0]}
242
+ },
243
+
244
+ :"object" => {
245
+ :"src_square" => {
246
+ :"...attacked?" => nil,
247
+ :"...occupied!" => false,
248
+ :"area" => :all
249
+ },
250
+ :"dst_square" => {
251
+ :"...attacked?" => nil,
252
+ :"...occupied!" => :an_enemy_actor,
253
+ :"area" => :all
254
+ },
255
+ :"promotable_into_actors" => [:self]
275
256
  }
276
- ],
277
-
278
-
279
-
280
- [
281
- {
282
- :"subject" => {
283
- :"...ally?" => true,
284
- :"actor" => :self,
285
- :"state" => {
286
- :"...last_moved_actor?" => nil,
287
- :"...previous_moves_counter" => nil
288
- }
289
- },
290
-
291
- :"verb" => {
292
- :"name" => :shift,
293
- :"vector" => {:"...maximum_magnitude" => nil, direction: [0,-1]}
294
- },
295
-
296
- :"object" => {
297
- :"src_square" => {
298
- :"...attacked?" => nil,
299
- :"...occupied!" => false,
300
- :"area" => :all
301
- },
302
- :"dst_square" => {
303
- :"...attacked?" => nil,
304
- :"...occupied!" => false,
305
- :"area" => :all
306
- },
307
- :"promotable_into_actors" => [:self]
257
+ }
258
+ ],
259
+
260
+
261
+
262
+ [
263
+ {
264
+ :"subject" => {
265
+ :"...ally?" => true,
266
+ :"actor" => :self,
267
+ :"state" => {
268
+ :"...last_moved_actor?" => nil,
269
+ :"...previous_moves_counter" => nil
308
270
  }
271
+ },
272
+
273
+ :"verb" => {
274
+ :"name" => :shift,
275
+ :"vector" => {:"...maximum_magnitude" => nil, direction: [0,-1]}
276
+ },
277
+
278
+ :"object" => {
279
+ :"src_square" => {
280
+ :"...attacked?" => nil,
281
+ :"...occupied!" => false,
282
+ :"area" => :all
283
+ },
284
+ :"dst_square" => {
285
+ :"...attacked?" => nil,
286
+ :"...occupied!" => false,
287
+ :"area" => :all
288
+ },
289
+ :"promotable_into_actors" => [:self]
309
290
  }
310
- ],
311
-
312
-
313
-
314
- [
315
- {
316
- :"subject" => {
317
- :"...ally?" => true,
318
- :"actor" => :self,
319
- :"state" => {
320
- :"...last_moved_actor?" => nil,
321
- :"...previous_moves_counter" => nil
322
- }
323
- },
324
-
325
- :"verb" => {
326
- :"name" => :shift,
327
- :"vector" => {:"...maximum_magnitude" => nil, direction: [0,-1]}
328
- },
329
-
330
- :"object" => {
331
- :"src_square" => {
332
- :"...attacked?" => nil,
333
- :"...occupied!" => false,
334
- :"area" => :all
335
- },
336
- :"dst_square" => {
337
- :"...attacked?" => nil,
338
- :"...occupied!" => false,
339
- :"area" => :all
340
- },
341
- :"promotable_into_actors" => [:self]
291
+ }
292
+ ],
293
+
294
+
295
+
296
+ [
297
+ {
298
+ :"subject" => {
299
+ :"...ally?" => true,
300
+ :"actor" => :self,
301
+ :"state" => {
302
+ :"...last_moved_actor?" => nil,
303
+ :"...previous_moves_counter" => nil
342
304
  }
343
305
  },
344
- {
345
- :"subject" => {
346
- :"...ally?" => true,
347
- :"actor" => :self,
348
- :"state" => {
349
- :"...last_moved_actor?" => nil,
350
- :"...previous_moves_counter" => nil
351
- }
352
- },
353
-
354
- :"verb" => {
355
- :"name" => :remove,
356
- :"vector" => {:"...maximum_magnitude" => 1, direction: [0,-1]}
357
- },
358
-
359
- :"object" => {
360
- :"src_square" => {
361
- :"...attacked?" => nil,
362
- :"...occupied!" => false,
363
- :"area" => :all
364
- },
365
- :"dst_square" => {
366
- :"...attacked?" => nil,
367
- :"...occupied!" => :an_enemy_actor,
368
- :"area" => :all
369
- },
370
- :"promotable_into_actors" => [:self]
306
+
307
+ :"verb" => {
308
+ :"name" => :shift,
309
+ :"vector" => {:"...maximum_magnitude" => nil, direction: [0,-1]}
310
+ },
311
+
312
+ :"object" => {
313
+ :"src_square" => {
314
+ :"...attacked?" => nil,
315
+ :"...occupied!" => false,
316
+ :"area" => :all
317
+ },
318
+ :"dst_square" => {
319
+ :"...attacked?" => nil,
320
+ :"...occupied!" => false,
321
+ :"area" => :all
322
+ },
323
+ :"promotable_into_actors" => [:self]
324
+ }
325
+ },
326
+ {
327
+ :"subject" => {
328
+ :"...ally?" => true,
329
+ :"actor" => :self,
330
+ :"state" => {
331
+ :"...last_moved_actor?" => nil,
332
+ :"...previous_moves_counter" => nil
371
333
  }
334
+ },
335
+
336
+ :"verb" => {
337
+ :"name" => :remove,
338
+ :"vector" => {:"...maximum_magnitude" => 1, direction: [0,-1]}
339
+ },
340
+
341
+ :"object" => {
342
+ :"src_square" => {
343
+ :"...attacked?" => nil,
344
+ :"...occupied!" => false,
345
+ :"area" => :all
346
+ },
347
+ :"dst_square" => {
348
+ :"...attacked?" => nil,
349
+ :"...occupied!" => :an_enemy_actor,
350
+ :"area" => :all
351
+ },
352
+ :"promotable_into_actors" => [:self]
372
353
  }
373
- ],
374
-
375
-
376
-
377
- [
378
- {
379
- :"subject" => {
380
- :"...ally?" => true,
381
- :"actor" => :self,
382
- :"state" => {
383
- :"...last_moved_actor?" => nil,
384
- :"...previous_moves_counter" => nil
385
- }
386
- },
387
-
388
- :"verb" => {
389
- :"name" => :shift,
390
- :"vector" => {:"...maximum_magnitude" => nil, direction: [0,1]}
391
- },
392
-
393
- :"object" => {
394
- :"src_square" => {
395
- :"...attacked?" => nil,
396
- :"...occupied!" => false,
397
- :"area" => :all
398
- },
399
- :"dst_square" => {
400
- :"...attacked?" => nil,
401
- :"...occupied!" => false,
402
- :"area" => :all
403
- },
404
- :"promotable_into_actors" => [:self]
354
+ }
355
+ ],
356
+
357
+
358
+
359
+ [
360
+ {
361
+ :"subject" => {
362
+ :"...ally?" => true,
363
+ :"actor" => :self,
364
+ :"state" => {
365
+ :"...last_moved_actor?" => nil,
366
+ :"...previous_moves_counter" => nil
405
367
  }
368
+ },
369
+
370
+ :"verb" => {
371
+ :"name" => :shift,
372
+ :"vector" => {:"...maximum_magnitude" => nil, direction: [0,1]}
373
+ },
374
+
375
+ :"object" => {
376
+ :"src_square" => {
377
+ :"...attacked?" => nil,
378
+ :"...occupied!" => false,
379
+ :"area" => :all
380
+ },
381
+ :"dst_square" => {
382
+ :"...attacked?" => nil,
383
+ :"...occupied!" => false,
384
+ :"area" => :all
385
+ },
386
+ :"promotable_into_actors" => [:self]
406
387
  }
407
- ],
408
-
409
-
410
-
411
- [
412
- {
413
- :"subject" => {
414
- :"...ally?" => true,
415
- :"actor" => :self,
416
- :"state" => {
417
- :"...last_moved_actor?" => nil,
418
- :"...previous_moves_counter" => nil
419
- }
420
- },
421
-
422
- :"verb" => {
423
- :"name" => :shift,
424
- :"vector" => {:"...maximum_magnitude" => nil, direction: [0,1]}
425
- },
426
-
427
- :"object" => {
428
- :"src_square" => {
429
- :"...attacked?" => nil,
430
- :"...occupied!" => false,
431
- :"area" => :all
432
- },
433
- :"dst_square" => {
434
- :"...attacked?" => nil,
435
- :"...occupied!" => false,
436
- :"area" => :all
437
- },
438
- :"promotable_into_actors" => [:self]
388
+ }
389
+ ],
390
+
391
+
392
+
393
+ [
394
+ {
395
+ :"subject" => {
396
+ :"...ally?" => true,
397
+ :"actor" => :self,
398
+ :"state" => {
399
+ :"...last_moved_actor?" => nil,
400
+ :"...previous_moves_counter" => nil
439
401
  }
440
402
  },
441
- {
442
- :"subject" => {
443
- :"...ally?" => true,
444
- :"actor" => :self,
445
- :"state" => {
446
- :"...last_moved_actor?" => nil,
447
- :"...previous_moves_counter" => nil
448
- }
449
- },
450
-
451
- :"verb" => {
452
- :"name" => :remove,
453
- :"vector" => {:"...maximum_magnitude" => 1, direction: [0,1]}
454
- },
455
-
456
- :"object" => {
457
- :"src_square" => {
458
- :"...attacked?" => nil,
459
- :"...occupied!" => false,
460
- :"area" => :all
461
- },
462
- :"dst_square" => {
463
- :"...attacked?" => nil,
464
- :"...occupied!" => :an_enemy_actor,
465
- :"area" => :all
466
- },
467
- :"promotable_into_actors" => [:self]
403
+
404
+ :"verb" => {
405
+ :"name" => :shift,
406
+ :"vector" => {:"...maximum_magnitude" => nil, direction: [0,1]}
407
+ },
408
+
409
+ :"object" => {
410
+ :"src_square" => {
411
+ :"...attacked?" => nil,
412
+ :"...occupied!" => false,
413
+ :"area" => :all
414
+ },
415
+ :"dst_square" => {
416
+ :"...attacked?" => nil,
417
+ :"...occupied!" => false,
418
+ :"area" => :all
419
+ },
420
+ :"promotable_into_actors" => [:self]
421
+ }
422
+ },
423
+ {
424
+ :"subject" => {
425
+ :"...ally?" => true,
426
+ :"actor" => :self,
427
+ :"state" => {
428
+ :"...last_moved_actor?" => nil,
429
+ :"...previous_moves_counter" => nil
468
430
  }
431
+ },
432
+
433
+ :"verb" => {
434
+ :"name" => :remove,
435
+ :"vector" => {:"...maximum_magnitude" => 1, direction: [0,1]}
436
+ },
437
+
438
+ :"object" => {
439
+ :"src_square" => {
440
+ :"...attacked?" => nil,
441
+ :"...occupied!" => false,
442
+ :"area" => :all
443
+ },
444
+ :"dst_square" => {
445
+ :"...attacked?" => nil,
446
+ :"...occupied!" => :an_enemy_actor,
447
+ :"area" => :all
448
+ },
449
+ :"promotable_into_actors" => [:self]
469
450
  }
470
- ],
471
-
472
-
473
-
474
- [
475
- {
476
- :"subject" => {
477
- :"...ally?" => true,
478
- :"actor" => :self,
479
- :"state" => {
480
- :"...last_moved_actor?" => nil,
481
- :"...previous_moves_counter" => nil
482
- }
483
- },
484
-
485
- :"verb" => {
486
- :"name" => :shift,
487
- :"vector" => {:"...maximum_magnitude" => nil, direction: [1,0]}
488
- },
489
-
490
- :"object" => {
491
- :"src_square" => {
492
- :"...attacked?" => nil,
493
- :"...occupied!" => false,
494
- :"area" => :all
495
- },
496
- :"dst_square" => {
497
- :"...attacked?" => nil,
498
- :"...occupied!" => false,
499
- :"area" => :all
500
- },
501
- :"promotable_into_actors" => [:self]
451
+ }
452
+ ],
453
+
454
+
455
+
456
+ [
457
+ {
458
+ :"subject" => {
459
+ :"...ally?" => true,
460
+ :"actor" => :self,
461
+ :"state" => {
462
+ :"...last_moved_actor?" => nil,
463
+ :"...previous_moves_counter" => nil
502
464
  }
465
+ },
466
+
467
+ :"verb" => {
468
+ :"name" => :shift,
469
+ :"vector" => {:"...maximum_magnitude" => nil, direction: [1,0]}
470
+ },
471
+
472
+ :"object" => {
473
+ :"src_square" => {
474
+ :"...attacked?" => nil,
475
+ :"...occupied!" => false,
476
+ :"area" => :all
477
+ },
478
+ :"dst_square" => {
479
+ :"...attacked?" => nil,
480
+ :"...occupied!" => false,
481
+ :"area" => :all
482
+ },
483
+ :"promotable_into_actors" => [:self]
503
484
  }
504
- ],
505
-
506
-
507
-
508
- [
509
- {
510
- :"subject" => {
511
- :"...ally?" => true,
512
- :"actor" => :self,
513
- :"state" => {
514
- :"...last_moved_actor?" => nil,
515
- :"...previous_moves_counter" => nil
516
- }
517
- },
518
-
519
- :"verb" => {
520
- :"name" => :shift,
521
- :"vector" => {:"...maximum_magnitude" => nil, direction: [1,0]}
522
- },
523
-
524
- :"object" => {
525
- :"src_square" => {
526
- :"...attacked?" => nil,
527
- :"...occupied!" => false,
528
- :"area" => :all
529
- },
530
- :"dst_square" => {
531
- :"...attacked?" => nil,
532
- :"...occupied!" => false,
533
- :"area" => :all
534
- },
535
- :"promotable_into_actors" => [:self]
485
+ }
486
+ ],
487
+
488
+
489
+
490
+ [
491
+ {
492
+ :"subject" => {
493
+ :"...ally?" => true,
494
+ :"actor" => :self,
495
+ :"state" => {
496
+ :"...last_moved_actor?" => nil,
497
+ :"...previous_moves_counter" => nil
536
498
  }
537
499
  },
538
- {
539
- :"subject" => {
540
- :"...ally?" => true,
541
- :"actor" => :self,
542
- :"state" => {
543
- :"...last_moved_actor?" => nil,
544
- :"...previous_moves_counter" => nil
545
- }
546
- },
547
-
548
- :"verb" => {
549
- :"name" => :remove,
550
- :"vector" => {:"...maximum_magnitude" => 1, direction: [1,0]}
551
- },
552
-
553
- :"object" => {
554
- :"src_square" => {
555
- :"...attacked?" => nil,
556
- :"...occupied!" => false,
557
- :"area" => :all
558
- },
559
- :"dst_square" => {
560
- :"...attacked?" => nil,
561
- :"...occupied!" => :an_enemy_actor,
562
- :"area" => :all
563
- },
564
- :"promotable_into_actors" => [:self]
500
+
501
+ :"verb" => {
502
+ :"name" => :shift,
503
+ :"vector" => {:"...maximum_magnitude" => nil, direction: [1,0]}
504
+ },
505
+
506
+ :"object" => {
507
+ :"src_square" => {
508
+ :"...attacked?" => nil,
509
+ :"...occupied!" => false,
510
+ :"area" => :all
511
+ },
512
+ :"dst_square" => {
513
+ :"...attacked?" => nil,
514
+ :"...occupied!" => false,
515
+ :"area" => :all
516
+ },
517
+ :"promotable_into_actors" => [:self]
518
+ }
519
+ },
520
+ {
521
+ :"subject" => {
522
+ :"...ally?" => true,
523
+ :"actor" => :self,
524
+ :"state" => {
525
+ :"...last_moved_actor?" => nil,
526
+ :"...previous_moves_counter" => nil
565
527
  }
528
+ },
529
+
530
+ :"verb" => {
531
+ :"name" => :remove,
532
+ :"vector" => {:"...maximum_magnitude" => 1, direction: [1,0]}
533
+ },
534
+
535
+ :"object" => {
536
+ :"src_square" => {
537
+ :"...attacked?" => nil,
538
+ :"...occupied!" => false,
539
+ :"area" => :all
540
+ },
541
+ :"dst_square" => {
542
+ :"...attacked?" => nil,
543
+ :"...occupied!" => :an_enemy_actor,
544
+ :"area" => :all
545
+ },
546
+ :"promotable_into_actors" => [:self]
566
547
  }
567
- ]
568
- ],
569
- :self
570
- ].hash
571
- )
548
+ }
549
+ ]
550
+ ],
551
+ :self
552
+ ].hash
572
553
  end
573
554
 
574
- it 'returns the GGN as a string' do
575
- @promotable_into_actors.to_s.must_equal(
576
- 'dDxzZWxmPl8mX15yZW1vdmVbLTEsMF0xL3Q9X0BmK2FsbH5fQGFuX2VuZW15X2FjdG9yK2FsbCVzZWxm' +
577
- 'LiB0PHNlbGY+XyZfXnJlbW92ZVswLC0xXTEvdD1fQGYrYWxsfl9AYW5fZW5lbXlfYWN0b3IrYWxsJXNl' +
578
- 'bGYuIHQ8c2VsZj5fJl9ecmVtb3ZlWzAsMV0xL3Q9X0BmK2FsbH5fQGFuX2VuZW15X2FjdG9yK2FsbCVz' +
579
- 'ZWxmLiB0PHNlbGY+XyZfXnJlbW92ZVsxLDBdMS90PV9AZithbGx+X0Bhbl9lbmVteV9hY3RvcithbGwl' +
580
- 'c2VsZi4gdDxzZWxmPl8mX15zaGlmdFstMSwwXV8vdD1fQGYrYWxsfl9AZithbGwlc2VsZi4gdDxzZWxm' +
581
- 'Pl8mX15zaGlmdFstMSwwXV8vdD1fQGYrYWxsfl9AZithbGwlc2VsZjsgdDxzZWxmPl8mX15yZW1vdmVb' +
582
- 'LTEsMF0xL3Q9X0BmK2FsbH5fQGFuX2VuZW15X2FjdG9yK2FsbCVzZWxmLiB0PHNlbGY+XyZfXnNoaWZ0' +
583
- 'WzAsLTFdXy90PV9AZithbGx+X0BmK2FsbCVzZWxmLiB0PHNlbGY+XyZfXnNoaWZ0WzAsLTFdXy90PV9A' +
584
- 'ZithbGx+X0BmK2FsbCVzZWxmOyB0PHNlbGY+XyZfXnJlbW92ZVswLC0xXTEvdD1fQGYrYWxsfl9AYW5f' +
585
- 'ZW5lbXlfYWN0b3IrYWxsJXNlbGYuIHQ8c2VsZj5fJl9ec2hpZnRbMCwxXV8vdD1fQGYrYWxsfl9AZith' +
586
- 'bGwlc2VsZi4gdDxzZWxmPl8mX15zaGlmdFswLDFdXy90PV9AZithbGx+X0BmK2FsbCVzZWxmOyB0PHNl' +
587
- 'bGY+XyZfXnJlbW92ZVswLDFdMS90PV9AZithbGx+X0Bhbl9lbmVteV9hY3RvcithbGwlc2VsZi4gdDxz' +
588
- 'ZWxmPl8mX15zaGlmdFsxLDBdXy90PV9AZithbGx+X0BmK2FsbCVzZWxmLiB0PHNlbGY+XyZfXnNoaWZ0' +
589
- 'WzEsMF1fL3Q9X0BmK2FsbH5fQGYrYWxsJXNlbGY7IHQ8c2VsZj5fJl9ecmVtb3ZlWzEsMF0xL3Q9X0Bm' +
590
- 'K2FsbH5fQGFuX2VuZW15X2FjdG9yK2FsbCVzZWxmLg==,self')
555
+ describe 'errors' do
556
+ it 'raises without a collection of actors' do
557
+ -> { subject.load 'foobar' }.must_raise ArgumentError
558
+ end
591
559
  end
592
560
  end
593
- end
594
561
 
595
- it 'raises an error' do
596
- -> { Sashite::GGN::PromotableIntoActors.new('foobar') }.must_raise ArgumentError
562
+ describe 'self' do
563
+ before do
564
+ @ggn_obj = 'self'
565
+ end
566
+
567
+ it 'loads a document from the current io stream' do
568
+ subject.load(@ggn_obj).must_equal [ :self ]
569
+ end
570
+
571
+ describe 'errors' do
572
+ it 'raises with more than one self' do
573
+ -> { subject.load 'self,self' }.must_raise ArgumentError
574
+ end
575
+ end
576
+ end
597
577
  end
598
578
  end