oktest 1.3.1 → 1.5.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/README.md +156 -18
- data/Rakefile.rb +1 -1
- data/benchmark/run_all.rb +1 -0
- data/bin/oktest +3 -0
- data/lib/oktest.rb +253 -143
- data/oktest.gemspec +4 -3
- data/test/{run_all.rb → all.rb} +1 -0
- data/test/assertion_test.rb +244 -229
- data/test/filter_test.rb +123 -120
- data/test/fixture_test.rb +34 -32
- data/test/generator_test.rb +26 -22
- data/test/helper_test.rb +382 -204
- data/test/init.rb +44 -0
- data/test/mainapp_test.rb +249 -199
- data/test/matcher_test.rb +157 -126
- data/test/misc_test.rb +32 -30
- data/test/nanot.rb +307 -0
- data/test/node_test.rb +321 -242
- data/test/reporter_test.rb +250 -208
- data/test/runner_test.rb +102 -100
- data/test/util_test.rb +197 -193
- data/test/utilhelper_test.rb +36 -38
- data/test/visitor_test.rb +55 -50
- metadata +21 -7
- data/test/initialize.rb +0 -21
- data/test/tc.rb +0 -127
data/test/assertion_test.rb
CHANGED
@@ -1,24 +1,25 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
4
|
###
|
4
|
-
### $Release: 1.
|
5
|
+
### $Release: 1.5.0 $
|
5
6
|
### $Copyright: copyright(c) 2011-2024 kuwata-lab.com all rights reserved $
|
6
7
|
### $License: MIT License $
|
7
8
|
###
|
8
9
|
|
9
|
-
require_relative './
|
10
|
+
require_relative './init'
|
10
11
|
|
11
12
|
|
12
|
-
class
|
13
|
-
|
14
|
-
|
13
|
+
class AssertionObject__Test
|
14
|
+
extend NanoTest
|
15
|
+
extend Oktest::SpecHelper
|
15
16
|
|
16
|
-
def FAIL!(errmsg, &b)
|
17
|
+
def self.FAIL!(errmsg, &b)
|
17
18
|
failmsg = "expected to be failed, but succeeded unexpectedly."
|
18
19
|
return ERROR!(Oktest::FAIL_EXCEPTION, errmsg, failmsg, &b)
|
19
20
|
end
|
20
21
|
|
21
|
-
def ERROR!(errcls, errmsg=nil, _failmsg=nil, &b)
|
22
|
+
def self.ERROR!(errcls, errmsg=nil, _failmsg=nil, &b)
|
22
23
|
exc = nil
|
23
24
|
begin
|
24
25
|
yield
|
@@ -28,92 +29,92 @@ class AssertionObject_TC < TC
|
|
28
29
|
raise
|
29
30
|
else
|
30
31
|
_failmsg ||= "#{errcls} expected to be raised, but nothing raised."
|
31
|
-
|
32
|
+
test_ok? false, _failmsg
|
32
33
|
end
|
33
34
|
#
|
34
35
|
if errmsg
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
36
|
+
test_ok? errmsg === exc.message,
|
37
|
+
msg: ("unexpected error message:\n"\
|
38
|
+
" expected: #{errmsg}\n"\
|
39
|
+
" actual: #{exc.message}")
|
39
40
|
end
|
40
41
|
#
|
41
42
|
return exc
|
42
43
|
end
|
43
44
|
|
44
|
-
def PASS!()
|
45
|
+
def self.PASS!(&b)
|
45
46
|
yield
|
46
47
|
end
|
47
48
|
|
48
|
-
def should_return_self
|
49
|
+
def self.should_return_self(&b)
|
49
50
|
obj = yield
|
50
|
-
|
51
|
+
test_ok? obj.class == Oktest::AssertionObject
|
51
52
|
end
|
52
53
|
|
53
54
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
sout, serr =
|
55
|
+
test_target 'Oktest::AssertionObject.report_not_yet()' do
|
56
|
+
test_subject "[!3nksf] reports if 'ok{}' called but assertion not performed." do
|
57
|
+
test_ok? Oktest::AssertionObject::NOT_YET.empty?, msg: "should be empty"
|
58
|
+
sout, serr = capture_output! do
|
58
59
|
Oktest::AssertionObject.report_not_yet()
|
59
60
|
end
|
60
|
-
|
61
|
-
|
61
|
+
test_eq? sout, ""
|
62
|
+
test_eq? serr, ""
|
62
63
|
#
|
63
64
|
lineno = __LINE__ + 1
|
64
65
|
ok {1+1}
|
65
|
-
|
66
|
-
sout, serr =
|
66
|
+
test_ok? ! Oktest::AssertionObject::NOT_YET.empty?, msg: "should not be empty"
|
67
|
+
sout, serr = capture_output! { Oktest::AssertionObject.report_not_yet() }
|
67
68
|
expected = "** warning: ok() is called but not tested yet (at #{__FILE__}:#{lineno}:in"
|
68
|
-
|
69
|
-
|
69
|
+
test_eq? sout, ""
|
70
|
+
test_ok? serr.start_with?(expected), msg: "not matched"
|
70
71
|
end
|
71
|
-
|
72
|
+
test_subject "[!f92q4] clears remained objects." do
|
72
73
|
ok {1+1}
|
73
|
-
|
74
|
-
sout, serr =
|
75
|
-
|
74
|
+
test_ok? ! Oktest::AssertionObject::NOT_YET.empty?, msg: "should not be empty"
|
75
|
+
sout, serr = capture_output! { Oktest::AssertionObject.report_not_yet() }
|
76
|
+
test_ok? Oktest::AssertionObject::NOT_YET.empty?, msg: "should be empty"
|
76
77
|
end
|
77
78
|
end
|
78
79
|
|
79
|
-
|
80
|
-
|
80
|
+
test_target 'Oktest::AssertionObject.NOT()' do
|
81
|
+
test_subject "[!g775v] returns self." do
|
81
82
|
begin
|
82
83
|
should_return_self { ok {1+1}.NOT }
|
83
84
|
ensure
|
84
85
|
Oktest::AssertionObject::NOT_YET.clear()
|
85
86
|
end
|
86
87
|
end
|
87
|
-
|
88
|
+
test_subject "[!63dde] toggles internal boolean." do
|
88
89
|
begin
|
89
90
|
x = ok {1+1}
|
90
|
-
|
91
|
+
test_eq? x.bool, true
|
91
92
|
x.NOT
|
92
|
-
|
93
|
+
test_eq? x.bool, false
|
93
94
|
ensure
|
94
95
|
Oktest::AssertionObject::NOT_YET.clear()
|
95
96
|
end
|
96
97
|
end
|
97
98
|
end
|
98
99
|
|
99
|
-
|
100
|
-
|
100
|
+
test_target 'Oktest::AssertionObject#==' do
|
101
|
+
test_subject "[!c6p0e] returns self when passed." do
|
101
102
|
should_return_self { ok {1+1} == 2 }
|
102
103
|
end
|
103
|
-
|
104
|
+
test_subject "[!1iun4] raises assertion error when failed." do
|
104
105
|
errmsg = "$<actual> == $<expected>: failed.\n"\
|
105
106
|
" $<actual>: 2\n"\
|
106
107
|
" $<expected>: 3"
|
107
108
|
FAIL!(errmsg) { ok {1+1} == 3 }
|
108
109
|
end
|
109
|
-
|
110
|
+
test_subject "[!eyslp] is avaialbe with NOT." do
|
110
111
|
PASS! { ok {1+1}.NOT == 3 }
|
111
112
|
errmsg = "$<actual> != $<expected>: failed.\n"\
|
112
113
|
" $<actual>: 2\n"\
|
113
114
|
" $<expected>: 2"
|
114
115
|
FAIL!(errmsg) { ok {1+1}.NOT == 2 }
|
115
116
|
end
|
116
|
-
|
117
|
+
test_subject "[!3xnqv] shows context diff when both actual and expected are text." do
|
117
118
|
expected = "Haruhi\nMikuru\nYuki\n"
|
118
119
|
actual = "Haruhi\nMichiru\nYuki\n"
|
119
120
|
errmsg = <<'END'
|
@@ -132,18 +133,18 @@ END
|
|
132
133
|
end
|
133
134
|
end
|
134
135
|
|
135
|
-
|
136
|
-
|
136
|
+
test_target 'Oktest::AssertionObject#!=' do
|
137
|
+
test_subject "[!iakbb] returns self when passed." do
|
137
138
|
should_return_self { ok {1+1} != 3 }
|
138
139
|
end
|
139
|
-
|
140
|
+
test_subject "[!90tfb] raises assertion error when failed." do
|
140
141
|
#errmsg = "<2> expected to be != to\n<2>."
|
141
142
|
errmsg = "$<actual> != $<expected>: failed.\n"\
|
142
143
|
" $<actual>: 2\n"\
|
143
144
|
" $<expected>: 2"
|
144
145
|
FAIL!(errmsg) { ok {1+1} != 2 }
|
145
146
|
end
|
146
|
-
|
147
|
+
test_subject "[!l6afg] is avaialbe with NOT." do
|
147
148
|
PASS! { ok {1+1}.NOT != 2 }
|
148
149
|
#errmsg = "<3> expected but was\n<2>."
|
149
150
|
errmsg = "$<actual> == $<expected>: failed.\n"\
|
@@ -153,39 +154,41 @@ END
|
|
153
154
|
end
|
154
155
|
end #if RUBY_VERSION >= "1.9"
|
155
156
|
|
156
|
-
|
157
|
-
|
157
|
+
test_target 'Oktest::AssertionObject#===' do
|
158
|
+
test_subject "[!uh8bm] returns self when passed." do
|
158
159
|
should_return_self { ok {String} === 'str' }
|
159
160
|
end
|
160
|
-
|
161
|
+
test_subject "[!42f6a] raises assertion error when failed." do
|
161
162
|
errmsg = "$<actual> === $<expected>: failed.\n"\
|
162
163
|
" $<actual>: Integer\n"\
|
163
164
|
" $<expected>: \"str\""
|
164
165
|
FAIL!(errmsg) { ok {Integer} === 'str' }
|
165
166
|
end
|
166
|
-
|
167
|
+
test_subject "[!vhvyu] is avaialbe with NOT." do
|
167
168
|
PASS! { ok {Integer}.NOT === 'str' }
|
168
169
|
errmsg = "!($<actual> === $<expected>): failed.\n"\
|
169
170
|
" $<actual>: String\n"\
|
170
171
|
" $<expected>: \"str\""
|
171
172
|
FAIL!(errmsg) { ok {String}.NOT === 'str' }
|
172
173
|
end
|
173
|
-
|
174
|
+
test_subject "[!mjh4d] raises error when combination of 'not_ok()' and matcher object." do
|
174
175
|
errmsg = "negative `===` is not available with matcher object."
|
175
|
-
|
176
|
+
exc = test_exception? Oktest::OktestError do
|
176
177
|
not_ok {Oktest::JsonMatcher.new({})} === {}
|
177
178
|
end
|
178
|
-
|
179
|
+
test_eq? errmsg, exc.message
|
180
|
+
exc = test_exception? Oktest::OktestError do
|
179
181
|
ok {Oktest::JsonMatcher.new({})}.NOT === {}
|
180
182
|
end
|
183
|
+
test_eq? errmsg, exc.message
|
181
184
|
end
|
182
185
|
end
|
183
186
|
|
184
|
-
|
185
|
-
|
187
|
+
test_target 'Oktest::AssertionObject>' do
|
188
|
+
test_subject "[!3j7ty] returns self when passed." do
|
186
189
|
should_return_self { ok {2} > 1 }
|
187
190
|
end
|
188
|
-
|
191
|
+
test_subject "[!vjjuq] raises assertion error when failed." do
|
189
192
|
#errmsg = "Expected 2 to be > 2."
|
190
193
|
errmsg = "2 > 2: failed."
|
191
194
|
FAIL!(errmsg) { ok {2} > 2 }
|
@@ -195,7 +198,7 @@ END
|
|
195
198
|
errmsg = "\"aaa\" > \"bbb\": failed."
|
196
199
|
FAIL!(errmsg) { ok {'aaa'} > 'bbb' }
|
197
200
|
end
|
198
|
-
|
201
|
+
test_subject "[!73a0t] is avaialbe with NOT." do
|
199
202
|
PASS! { ok {2}.NOT > 2 }
|
200
203
|
#errmsg = "Expected 2 to be <= 1."
|
201
204
|
errmsg = "2 <= 1: failed."
|
@@ -203,12 +206,12 @@ END
|
|
203
206
|
end
|
204
207
|
end
|
205
208
|
|
206
|
-
|
207
|
-
|
209
|
+
test_target 'Oktest::AssertionObject>=' do
|
210
|
+
test_subject "[!75iqw] returns self when passed." do
|
208
211
|
should_return_self { ok {2} >= 2 }
|
209
212
|
should_return_self { ok {2} >= 1 }
|
210
213
|
end
|
211
|
-
|
214
|
+
test_subject "[!isdfc] raises assertion error when failed." do
|
212
215
|
#errmsg = "Expected 1 to be >= 2."
|
213
216
|
errmsg = "1 >= 2: failed."
|
214
217
|
FAIL!(errmsg) { ok {1} >= 2 }
|
@@ -216,7 +219,7 @@ END
|
|
216
219
|
errmsg = "\"aaa\" >= \"bbb\": failed."
|
217
220
|
FAIL!(errmsg) { ok {'aaa'} >= 'bbb' }
|
218
221
|
end
|
219
|
-
|
222
|
+
test_subject "[!3dgmh] is avaialbe with NOT." do
|
220
223
|
PASS! { ok {1}.NOT >= 2 }
|
221
224
|
#errmsg = "Expected 2 to be < 2."
|
222
225
|
errmsg = "2 < 2: failed."
|
@@ -224,11 +227,11 @@ END
|
|
224
227
|
end
|
225
228
|
end
|
226
229
|
|
227
|
-
|
228
|
-
|
230
|
+
test_target 'Oktest::AssertionObject<' do
|
231
|
+
test_subject "[!vkwcc] returns self when passed." do
|
229
232
|
should_return_self { ok {1} < 2 }
|
230
233
|
end
|
231
|
-
|
234
|
+
test_subject "[!ukqa0] raises assertion error when failed." do
|
232
235
|
#errmsg = "Expected 2 to be < 2."
|
233
236
|
errmsg = "2 < 2: failed."
|
234
237
|
FAIL!(errmsg) { ok {2} < 2 }
|
@@ -238,7 +241,7 @@ END
|
|
238
241
|
errmsg = "\"bbb\" < \"aaa\": failed."
|
239
242
|
FAIL!(errmsg) { ok {'bbb'} < 'aaa' }
|
240
243
|
end
|
241
|
-
|
244
|
+
test_subject "[!gwvdl] is avaialbe with NOT." do
|
242
245
|
PASS! { ok {2}.NOT < 2 }
|
243
246
|
#errmsg = "Expected 1 to be >= 2."
|
244
247
|
errmsg = "1 >= 2: failed."
|
@@ -246,12 +249,12 @@ END
|
|
246
249
|
end
|
247
250
|
end
|
248
251
|
|
249
|
-
|
250
|
-
|
252
|
+
test_target 'Oktest::AssertionObject<=' do
|
253
|
+
test_subject "[!yk7t2] returns self when passed." do
|
251
254
|
should_return_self { ok {1} <= 2 }
|
252
255
|
should_return_self { ok {1} <= 1 }
|
253
256
|
end
|
254
|
-
|
257
|
+
test_subject "[!ordwe] raises assertion error when failed." do
|
255
258
|
#errmsg = "Expected 2 to be <= 1."
|
256
259
|
errmsg = "2 <= 1: failed."
|
257
260
|
FAIL!(errmsg) { ok {2} <= 1 }
|
@@ -259,7 +262,7 @@ END
|
|
259
262
|
errmsg = "\"bbb\" <= \"aaa\": failed."
|
260
263
|
FAIL!(errmsg) { ok {'bbb'} <= 'aaa' }
|
261
264
|
end
|
262
|
-
|
265
|
+
test_subject "[!mcb9w] is avaialbe with NOT." do
|
263
266
|
PASS! { ok {2}.NOT <= 1 }
|
264
267
|
#errmsg = "Expected 1 to be > 2."
|
265
268
|
errmsg = "1 > 2: failed."
|
@@ -267,11 +270,11 @@ END
|
|
267
270
|
end
|
268
271
|
end
|
269
272
|
|
270
|
-
|
271
|
-
|
273
|
+
test_target 'Oktest::AssertionObject=~' do
|
274
|
+
test_subject "[!acypf] returns self when passed." do
|
272
275
|
should_return_self { ok {'SOS'} =~ /^[A-Z]+$/ }
|
273
276
|
end
|
274
|
-
|
277
|
+
test_subject "[!xkldu] raises assertion error when failed." do
|
275
278
|
#errmsg = 'Expected /^\\d+$/ to match "SOS".'
|
276
279
|
errmsg = "$<actual> =~ $<expected>: failed.\n"\
|
277
280
|
" $<expected>: /^\\d+$/\n"\
|
@@ -280,7 +283,7 @@ END
|
|
280
283
|
"END\n"
|
281
284
|
FAIL!(errmsg) { ok {"SOS\n"} =~ /^\d+$/ }
|
282
285
|
end
|
283
|
-
|
286
|
+
test_subject "[!2aa6f] is avaialbe with NOT." do
|
284
287
|
PASS! { ok {'SOS'}.NOT =~ /^\d+$/ }
|
285
288
|
#errmsg = "</\\w+/> expected to not match\n<\"SOS\">."
|
286
289
|
errmsg = "$<actual> !~ $<expected>: failed.\n"\
|
@@ -290,18 +293,18 @@ END
|
|
290
293
|
end if false
|
291
294
|
end
|
292
295
|
|
293
|
-
|
294
|
-
|
296
|
+
test_target 'Oktest::AssertionObject!~' do
|
297
|
+
test_subject "[!xywdr] returns self when passed." do
|
295
298
|
should_return_self { ok {'SOS'} !~ /^\d+$/ }
|
296
299
|
end
|
297
|
-
|
300
|
+
test_subject "[!58udu] raises assertion error when failed." do
|
298
301
|
#errmsg = "</^\\w+$/> expected to not match\n<\"SOS\">."
|
299
302
|
errmsg = "$<actual> !~ $<expected>: failed.\n"\
|
300
303
|
" $<expected>: /^\\w+$/\n"\
|
301
304
|
" $<actual>: \"SOS\"\n"
|
302
305
|
FAIL!(errmsg) { ok {'SOS'} !~ /^\w+$/ }
|
303
306
|
end
|
304
|
-
|
307
|
+
test_subject "[!iuf5j] is avaialbe with NOT." do
|
305
308
|
PASS! { ok {'SOS'}.NOT !~ /^\w+$/ }
|
306
309
|
#errmsg = "Expected /\\d+/ to match \"SOS\"."
|
307
310
|
errmsg = "$<actual> =~ $<expected>: failed.\n"\
|
@@ -311,18 +314,18 @@ END
|
|
311
314
|
end
|
312
315
|
end #if RUBY_VERSION >= "1.9"
|
313
316
|
|
314
|
-
|
315
|
-
|
317
|
+
test_target 'Oktest::AssertionObject#in_delta?' do
|
318
|
+
test_subject "[!m0791] returns self when passed." do
|
316
319
|
should_return_self { ok {3.14159}.in_delta?(3.141, 0.001) }
|
317
320
|
end
|
318
|
-
|
321
|
+
test_subject "[!f3zui] raises assertion error when failed." do
|
319
322
|
errmsg = "($<actual> - $<expected>).abs < #{0.1}: failed.\n"\
|
320
323
|
" $<actual>: 1.375\n"\
|
321
324
|
" $<expected>: 1.5\n"\
|
322
325
|
" ($<actual> - $<expected>).abs: #{0.125}"
|
323
326
|
FAIL!(errmsg) { ok {1.375}.in_delta?(1.5, 0.1) }
|
324
327
|
end
|
325
|
-
|
328
|
+
test_subject "[!t7liw] is avaialbe with NOT." do
|
326
329
|
PASS! { ok {1.375}.NOT.in_delta?(1.5, 0.1) }
|
327
330
|
errmsg = "($<actual> - $<expected>).abs < #{0.2} == false: failed.\n"\
|
328
331
|
" $<actual>: 1.375\n"\
|
@@ -332,18 +335,18 @@ END
|
|
332
335
|
end
|
333
336
|
end
|
334
337
|
|
335
|
-
|
336
|
-
|
338
|
+
test_target 'Oktest::AssertionObject#same?' do
|
339
|
+
test_subject "[!yk7zo] returns self when passed." do
|
337
340
|
should_return_self { ok {:SOS}.same?(:SOS) }
|
338
341
|
end
|
339
|
-
|
342
|
+
test_subject "[!ozbf4] raises assertion error when failed." do
|
340
343
|
errmsg = "$<actual>.equal?($<expected>): failed.\n"\
|
341
344
|
" $<actual>: \"SOS\"\n"\
|
342
345
|
" $<expected>: \"SOS\"\n"
|
343
|
-
FAIL!(errmsg) { ok {'SOS'}.same?('SOS') }
|
346
|
+
FAIL!(errmsg) { ok {'SOS'.dup}.same?('SOS') }
|
344
347
|
end
|
345
|
-
|
346
|
-
PASS! { ok {'SOS'}.NOT.same? 'SOS' }
|
348
|
+
test_subject "[!dwtig] is avaialbe with NOT." do
|
349
|
+
PASS! { ok {'SOS'.dup}.NOT.same? 'SOS' }
|
347
350
|
errmsg = "$<actual>.equal?($<expected>) == false: failed.\n"\
|
348
351
|
" $<actual>: :SOS\n"\
|
349
352
|
" $<expected>: :SOS\n"
|
@@ -351,21 +354,21 @@ END
|
|
351
354
|
end
|
352
355
|
end
|
353
356
|
|
354
|
-
|
355
|
-
|
357
|
+
test_target 'Oktest::AssertionObject#method_missing()' do
|
358
|
+
test_subject "[!7bbrv] returns self when passed." do
|
356
359
|
should_return_self { ok {"file.png"}.end_with?(".png") }
|
357
360
|
end
|
358
|
-
|
361
|
+
test_subject "[!yjnxb] enables to handle boolean methods." do
|
359
362
|
PASS! { ok {""}.empty? }
|
360
363
|
PASS! { ok {nil}.nil? }
|
361
364
|
PASS! { ok {1}.is_a?(Integer) }
|
362
365
|
end
|
363
|
-
|
366
|
+
test_subject "[!ttow6] raises NoMethodError when not a boolean method." do
|
364
367
|
ERROR!(NoMethodError) do
|
365
368
|
ok {"a"}.start_with
|
366
369
|
end
|
367
370
|
end
|
368
|
-
|
371
|
+
test_subject "[!gd3vg] supports keyword arguments on Ruby >= 2.7." do
|
369
372
|
#if RUBY_VERSION >= "2.7"
|
370
373
|
if true
|
371
374
|
eval <<-END
|
@@ -386,14 +389,14 @@ END
|
|
386
389
|
end
|
387
390
|
end
|
388
391
|
end
|
389
|
-
|
392
|
+
test_subject "[!f0ekh] skip top of backtrace when NoMethodError raised." do
|
390
393
|
exc = ERROR!(NoMethodError) do
|
391
394
|
ok {[1]}.start_with?(1)
|
392
395
|
end
|
393
|
-
|
394
|
-
|
396
|
+
test_ok? exc.backtrace[0] !~ /\/oktest\.rbc?:/, msg: "backtrace not skipped"
|
397
|
+
test_ok? exc.backtrace[0].start_with?(__FILE__), msg: "backtrace not skipped"
|
395
398
|
end
|
396
|
-
|
399
|
+
test_subject "[!cun59] fails when boolean method failed returned false." do
|
397
400
|
errmsg = "$<actual>.empty?: failed.\n $<actual>: \"SOS\""
|
398
401
|
FAIL!(errmsg) { ok {"SOS"}.empty? }
|
399
402
|
errmsg = "$<actual>.nil?: failed.\n $<actual>: \"\""
|
@@ -401,7 +404,7 @@ END
|
|
401
404
|
errmsg = "$<actual>.is_a?(Integer): failed.\n $<actual>: 3.14"
|
402
405
|
FAIL!(errmsg) { ok {3.14}.is_a?(Integer) }
|
403
406
|
end
|
404
|
-
|
407
|
+
test_subject "[!4objh] is available with NOT." do
|
405
408
|
ok {"SOS"}.NOT.empty?
|
406
409
|
ok {"SOS"}.NOT.nil?
|
407
410
|
ok {"SOS"}.NOT.is_a?(Integer)
|
@@ -412,15 +415,15 @@ END
|
|
412
415
|
errmsg = "$<actual>.is_a?(Integer) == false: failed.\n $<actual>: 1"
|
413
416
|
FAIL!(errmsg) { ok {1}.NOT.is_a?(Integer) }
|
414
417
|
end
|
415
|
-
|
418
|
+
test_subject "[!sljta] raises TypeError when boolean method returned non-boolean value." do
|
416
419
|
errmsg = "ok(): String#sos?() expected to return true or false, but got 1."
|
417
420
|
ERROR!(TypeError, errmsg) do
|
418
|
-
s = "SOS"
|
421
|
+
s = "SOS".dup
|
419
422
|
def s.sos?; return 1; end
|
420
423
|
ok {s}.sos?
|
421
424
|
end
|
422
425
|
end
|
423
|
-
|
426
|
+
test_subject "[!5y9iu] reports args and kwargs in error message." do
|
424
427
|
if RUBY_VERSION >= "2.7"
|
425
428
|
str = '123, "abc", x: "45", y: true'
|
426
429
|
else
|
@@ -429,7 +432,7 @@ END
|
|
429
432
|
errmsg = "$<actual>.bla?(#{str}): failed.\n"\
|
430
433
|
" $<actual>: \"Blabla\""
|
431
434
|
FAIL!(errmsg) do
|
432
|
-
s = "Blabla"
|
435
|
+
s = "Blabla".dup
|
433
436
|
def s.bla?(*a, **k); return false; end
|
434
437
|
ok {s}.bla?(123, "abc", x: "45", y: true)
|
435
438
|
end
|
@@ -439,12 +442,12 @@ END
|
|
439
442
|
actual = obj.instance_eval {
|
440
443
|
__inspect_args_and_kwargs([123, "abc"], c: "45", d: true)
|
441
444
|
}
|
442
|
-
|
445
|
+
test_eq? actual, expected
|
443
446
|
end
|
444
447
|
end
|
445
448
|
|
446
|
-
|
447
|
-
|
449
|
+
test_target 'Oktest::AssertionObject#raise?' do
|
450
|
+
test_subject "[!y1b28] returns exception object." do
|
448
451
|
pr = proc { "SOS".sos }
|
449
452
|
if RUBY_VERSION >= "3.3"
|
450
453
|
expected = "undefined method `sos' for an instance of String"
|
@@ -457,10 +460,10 @@ END
|
|
457
460
|
expected = "undefined method `sos' for \"SOS\":String"
|
458
461
|
end
|
459
462
|
ret = ok {pr}.raise?(NoMethodError, expected)
|
460
|
-
|
461
|
-
|
463
|
+
test_eq? ret.class, NoMethodError
|
464
|
+
test_eq? ret.message, expected
|
462
465
|
end
|
463
|
-
|
466
|
+
test_subject "[!2rnni] 1st argument can be error message string or rexp." do
|
464
467
|
pr = proc { raise "something wrong" }
|
465
468
|
PASS! { ok {pr}.raise?("something wrong") }
|
466
469
|
PASS! { ok {pr}.raise?(/something wrong/) }
|
@@ -468,31 +471,31 @@ END
|
|
468
471
|
pr = proc { raise StandardError, "something wrong" }
|
469
472
|
ERROR!(StandardError, "something wrong") { ok {pr}.raise?("something wrong") }
|
470
473
|
end
|
471
|
-
|
472
|
-
|
474
|
+
test_target 'Oktest::AssertionObject[!dpv5g] when `ok{}` called...' do
|
475
|
+
test_subject "[!yps62] assertion passes when expected exception raised." do
|
473
476
|
pr = proc { "SOS".sub() }
|
474
477
|
PASS! { ok {pr}.raise?(ArgumentError) }
|
475
478
|
pr = proc { 1/0 }
|
476
479
|
PASS! { ok {pr}.raise?(ZeroDivisionError) }
|
477
480
|
end
|
478
|
-
|
481
|
+
test_subject "[!wbwdo] raises assertion error when nothing raised." do
|
479
482
|
pr = proc { nil }
|
480
483
|
errmsg = "Expected ArgumentError to be raised but nothing raised."
|
481
484
|
FAIL!(errmsg) { ok {pr}.raise?(ArgumentError) }
|
482
485
|
end
|
483
|
-
|
486
|
+
test_subject "[!lq6jv] compares error class with '==' operator, not '.is_a?'." do
|
484
487
|
pr = proc { "SOS".foobar }
|
485
488
|
PASS! { ok {pr}.raise?(NoMethodError) }
|
486
|
-
|
489
|
+
test_ok? NoMethodError < NameError, msg: "NoMethodError extends NameError"
|
487
490
|
ERROR!(NoMethodError, /foobar/) { ok {pr}.raise?(NameError) }
|
488
491
|
end
|
489
|
-
|
492
|
+
test_subject "[!hwg0z] compares error class with '.is_a?' if '_subclass: true' specified." do
|
490
493
|
pr = proc { "SOS".foobar }
|
491
494
|
PASS! { ok {pr}.raise?(NoMethodError, nil) }
|
492
|
-
|
495
|
+
test_ok? NoMethodError < NameError, msg: "NoMethodError extends NameError"
|
493
496
|
PASS! { ok {pr}.raise?(NameError, nil, _subclass: true) }
|
494
497
|
end
|
495
|
-
|
498
|
+
test_subject "[!4n3ed] reraises if exception is not matched to specified error class." do
|
496
499
|
pr = proc { "SOS".sos }
|
497
500
|
if RUBY_VERSION >= "3.3"
|
498
501
|
errmsg = "undefined method `sos' for an instance of String"
|
@@ -506,7 +509,7 @@ END
|
|
506
509
|
end
|
507
510
|
ERROR!(NoMethodError, errmsg) { ok {pr}.raise?(ArgumentError) }
|
508
511
|
end
|
509
|
-
|
512
|
+
test_subject "[!tpxlv] accepts string or regexp as error message." do
|
510
513
|
if RUBY_VERSION >= "3.1"
|
511
514
|
expected = "undefined method `sos' for \"SOS\":String\n"\
|
512
515
|
"\n"\
|
@@ -525,7 +528,7 @@ END
|
|
525
528
|
end
|
526
529
|
PASS! { ok {pr}.raise?(NoMethodError, expected) }
|
527
530
|
end
|
528
|
-
|
531
|
+
test_subject "[!4c6x3] not check exception class when nil specified as errcls." do
|
529
532
|
pr = proc { foobar() }
|
530
533
|
PASS! { ok {pr}.raise?(nil, /undefined method `foobar'/) }
|
531
534
|
pr = proc { 1/0 }
|
@@ -533,31 +536,31 @@ END
|
|
533
536
|
pr = proc { 1/0 }
|
534
537
|
PASS! { ok {pr}.raise?(nil) }
|
535
538
|
end
|
536
|
-
|
539
|
+
test_subject "[!dq97o] if block given, call test_subject with exception object." do
|
537
540
|
pr = proc { "SOS".foobar }
|
538
541
|
exc1 = nil
|
539
542
|
ok {pr}.raise?(NoMethodError) do |exc2|
|
540
543
|
exc1 = exc2
|
541
544
|
end
|
542
|
-
|
543
|
-
|
545
|
+
test_ok? exc1 != nil
|
546
|
+
test_ok? exc1.equal?(pr.exc)
|
544
547
|
end
|
545
548
|
end
|
546
|
-
|
547
|
-
|
549
|
+
test_target 'Oktest::AssertionObject[!qkr3h] when `ok{}.NOT` called...' do
|
550
|
+
test_subject "[!cownv] not support error message." do
|
548
551
|
pr = proc { raise "some error" }
|
549
552
|
errmsg = "\"some error\": NOT.raise?() can't take errmsg."
|
550
553
|
ERROR!(ArgumentError, errmsg) { ok {pr}.NOT.raise?(Exception, "some error") }
|
551
554
|
end
|
552
|
-
|
555
|
+
test_subject "[!spzy2] is available with NOT." do
|
553
556
|
pr = proc { "SOS".length }
|
554
557
|
PASS! { ok {pr}.NOT.raise? }
|
555
558
|
end
|
556
|
-
|
559
|
+
test_subject "[!a1a40] assertion passes when nothing raised." do
|
557
560
|
pr = proc { nil }
|
558
561
|
PASS! { ok {pr}.NOT.raise? }
|
559
562
|
end
|
560
|
-
|
563
|
+
test_subject "[!61vtv] assertion fails when specified exception raised." do
|
561
564
|
pr = proc { "SOS".foobar }
|
562
565
|
if RUBY_VERSION >= "3.3"
|
563
566
|
errmsg = "NoMethodError should not be raised but got #<NoMethodError: undefined method `foobar' for an instance of String>."
|
@@ -571,36 +574,36 @@ END
|
|
571
574
|
end
|
572
575
|
FAIL!(errmsg) { ok {pr}.NOT.raise?(NoMethodError) }
|
573
576
|
end
|
574
|
-
|
577
|
+
test_subject "[!smprc] compares error class with '==' operator, not '.is_a?'." do
|
575
578
|
pr = proc { "SOS".foobar }
|
576
579
|
FAIL!(/foobar/) { ok {pr}.NOT.raise?(NoMethodError) }
|
577
|
-
|
580
|
+
test_ok? NoMethodError < NameError, msg: "NoMethodError extends NameError"
|
578
581
|
ERROR!(NoMethodError) { ok {pr}.NOT.raise?(NameError) }
|
579
582
|
end
|
580
|
-
|
583
|
+
test_subject "[!34nd8] compares error class with '.is_a?' if '_subclass: true' specified." do
|
581
584
|
pr = proc { "SOS".foobar }
|
582
585
|
FAIL!(/foobar/) { ok {pr}.NOT.raise?(NoMethodError, nil) }
|
583
|
-
|
586
|
+
test_ok? NoMethodError < NameError, msg: "NoMethodError extends NameError"
|
584
587
|
FAIL!(/foobar/) { ok {pr}.NOT.raise?(NameError, nil, _subclass: true) }
|
585
588
|
end
|
586
|
-
|
589
|
+
test_subject "[!shxne] reraises exception if different from specified error class." do
|
587
590
|
pr = proc { 1/0 }
|
588
591
|
errmsg = "divided by 0"
|
589
592
|
ERROR!(ZeroDivisionError, errmsg) { ok {pr}.NOT.raise?(NoMethodError) }
|
590
593
|
end
|
591
|
-
|
594
|
+
test_subject "[!36032] re-raises exception when errcls is nil." do
|
592
595
|
pr = proc { foobar() }
|
593
596
|
ERROR!(NoMethodError) { ok {pr}.NOT.raise?(nil) }
|
594
597
|
pr = proc { 1/0 }
|
595
598
|
ERROR!(ZeroDivisionError) { ok {pr}.NOT.raise?(nil) }
|
596
599
|
end
|
597
600
|
end
|
598
|
-
|
601
|
+
test_subject "[!vnc6b] sets exception object into '#exc' attribute." do
|
599
602
|
pr = proc { "SOS".foobar }
|
600
|
-
|
603
|
+
test_ok? !pr.respond_to?(:exc)
|
601
604
|
PASS! { ok {pr}.raise?(NoMethodError) }
|
602
|
-
|
603
|
-
|
605
|
+
test_ok? pr.respond_to?(:exc)
|
606
|
+
test_ok? pr.exc.is_a?(NoMethodError)
|
604
607
|
if RUBY_VERSION >= "3.3"
|
605
608
|
errmsg = "undefined method `foobar' for an instance of String"
|
606
609
|
elsif RUBY_VERSION =~ /^3\.1\./
|
@@ -611,18 +614,18 @@ END
|
|
611
614
|
else
|
612
615
|
errmsg = "undefined method `foobar' for \"SOS\":String"
|
613
616
|
end
|
614
|
-
|
617
|
+
test_eq? pr.exc.message, errmsg
|
615
618
|
#
|
616
619
|
pr = proc { nil }
|
617
|
-
|
620
|
+
test_ok? !pr.respond_to?(:exc)
|
618
621
|
PASS! { ok {pr}.NOT.raise?(NoMethodError) }
|
619
|
-
|
620
|
-
|
622
|
+
test_ok? pr.respond_to?(:exc)
|
623
|
+
test_eq? pr.exc, nil
|
621
624
|
end
|
622
625
|
end
|
623
626
|
|
624
|
-
|
625
|
-
|
627
|
+
test_target 'Oktest::AssertionObject#raise!' do
|
628
|
+
test_subject "[!8k6ee] compares error class by '.is_a?' instead of '=='." do
|
626
629
|
pr = proc { "SOS".foobar }
|
627
630
|
PASS! { ok {pr}.raise!(NoMethodError) }
|
628
631
|
PASS! { ok {pr}.raise!(NameError) }
|
@@ -630,47 +633,59 @@ END
|
|
630
633
|
end
|
631
634
|
end
|
632
635
|
|
633
|
-
|
634
|
-
|
636
|
+
test_target 'Oktest::AssertionObject#raise_nothing?' do
|
637
|
+
test_subject "[!leqey] do nothing without calling proc object." do
|
638
|
+
pr = proc { 1/0 }
|
639
|
+
ERROR!(ZeroDivisionError) { ok {pr}.raise_nothing? }
|
640
|
+
end
|
641
|
+
test_subject "[!a61b7] not available with `.NOT`." do
|
642
|
+
pr = proc { nil }
|
643
|
+
errmsg = "`raise_nothing?()` is not available with `.NOT`."
|
644
|
+
ERROR!(Oktest::OktestError, errmsg) { ok {pr}.NOT.raise_nothing? }
|
645
|
+
end
|
646
|
+
end
|
647
|
+
|
648
|
+
test_target 'Oktest::AssertionObject#thrown?' do
|
649
|
+
test_subject "[!w7935] raises ArgumentError when arg of 'thrown?()' is nil." do
|
635
650
|
ERROR!(ArgumentError, "throw?(nil): expected tag required.") do
|
636
651
|
pr = proc { throw :sym1 }
|
637
652
|
ok {pr}.throw?(nil)
|
638
653
|
end
|
639
654
|
end
|
640
|
-
|
655
|
+
test_subject "[!lglzr] assertion passes when expected symbol thrown." do
|
641
656
|
pr = proc { throw :sym2 }
|
642
657
|
ok {pr}.throw?(:sym2)
|
643
|
-
|
658
|
+
test_ok? true, msg: "ok"
|
644
659
|
end
|
645
|
-
|
660
|
+
test_subject "[!gf9nx] assertion fails when thrown tag is equal to but not same as expected." do
|
646
661
|
pr = proc { throw "sym" }
|
647
662
|
expected = ("Thrown tag \"sym\" is equal to but not same as expected.\n"\
|
648
663
|
" (`\"sym\".equal?(\"sym\")` should be true but not.)")
|
649
|
-
FAIL!(expected) { ok {pr}.throw?("sym") }
|
664
|
+
FAIL!(expected) { ok {pr}.throw?("sym".dup) }
|
650
665
|
end
|
651
|
-
|
666
|
+
test_subject "[!flgwy] assertion fails when thrown tag is different from expectd." do
|
652
667
|
FAIL!(":sym4 should be thrown but actually :sym9 thrown.") do
|
653
668
|
pr = proc { throw :sym9 }
|
654
669
|
ok {pr}.throw?(:sym4)
|
655
670
|
end
|
656
671
|
end
|
657
|
-
|
672
|
+
test_subject "[!9ik3x] assertion fails when nothing thrown." do
|
658
673
|
pr = proc { nil }
|
659
674
|
expected = ":sym5 should be thrown but nothing thrown."
|
660
675
|
FAIL!(expected) { ok {pr}.throw?(:sym5) }
|
661
676
|
end
|
662
|
-
|
677
|
+
test_subject "[!m03vq] raises ArgumentError when non-nil arg passed to 'NOT.thrown?()'." do
|
663
678
|
ERROR!(ArgumentError, "NOT.throw?(:sym6): argument should be nil.") do
|
664
679
|
pr = proc { nil }
|
665
680
|
ok {pr}.NOT.throw?(:sym6)
|
666
681
|
end
|
667
682
|
end
|
668
|
-
|
683
|
+
test_subject "[!kxizg] assertion fails when something thrown in 'NOT.throw?()'." do
|
669
684
|
pr = proc { throw :sym7 }
|
670
685
|
expected = "Nothing should be thrown but :sym7 thrown."
|
671
686
|
FAIL!(expected) { ok {pr}.NOT.throw?(nil) }
|
672
687
|
end
|
673
|
-
|
688
|
+
test_subject "[!zq9h6] returns self when passed." do
|
674
689
|
pr = proc { throw :sym8 }
|
675
690
|
should_return_self { ok {pr}.throw?(:sym8) }
|
676
691
|
#
|
@@ -679,17 +694,17 @@ END
|
|
679
694
|
end
|
680
695
|
end
|
681
696
|
|
682
|
-
|
683
|
-
|
697
|
+
test_target 'Oktest::AssertionObject#in?' do
|
698
|
+
test_subject "[!jzoxg] returns self when passed." do
|
684
699
|
should_return_self { ok {3}.in?(1..5) }
|
685
700
|
end
|
686
|
-
|
701
|
+
test_subject "[!9rm8g] raises assertion error when failed." do
|
687
702
|
errmsg = "$<expected>.include?($<actual>): failed.\n"\
|
688
703
|
" $<actual>: 3\n"\
|
689
704
|
" $<expected>: 1..2"
|
690
705
|
FAIL!(errmsg) { ok {3}.in?(1..2) }
|
691
706
|
end
|
692
|
-
|
707
|
+
test_subject "[!singl] is available with NOT." do
|
693
708
|
PASS! { ok {3}.NOT.in?(1..2) }
|
694
709
|
errmsg = "$<expected>.include?($<actual>) == false: failed.\n"\
|
695
710
|
" $<actual>: 3\n"\
|
@@ -698,17 +713,17 @@ END
|
|
698
713
|
end
|
699
714
|
end
|
700
715
|
|
701
|
-
|
702
|
-
|
716
|
+
test_target 'Oktest::AssertionObject#attr()' do
|
717
|
+
test_subject "[!lz3lb] returns self when passed." do
|
703
718
|
should_return_self { ok {"SOS"}.attr(:length, 3) }
|
704
719
|
end
|
705
|
-
|
720
|
+
test_subject "[!79tgn] raises assertion error when failed." do
|
706
721
|
errmsg = "$<actual>.size == $<expected>: failed.\n"\
|
707
722
|
" $<actual>.size: 3\n"\
|
708
723
|
" $<expected>: 2"
|
709
724
|
FAIL!(errmsg) { ok {"SOS"}.attr(:size, 2) }
|
710
725
|
end
|
711
|
-
|
726
|
+
test_subject "[!cqnu3] is available with NOT." do
|
712
727
|
PASS! { ok {"SOS"}.NOT.attr(:length, 2) }
|
713
728
|
errmsg = "$<actual>.size != $<expected>: failed.\n"\
|
714
729
|
" $<actual>.size: 3\n"\
|
@@ -717,17 +732,17 @@ END
|
|
717
732
|
end
|
718
733
|
end
|
719
734
|
|
720
|
-
|
721
|
-
|
735
|
+
test_target 'Oktest::AssertionObject#attrs()' do
|
736
|
+
test_subject "[!rtq9f] returns self when passed." do
|
722
737
|
should_return_self { ok {"SOS"}.attrs(:length=>3, :size=>3) }
|
723
738
|
end
|
724
|
-
|
739
|
+
test_subject "[!7ta0s] raises assertion error when failed." do
|
725
740
|
errmsg = "$<actual>.size == $<expected>: failed.\n"\
|
726
741
|
" $<actual>.size: 3\n"\
|
727
742
|
" $<expected>: 2"
|
728
743
|
FAIL!(errmsg) { ok {"SOS"}.attrs(:size=>2) }
|
729
744
|
end
|
730
|
-
|
745
|
+
test_subject "[!s0pnk] is available with NOT." do
|
731
746
|
PASS! { ok {"SOS"}.NOT.attrs(:length=>2) }
|
732
747
|
errmsg = "$<actual>.size != $<expected>: failed.\n"\
|
733
748
|
" $<actual>.size: 3\n"\
|
@@ -736,19 +751,19 @@ END
|
|
736
751
|
end
|
737
752
|
end
|
738
753
|
|
739
|
-
|
740
|
-
|
754
|
+
test_target 'Oktest::AssertionObject#keyval()' do
|
755
|
+
test_subject "[!byebv] returns self when passed." do
|
741
756
|
d = {'a'=>1}
|
742
757
|
should_return_self { ok {d}.keyval('a', 1) }
|
743
758
|
end
|
744
|
-
|
759
|
+
test_subject "[!vtrlz] raises assertion error when failed." do
|
745
760
|
d = {'a'=>1}
|
746
761
|
errmsg = "$<actual>[\"a\"] == $<expected>: failed.\n"\
|
747
762
|
" $<actual>[\"a\"]: 1\n"\
|
748
763
|
" $<expected>: \"1\""
|
749
764
|
FAIL!(errmsg) { ok {d}.keyval('a', '1') }
|
750
765
|
end
|
751
|
-
|
766
|
+
test_subject "[!mmpwz] is available with NOT." do
|
752
767
|
d = {'a'=>1}
|
753
768
|
PASS! { ok {d}.NOT.keyval('a', '1') }
|
754
769
|
errmsg = "$<actual>[\"a\"] != $<expected>: failed.\n"\
|
@@ -758,19 +773,19 @@ END
|
|
758
773
|
end
|
759
774
|
end
|
760
775
|
|
761
|
-
|
762
|
-
|
776
|
+
test_target 'Oktest::AssertionObject#keyvals()' do
|
777
|
+
test_subject "[!vtw22] returns self when passed." do
|
763
778
|
d = {'a'=>1, 'b'=>2}
|
764
779
|
should_return_self { ok {d}.keyvals('a'=>1, 'b'=>2) }
|
765
780
|
end
|
766
|
-
|
781
|
+
test_subject "[!fyvmn] raises assertion error when failed." do
|
767
782
|
d = {'a'=>1, 'b'=>2}
|
768
783
|
errmsg = "$<actual>[\"a\"] == $<expected>: failed.\n"\
|
769
784
|
" $<actual>[\"a\"]: 1\n"\
|
770
785
|
" $<expected>: \"1\""
|
771
786
|
FAIL!(errmsg) { ok {d}.keyvals('a'=>'1', 'b'=>2) }
|
772
787
|
end
|
773
|
-
|
788
|
+
test_subject "[!js2j2] is available with NOT." do
|
774
789
|
d = {'a'=>1, 'b'=>2}
|
775
790
|
PASS! { ok {d}.NOT.keyvals('a'=>'1') }
|
776
791
|
errmsg = "$<actual>[\"a\"] != $<expected>: failed.\n"\
|
@@ -780,17 +795,17 @@ END
|
|
780
795
|
end
|
781
796
|
end
|
782
797
|
|
783
|
-
|
784
|
-
|
798
|
+
test_target 'Oktest::AssertionObject#length' do
|
799
|
+
test_subject "[!l9vnv] returns self when passed." do
|
785
800
|
should_return_self { ok {"SOS"}.length(3) }
|
786
801
|
end
|
787
|
-
|
802
|
+
test_subject "[!1y787] raises assertion error when failed." do
|
788
803
|
errmsg = "$<actual>.length == 5: failed.\n"\
|
789
804
|
" $<actual>.length: 3\n"\
|
790
805
|
" $<actual>: \"SOS\""
|
791
806
|
FAIL!(errmsg) { ok {"SOS"}.length(5) }
|
792
807
|
end
|
793
|
-
|
808
|
+
test_subject "[!kryx2] is available with NOT." do
|
794
809
|
PASS! { ok {"SOS"}.NOT.length(5) }
|
795
810
|
errmsg = "$<actual>.length != 3: failed.\n"\
|
796
811
|
" $<actual>.length: 3\n"\
|
@@ -799,16 +814,16 @@ END
|
|
799
814
|
end
|
800
815
|
end
|
801
816
|
|
802
|
-
|
803
|
-
|
817
|
+
test_target 'Oktest::AssertionObject#truthy?' do
|
818
|
+
test_subject "[!nhmuk] returns self when passed." do
|
804
819
|
should_return_self { ok {""}.truthy? }
|
805
820
|
end
|
806
|
-
|
821
|
+
test_subject "[!3d94h] raises assertion error when failed." do
|
807
822
|
errmsg = "!!$<actual> == true: failed.\n"\
|
808
823
|
" $<actual>: nil"
|
809
824
|
FAIL!(errmsg) { ok {nil}.truthy? }
|
810
825
|
end
|
811
|
-
|
826
|
+
test_subject "[!8rmgp] is available with NOT." do
|
812
827
|
PASS! { ok {nil}.NOT.truthy? }
|
813
828
|
errmsg = "!!$<actual> != true: failed.\n"\
|
814
829
|
" $<actual>: 0"
|
@@ -816,16 +831,16 @@ END
|
|
816
831
|
end
|
817
832
|
end
|
818
833
|
|
819
|
-
|
820
|
-
|
834
|
+
test_target 'Oktest::AssertionObject#falsy?' do
|
835
|
+
test_subject "[!w1vm6] returns self when passed." do
|
821
836
|
should_return_self { ok {nil}.falsy? }
|
822
837
|
end
|
823
|
-
|
838
|
+
test_subject "[!7o48g] raises assertion error when failed." do
|
824
839
|
errmsg = "!!$<actual> == false: failed.\n"\
|
825
840
|
" $<actual>: 0"
|
826
841
|
FAIL!(errmsg) { ok {0}.falsy? }
|
827
842
|
end
|
828
|
-
|
843
|
+
test_subject "[!i44q6] is available with NOT." do
|
829
844
|
PASS! { ok {0}.NOT.falsy? }
|
830
845
|
errmsg = "!!$<actual> != false: failed.\n"\
|
831
846
|
" $<actual>: nil"
|
@@ -833,16 +848,16 @@ END
|
|
833
848
|
end
|
834
849
|
end
|
835
850
|
|
836
|
-
|
837
|
-
|
851
|
+
test_target 'Oktest::AssertionObject#file_exist?' do
|
852
|
+
test_subject "[!6bcpp] returns self when passed." do
|
838
853
|
should_return_self { ok {__FILE__}.file_exist? }
|
839
854
|
end
|
840
|
-
|
855
|
+
test_subject "[!69bs0] raises assertion error when failed." do
|
841
856
|
errmsg = "File.file?($<actual>): failed.\n"\
|
842
857
|
" $<actual>: \".\""
|
843
858
|
FAIL!(errmsg) { ok {'.'}.file_exist? }
|
844
859
|
end
|
845
|
-
|
860
|
+
test_subject "[!r1mze] is available with NOT." do
|
846
861
|
PASS! { ok {'.'}.NOT.file_exist? }
|
847
862
|
errmsg = "File.file?($<actual>) == false: failed.\n"\
|
848
863
|
" $<actual>: \"#{__FILE__}\""
|
@@ -850,16 +865,16 @@ END
|
|
850
865
|
end
|
851
866
|
end
|
852
867
|
|
853
|
-
|
854
|
-
|
868
|
+
test_target 'Oktest::AssertionObject#dir_exist?' do
|
869
|
+
test_subject "[!8qe7u] returns self when passed." do
|
855
870
|
should_return_self { ok {'.'}.dir_exist? }
|
856
871
|
end
|
857
|
-
|
872
|
+
test_subject "[!vfh7a] raises assertion error when failed." do
|
858
873
|
errmsg = "File.directory?($<actual>): failed.\n"\
|
859
874
|
" $<actual>: \"#{__FILE__}\""
|
860
875
|
FAIL!(errmsg) { ok {__FILE__}.dir_exist? }
|
861
876
|
end
|
862
|
-
|
877
|
+
test_subject "[!qtllp] is available with NOT." do
|
863
878
|
PASS! { ok {__FILE__}.NOT.dir_exist? }
|
864
879
|
errmsg = "File.directory?($<actual>) == false: failed.\n"\
|
865
880
|
" $<actual>: \".\""
|
@@ -867,20 +882,20 @@ END
|
|
867
882
|
end
|
868
883
|
end
|
869
884
|
|
870
|
-
|
871
|
-
def with_symlink
|
885
|
+
test_target 'Oktest::AssertionObject#symlink_exist?' do
|
886
|
+
def self.with_symlink(&b)
|
872
887
|
linkname = "_sym_#{rand().to_s[2...7]}"
|
873
888
|
File.symlink(__FILE__, linkname)
|
874
|
-
|
889
|
+
b.call linkname
|
875
890
|
ensure
|
876
891
|
File.unlink(linkname)
|
877
892
|
end
|
878
|
-
|
893
|
+
test_subject "[!ugfi3] returns self when passed." do
|
879
894
|
with_symlink do |linkname|
|
880
895
|
should_return_self { ok {linkname}.symlink_exist? }
|
881
896
|
end
|
882
897
|
end
|
883
|
-
|
898
|
+
test_subject "[!qwngl] raises assertion error when failed." do
|
884
899
|
with_symlink do |linkname|
|
885
900
|
errmsg = "File.symlink?($<actual>): failed.\n"\
|
886
901
|
" $<actual>: \"_not_exist\""
|
@@ -890,7 +905,7 @@ END
|
|
890
905
|
FAIL!(errmsg) { ok {'.'}.symlink_exist? }
|
891
906
|
end
|
892
907
|
end
|
893
|
-
|
908
|
+
test_subject "[!cgpbt] is available with NOT." do
|
894
909
|
with_symlink do |linkname|
|
895
910
|
PASS! { ok {'_not_exist'}.NOT.symlink_exist? }
|
896
911
|
PASS! { ok {'.'}.NOT.symlink_exist? }
|
@@ -901,16 +916,16 @@ END
|
|
901
916
|
end
|
902
917
|
end
|
903
918
|
|
904
|
-
|
905
|
-
|
919
|
+
test_target 'Oktest::AssertionObject#not_exist?' do
|
920
|
+
test_subject "[!1ujag] returns self when passed." do
|
906
921
|
should_return_self { ok {'_not_exist'}.not_exist? }
|
907
922
|
end
|
908
|
-
|
923
|
+
test_subject "[!ja84s] raises assertion error when failed." do
|
909
924
|
errmsg = "File.exist?($<actual>) == false: failed.\n"\
|
910
925
|
" $<actual>: \".\""
|
911
926
|
FAIL!(errmsg) { ok {'.'}.not_exist? }
|
912
927
|
end
|
913
|
-
|
928
|
+
test_subject "[!to5z3] is available with NOT." do
|
914
929
|
PASS! { ok {'.'}.NOT.not_exist? }
|
915
930
|
errmsg = "File.exist?($<actual>): failed.\n"\
|
916
931
|
" $<actual>: \"_not_exist\""
|
@@ -918,59 +933,59 @@ END
|
|
918
933
|
end
|
919
934
|
end
|
920
935
|
|
921
|
-
|
922
|
-
|
936
|
+
test_target 'Oktest::AssertionObject#JSON()' do
|
937
|
+
test_subject "[!n0k03] creates JsonMatcher object." do
|
923
938
|
o = JSON({})
|
924
|
-
|
939
|
+
test_eq? o.class, Oktest::JsonMatcher
|
925
940
|
end
|
926
941
|
end
|
927
942
|
|
928
|
-
|
929
|
-
|
943
|
+
test_target 'Oktest::AssertionObject#Enum()' do
|
944
|
+
test_subject "[!fbfr0] creates Enum object which is a subclass of Set." do
|
930
945
|
o = Enum("a", "b", "c")
|
931
|
-
|
932
|
-
|
933
|
-
|
934
|
-
|
935
|
-
|
936
|
-
|
946
|
+
test_eq? o.class, Oktest::JsonMatcher::Enum
|
947
|
+
test_ok? o.class < Set
|
948
|
+
test_eq? (o === "a"), true
|
949
|
+
test_eq? (o === "b"), true
|
950
|
+
test_eq? (o === "c"), true
|
951
|
+
test_eq? (o === "d"), false
|
937
952
|
end
|
938
953
|
end
|
939
954
|
|
940
|
-
|
941
|
-
|
942
|
-
|
943
|
-
|
944
|
-
|
945
|
-
|
946
|
-
|
955
|
+
test_target 'Oktest::AssertionObject#Bool()' do
|
956
|
+
test_subject "[!vub5j] creates a set of true and false." do
|
957
|
+
test_eq? Bool().class, Oktest::JsonMatcher::Enum
|
958
|
+
test_ok? Bool() === true
|
959
|
+
test_ok? Bool() === false
|
960
|
+
test_eq? (Bool() === 1), false
|
961
|
+
test_eq? (Bool() === 0), false
|
947
962
|
end
|
948
963
|
end
|
949
964
|
|
950
|
-
|
951
|
-
|
965
|
+
test_target 'Oktest::AssertionObject#OR()' do
|
966
|
+
test_subject "[!9e8im] creates `OR` object." do
|
952
967
|
o = OR(1, 2, 3)
|
953
|
-
|
968
|
+
test_eq? o.class, Oktest::JsonMatcher::OR
|
954
969
|
end
|
955
970
|
end
|
956
971
|
|
957
|
-
|
958
|
-
|
972
|
+
test_target 'Oktest::AssertionObject#AND()' do
|
973
|
+
test_subject "[!38jln] creates `AND` object." do
|
959
974
|
o = AND(4, 5, 6)
|
960
|
-
|
975
|
+
test_eq? o.class, Oktest::JsonMatcher::AND
|
961
976
|
end
|
962
977
|
end
|
963
978
|
|
964
|
-
|
965
|
-
|
979
|
+
test_target 'Oktest::AssertionObject#Length()' do
|
980
|
+
test_subject "[!qqas3] creates Length object." do
|
966
981
|
o = Length(3)
|
967
|
-
|
982
|
+
test_eq? o.class, Oktest::JsonMatcher::Length
|
968
983
|
end
|
969
984
|
end
|
970
985
|
|
971
|
-
|
972
|
-
|
973
|
-
|
986
|
+
test_target 'Oktest::AssertionObject#Any()' do
|
987
|
+
test_subject "[!dlo1o] creates an 'Any' object." do
|
988
|
+
test_eq? Any().class, Oktest::JsonMatcher::Any
|
974
989
|
end
|
975
990
|
end
|
976
991
|
|