rex 0.0.4
Sign up to get free protection for your applications and to get access to all the features.
- data/README +50 -0
- data/lib/rex.rb +23 -0
- data/lib/rex/array.rb +13 -0
- data/lib/rex/kernel.rb +11 -0
- data/lib/rex/modules/boolean.rb +14 -0
- data/lib/rex/modules/caller_name.rb +15 -0
- data/lib/rex/modules/ordinal.rb +35 -0
- data/lib/rex/modules/propercase.rb +15 -0
- data/lib/rex/modules/roman.rb +41 -0
- data/lib/rex/modules/scrub.rb +66 -0
- data/lib/rex/modules/stacktrace.rb +31 -0
- data/lib/rex/modules/swap.rb +13 -0
- data/lib/rex/modules/to_proc.rb +13 -0
- data/lib/rex/modules/tuple.rb +14 -0
- data/lib/rex/modules/wrap.rb +15 -0
- data/lib/rex/numeric.rb +19 -0
- data/lib/rex/string.rb +21 -0
- data/lib/rex/symbol.rb +13 -0
- data/test/boolean.rb +64 -0
- data/test/caller_name.rb +26 -0
- data/test/ordinal.rb +609 -0
- data/test/propercase.rb +40 -0
- data/test/roman.rb +335 -0
- data/test/scrub.rb +27 -0
- data/test/stacktrace.rb +24 -0
- data/test/swap.rb +44 -0
- data/test/to_proc.rb +24 -0
- data/test/tuple.rb +26 -0
- data/test/wrap.rb +44 -0
- metadata +92 -0
data/test/boolean.rb
ADDED
@@ -0,0 +1,64 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# boolean.rb
|
4
|
+
# Kernel#boolean? unit tests
|
5
|
+
|
6
|
+
require 'test/unit'
|
7
|
+
|
8
|
+
require 'pathname'
|
9
|
+
dir = Pathname.new(File.expand_path(__FILE__)).realpath
|
10
|
+
require File.join(File.dirname(dir.to_s), '../lib/rex')
|
11
|
+
|
12
|
+
class BooleanTests < Test::Unit::TestCase
|
13
|
+
def test_true
|
14
|
+
expected = true
|
15
|
+
actual = nil
|
16
|
+
|
17
|
+
assert_nothing_raised do
|
18
|
+
actual = true.boolean?
|
19
|
+
end
|
20
|
+
|
21
|
+
assert_not_nil(actual)
|
22
|
+
assert_instance_of(TrueClass, actual)
|
23
|
+
assert_equal(expected, actual)
|
24
|
+
end
|
25
|
+
|
26
|
+
def test_false
|
27
|
+
expected = true
|
28
|
+
actual = nil
|
29
|
+
|
30
|
+
assert_nothing_raised do
|
31
|
+
actual = false.boolean?
|
32
|
+
end
|
33
|
+
|
34
|
+
assert_not_nil(actual)
|
35
|
+
assert_instance_of(TrueClass, actual)
|
36
|
+
assert_equal(expected, actual)
|
37
|
+
end
|
38
|
+
|
39
|
+
def test_string
|
40
|
+
expected = false
|
41
|
+
actual = nil
|
42
|
+
|
43
|
+
assert_nothing_raised do
|
44
|
+
actual = 'la la la'.boolean?
|
45
|
+
end
|
46
|
+
|
47
|
+
assert_not_nil(actual)
|
48
|
+
assert_instance_of(FalseClass, actual)
|
49
|
+
assert_equal(expected, actual)
|
50
|
+
end
|
51
|
+
|
52
|
+
def test_nil
|
53
|
+
expected = nil
|
54
|
+
actual = nil
|
55
|
+
|
56
|
+
assert_raise(ArgumentError) do
|
57
|
+
actual = nil.boolean?
|
58
|
+
end
|
59
|
+
|
60
|
+
assert_nil(actual)
|
61
|
+
assert_instance_of(NilClass, actual)
|
62
|
+
assert_equal(expected, actual)
|
63
|
+
end
|
64
|
+
end
|
data/test/caller_name.rb
ADDED
@@ -0,0 +1,26 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# caller_name.rb
|
4
|
+
# Kernel#caller_name unit tests
|
5
|
+
|
6
|
+
require 'test/unit'
|
7
|
+
|
8
|
+
require 'pathname'
|
9
|
+
dir = Pathname.new(File.expand_path(__FILE__)).realpath
|
10
|
+
require File.join(File.dirname(dir.to_s), '../lib/rex')
|
11
|
+
|
12
|
+
class CallerNameTests < Test::Unit::TestCase
|
13
|
+
def test_caller_name
|
14
|
+
expected = File.basename(__FILE__)
|
15
|
+
actual = nil
|
16
|
+
|
17
|
+
assert_nothing_raised do
|
18
|
+
actual = File.basename(caller_name)
|
19
|
+
end
|
20
|
+
|
21
|
+
assert_not_nil(actual)
|
22
|
+
assert_instance_of(String, actual)
|
23
|
+
assert_equal(false, actual.empty?)
|
24
|
+
assert_equal(expected, actual)
|
25
|
+
end
|
26
|
+
end
|
data/test/ordinal.rb
ADDED
@@ -0,0 +1,609 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# ordinal.rb
|
4
|
+
# Integer#to_ordinal and Integer#from_ordinal unit tests
|
5
|
+
|
6
|
+
require 'test/unit'
|
7
|
+
|
8
|
+
require 'pathname'
|
9
|
+
dir = Pathname.new(File.expand_path(__FILE__)).realpath
|
10
|
+
require File.join(File.dirname(dir.to_s), '../lib/rex')
|
11
|
+
|
12
|
+
class OrdinalToTests < Test::Unit::TestCase
|
13
|
+
def test_to_0
|
14
|
+
expected = '0th'
|
15
|
+
actual = nil
|
16
|
+
|
17
|
+
assert_nothing_raised do
|
18
|
+
actual = 0.to_ordinal
|
19
|
+
end
|
20
|
+
|
21
|
+
assert_not_nil(actual)
|
22
|
+
assert_instance_of(String, actual)
|
23
|
+
assert_equal(false, actual.empty?)
|
24
|
+
assert_equal(expected, actual)
|
25
|
+
end
|
26
|
+
|
27
|
+
def test_to_1
|
28
|
+
expected = '1st'
|
29
|
+
actual = nil
|
30
|
+
|
31
|
+
assert_nothing_raised do
|
32
|
+
actual = 1.to_ordinal
|
33
|
+
end
|
34
|
+
|
35
|
+
assert_not_nil(actual)
|
36
|
+
assert_instance_of(String, actual)
|
37
|
+
assert_equal(false, actual.empty?)
|
38
|
+
assert_equal(expected, actual)
|
39
|
+
end
|
40
|
+
|
41
|
+
def test_to_2
|
42
|
+
expected = '2nd'
|
43
|
+
actual = nil
|
44
|
+
|
45
|
+
assert_nothing_raised do
|
46
|
+
actual = 2.to_ordinal
|
47
|
+
end
|
48
|
+
|
49
|
+
assert_not_nil(actual)
|
50
|
+
assert_instance_of(String, actual)
|
51
|
+
assert_equal(false, actual.empty?)
|
52
|
+
assert_equal(expected, actual)
|
53
|
+
end
|
54
|
+
|
55
|
+
def test_to_3
|
56
|
+
expected = '3rd'
|
57
|
+
actual = nil
|
58
|
+
caught_exception = false
|
59
|
+
|
60
|
+
assert_nothing_raised do
|
61
|
+
actual = 3.to_ordinal
|
62
|
+
end
|
63
|
+
|
64
|
+
assert_not_nil(actual)
|
65
|
+
assert_instance_of(String, actual)
|
66
|
+
assert_equal(false, actual.empty?)
|
67
|
+
assert_equal(expected, actual)
|
68
|
+
end
|
69
|
+
|
70
|
+
def test_to_4
|
71
|
+
expected = '4th'
|
72
|
+
actual = nil
|
73
|
+
|
74
|
+
assert_nothing_raised do
|
75
|
+
actual = 4.to_ordinal
|
76
|
+
end
|
77
|
+
|
78
|
+
assert_not_nil(actual)
|
79
|
+
assert_instance_of(String, actual)
|
80
|
+
assert_equal(false, actual.empty?)
|
81
|
+
assert_equal(expected, actual)
|
82
|
+
end
|
83
|
+
|
84
|
+
def test_to_10
|
85
|
+
expected = '10th'
|
86
|
+
actual = nil
|
87
|
+
|
88
|
+
assert_nothing_raised do
|
89
|
+
actual = 10.to_ordinal
|
90
|
+
end
|
91
|
+
|
92
|
+
assert_not_nil(actual)
|
93
|
+
assert_equal(String, actual.class)
|
94
|
+
assert_equal(false, actual.empty?)
|
95
|
+
assert_equal(expected, actual)
|
96
|
+
end
|
97
|
+
|
98
|
+
def test_to_11
|
99
|
+
expected = '11th'
|
100
|
+
actual = nil
|
101
|
+
|
102
|
+
assert_nothing_raised do
|
103
|
+
actual = 11.to_ordinal
|
104
|
+
end
|
105
|
+
|
106
|
+
assert_not_nil(actual)
|
107
|
+
assert_instance_of(String, actual)
|
108
|
+
assert_equal(false, actual.empty?)
|
109
|
+
assert_equal(expected, actual)
|
110
|
+
end
|
111
|
+
|
112
|
+
def test_to_12
|
113
|
+
expected = '12th'
|
114
|
+
actual = nil
|
115
|
+
|
116
|
+
assert_nothing_raised do
|
117
|
+
actual = 12.to_ordinal
|
118
|
+
end
|
119
|
+
|
120
|
+
assert_not_nil(actual)
|
121
|
+
assert_instance_of(String, actual)
|
122
|
+
assert_equal(false, actual.empty?)
|
123
|
+
assert_equal(expected, actual)
|
124
|
+
end
|
125
|
+
|
126
|
+
def test_to_13
|
127
|
+
expected = '13th'
|
128
|
+
actual = nil
|
129
|
+
|
130
|
+
assert_nothing_raised do
|
131
|
+
actual = 13.to_ordinal
|
132
|
+
end
|
133
|
+
|
134
|
+
assert_not_nil(actual)
|
135
|
+
assert_instance_of(String, actual)
|
136
|
+
assert_equal(false, actual.empty?)
|
137
|
+
assert_equal(expected, actual)
|
138
|
+
end
|
139
|
+
|
140
|
+
def test_to_14
|
141
|
+
expected = '14th'
|
142
|
+
actual = nil
|
143
|
+
|
144
|
+
assert_nothing_raised do
|
145
|
+
actual = 14.to_ordinal
|
146
|
+
end
|
147
|
+
|
148
|
+
assert_not_nil(actual)
|
149
|
+
assert_instance_of(String, actual)
|
150
|
+
assert_equal(false, actual.empty?)
|
151
|
+
assert_equal(expected, actual)
|
152
|
+
end
|
153
|
+
|
154
|
+
def test_to_20
|
155
|
+
expected = '20th'
|
156
|
+
actual = nil
|
157
|
+
|
158
|
+
assert_nothing_raised do
|
159
|
+
actual = 20.to_ordinal
|
160
|
+
end
|
161
|
+
|
162
|
+
assert_not_nil(actual)
|
163
|
+
assert_instance_of(String, actual)
|
164
|
+
assert_equal(false, actual.empty?)
|
165
|
+
assert_equal(expected, actual)
|
166
|
+
end
|
167
|
+
|
168
|
+
def test_to_21
|
169
|
+
expected = '21st'
|
170
|
+
actual = nil
|
171
|
+
|
172
|
+
assert_nothing_raised do
|
173
|
+
actual = 21.to_ordinal
|
174
|
+
end
|
175
|
+
|
176
|
+
assert_not_nil(actual)
|
177
|
+
assert_instance_of(String, actual)
|
178
|
+
assert_equal(false, actual.empty?)
|
179
|
+
assert_equal(expected, actual)
|
180
|
+
end
|
181
|
+
|
182
|
+
def test_to_22
|
183
|
+
expected = '22nd'
|
184
|
+
actual = nil
|
185
|
+
|
186
|
+
assert_nothing_raised do
|
187
|
+
actual = 22.to_ordinal
|
188
|
+
end
|
189
|
+
|
190
|
+
assert_not_nil(actual)
|
191
|
+
assert_instance_of(String, actual)
|
192
|
+
assert_equal(false, actual.empty?)
|
193
|
+
assert_equal(expected, actual)
|
194
|
+
end
|
195
|
+
|
196
|
+
def test_to_23
|
197
|
+
expected = '23rd'
|
198
|
+
actual = nil
|
199
|
+
|
200
|
+
assert_nothing_raised do
|
201
|
+
actual = 23.to_ordinal
|
202
|
+
end
|
203
|
+
|
204
|
+
assert_not_nil(actual)
|
205
|
+
assert_instance_of(String, actual)
|
206
|
+
assert_equal(false, actual.empty?)
|
207
|
+
assert_equal(expected, actual)
|
208
|
+
end
|
209
|
+
|
210
|
+
def test_to_24
|
211
|
+
expected = '24th'
|
212
|
+
actual = nil
|
213
|
+
|
214
|
+
assert_nothing_raised do
|
215
|
+
actual = 24.to_ordinal
|
216
|
+
end
|
217
|
+
|
218
|
+
assert_not_nil(actual)
|
219
|
+
assert_instance_of(String, actual)
|
220
|
+
assert_equal(false, actual.empty?)
|
221
|
+
assert_equal(expected, actual)
|
222
|
+
end
|
223
|
+
|
224
|
+
def test_to_100
|
225
|
+
expected = '100th'
|
226
|
+
actual = nil
|
227
|
+
|
228
|
+
assert_nothing_raised do
|
229
|
+
actual = 100.to_ordinal
|
230
|
+
end
|
231
|
+
|
232
|
+
assert_not_nil(actual)
|
233
|
+
assert_instance_of(String, actual)
|
234
|
+
assert_equal(false, actual.empty?)
|
235
|
+
assert_equal(expected, actual)
|
236
|
+
end
|
237
|
+
|
238
|
+
def test_to_101
|
239
|
+
expected = '101st'
|
240
|
+
actual = nil
|
241
|
+
|
242
|
+
assert_nothing_raised do
|
243
|
+
actual = 101.to_ordinal
|
244
|
+
end
|
245
|
+
|
246
|
+
assert_not_nil(actual)
|
247
|
+
assert_instance_of(String, actual)
|
248
|
+
assert_equal(false, actual.empty?)
|
249
|
+
assert_equal(expected, actual)
|
250
|
+
end
|
251
|
+
|
252
|
+
def test_to_102
|
253
|
+
expected = '102nd'
|
254
|
+
actual = nil
|
255
|
+
|
256
|
+
assert_nothing_raised do
|
257
|
+
actual = 102.to_ordinal
|
258
|
+
end
|
259
|
+
|
260
|
+
assert_not_nil(actual)
|
261
|
+
assert_instance_of(String, actual)
|
262
|
+
assert_equal(false, actual.empty?)
|
263
|
+
assert_equal(expected, actual)
|
264
|
+
end
|
265
|
+
|
266
|
+
def test_to_103
|
267
|
+
expected = '103rd'
|
268
|
+
actual = nil
|
269
|
+
|
270
|
+
assert_nothing_raised do
|
271
|
+
actual = 103.to_ordinal
|
272
|
+
end
|
273
|
+
|
274
|
+
assert_not_nil(actual)
|
275
|
+
assert_instance_of(String, actual)
|
276
|
+
assert_equal(false, actual.empty?)
|
277
|
+
assert_equal(expected, actual)
|
278
|
+
end
|
279
|
+
|
280
|
+
def test_to_104
|
281
|
+
expected = '104th'
|
282
|
+
actual = nil
|
283
|
+
|
284
|
+
assert_nothing_raised do
|
285
|
+
actual = 104.to_ordinal
|
286
|
+
end
|
287
|
+
|
288
|
+
assert_not_nil(actual)
|
289
|
+
assert_instance_of(String, actual)
|
290
|
+
assert_equal(false, actual.empty?)
|
291
|
+
assert_equal(expected, actual)
|
292
|
+
end
|
293
|
+
|
294
|
+
def test_to_1000000003
|
295
|
+
expected = '1000000003rd'
|
296
|
+
actual = nil
|
297
|
+
|
298
|
+
assert_nothing_raised do
|
299
|
+
actual = 1000000003.to_ordinal
|
300
|
+
end
|
301
|
+
|
302
|
+
assert_not_nil(actual)
|
303
|
+
assert_instance_of(String, actual)
|
304
|
+
assert_equal(false, actual.empty?)
|
305
|
+
assert_equal(expected, actual)
|
306
|
+
end
|
307
|
+
|
308
|
+
def test_to_123343434234234234004568937593847598437539847534958000000000223112323432452
|
309
|
+
expected = '123343434234234234004568937593847598437539847534958000000000223112323432452nd'
|
310
|
+
actual = nil
|
311
|
+
|
312
|
+
assert_nothing_raised do
|
313
|
+
actual = 123343434234234234004568937593847598437539847534958000000000223112323432452.to_ordinal
|
314
|
+
end
|
315
|
+
|
316
|
+
assert_not_nil(actual)
|
317
|
+
assert_equal(String, actual.class)
|
318
|
+
assert_equal(false, actual.empty?)
|
319
|
+
assert_equal(expected, actual)
|
320
|
+
end
|
321
|
+
end
|
322
|
+
|
323
|
+
class OrdinalFromTests < Test::Unit::TestCase
|
324
|
+
def test_from_0
|
325
|
+
expected = 0
|
326
|
+
actual = nil
|
327
|
+
|
328
|
+
assert_nothing_raised do
|
329
|
+
actual = Integer.from_ordinal('0th')
|
330
|
+
end
|
331
|
+
|
332
|
+
assert_not_nil(actual)
|
333
|
+
assert_instance_of(Fixnum, actual)
|
334
|
+
assert_equal(expected, actual)
|
335
|
+
end
|
336
|
+
|
337
|
+
def test_from_1
|
338
|
+
expected = 1
|
339
|
+
actual = nil
|
340
|
+
|
341
|
+
assert_nothing_raised do
|
342
|
+
actual = Integer.from_ordinal('1st')
|
343
|
+
end
|
344
|
+
|
345
|
+
assert_not_nil(actual)
|
346
|
+
assert_instance_of(Fixnum, actual)
|
347
|
+
assert_equal(expected, actual)
|
348
|
+
end
|
349
|
+
|
350
|
+
def test_from_2
|
351
|
+
expected = 2
|
352
|
+
actual = nil
|
353
|
+
|
354
|
+
assert_nothing_raised do
|
355
|
+
actual = Integer.from_ordinal('2nd')
|
356
|
+
end
|
357
|
+
|
358
|
+
assert_not_nil(actual)
|
359
|
+
assert_instance_of(Fixnum, actual)
|
360
|
+
assert_equal(expected, actual)
|
361
|
+
end
|
362
|
+
|
363
|
+
def test_from_3
|
364
|
+
expected = 3
|
365
|
+
actual = nil
|
366
|
+
|
367
|
+
assert_nothing_raised do
|
368
|
+
actual = Integer.from_ordinal('3rd')
|
369
|
+
end
|
370
|
+
|
371
|
+
assert_not_nil(actual)
|
372
|
+
assert_equal(Fixnum, actual.class)
|
373
|
+
assert_equal(expected, actual)
|
374
|
+
end
|
375
|
+
|
376
|
+
def test_from_4
|
377
|
+
expected = 4
|
378
|
+
actual = nil
|
379
|
+
|
380
|
+
assert_nothing_raised do
|
381
|
+
actual = Integer.from_ordinal('4th')
|
382
|
+
end
|
383
|
+
|
384
|
+
assert_not_nil(actual)
|
385
|
+
assert_instance_of(Fixnum, actual)
|
386
|
+
assert_equal(expected, actual)
|
387
|
+
end
|
388
|
+
|
389
|
+
def test_from_10
|
390
|
+
expected = 10
|
391
|
+
actual = nil
|
392
|
+
|
393
|
+
assert_nothing_raised do
|
394
|
+
actual = Integer.from_ordinal('10th')
|
395
|
+
end
|
396
|
+
|
397
|
+
assert_not_nil(actual)
|
398
|
+
assert_instance_of(Fixnum, actual)
|
399
|
+
assert_equal(expected, actual)
|
400
|
+
end
|
401
|
+
|
402
|
+
def test_from_11
|
403
|
+
expected = 11
|
404
|
+
actual = nil
|
405
|
+
|
406
|
+
assert_nothing_raised do
|
407
|
+
actual = Integer.from_ordinal('11th')
|
408
|
+
end
|
409
|
+
|
410
|
+
assert_not_nil(actual)
|
411
|
+
assert_instance_of(Fixnum, actual)
|
412
|
+
assert_equal(expected, actual)
|
413
|
+
end
|
414
|
+
|
415
|
+
def test_from_12
|
416
|
+
expected = 12
|
417
|
+
actual = nil
|
418
|
+
|
419
|
+
assert_nothing_raised do
|
420
|
+
actual = Integer.from_ordinal('12th')
|
421
|
+
end
|
422
|
+
|
423
|
+
assert_not_nil(actual)
|
424
|
+
assert_instance_of(Fixnum, actual)
|
425
|
+
assert_equal(expected, actual)
|
426
|
+
end
|
427
|
+
|
428
|
+
def test_from_13
|
429
|
+
expected = 13
|
430
|
+
actual = nil
|
431
|
+
|
432
|
+
assert_nothing_raised do
|
433
|
+
actual = Integer.from_ordinal('13th')
|
434
|
+
end
|
435
|
+
|
436
|
+
assert_not_nil(actual)
|
437
|
+
assert_instance_of(Fixnum, actual)
|
438
|
+
assert_equal(expected, actual)
|
439
|
+
end
|
440
|
+
|
441
|
+
def test_from_14
|
442
|
+
expected = 14
|
443
|
+
actual = nil
|
444
|
+
|
445
|
+
assert_nothing_raised do
|
446
|
+
actual = Integer.from_ordinal('14th')
|
447
|
+
end
|
448
|
+
|
449
|
+
assert_not_nil(actual)
|
450
|
+
assert_instance_of(Fixnum, actual)
|
451
|
+
assert_equal(expected, actual)
|
452
|
+
end
|
453
|
+
|
454
|
+
def test_from_20
|
455
|
+
expected = 20
|
456
|
+
actual = nil
|
457
|
+
|
458
|
+
assert_nothing_raised do
|
459
|
+
actual = Integer.from_ordinal('20th')
|
460
|
+
end
|
461
|
+
|
462
|
+
assert_not_nil(actual)
|
463
|
+
assert_instance_of(Fixnum, actual)
|
464
|
+
assert_equal(expected, actual)
|
465
|
+
end
|
466
|
+
|
467
|
+
def test_from_21
|
468
|
+
expected = 21
|
469
|
+
actual = nil
|
470
|
+
|
471
|
+
assert_nothing_raised do
|
472
|
+
actual = Integer.from_ordinal('21st')
|
473
|
+
end
|
474
|
+
|
475
|
+
assert_not_nil(actual)
|
476
|
+
assert_instance_of(Fixnum, actual)
|
477
|
+
assert_equal(expected, actual)
|
478
|
+
end
|
479
|
+
|
480
|
+
def test_from_22
|
481
|
+
expected = 22
|
482
|
+
actual = nil
|
483
|
+
|
484
|
+
assert_nothing_raised do
|
485
|
+
actual = Integer.from_ordinal('22nd')
|
486
|
+
end
|
487
|
+
|
488
|
+
assert_not_nil(actual)
|
489
|
+
assert_instance_of(Fixnum, actual)
|
490
|
+
assert_equal(expected, actual)
|
491
|
+
end
|
492
|
+
|
493
|
+
def test_from_23
|
494
|
+
expected = 23
|
495
|
+
actual = nil
|
496
|
+
|
497
|
+
assert_nothing_raised do
|
498
|
+
actual = Integer.from_ordinal('23rd')
|
499
|
+
end
|
500
|
+
|
501
|
+
assert_not_nil(actual)
|
502
|
+
assert_instance_of(Fixnum, actual)
|
503
|
+
assert_equal(expected, actual)
|
504
|
+
end
|
505
|
+
|
506
|
+
def test_from_24
|
507
|
+
expected = 24
|
508
|
+
actual = nil
|
509
|
+
|
510
|
+
assert_nothing_raised do
|
511
|
+
actual = Integer.from_ordinal('24th')
|
512
|
+
end
|
513
|
+
|
514
|
+
assert_not_nil(actual)
|
515
|
+
assert_instance_of(Fixnum, actual)
|
516
|
+
assert_equal(expected, actual)
|
517
|
+
end
|
518
|
+
|
519
|
+
def test_from_100
|
520
|
+
expected = 100
|
521
|
+
actual = nil
|
522
|
+
|
523
|
+
assert_nothing_raised do
|
524
|
+
actual = Integer.from_ordinal('100th')
|
525
|
+
end
|
526
|
+
|
527
|
+
assert_not_nil(actual)
|
528
|
+
assert_instance_of(Fixnum, actual)
|
529
|
+
assert_equal(expected, actual)
|
530
|
+
end
|
531
|
+
|
532
|
+
def test_from_101
|
533
|
+
expected = 101
|
534
|
+
actual = nil
|
535
|
+
|
536
|
+
assert_nothing_raised do
|
537
|
+
actual = Integer.from_ordinal('101st')
|
538
|
+
end
|
539
|
+
|
540
|
+
assert_not_nil(actual)
|
541
|
+
assert_instance_of(Fixnum, actual)
|
542
|
+
assert_equal(expected, actual)
|
543
|
+
end
|
544
|
+
|
545
|
+
def test_from_102
|
546
|
+
expected = 102
|
547
|
+
actual = nil
|
548
|
+
|
549
|
+
assert_nothing_raised do
|
550
|
+
actual = Integer.from_ordinal('102nd')
|
551
|
+
end
|
552
|
+
|
553
|
+
assert_not_nil(actual)
|
554
|
+
assert_instance_of(Fixnum, actual)
|
555
|
+
assert_equal(expected, actual)
|
556
|
+
end
|
557
|
+
|
558
|
+
def test_from_103
|
559
|
+
expected = 103
|
560
|
+
actual = nil
|
561
|
+
|
562
|
+
assert_nothing_raised do
|
563
|
+
actual = Integer.from_ordinal('103rd')
|
564
|
+
end
|
565
|
+
|
566
|
+
assert_not_nil(actual)
|
567
|
+
assert_instance_of(Fixnum, actual)
|
568
|
+
assert_equal(expected, actual)
|
569
|
+
end
|
570
|
+
|
571
|
+
def test_from_104
|
572
|
+
expected = 104
|
573
|
+
actual = nil
|
574
|
+
|
575
|
+
assert_nothing_raised do
|
576
|
+
actual = Integer.from_ordinal('104th')
|
577
|
+
end
|
578
|
+
|
579
|
+
assert_not_nil(actual)
|
580
|
+
assert_instance_of(Fixnum, actual)
|
581
|
+
assert_equal(expected, actual)
|
582
|
+
end
|
583
|
+
|
584
|
+
def test_from_1000000003
|
585
|
+
expected = 1000000003
|
586
|
+
actual = nil
|
587
|
+
|
588
|
+
assert_nothing_raised do
|
589
|
+
actual = Integer.from_ordinal('1000000003rd')
|
590
|
+
end
|
591
|
+
|
592
|
+
assert_not_nil(actual)
|
593
|
+
assert_instance_of(Fixnum, actual)
|
594
|
+
assert_equal(expected, actual)
|
595
|
+
end
|
596
|
+
|
597
|
+
def test_from_123343434234234234004568937593847598437539847534958000000000223112323432452
|
598
|
+
expected = 123343434234234234004568937593847598437539847534958000000000223112323432452
|
599
|
+
actual = nil
|
600
|
+
|
601
|
+
assert_nothing_raised do
|
602
|
+
actual = Integer.from_ordinal('123343434234234234004568937593847598437539847534958000000000223112323432452nd')
|
603
|
+
end
|
604
|
+
|
605
|
+
assert_not_nil(actual)
|
606
|
+
assert_instance_of(Bignum, actual)
|
607
|
+
assert_equal(expected, actual)
|
608
|
+
end
|
609
|
+
end
|