cw 0.2.4 → 0.3.0
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.
- checksums.yaml +4 -4
- data/.cw_config +18 -0
- data/.gitignore +10 -1
- data/LICENSE +2 -1
- data/README.md +212 -96
- data/Rakefile +15 -2
- data/VERSION +1 -1
- data/Vagrantfile +45 -0
- data/cw.gemspec +6 -1
- data/data/text/book_to_read.txt +4 -0
- data/data/text/english.txt +10000 -0
- data/example.rb +172 -106
- data/lib/cw.rb +10 -126
- data/lib/cw/alphabet.rb +53 -46
- data/lib/cw/audio_player.rb +83 -72
- data/lib/cw/book.rb +160 -185
- data/lib/cw/book_details.rb +38 -49
- data/lib/cw/cl.rb +101 -95
- data/lib/cw/common_words.rb +76 -0
- data/lib/cw/config.rb +50 -0
- data/lib/cw/current_word.rb +23 -24
- data/lib/cw/cw_dsl.rb +264 -131
- data/lib/cw/cw_encoding.rb +63 -69
- data/lib/cw/cw_stream.rb +86 -82
- data/lib/cw/cw_threads.rb +132 -22
- data/lib/cw/element.rb +60 -54
- data/lib/cw/file_details.rb +26 -11
- data/lib/cw/key_input.rb +53 -35
- data/lib/cw/numbers.rb +26 -19
- data/lib/cw/os.rb +13 -0
- data/lib/cw/play.rb +92 -0
- data/lib/cw/print.rb +102 -100
- data/lib/cw/process.rb +3 -0
- data/lib/cw/progress.rb +20 -17
- data/lib/cw/randomize.rb +56 -52
- data/lib/cw/repeat_word.rb +59 -66
- data/lib/cw/reveal.rb +32 -31
- data/lib/cw/rss.rb +52 -48
- data/lib/cw/sentence.rb +83 -76
- data/lib/cw/speak.rb +8 -4
- data/lib/cw/spoken.rb +8 -4
- data/lib/cw/str.rb +62 -30
- data/lib/cw/test_letters.rb +20 -28
- data/lib/cw/test_words.rb +25 -31
- data/lib/cw/tester.rb +219 -226
- data/lib/cw/text_helpers.rb +19 -15
- data/lib/cw/timing.rb +63 -67
- data/lib/cw/tone_generator.rb +176 -153
- data/lib/cw/tone_helpers.rb +15 -23
- data/lib/cw/voice.rb +12 -8
- data/lib/cw/words.rb +136 -106
- data/run_script_tests.rb +165 -0
- data/test/my_words.txt +1 -0
- data/test/test_common_words.rb +71 -0
- data/test/test_config.rb +98 -0
- data/test/test_current_word.rb +62 -0
- data/test/test_cw.rb +87 -120
- data/test/test_cw_threads.rb +123 -0
- data/test/test_filtering.rb +439 -0
- data/test/test_params.rb +28 -0
- data/test/test_play.rb +51 -0
- data/test/test_stream.rb +83 -83
- data/test/test_tester.rb +9 -27
- data/test/test_timing.rb +212 -0
- metadata +94 -12
- data/lib/cw/config_file.rb +0 -69
- data/lib/cw/monitor_keys.rb +0 -37
- data/lib/cw/params.rb +0 -104
@@ -0,0 +1,123 @@
|
|
1
|
+
require 'simplecov'
|
2
|
+
$VERBOSE = nil #FIXME
|
3
|
+
#SimpleCov.start
|
4
|
+
|
5
|
+
require 'minitest/autorun'
|
6
|
+
require 'minitest/pride'
|
7
|
+
require_relative '../lib/cw/cw_threads.rb'
|
8
|
+
|
9
|
+
class TestCWStream < MiniTest::Test
|
10
|
+
|
11
|
+
ROOT = File.expand_path File.dirname(__FILE__) + '/../../'
|
12
|
+
|
13
|
+
def a_thread
|
14
|
+
@test_var = 2 + 3
|
15
|
+
end
|
16
|
+
|
17
|
+
def sleep_thread
|
18
|
+
sleep 100
|
19
|
+
end
|
20
|
+
|
21
|
+
def setup
|
22
|
+
@test_var = 0
|
23
|
+
@threads = CWG::CWThreads.new(self, [:a_thread])
|
24
|
+
end
|
25
|
+
|
26
|
+
def teardown
|
27
|
+
@cw = nil
|
28
|
+
end
|
29
|
+
|
30
|
+
def test_cw_threads
|
31
|
+
assert true
|
32
|
+
end
|
33
|
+
|
34
|
+
def test_threads_exposes_name
|
35
|
+
@threads.start_threads
|
36
|
+
assert_equal :a_thread, (@threads.threads)[0][:name]
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_threads_exposes_thread
|
40
|
+
@threads.start_threads
|
41
|
+
assert @threads.threads[0][:thread].is_a? Thread
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_start_threads_runs_thread
|
45
|
+
@threads.start_threads
|
46
|
+
sleep 0.1
|
47
|
+
assert_equal 5, @test_var
|
48
|
+
end
|
49
|
+
|
50
|
+
# failed on one build
|
51
|
+
# def test_kill_thread_kills_thread
|
52
|
+
# threads = CWG::CWThreads.new(self, [:sleep_thread])
|
53
|
+
# threads.start_threads
|
54
|
+
# thread = threads.threads[0]
|
55
|
+
# assert_equal "run", thread[:thread].status
|
56
|
+
# threads.kill_thread thread
|
57
|
+
# count = 0
|
58
|
+
# status = ''
|
59
|
+
# loop do
|
60
|
+
# status = thread[:thread].status
|
61
|
+
# break unless status
|
62
|
+
# sleep 0.01
|
63
|
+
# count += 1
|
64
|
+
# break if(count >= 10)
|
65
|
+
# end
|
66
|
+
#
|
67
|
+
# assert(count < 10)
|
68
|
+
# end
|
69
|
+
#
|
70
|
+
def test_handles_multiple_threads
|
71
|
+
threads = CWG::CWThreads.new(self, [:a_thread, :sleep_thread])
|
72
|
+
threads.start_threads
|
73
|
+
assert threads.threads[0][:thread].is_a? Thread
|
74
|
+
assert threads.threads[1][:thread].is_a? Thread
|
75
|
+
assert_nil threads.threads[2]
|
76
|
+
end
|
77
|
+
|
78
|
+
# failed on one build
|
79
|
+
# def test_thread_false_or_nil_returns_true_and_false
|
80
|
+
# @threads.start_threads
|
81
|
+
# thread = @threads.threads[0]
|
82
|
+
# refute @threads.thread_false_or_nil?(@threads.threads[0])
|
83
|
+
# @threads.kill_thread thread
|
84
|
+
# count = 0
|
85
|
+
# status = ''
|
86
|
+
# loop do
|
87
|
+
# status = thread[:thread].status
|
88
|
+
# break unless status
|
89
|
+
# sleep 0.01
|
90
|
+
# count += 1
|
91
|
+
# break if(count >= 10)
|
92
|
+
# end
|
93
|
+
# assert count < 10
|
94
|
+
# assert @threads.thread_false_or_nil?(@threads.threads[0])
|
95
|
+
# end
|
96
|
+
|
97
|
+
#todo Too fragile!
|
98
|
+
# def test_kill_open_threads_kills_threads
|
99
|
+
# threads = CWThreads.new(self, [:sleep_thread, :a_thread])
|
100
|
+
# threads.start_threads
|
101
|
+
# thread0 = threads.threads[0]
|
102
|
+
# assert_equal "run", thread0[:thread].status
|
103
|
+
# thread1 = threads.threads[1]
|
104
|
+
# assert_equal "run", thread1[:thread].status
|
105
|
+
# threads.kill_open_threads
|
106
|
+
# count = 0
|
107
|
+
# found = 0
|
108
|
+
# loop do
|
109
|
+
# found = 0
|
110
|
+
# [thread0, thread1].each do |thr|
|
111
|
+
# found += 1 if thr[:thread].status == false
|
112
|
+
# end
|
113
|
+
# break if(found == 2)
|
114
|
+
# count += 1
|
115
|
+
# puts count
|
116
|
+
# break if count > 10
|
117
|
+
# sleep 0.01
|
118
|
+
# end
|
119
|
+
# assert(count < 10)
|
120
|
+
# assert_equal 2, found
|
121
|
+
# end
|
122
|
+
|
123
|
+
end
|
@@ -0,0 +1,439 @@
|
|
1
|
+
require 'simplecov'
|
2
|
+
$VERBOSE = nil #FIXME
|
3
|
+
SimpleCov.start
|
4
|
+
|
5
|
+
require 'minitest/autorun'
|
6
|
+
require 'minitest/pride'
|
7
|
+
require_relative '../lib/cw'
|
8
|
+
|
9
|
+
class TestCW < MiniTest::Test
|
10
|
+
|
11
|
+
ROOT = File.expand_path File.dirname(__FILE__) + '/../'
|
12
|
+
|
13
|
+
def setup
|
14
|
+
@cw = CW.new
|
15
|
+
@cw.no_run
|
16
|
+
end
|
17
|
+
|
18
|
+
def teardown
|
19
|
+
@cw = nil
|
20
|
+
end
|
21
|
+
|
22
|
+
def test_something
|
23
|
+
assert true
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_beginning_with_a
|
27
|
+
@cw.words = ['able', 'zero']
|
28
|
+
@cw.beginning_with('a')
|
29
|
+
assert_equal ['able'], @cw.words
|
30
|
+
end
|
31
|
+
|
32
|
+
def test_beginning_with_z
|
33
|
+
@cw.words = ['able', 'zero']
|
34
|
+
@cw.beginning_with('z')
|
35
|
+
assert_equal ['zero'], @cw.words
|
36
|
+
end
|
37
|
+
|
38
|
+
def test_beginning_with_ab
|
39
|
+
@cw.words = ['ardvark', 'able', 'zero']
|
40
|
+
@cw.beginning_with('ab')
|
41
|
+
assert_equal ['able'], @cw.words
|
42
|
+
end
|
43
|
+
|
44
|
+
def test_beginning_with_range
|
45
|
+
@cw.words = ['able', 'delta', 'zero']
|
46
|
+
@cw.beginning_with('a'..'d')
|
47
|
+
assert_equal ['able', 'delta'], @cw.words
|
48
|
+
end
|
49
|
+
|
50
|
+
def test_beginning_with_with_no_match
|
51
|
+
@cw.words = ['able', 'zero']
|
52
|
+
@cw.beginning_with('b')
|
53
|
+
assert_equal [], @cw.words
|
54
|
+
end
|
55
|
+
|
56
|
+
def test_beginning_with_with_empty_string_returns_all
|
57
|
+
@cw.words = ['able', 'zero']
|
58
|
+
@cw.beginning_with('')
|
59
|
+
assert_equal ['able', 'zero'], @cw.words
|
60
|
+
end
|
61
|
+
|
62
|
+
def test_words_beginning_with_a
|
63
|
+
@cw.words = ['able', 'zero']
|
64
|
+
@cw.words_beginning_with('a')
|
65
|
+
assert_equal ['able'], @cw.words
|
66
|
+
end
|
67
|
+
|
68
|
+
def test_words_beginning_with_z
|
69
|
+
@cw.words = ['able', 'zero']
|
70
|
+
@cw.words_beginning_with('z')
|
71
|
+
assert_equal ['zero'], @cw.words
|
72
|
+
end
|
73
|
+
|
74
|
+
def test_words_beginning_with_ab
|
75
|
+
@cw.words = ['ardvark', 'able', 'zero']
|
76
|
+
@cw.words_beginning_with('ab')
|
77
|
+
assert_equal ['able'], @cw.words
|
78
|
+
end
|
79
|
+
|
80
|
+
def test_words_beginning_with_range
|
81
|
+
@cw.words = ['able', 'delta', 'zero']
|
82
|
+
@cw.words_beginning_with('a'..'d')
|
83
|
+
assert_equal ['able', 'delta'], @cw.words
|
84
|
+
end
|
85
|
+
|
86
|
+
def test_words_beginning_with_with_no_match
|
87
|
+
@cw.words = ['able', 'zero']
|
88
|
+
@cw.words_beginning_with('b')
|
89
|
+
assert_equal [], @cw.words
|
90
|
+
end
|
91
|
+
|
92
|
+
def test_words_beginning_with_with_empty_string_returns_all
|
93
|
+
@cw.words = ['able', 'zero']
|
94
|
+
@cw.words_beginning_with('')
|
95
|
+
assert_equal ['able', 'zero'], @cw.words
|
96
|
+
end
|
97
|
+
|
98
|
+
def test_ending_with_a
|
99
|
+
@cw.words = ['else', 'antenna', 'alba', 'zero']
|
100
|
+
@cw.ending_with('a')
|
101
|
+
assert_equal ['antenna', 'alba'], @cw.words
|
102
|
+
end
|
103
|
+
|
104
|
+
def test_ending_with_z
|
105
|
+
@cw.words = ['joy', 'pazazz']
|
106
|
+
@cw.ending_with('z')
|
107
|
+
assert_equal ['pazazz'], @cw.words
|
108
|
+
end
|
109
|
+
|
110
|
+
def test_ending_with_tion
|
111
|
+
@cw.words = ['tiona', 'lion', 'station', 'creation']
|
112
|
+
@cw.ending_with('tion')
|
113
|
+
assert_equal ['station', 'creation'], @cw.words
|
114
|
+
end
|
115
|
+
|
116
|
+
def test_ending_with_range
|
117
|
+
@cw.words = ['may', 'kay', 'yam', 'eye', 'pizazz']
|
118
|
+
@cw.ending_with('y'..'z')
|
119
|
+
assert_equal ['may', 'kay', 'pizazz'], @cw.words
|
120
|
+
end
|
121
|
+
|
122
|
+
def test_ending_with_with_no_match
|
123
|
+
@cw.words = ['able', 'zero']
|
124
|
+
@cw.ending_with('b')
|
125
|
+
assert_equal [], @cw.words
|
126
|
+
end
|
127
|
+
|
128
|
+
def test_ending_with_with_empty_string_returns_all
|
129
|
+
@cw.words = ['able', 'zero']
|
130
|
+
@cw.ending_with('')
|
131
|
+
assert_equal ['able', 'zero'], @cw.words
|
132
|
+
end
|
133
|
+
|
134
|
+
def test_words_ending_with_a
|
135
|
+
@cw.words = ['else', 'antenna', 'alba', 'zero']
|
136
|
+
@cw.words_ending_with('a')
|
137
|
+
assert_equal ['antenna', 'alba'], @cw.words
|
138
|
+
end
|
139
|
+
|
140
|
+
def test_words_ending_with_z
|
141
|
+
@cw.words = ['joy', 'pazazz']
|
142
|
+
@cw.words_ending_with('z')
|
143
|
+
assert_equal ['pazazz'], @cw.words
|
144
|
+
end
|
145
|
+
|
146
|
+
def test_words_ending_with_tion
|
147
|
+
@cw.words = ['tiona', 'lion', 'station', 'creation']
|
148
|
+
@cw.words_ending_with('tion')
|
149
|
+
assert_equal ['station', 'creation'], @cw.words
|
150
|
+
end
|
151
|
+
|
152
|
+
def test_words_ending_with_range
|
153
|
+
@cw.words = ['may', 'kay', 'yam', 'eye', 'pizazz']
|
154
|
+
@cw.words_ending_with('y'..'z')
|
155
|
+
assert_equal ['may', 'kay', 'pizazz'], @cw.words
|
156
|
+
end
|
157
|
+
|
158
|
+
def test_words_ending_with_with_no_match
|
159
|
+
@cw.words = ['able', 'zero']
|
160
|
+
@cw.words_ending_with('b')
|
161
|
+
assert_equal [], @cw.words
|
162
|
+
end
|
163
|
+
|
164
|
+
def test_words_ending_with_with_empty_string_returns_all
|
165
|
+
@cw.words = ['able', 'zero']
|
166
|
+
@cw.words_ending_with('')
|
167
|
+
assert_equal ['able', 'zero'], @cw.words
|
168
|
+
end
|
169
|
+
|
170
|
+
def test_including_a
|
171
|
+
@cw.words = ['else', 'banter', 'alt', 'zero']
|
172
|
+
@cw.including('a')
|
173
|
+
assert_equal ['banter', 'alt'], @cw.words
|
174
|
+
end
|
175
|
+
|
176
|
+
def test_including_z
|
177
|
+
@cw.words = ['joy', 'amaze', '123']
|
178
|
+
@cw.including('z')
|
179
|
+
assert_equal ['amaze'], @cw.words
|
180
|
+
end
|
181
|
+
|
182
|
+
def test_including_tion
|
183
|
+
@cw.words = ['tiona', 'lion', 'station', 'creation']
|
184
|
+
@cw.including('tion')
|
185
|
+
assert_equal ['tiona', 'station', 'creation'], @cw.words
|
186
|
+
end
|
187
|
+
|
188
|
+
def test_including_range
|
189
|
+
@cw.words = ['may', 'kay', 'yam', 'eye', 'pizazz']
|
190
|
+
@cw.including('g'..'k')
|
191
|
+
assert_equal ['pizazz', 'kay'], @cw.words
|
192
|
+
end
|
193
|
+
|
194
|
+
def test_including_with_no_match
|
195
|
+
@cw.words = ['able', 'zero']
|
196
|
+
@cw.including('c')
|
197
|
+
assert_equal [], @cw.words
|
198
|
+
end
|
199
|
+
|
200
|
+
def test_including_with_empty_string_returns_all
|
201
|
+
@cw.words = ['able', 'zero']
|
202
|
+
@cw.including('')
|
203
|
+
assert_equal ['able', 'zero'], @cw.words
|
204
|
+
end
|
205
|
+
|
206
|
+
def test_words_including_a
|
207
|
+
@cw.words = ['else', 'banter', 'alt', 'zero']
|
208
|
+
@cw.words_including('a')
|
209
|
+
assert_equal ['banter', 'alt'], @cw.words
|
210
|
+
end
|
211
|
+
|
212
|
+
def test_words_including_z
|
213
|
+
@cw.words = ['joy', 'amaze', '123']
|
214
|
+
@cw.words_including('z')
|
215
|
+
assert_equal ['amaze'], @cw.words
|
216
|
+
end
|
217
|
+
|
218
|
+
def test_words_including_tion
|
219
|
+
@cw.words = ['tiona', 'lion', 'station', 'creation']
|
220
|
+
@cw.words_including('tion')
|
221
|
+
assert_equal ['tiona', 'station', 'creation'], @cw.words
|
222
|
+
end
|
223
|
+
|
224
|
+
def test_words_including_range
|
225
|
+
@cw.words = ['may', 'kay', 'yam', 'eye', 'pizazz']
|
226
|
+
@cw.words_including('g'..'k')
|
227
|
+
assert_equal ['pizazz', 'kay'], @cw.words
|
228
|
+
end
|
229
|
+
|
230
|
+
def test_words_including_with_no_match
|
231
|
+
@cw.words = ['able', 'zero']
|
232
|
+
@cw.words_including('c')
|
233
|
+
assert_equal [], @cw.words
|
234
|
+
end
|
235
|
+
|
236
|
+
def test_words_including_with_empty_string_returns_all
|
237
|
+
@cw.words = ['able', 'zero']
|
238
|
+
@cw.words_including('')
|
239
|
+
assert_equal ['able', 'zero'], @cw.words
|
240
|
+
end
|
241
|
+
|
242
|
+
def test_no_longer_than_1
|
243
|
+
@cw.words = ['1', '12', '123']
|
244
|
+
@cw.no_longer_than(1)
|
245
|
+
assert_equal ['1'], @cw.words
|
246
|
+
end
|
247
|
+
|
248
|
+
def test_no_longer_than_2
|
249
|
+
@cw.words = ['1', '12', '123']
|
250
|
+
@cw.no_longer_than(2)
|
251
|
+
assert_equal ['1', '12'], @cw.words
|
252
|
+
end
|
253
|
+
|
254
|
+
def test_no_longer_than_with_no_match
|
255
|
+
@cw.words = ['123', '1234', '12345']
|
256
|
+
@cw.no_longer_than(2)
|
257
|
+
assert_equal [], @cw.words
|
258
|
+
end
|
259
|
+
|
260
|
+
def test_words_no_longer_than_0
|
261
|
+
@cw.words = ['1', '12', '123']
|
262
|
+
@cw.words_no_longer_than(0)
|
263
|
+
assert_equal [], @cw.words
|
264
|
+
end
|
265
|
+
|
266
|
+
def test_words_no_longer_than_1
|
267
|
+
@cw.words = ['1', '12', '123']
|
268
|
+
@cw.words_no_longer_than(1)
|
269
|
+
assert_equal ['1'], @cw.words
|
270
|
+
end
|
271
|
+
|
272
|
+
def test_words_no_longer_than_2
|
273
|
+
@cw.words = ['1', '12', '123']
|
274
|
+
@cw.words_no_longer_than(2)
|
275
|
+
assert_equal ['1', '12'], @cw.words
|
276
|
+
end
|
277
|
+
|
278
|
+
def test_words_no_longer_than_with_words_no_match
|
279
|
+
@cw.words = ['123', '1234', '12345']
|
280
|
+
@cw.words_no_longer_than(2)
|
281
|
+
assert_equal [], @cw.words
|
282
|
+
end
|
283
|
+
|
284
|
+
def test_words_no_longer_than_0
|
285
|
+
@cw.words = ['1', '12', '123']
|
286
|
+
@cw.words_no_longer_than(0)
|
287
|
+
assert_equal [], @cw.words
|
288
|
+
end
|
289
|
+
|
290
|
+
def test_no_shorter_than_1
|
291
|
+
@cw.words = ['1', '12', '123']
|
292
|
+
@cw.no_shorter_than(1)
|
293
|
+
assert_equal ['1', '12', '123'], @cw.words
|
294
|
+
end
|
295
|
+
|
296
|
+
def test_no_shorter_than_2
|
297
|
+
@cw.words = ['1', '12', '123']
|
298
|
+
@cw.no_shorter_than(2)
|
299
|
+
assert_equal ['12', '123'], @cw.words
|
300
|
+
end
|
301
|
+
|
302
|
+
def test_no_shorter_than_3
|
303
|
+
@cw.words = ['1', '12', '123']
|
304
|
+
@cw.no_shorter_than(3)
|
305
|
+
assert_equal ['123'], @cw.words
|
306
|
+
end
|
307
|
+
|
308
|
+
def test_no_shorter_than_with_no_match
|
309
|
+
@cw.words = ['123', '1234', '12345']
|
310
|
+
@cw.no_shorter_than(4)
|
311
|
+
assert_equal ['1234', '12345'], @cw.words
|
312
|
+
end
|
313
|
+
|
314
|
+
def test_words_no_shorter_than_0
|
315
|
+
@cw.words = ['1', '12', '123']
|
316
|
+
@cw.words_no_shorter_than(0)
|
317
|
+
assert_equal ['1', '12', '123'], @cw.words
|
318
|
+
end
|
319
|
+
|
320
|
+
def test_words_no_shorter_than_1
|
321
|
+
@cw.words = ['1', '12', '123']
|
322
|
+
@cw.words_no_shorter_than(1)
|
323
|
+
assert_equal ['1', '12', '123'], @cw.words
|
324
|
+
end
|
325
|
+
|
326
|
+
def test_words_no_shorter_than_2
|
327
|
+
@cw.words = ['1', '12', '123']
|
328
|
+
@cw.words_no_shorter_than(2)
|
329
|
+
assert_equal ['12', '123'], @cw.words
|
330
|
+
end
|
331
|
+
|
332
|
+
def test_words_no_shorter_than_3
|
333
|
+
@cw.words = ['1', '12', '123']
|
334
|
+
@cw.words_no_shorter_than(3)
|
335
|
+
assert_equal ['123'], @cw.words
|
336
|
+
end
|
337
|
+
|
338
|
+
def test_words_no_shorter_than_with_words_no_match
|
339
|
+
@cw.words = ['123', '1234', '12345']
|
340
|
+
@cw.words_no_shorter_than(4)
|
341
|
+
assert_equal ['1234', '12345'], @cw.words
|
342
|
+
end
|
343
|
+
|
344
|
+
def test_words_no_shorter_than_0
|
345
|
+
@cw.words = ['1', '12', '123']
|
346
|
+
@cw.words_no_shorter_than(0)
|
347
|
+
assert_equal ['1', '12', '123'], @cw.words
|
348
|
+
end
|
349
|
+
|
350
|
+
def test_double_words
|
351
|
+
@cw.words = ['1', '12', '123']
|
352
|
+
@cw.double_words
|
353
|
+
assert_equal ['1', '1', '12', '12', '123', '123'], @cw.words
|
354
|
+
end
|
355
|
+
|
356
|
+
def test_repeat_once
|
357
|
+
@cw.words = ['1', '12', '123']
|
358
|
+
@cw.repeat 1
|
359
|
+
assert_equal ['1', '12', '123', '1', '12', '123'], @cw.words
|
360
|
+
end
|
361
|
+
|
362
|
+
def test_repeat_twice
|
363
|
+
@cw.words = ['1', '12', '123']
|
364
|
+
@cw.repeat 2
|
365
|
+
assert_equal ['1', '12', '123', '1', '12', '123', '1', '12', '123'], @cw.words
|
366
|
+
end
|
367
|
+
def test_repeat_none
|
368
|
+
@cw.words = ['1', '12', '123']
|
369
|
+
@cw.repeat 0
|
370
|
+
assert_equal ['1', '12', '123'], @cw.words
|
371
|
+
end
|
372
|
+
|
373
|
+
def test_word_size_1
|
374
|
+
@cw.words = ['1', '12', '123']
|
375
|
+
@cw.word_size 1
|
376
|
+
assert_equal ['1'], @cw.words
|
377
|
+
end
|
378
|
+
|
379
|
+
def test_word_size_2
|
380
|
+
@cw.words = ['1', '12', '23', '123']
|
381
|
+
@cw.word_size 2
|
382
|
+
assert_equal ['12','23'], @cw.words
|
383
|
+
end
|
384
|
+
|
385
|
+
def test_word_size_3
|
386
|
+
@cw.words = ['1', '12', '23', '123']
|
387
|
+
@cw.word_size 3
|
388
|
+
assert_equal ['123'], @cw.words
|
389
|
+
end
|
390
|
+
|
391
|
+
def test_having_size_of_1
|
392
|
+
@cw.words = ['1', '12', '123']
|
393
|
+
@cw.having_size_of 1
|
394
|
+
assert_equal ['1'], @cw.words
|
395
|
+
end
|
396
|
+
|
397
|
+
def test_having_size_of_2
|
398
|
+
@cw.words = ['1', '12', '23', '123']
|
399
|
+
@cw.having_size_of 2
|
400
|
+
assert_equal ['12','23'], @cw.words
|
401
|
+
end
|
402
|
+
|
403
|
+
def test_having_size_of_3
|
404
|
+
@cw.words = ['1', '12', '23', '123']
|
405
|
+
@cw.having_size_of 3
|
406
|
+
assert_equal ['123'], @cw.words
|
407
|
+
end
|
408
|
+
|
409
|
+
def test_word_length_1
|
410
|
+
@cw.words = ['1', '12', '123']
|
411
|
+
@cw.word_length 1
|
412
|
+
assert_equal ['1'], @cw.words
|
413
|
+
end
|
414
|
+
|
415
|
+
def test_word_length_2
|
416
|
+
@cw.words = ['1', '12', '23', '123']
|
417
|
+
@cw.word_length 2
|
418
|
+
assert_equal ['12','23'], @cw.words
|
419
|
+
end
|
420
|
+
|
421
|
+
def test_word_length_3
|
422
|
+
@cw.words = ['1', '12', '23', '123']
|
423
|
+
@cw.word_length 3
|
424
|
+
assert_equal ['123'], @cw.words
|
425
|
+
end
|
426
|
+
|
427
|
+
def test_containing_abc
|
428
|
+
@cw.words = ['abd', 'abc', 'acb', 'cba', '123', 'ab', 'ad', 'cb']
|
429
|
+
@cw.containing ['a','b','c']
|
430
|
+
assert_equal ['abc', 'acb', 'cba', 'ab', 'cb'], @cw.words
|
431
|
+
end
|
432
|
+
|
433
|
+
def test_containing_with_range
|
434
|
+
@cw.words = ['abd', 'abc', 'acb', 'cba', '123', 'ab', 'ad', 'cb']
|
435
|
+
@cw.containing ['a'..'c']
|
436
|
+
assert_equal ['abc', 'acb', 'cba', 'ab', 'cb'], @cw.words
|
437
|
+
end
|
438
|
+
end
|
439
|
+
|