glimmer 0.1.5.470 → 0.1.8.470
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.coveralls.yml +1 -0
- data/.rspec +2 -0
- data/Gemfile +2 -0
- data/README.markdown +7 -2
- data/Rakefile +7 -8
- data/TODO.md +1 -1
- data/VERSION +1 -1
- data/bin/girb +3 -0
- data/bin/girb_runner.rb +5 -0
- data/glimmer.gemspec +29 -19
- data/lib/glimmer_application.rb +1 -2
- data/lib/shine.rb +23 -21
- data/lib/xml_command_handlers/models/node.rb +11 -11
- data/lib/xml_command_handlers/models/xml_visitor.rb +12 -12
- data/samples/tictactoe/tic_tac_toe.rb +11 -11
- data/spec/lib/command_handlers/models/observable_model_spec.rb +22 -0
- data/spec/lib/command_handlers/models/r_widget_spec.rb +52 -0
- data/{test/glimmer_combo_data_binding_test.rb → spec/lib/glimmer__combo_data_binding__spec.rb} +48 -49
- data/spec/lib/glimmer__constant__spec.rb +30 -0
- data/{test/glimmer_data_binding_test.rb → spec/lib/glimmer__data_binding__spec.rb} +95 -94
- data/spec/lib/glimmer__list_data_binding__spec.rb +224 -0
- data/{test/glimmer_listeners_test.rb → spec/lib/glimmer__listeners__spec.rb} +18 -19
- data/spec/lib/glimmer__shine_data_binding__spec.rb +89 -0
- data/spec/lib/glimmer__tab_item__spec.rb +55 -0
- data/spec/lib/glimmer__table_data_binding__spec.rb +121 -0
- data/spec/lib/glimmer_spec.rb +251 -0
- data/spec/lib/xml/glimmer_xml_spec.rb +154 -0
- data/spec/samples/contactmanager/contact_manager_presenter_spec.rb +81 -0
- data/spec/samples/tictactoe/tic_tac_toe_spec.rb +263 -0
- data/spec/spec_helper.rb +123 -0
- metadata +50 -17
- data/test/glimmer_constant_test.rb +0 -30
- data/test/glimmer_list_data_binding_test.rb +0 -223
- data/test/glimmer_shine_data_binding_test.rb +0 -89
- data/test/glimmer_tab_item_test.rb +0 -61
- data/test/glimmer_table_data_binding_test.rb +0 -122
- data/test/glimmer_test.rb +0 -237
- data/test/helper.rb +0 -24
- data/test/observable_model_test.rb +0 -25
- data/test/r_widget_test.rb +0 -52
- data/test/samples/contactmanager/contact_manager_presenter_test.rb +0 -81
- data/test/samples/tictactoe/tic_tac_toe_test.rb +0 -262
- data/test/xml/glimmer_xml_test.rb +0 -163
data/test/glimmer_test.rb
DELETED
@@ -1,237 +0,0 @@
|
|
1
|
-
require_relative "helper"
|
2
|
-
|
3
|
-
class GlimmerTest < Test::Unit::TestCase
|
4
|
-
include Glimmer
|
5
|
-
|
6
|
-
include_package 'org.eclipse.swt'
|
7
|
-
include_package 'org.eclipse.swt.widgets'
|
8
|
-
include_package 'org.eclipse.swt.layout'
|
9
|
-
include_package 'org.eclipse.swt.graphics'
|
10
|
-
|
11
|
-
def setup
|
12
|
-
dsl :swt
|
13
|
-
end
|
14
|
-
|
15
|
-
def teardown
|
16
|
-
@target.display.dispose if @target.display
|
17
|
-
end
|
18
|
-
|
19
|
-
def test_shell_with_default_layout
|
20
|
-
@target = shell
|
21
|
-
|
22
|
-
assert_not_nil @target
|
23
|
-
assert_not_nil @target.widget
|
24
|
-
assert_instance_of Shell, @target.widget
|
25
|
-
assert_not_nil @target.widget.getLayout
|
26
|
-
assert_instance_of FillLayout, @target.widget.getLayout
|
27
|
-
end
|
28
|
-
|
29
|
-
def test_shell_with_title_and_layout
|
30
|
-
shell_layout = GridLayout.new
|
31
|
-
@target = shell {
|
32
|
-
text "Title"
|
33
|
-
layout shell_layout
|
34
|
-
}
|
35
|
-
|
36
|
-
assert_equal "Title", @target.widget.getText
|
37
|
-
assert_equal shell_layout, @target.widget.getLayout
|
38
|
-
end
|
39
|
-
|
40
|
-
def test_shell_with_bounds
|
41
|
-
@target = shell {
|
42
|
-
bounds 50, 75, 800, 600
|
43
|
-
}
|
44
|
-
|
45
|
-
assert_equal Rectangle.new(50, 75, 800, 600), @target.widget.getBounds
|
46
|
-
end
|
47
|
-
|
48
|
-
def test_shell_with_size
|
49
|
-
GlimmerTest.class_eval("undef_method :size") #hack to remove existing size method in test class
|
50
|
-
|
51
|
-
@target = shell {
|
52
|
-
size 800, 600
|
53
|
-
}
|
54
|
-
|
55
|
-
assert_equal Point.new(800, 600), @target.widget.getSize
|
56
|
-
end
|
57
|
-
|
58
|
-
def test_shell_and_composite_with_default_style_and_layout
|
59
|
-
@target = shell {
|
60
|
-
composite
|
61
|
-
}
|
62
|
-
|
63
|
-
assert_equal 1, @target.widget.children.size
|
64
|
-
assert_instance_of Composite, @target.widget.children[0]
|
65
|
-
composite_widget = @target.widget.children[0]
|
66
|
-
assert_has_style :none, composite_widget
|
67
|
-
assert_instance_of GridLayout, composite_widget.getLayout
|
68
|
-
grid_layout = composite_widget.getLayout
|
69
|
-
assert_equal 1, grid_layout.numColumns
|
70
|
-
assert_equal false, grid_layout.makeColumnsEqualWidth
|
71
|
-
end
|
72
|
-
|
73
|
-
def test_shell_and_group_with_default_style_and_layout
|
74
|
-
@target = shell {
|
75
|
-
group {
|
76
|
-
text "Title"
|
77
|
-
}
|
78
|
-
}
|
79
|
-
|
80
|
-
assert_equal 1, @target.widget.children.size
|
81
|
-
assert_instance_of Group, @target.widget.children[0]
|
82
|
-
group_widget = @target.widget.children[0]
|
83
|
-
assert_has_style :none, group_widget
|
84
|
-
assert_instance_of GridLayout, group_widget.getLayout
|
85
|
-
grid_layout = group_widget.getLayout
|
86
|
-
assert_equal 1, grid_layout.numColumns
|
87
|
-
assert_equal false, grid_layout.makeColumnsEqualWidth
|
88
|
-
assert_equal "Title", group_widget.getText
|
89
|
-
end
|
90
|
-
|
91
|
-
def test_shell_and_composite_with_style_and_layout
|
92
|
-
composite_layout = RowLayout.new
|
93
|
-
@target = shell {
|
94
|
-
composite(:no_focus) {
|
95
|
-
layout composite_layout
|
96
|
-
}
|
97
|
-
}
|
98
|
-
|
99
|
-
assert_equal 1, @target.widget.children.size
|
100
|
-
assert_instance_of Composite, @target.widget.children[0]
|
101
|
-
composite_widget = @target.widget.children[0]
|
102
|
-
assert_has_style :no_focus, composite_widget
|
103
|
-
assert_equal composite_layout, composite_widget.getLayout
|
104
|
-
end
|
105
|
-
|
106
|
-
def test_shell_and_composite_and_text_with_default_style
|
107
|
-
@target = shell {
|
108
|
-
composite {
|
109
|
-
text
|
110
|
-
}
|
111
|
-
}
|
112
|
-
|
113
|
-
composite_widget = @target.widget.children[0]
|
114
|
-
assert_equal 1, composite_widget.children.size
|
115
|
-
assert_instance_of Text, composite_widget.children[0]
|
116
|
-
text_widget = composite_widget.children[0]
|
117
|
-
assert_has_style :border, text_widget
|
118
|
-
end
|
119
|
-
|
120
|
-
def test_shell_and_composite_with_custom_layout_and_text_with_default_style
|
121
|
-
composite_layout = RowLayout.new
|
122
|
-
@target = shell {
|
123
|
-
composite {
|
124
|
-
text
|
125
|
-
layout composite_layout
|
126
|
-
}
|
127
|
-
}
|
128
|
-
|
129
|
-
composite_widget = @target.widget.children[0]
|
130
|
-
assert_equal composite_layout, composite_widget.getLayout
|
131
|
-
assert_equal 1, composite_widget.children.size
|
132
|
-
assert_instance_of Text, composite_widget.children[0]
|
133
|
-
text_widget = composite_widget.children[0]
|
134
|
-
assert_has_style :border, text_widget
|
135
|
-
end
|
136
|
-
|
137
|
-
def test_shell_and_composite_and_text_with_style_and_text
|
138
|
-
@target = shell {
|
139
|
-
composite {
|
140
|
-
text(:password) {
|
141
|
-
text "Hello"
|
142
|
-
}
|
143
|
-
}
|
144
|
-
}
|
145
|
-
|
146
|
-
composite_widget = @target.widget.children[0]
|
147
|
-
assert_equal 1, composite_widget.children.size
|
148
|
-
assert_instance_of Text, composite_widget.children[0]
|
149
|
-
text_widget = composite_widget.children[0]
|
150
|
-
assert_has_style :password, text_widget
|
151
|
-
assert_equal "Hello", text_widget.getText
|
152
|
-
end
|
153
|
-
|
154
|
-
def test_shell_and_spinner_default
|
155
|
-
@target = shell {
|
156
|
-
@spinner = spinner {
|
157
|
-
selection 55
|
158
|
-
}
|
159
|
-
}
|
160
|
-
|
161
|
-
assert_instance_of Spinner, @spinner.widget
|
162
|
-
assert_has_style :border, @spinner.widget
|
163
|
-
assert_equal 55, @spinner.widget.getSelection
|
164
|
-
end
|
165
|
-
|
166
|
-
def test_shell_and_list_default
|
167
|
-
@target = shell {
|
168
|
-
@list = list {
|
169
|
-
}
|
170
|
-
}
|
171
|
-
|
172
|
-
assert_instance_of List, @list.widget
|
173
|
-
assert_has_style :border, @list.widget
|
174
|
-
assert_has_style :single, @list.widget
|
175
|
-
assert_has_style :v_scroll, @list.widget
|
176
|
-
end
|
177
|
-
|
178
|
-
def test_shell_and_button_default
|
179
|
-
@target = shell {
|
180
|
-
@button = button {
|
181
|
-
text "Push Me"
|
182
|
-
}
|
183
|
-
}
|
184
|
-
|
185
|
-
assert_instance_of Button, @button.widget
|
186
|
-
assert_has_style :push, @button.widget
|
187
|
-
assert_equal "Push Me", @button.widget.text
|
188
|
-
end
|
189
|
-
|
190
|
-
def test_shell_and_table_and_table_column_defaults
|
191
|
-
@target = shell {
|
192
|
-
@table = table {
|
193
|
-
@table_column = table_column
|
194
|
-
}
|
195
|
-
}
|
196
|
-
|
197
|
-
assert_has_style :border, @table.widget
|
198
|
-
assert @table.widget.getHeaderVisible
|
199
|
-
assert @table.widget.getLinesVisible
|
200
|
-
assert_equal 80, @table_column.widget.getWidth
|
201
|
-
end
|
202
|
-
|
203
|
-
def test_shell_containing_undefined_command
|
204
|
-
@target = shell {
|
205
|
-
undefined_command(:undefined_parameter) {
|
206
|
-
}
|
207
|
-
}
|
208
|
-
|
209
|
-
assert_not_nil @target
|
210
|
-
assert_not_nil @target.widget
|
211
|
-
assert_instance_of Shell, @target.widget
|
212
|
-
assert_not_nil @target.widget.getLayout
|
213
|
-
assert_instance_of FillLayout, @target.widget.getLayout
|
214
|
-
end
|
215
|
-
|
216
|
-
|
217
|
-
def test_add_contents
|
218
|
-
@target = shell {
|
219
|
-
}
|
220
|
-
|
221
|
-
add_contents(@target) {
|
222
|
-
composite {
|
223
|
-
text(:password) {
|
224
|
-
text "Hello"
|
225
|
-
}
|
226
|
-
}
|
227
|
-
}
|
228
|
-
|
229
|
-
composite_widget = @target.widget.children[0]
|
230
|
-
assert_equal 1, composite_widget.children.size
|
231
|
-
assert_instance_of Text, composite_widget.children[0]
|
232
|
-
text_widget = composite_widget.children[0]
|
233
|
-
assert_has_style :password, text_widget
|
234
|
-
assert_equal "Hello", text_widget.getText
|
235
|
-
end
|
236
|
-
|
237
|
-
end
|
data/test/helper.rb
DELETED
@@ -1,24 +0,0 @@
|
|
1
|
-
require 'rubygems'
|
2
|
-
require 'simplecov'
|
3
|
-
SimpleCov.start
|
4
|
-
require 'bundler'
|
5
|
-
require 'test/unit'
|
6
|
-
require 'puts_debuggerer'
|
7
|
-
|
8
|
-
begin
|
9
|
-
Bundler.setup(:default, :development)
|
10
|
-
rescue Bundler::BundlerError => e
|
11
|
-
$stderr.puts e.message
|
12
|
-
$stderr.puts "Run `bundle install` to install missing gems"
|
13
|
-
exit e.status_code
|
14
|
-
end
|
15
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
|
16
|
-
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'samples'))
|
17
|
-
$LOAD_PATH.unshift(File.dirname(__FILE__))
|
18
|
-
require 'glimmer'
|
19
|
-
|
20
|
-
class Test::Unit::TestCase
|
21
|
-
def assert_has_style(style, widget)
|
22
|
-
assert_equal style.swt_constant, widget.getStyle & style.swt_constant
|
23
|
-
end
|
24
|
-
end
|
@@ -1,25 +0,0 @@
|
|
1
|
-
require_relative "helper"
|
2
|
-
|
3
|
-
require_relative "../lib/command_handlers/models/observable_model"
|
4
|
-
|
5
|
-
require "test/unit"
|
6
|
-
class ObservableModelTest < Test::Unit::TestCase
|
7
|
-
class Person
|
8
|
-
attr_accessor :name
|
9
|
-
end
|
10
|
-
|
11
|
-
def test_observe_model
|
12
|
-
person = Person.new
|
13
|
-
person.name = "Marty"
|
14
|
-
assert_equal "Marty", person.name
|
15
|
-
person.extend ObservableModel
|
16
|
-
person.add_observer(:name, self)
|
17
|
-
person.name = "Julia"
|
18
|
-
assert_equal "Julia", @observed_name
|
19
|
-
assert_equal "Julia", person.name
|
20
|
-
end
|
21
|
-
|
22
|
-
def update(name)
|
23
|
-
@observed_name = name
|
24
|
-
end
|
25
|
-
end
|
data/test/r_widget_test.rb
DELETED
@@ -1,52 +0,0 @@
|
|
1
|
-
require_relative "helper"
|
2
|
-
|
3
|
-
class RWidgetTest < Test::Unit::TestCase
|
4
|
-
include Glimmer
|
5
|
-
|
6
|
-
def setup
|
7
|
-
dsl :swt
|
8
|
-
end
|
9
|
-
|
10
|
-
def test_async_exec
|
11
|
-
@target = shell {
|
12
|
-
@text = text {
|
13
|
-
text "text1"
|
14
|
-
}
|
15
|
-
}
|
16
|
-
|
17
|
-
@target.async_exec do
|
18
|
-
@text.widget.setText("text2")
|
19
|
-
end
|
20
|
-
|
21
|
-
@target.async_exec do
|
22
|
-
assert_equal "text2", @text.widget.getText
|
23
|
-
@target.widget.close
|
24
|
-
end
|
25
|
-
|
26
|
-
@target.open
|
27
|
-
end
|
28
|
-
|
29
|
-
def test_sync_exec
|
30
|
-
@target = shell {
|
31
|
-
@text = text {
|
32
|
-
text "text1"
|
33
|
-
}
|
34
|
-
}
|
35
|
-
|
36
|
-
@target.async_exec do
|
37
|
-
assert_equal "text2", @text.widget.getText
|
38
|
-
@text.widget.setText("text3")
|
39
|
-
end
|
40
|
-
|
41
|
-
@target.sync_exec do
|
42
|
-
@text.widget.setText("text2")
|
43
|
-
end
|
44
|
-
|
45
|
-
@target.async_exec do
|
46
|
-
@target.widget.close
|
47
|
-
end
|
48
|
-
|
49
|
-
@target.open
|
50
|
-
end
|
51
|
-
|
52
|
-
end
|
@@ -1,81 +0,0 @@
|
|
1
|
-
require_relative "../../helper"
|
2
|
-
require_relative "../../../samples/contactmanager/contact_manager_presenter"
|
3
|
-
|
4
|
-
class ContactManagerPresenterTest < Test::Unit::TestCase
|
5
|
-
|
6
|
-
def test_find_specify_all_fields_for_one_result
|
7
|
-
contact_manager_presenter = ContactManagerPresenter.new
|
8
|
-
contact_manager_presenter.first_name = "Frank"
|
9
|
-
contact_manager_presenter.last_name = "Deelio"
|
10
|
-
contact_manager_presenter.email = "frank@deelio.com"
|
11
|
-
contact_manager_presenter.find
|
12
|
-
contacts = contact_manager_presenter.results
|
13
|
-
assert_not_nil contacts
|
14
|
-
assert_equal 1, contacts.size
|
15
|
-
contact = contacts[0]
|
16
|
-
assert contact.is_a?(Contact)
|
17
|
-
assert_equal "Frank", contact.first_name
|
18
|
-
assert_equal "Deelio", contact.last_name
|
19
|
-
assert_equal "frank@deelio.com", contact.email
|
20
|
-
end
|
21
|
-
|
22
|
-
def test_find_specify_one_field_for_two_results
|
23
|
-
contact_manager_presenter = ContactManagerPresenter.new
|
24
|
-
contact_manager_presenter.first_name = "Frank"
|
25
|
-
contact_manager_presenter.find
|
26
|
-
contacts = contact_manager_presenter.results
|
27
|
-
assert_not_nil contacts
|
28
|
-
assert_equal 2, contacts.size
|
29
|
-
contact1 = contacts[0]
|
30
|
-
contact2 = contacts[1]
|
31
|
-
assert_equal "Frank", contact1.first_name
|
32
|
-
assert_equal "Deelio", contact1.last_name
|
33
|
-
assert_equal "frank@deelio.com", contact1.email
|
34
|
-
assert_equal "franky", contact2.first_name
|
35
|
-
assert_equal "miller", contact2.last_name
|
36
|
-
assert_equal "frank@miller.com", contact2.email
|
37
|
-
end
|
38
|
-
|
39
|
-
def test_find_specify_all_fields_for_no_results
|
40
|
-
contact_manager_presenter = ContactManagerPresenter.new
|
41
|
-
contact_manager_presenter.first_name = "Julia"
|
42
|
-
contact_manager_presenter.last_name = "Big"
|
43
|
-
contact_manager_presenter.email = "julia@big.com"
|
44
|
-
contact_manager_presenter.find
|
45
|
-
contacts = contact_manager_presenter.results
|
46
|
-
assert_not_nil contacts
|
47
|
-
assert_equal 0, contacts.size
|
48
|
-
end
|
49
|
-
|
50
|
-
def test_find_specify_no_fields_for_all_results
|
51
|
-
contact_manager_presenter = ContactManagerPresenter.new
|
52
|
-
contact_manager_presenter.find
|
53
|
-
contacts = contact_manager_presenter.results
|
54
|
-
assert_not_nil contacts
|
55
|
-
assert_equal 4, contacts.size
|
56
|
-
assert_equal "Anne", contacts[0].first_name
|
57
|
-
assert_equal "Beatrice", contacts[1].first_name
|
58
|
-
assert_equal "Frank", contacts[2].first_name
|
59
|
-
assert_equal "franky", contacts[3].first_name
|
60
|
-
end
|
61
|
-
|
62
|
-
def test_list_all_results
|
63
|
-
contact_manager_presenter = ContactManagerPresenter.new
|
64
|
-
contact_manager_presenter.list
|
65
|
-
contacts = contact_manager_presenter.results
|
66
|
-
assert_not_nil contacts
|
67
|
-
assert_equal 4, contacts.size
|
68
|
-
assert_equal "Anne", contacts[0].first_name
|
69
|
-
assert_equal "Beatrice", contacts[1].first_name
|
70
|
-
assert_equal "Frank", contacts[2].first_name
|
71
|
-
assert_equal "franky", contacts[3].first_name
|
72
|
-
end
|
73
|
-
|
74
|
-
def test_initial_results
|
75
|
-
contact_manager_presenter = ContactManagerPresenter.new
|
76
|
-
contacts = contact_manager_presenter.results
|
77
|
-
assert_not_nil contacts
|
78
|
-
assert_equal 0, contacts.size
|
79
|
-
end
|
80
|
-
|
81
|
-
end
|
@@ -1,262 +0,0 @@
|
|
1
|
-
require_relative "../../helper"
|
2
|
-
require_relative "../../../samples/tictactoe/tic_tac_toe_board"
|
3
|
-
|
4
|
-
class TicTacToeTest < Test::Unit::TestCase
|
5
|
-
|
6
|
-
def setup
|
7
|
-
@board = TicTacToeBoard.new
|
8
|
-
end
|
9
|
-
|
10
|
-
def test_mark_center_x
|
11
|
-
assert_equal("", @board.box(2, 2).sign)
|
12
|
-
@board.mark_box(2, 2)
|
13
|
-
assert ! @board.box(2, 2).empty
|
14
|
-
assert_equal("X", @board.box(2, 2).sign)
|
15
|
-
assert @board.box(1, 1).empty
|
16
|
-
assert @board.box(1, 2).empty
|
17
|
-
assert @board.box(1, 3).empty
|
18
|
-
assert @board.box(2, 1).empty
|
19
|
-
assert @board.box(2, 3).empty
|
20
|
-
assert @board.box(3, 1).empty
|
21
|
-
assert @board.box(3, 2).empty
|
22
|
-
assert @board.box(3, 3).empty
|
23
|
-
end
|
24
|
-
|
25
|
-
def test_mark_center_x_top_center_o_bottom_right_x
|
26
|
-
@board.mark_box(2, 2)
|
27
|
-
@board.mark_box(1, 2)
|
28
|
-
@board.mark_box(3, 3)
|
29
|
-
assert ! @board.box(2, 2).empty
|
30
|
-
assert ! @board.box(1, 2).empty
|
31
|
-
assert ! @board.box(3, 3).empty
|
32
|
-
assert_equal("X", @board.box(2, 2).sign)
|
33
|
-
assert_equal("O", @board.box(1, 2).sign)
|
34
|
-
assert_equal("X", @board.box(3, 3).sign)
|
35
|
-
end
|
36
|
-
|
37
|
-
def test_top_center_not_marked
|
38
|
-
assert @board.box(1, 2).empty
|
39
|
-
end
|
40
|
-
|
41
|
-
def test_top_right_marked
|
42
|
-
@board.mark_box(1, 3)
|
43
|
-
assert ! @board.box(1, 3).empty
|
44
|
-
end
|
45
|
-
|
46
|
-
def test_lower_right_marked
|
47
|
-
@board.mark_box(3, 3)
|
48
|
-
assert ! @board.box(3, 3).empty
|
49
|
-
end
|
50
|
-
|
51
|
-
def test_game_over_false
|
52
|
-
assert ! @board.game_over?
|
53
|
-
assert_equal "X", @board.current_sign
|
54
|
-
assert_equal TicTacToeBoard::IN_PROGRESS, @board.game_status
|
55
|
-
end
|
56
|
-
|
57
|
-
def test_game_over_X_wins_top_row_across
|
58
|
-
@board.mark_box(1, 1)
|
59
|
-
assert_equal("X", @board.box(1, 1).sign)
|
60
|
-
@board.mark_box(2, 1)
|
61
|
-
assert_equal("O", @board.box(2, 1).sign)
|
62
|
-
@board.mark_box(1, 2)
|
63
|
-
assert_equal("X", @board.box(1, 2).sign)
|
64
|
-
@board.mark_box(2, 2)
|
65
|
-
assert_equal("O", @board.box(2, 2).sign)
|
66
|
-
@board.mark_box(1, 3)
|
67
|
-
assert_equal("X", @board.box(1, 3).sign)
|
68
|
-
assert @board.game_over?
|
69
|
-
assert_equal "X", @board.winning_sign
|
70
|
-
assert_equal TicTacToeBoard::WIN, @board.game_status
|
71
|
-
end
|
72
|
-
|
73
|
-
def test_game_over_O_wins_top_row_across
|
74
|
-
@board.mark_box(2, 1)
|
75
|
-
@board.mark_box(1, 1)
|
76
|
-
@board.mark_box(2, 2)
|
77
|
-
@board.mark_box(1, 2)
|
78
|
-
@board.mark_box(3, 3)
|
79
|
-
@board.mark_box(1, 3)
|
80
|
-
assert @board.game_over?
|
81
|
-
assert_equal "O", @board.winning_sign
|
82
|
-
end
|
83
|
-
|
84
|
-
def test_game_over_X_wins_second_row_across
|
85
|
-
@board.mark_box(2, 1)
|
86
|
-
@board.mark_box(1, 1)
|
87
|
-
@board.mark_box(2, 2)
|
88
|
-
@board.mark_box(1, 2)
|
89
|
-
@board.mark_box(2, 3)
|
90
|
-
assert @board.game_over?
|
91
|
-
assert_equal "X", @board.winning_sign
|
92
|
-
end
|
93
|
-
|
94
|
-
def test_game_over_O_wins_second_row_across
|
95
|
-
@board.mark_box(1, 1)
|
96
|
-
@board.mark_box(2, 1)
|
97
|
-
@board.mark_box(3, 1)
|
98
|
-
@board.mark_box(2, 2)
|
99
|
-
@board.mark_box(1, 2)
|
100
|
-
@board.mark_box(2, 3)
|
101
|
-
assert @board.game_over?
|
102
|
-
assert_equal "O", @board.winning_sign
|
103
|
-
end
|
104
|
-
|
105
|
-
def test_game_over_X_wins_third_row_across
|
106
|
-
@board.mark_box(3, 1)
|
107
|
-
@board.mark_box(1, 1)
|
108
|
-
@board.mark_box(3, 2)
|
109
|
-
@board.mark_box(1, 2)
|
110
|
-
@board.mark_box(3, 3)
|
111
|
-
assert @board.game_over?
|
112
|
-
assert_equal "X", @board.winning_sign
|
113
|
-
end
|
114
|
-
|
115
|
-
def test_game_over_O_wins_third_row_across
|
116
|
-
@board.mark_box(1, 1)
|
117
|
-
@board.mark_box(3, 1)
|
118
|
-
@board.mark_box(1, 2)
|
119
|
-
@board.mark_box(3, 2)
|
120
|
-
@board.mark_box(2, 3)
|
121
|
-
@board.mark_box(3, 3)
|
122
|
-
assert @board.game_over?
|
123
|
-
end
|
124
|
-
|
125
|
-
def test_game_over_X_wins_first_column_down
|
126
|
-
@board.mark_box(1, 1)
|
127
|
-
@board.mark_box(2, 2)
|
128
|
-
@board.mark_box(2, 1)
|
129
|
-
@board.mark_box(3, 2)
|
130
|
-
@board.mark_box(3, 1)
|
131
|
-
assert @board.game_over?
|
132
|
-
assert_equal "X", @board.winning_sign
|
133
|
-
end
|
134
|
-
|
135
|
-
def test_game_over_O_wins_first_column_down
|
136
|
-
@board.mark_box(2, 2)
|
137
|
-
@board.mark_box(1, 1)
|
138
|
-
@board.mark_box(3, 2)
|
139
|
-
@board.mark_box(2, 1)
|
140
|
-
@board.mark_box(3, 3)
|
141
|
-
@board.mark_box(3, 1)
|
142
|
-
assert @board.game_over?
|
143
|
-
end
|
144
|
-
|
145
|
-
def test_game_over_X_wins_second_column_down
|
146
|
-
@board.mark_box(1, 2)
|
147
|
-
@board.mark_box(2, 1)
|
148
|
-
@board.mark_box(2, 2)
|
149
|
-
@board.mark_box(3, 1)
|
150
|
-
@board.mark_box(3, 2)
|
151
|
-
assert @board.game_over?
|
152
|
-
assert_equal "X", @board.winning_sign
|
153
|
-
end
|
154
|
-
|
155
|
-
def test_game_over_O_wins_second_column_down
|
156
|
-
@board.mark_box(2, 1)
|
157
|
-
@board.mark_box(1, 2)
|
158
|
-
@board.mark_box(3, 1)
|
159
|
-
@board.mark_box(2, 2)
|
160
|
-
@board.mark_box(2, 3)
|
161
|
-
@board.mark_box(3, 2)
|
162
|
-
assert @board.game_over?
|
163
|
-
assert_equal "O", @board.winning_sign
|
164
|
-
end
|
165
|
-
|
166
|
-
def test_game_over_X_wins_third_column_down
|
167
|
-
@board.mark_box(1, 3)
|
168
|
-
@board.mark_box(2, 1)
|
169
|
-
@board.mark_box(2, 3)
|
170
|
-
@board.mark_box(3, 1)
|
171
|
-
@board.mark_box(3, 3)
|
172
|
-
assert @board.game_over?
|
173
|
-
assert_equal "X", @board.winning_sign
|
174
|
-
end
|
175
|
-
|
176
|
-
def test_game_over_O_wins_third_column_down
|
177
|
-
@board.mark_box(2, 1)
|
178
|
-
@board.mark_box(1, 3)
|
179
|
-
@board.mark_box(3, 1)
|
180
|
-
@board.mark_box(2, 3)
|
181
|
-
@board.mark_box(3, 2)
|
182
|
-
@board.mark_box(3, 3)
|
183
|
-
assert @board.game_over?
|
184
|
-
assert_equal "O", @board.winning_sign
|
185
|
-
end
|
186
|
-
|
187
|
-
def test_game_over_X_wins_top_left_to_bottom_right
|
188
|
-
@board.mark_box(1, 1)
|
189
|
-
@board.mark_box(2, 1)
|
190
|
-
@board.mark_box(2, 2)
|
191
|
-
@board.mark_box(3, 2)
|
192
|
-
@board.mark_box(3, 3)
|
193
|
-
assert_equal "X", @board.winning_sign
|
194
|
-
assert @board.game_over?
|
195
|
-
end
|
196
|
-
|
197
|
-
def test_game_over_O_wins_top_left_to_bottom_right
|
198
|
-
@board.mark_box(2, 1)
|
199
|
-
@board.mark_box(1, 1)
|
200
|
-
@board.mark_box(3, 2)
|
201
|
-
@board.mark_box(2, 2)
|
202
|
-
@board.mark_box(2, 3)
|
203
|
-
@board.mark_box(3, 3)
|
204
|
-
assert_equal "O", @board.winning_sign
|
205
|
-
assert @board.game_over?
|
206
|
-
end
|
207
|
-
|
208
|
-
def test_game_over_X_wins_top_right_to_bottom_left
|
209
|
-
@board.mark_box(1, 3)
|
210
|
-
@board.mark_box(2, 1)
|
211
|
-
@board.mark_box(2, 2)
|
212
|
-
@board.mark_box(3, 2)
|
213
|
-
@board.mark_box(3, 1)
|
214
|
-
assert_equal "X", @board.winning_sign
|
215
|
-
assert @board.game_over?
|
216
|
-
end
|
217
|
-
|
218
|
-
def test_game_over_O_wins_top_right_to_bottom_left
|
219
|
-
@board.mark_box(2, 1)
|
220
|
-
@board.mark_box(1, 3)
|
221
|
-
@board.mark_box(3, 2)
|
222
|
-
@board.mark_box(2, 2)
|
223
|
-
@board.mark_box(1, 1)
|
224
|
-
@board.mark_box(3, 1)
|
225
|
-
assert_equal "O", @board.winning_sign
|
226
|
-
assert @board.game_over?
|
227
|
-
end
|
228
|
-
|
229
|
-
# 1 2 3
|
230
|
-
#1 x o x
|
231
|
-
#2 o x x
|
232
|
-
#3 o x o
|
233
|
-
def test_game_over_draw
|
234
|
-
@board.mark_box(1, 1)
|
235
|
-
@board.mark_box(1, 2)
|
236
|
-
@board.mark_box(1, 3)
|
237
|
-
@board.mark_box(2, 1)
|
238
|
-
@board.mark_box(2, 2)
|
239
|
-
@board.mark_box(3, 1)
|
240
|
-
@board.mark_box(2, 3)
|
241
|
-
@board.mark_box(3, 3)
|
242
|
-
assert ! @board.game_over?
|
243
|
-
@board.mark_box(3, 2)
|
244
|
-
assert @board.game_over?
|
245
|
-
assert_equal TicTacToeBox::EMPTY, @board.winning_sign
|
246
|
-
assert_equal TicTacToeBoard::DRAW, @board.game_status
|
247
|
-
end
|
248
|
-
|
249
|
-
def test_reset
|
250
|
-
@board.mark_box(1, 3)
|
251
|
-
@board.mark_box(2, 1)
|
252
|
-
@board.mark_box(2, 2)
|
253
|
-
@board.mark_box(3, 2)
|
254
|
-
@board.mark_box(3, 1)
|
255
|
-
@board.reset
|
256
|
-
assert ! @board.game_over?
|
257
|
-
assert_equal TicTacToeBox::EMPTY, @board.winning_sign
|
258
|
-
assert_equal TicTacToeBoard::IN_PROGRESS, @board.game_status
|
259
|
-
assert_equal "X", @board.current_sign
|
260
|
-
end
|
261
|
-
|
262
|
-
end
|