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/matcher_test.rb
CHANGED
@@ -1,193 +1,210 @@
|
|
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
|
require 'set'
|
11
12
|
|
12
13
|
|
13
|
-
class
|
14
|
+
class Matcher__Test
|
15
|
+
extend NanoTest
|
16
|
+
extend Oktest::SpecHelper
|
14
17
|
|
15
|
-
|
16
|
-
|
18
|
+
test_target 'Oktest::Matcher#===' do
|
19
|
+
test_subject "[!spybn] raises NotImplementedError." do
|
17
20
|
errmsg = "Oktest::Matcher#===(): not implemented yet."
|
18
|
-
|
21
|
+
exc = test_exception? NotImplementedError do
|
19
22
|
Oktest::Matcher.new(nil) === nil
|
20
23
|
end
|
24
|
+
test_eq? exc.message, errmsg
|
21
25
|
end
|
22
26
|
end
|
23
27
|
|
24
|
-
|
25
|
-
|
28
|
+
test_target 'Oktest::Matcher#==' do
|
29
|
+
test_subject "[!ymt1b] raises OktestError." do
|
26
30
|
errmsg = "JSON(): use `===` instead of `==`."
|
27
|
-
|
31
|
+
exc = test_exception? Oktest::OktestError do
|
28
32
|
Oktest::Matcher.new(nil) == nil
|
29
33
|
end
|
34
|
+
test_eq? exc.message, errmsg
|
30
35
|
end
|
31
36
|
end
|
32
37
|
|
33
|
-
|
34
|
-
|
38
|
+
test_target 'Oktest::Matcher#fail()' do
|
39
|
+
test_subject "[!8qpsd] raises assertion error." do
|
35
40
|
errmsg = "<<errmsg>>"
|
36
|
-
|
41
|
+
exc = test_exception? Oktest::FAIL_EXCEPTION do
|
37
42
|
Oktest::Matcher.new(nil).fail("<<errmsg>>")
|
38
43
|
end
|
44
|
+
test_eq? exc.message, errmsg
|
39
45
|
end
|
40
46
|
end
|
41
47
|
|
42
48
|
end
|
43
49
|
|
44
50
|
|
45
|
-
class
|
51
|
+
class JsonMatcher__Test
|
52
|
+
extend NanoTest
|
46
53
|
|
47
|
-
def JSON(x)
|
54
|
+
def self.JSON(x)
|
48
55
|
return Oktest::JsonMatcher.new(x)
|
49
56
|
end
|
50
57
|
|
51
|
-
def OR(*args)
|
58
|
+
def self.OR(*args)
|
52
59
|
return Oktest::JsonMatcher::OR.new(*args)
|
53
60
|
end
|
54
61
|
|
55
|
-
def AND(*args)
|
62
|
+
def self.AND(*args)
|
56
63
|
return Oktest::JsonMatcher::AND.new(*args)
|
57
64
|
end
|
58
65
|
|
59
|
-
def ANY()
|
66
|
+
def self.ANY()
|
60
67
|
return Oktest::JsonMatcher::Any.new
|
61
68
|
end
|
62
69
|
|
63
|
-
|
64
|
-
|
65
|
-
|
70
|
+
test_target 'Oktest::JsonMatcher#===' do
|
71
|
+
test_subject "[!4uf1o] raises assertion error when JSON not matched." do
|
72
|
+
exc = test_exception? Oktest::FAIL_EXCEPTION do
|
66
73
|
JSON({"status": "ok"}) === {"status": "OK"}
|
67
74
|
end
|
68
75
|
end
|
69
|
-
|
76
|
+
test_subject "[!0g0u4] returns true when JSON matched." do
|
70
77
|
result = JSON({"status": "ok"}) === {"status": "ok"}
|
71
|
-
|
78
|
+
test_eq? result, true
|
72
79
|
end
|
73
|
-
|
80
|
+
test_subject "[!1ukbv] scalar value matches to integer, string, bool, and so son." do
|
74
81
|
actual = {"name": "Alice", "age": 20, "deleted": false}
|
75
82
|
result = JSON(actual) === {"name": "Alice", "age": 20, "deleted": false}
|
76
|
-
|
83
|
+
test_eq? result, true
|
77
84
|
#
|
78
85
|
errmsg = ("$<JSON>[\"name\"]: $<expected> === $<actual> : failed.\n"\
|
79
86
|
" $<actual>: \"Alice\"\n"\
|
80
87
|
" $<expected>: \"alice\"\n")
|
81
|
-
|
88
|
+
exc = test_exception? Oktest::FAIL_EXCEPTION do
|
82
89
|
JSON(actual) === {"name": "alice", "age": 20, "deleted": false}
|
83
90
|
end
|
91
|
+
test_eq? exc.message, errmsg
|
84
92
|
end
|
85
|
-
|
93
|
+
test_subject "[!8o55d] class object matches to instance object." do
|
86
94
|
actual = {"name": "Alice", "age": 20, "deleted": false}
|
87
95
|
result = JSON(actual) === {"name": String, "age": Integer, "deleted": FalseClass}
|
88
|
-
|
96
|
+
test_eq? result, true
|
89
97
|
#
|
90
98
|
errmsg = ("$<JSON>[\"deleted\"]: $<expected> === $<actual> : failed.\n"\
|
91
99
|
" $<actual>: false\n"\
|
92
100
|
" $<expected>: TrueClass\n")
|
93
|
-
|
101
|
+
exc = test_exception? Oktest::FAIL_EXCEPTION do
|
94
102
|
JSON(actual) === {"name": String, "age": Integer, "deleted": TrueClass}
|
95
103
|
end
|
104
|
+
test_eq? exc.message, errmsg
|
96
105
|
end
|
97
|
-
|
106
|
+
test_subject "[!s625d] regexp object matches to string value." do
|
98
107
|
actual = {"email": "alice@example.com"}
|
99
108
|
result = JSON(actual) === {"email": /^\w[-.\w]+@example\.(com|net|org)$/}
|
100
|
-
|
109
|
+
test_eq? result, true
|
101
110
|
#
|
102
111
|
errmsg = ("$<JSON>[\"email\"]: $<expected> === $<actual> : failed.\n"\
|
103
112
|
" $<actual>: \"alice@example.com\"\n"\
|
104
113
|
" $<expected>: /^\\w[-.\\w]+@example\\.org$/\n")
|
105
|
-
|
114
|
+
exc = test_exception? Oktest::FAIL_EXCEPTION do
|
106
115
|
JSON(actual) === {"email": /^\w[-.\w]+@example\.org$/}
|
107
116
|
end
|
117
|
+
test_eq? exc.message, errmsg
|
108
118
|
end
|
109
|
-
|
119
|
+
test_subject "[!aqkk0] range object matches to scalar value." do
|
110
120
|
actual = {"int": 5, "float": 3.14, "str": "abc"}
|
111
121
|
result = JSON(actual) === {"int": 1..10, "float": 3.1..3.2, "str": "aaa".."zzz"}
|
112
|
-
|
122
|
+
test_eq? result, true
|
113
123
|
#
|
114
124
|
errmsg = ("$<JSON>[\"int\"]: $<expected> === $<actual> : failed.\n"\
|
115
125
|
" $<actual>: 5\n"\
|
116
126
|
" $<expected>: 1...5\n")
|
117
|
-
|
127
|
+
exc = test_exception? Oktest::FAIL_EXCEPTION do
|
118
128
|
JSON(actual) === {"int": 1...5, "float": 3.1..3.2, "str": "aaa".."zzz"}
|
119
129
|
end
|
130
|
+
test_eq? exc.message, errmsg
|
120
131
|
end
|
121
|
-
|
132
|
+
test_subject "[!4ymj2] fails when actual value is not matched to item class of range object." do
|
122
133
|
actual = {"val": 1.5}
|
123
134
|
errmsg = ("$<JSON>[\"val\"]: expected #{1.class.name} value, but got Float value.\n"\
|
124
135
|
" $<actual>: 1.5\n"\
|
125
136
|
" $<expected>: 1..10\n")
|
126
|
-
|
137
|
+
exc = test_exception? Oktest::FAIL_EXCEPTION do
|
127
138
|
JSON(actual) === {"val": 1..10}
|
128
139
|
end
|
140
|
+
test_eq? exc.message, errmsg
|
129
141
|
end
|
130
|
-
|
142
|
+
test_subject "[!a7bfs] Set object matches to enum value." do
|
131
143
|
actual = {"gender": "female"}
|
132
144
|
result = JSON(actual) === {"gender": Set.new(["male", "female"])}
|
133
|
-
|
145
|
+
test_eq? result, true
|
134
146
|
#
|
135
147
|
errmsg = ("$<JSON>[\"gender\"]: $<expected> === $<actual> : failed.\n"\
|
136
148
|
" $<actual>: \"female\"\n"\
|
137
149
|
" $<expected>: #<Set: {\"M\", \"F\"}>\n")
|
138
|
-
|
150
|
+
exc = test_exception? Oktest::FAIL_EXCEPTION do
|
139
151
|
JSON(actual) === {"gender": Set.new(["M", "F"])}
|
140
152
|
end
|
153
|
+
test_eq? exc.message, errmsg
|
141
154
|
end
|
142
|
-
|
155
|
+
test_subject "[!sh5cg] Enumerator object matches to repeat of rule." do
|
143
156
|
actual = {"tags": ["foo", "bar", "baz"]}
|
144
157
|
result = JSON(actual) === {"tags": [String].each}
|
145
|
-
|
158
|
+
test_eq? result, true
|
146
159
|
#
|
147
160
|
errmsg = ("$<JSON>[\"tags\"][0]: $<expected> === $<actual> : failed.\n"\
|
148
161
|
" $<actual>: \"foo\"\n"\
|
149
162
|
" $<expected>: Integer\n")
|
150
|
-
|
163
|
+
exc = test_exception? Oktest::FAIL_EXCEPTION do
|
151
164
|
JSON(actual) === {"tags": [Integer].each}
|
152
165
|
end
|
166
|
+
test_eq? exc.message, errmsg
|
153
167
|
end
|
154
|
-
|
168
|
+
test_subject "[!ljrmc] fails when expected is an Enumerator object and actual is not an array." do
|
155
169
|
actual = {"tags": "foo"}
|
156
170
|
errmsg = ("$<JSON>[\"tags\"]: Array value expected but got String value.\n"\
|
157
171
|
" $<actual>: \"foo\"\n"\
|
158
172
|
" $<expected>: [String].each\n")
|
159
|
-
|
173
|
+
exc = test_exception? Oktest::FAIL_EXCEPTION do
|
160
174
|
JSON(actual) === {"tags": [String].each}
|
161
175
|
end
|
176
|
+
test_eq? exc.message, errmsg
|
162
177
|
end
|
163
|
-
|
178
|
+
test_subject "[!lh6d6] compares array items recursively." do
|
164
179
|
actual = {"items": [{"name": "Alice", "id": 101}, {"name": "Bob"}]}
|
165
180
|
result = JSON(actual) === {
|
166
181
|
"items": [{"name": String, "id?": 100..999}].each
|
167
182
|
}
|
168
|
-
|
183
|
+
test_eq? result, true
|
169
184
|
#
|
170
185
|
errmsg = ("$<JSON>[\"items\"][0][\"id\"]: $<expected> === $<actual> : failed.\n"\
|
171
186
|
" $<actual>: 101\n"\
|
172
187
|
" $<expected>: 1000..9999\n")
|
173
|
-
|
188
|
+
exc = test_exception? Oktest::FAIL_EXCEPTION do
|
174
189
|
JSON(actual) === {
|
175
190
|
"items": [{"name": String, "id?": 1000..9999}].each
|
176
191
|
}
|
192
|
+
test_es exc.message, errmsg
|
177
193
|
end
|
178
194
|
end
|
179
|
-
|
195
|
+
test_subject "[!bz74w] fails when array lengths are different." do
|
180
196
|
actual = {"arr": ["A", "B", "C"]}
|
181
197
|
errmsg = ("$<JSON>[\"arr\"]: $<actual>.length == $<expected>.length : failed.\n"\
|
182
198
|
" $<actual>.length: 3\n"\
|
183
199
|
" $<expected>.length: 4\n"\
|
184
200
|
" $<actual>: [\"A\", \"B\", \"C\"]\n"\
|
185
201
|
" $<expected>: [\"A\", \"B\", \"C\", \"D\"]\n")
|
186
|
-
|
202
|
+
exc = test_exception? Oktest::FAIL_EXCEPTION do
|
187
203
|
JSON(actual) === {"arr": ["A", "B", "C", "D"]}
|
188
204
|
end
|
205
|
+
test_eq? exc.message, errmsg
|
189
206
|
end
|
190
|
-
|
207
|
+
test_subject "[!fmxyg] compares hash objects recursively." do
|
191
208
|
actual = {
|
192
209
|
"owner": {"name": "Alice", "age": 20},
|
193
210
|
"item": {"id": 10001, "name": "Something", "price": 500},
|
@@ -196,228 +213,242 @@ class JsonMatcher_TC < TC
|
|
196
213
|
"owner": {"name": String, "age": 0..100},
|
197
214
|
"item": {"id": 1..99999, "name": String, "price?": Numeric},
|
198
215
|
}
|
199
|
-
|
216
|
+
test_eq? result, true
|
200
217
|
#
|
201
218
|
errmsg = ("$<JSON>[\"item\"][\"price\"]: $<expected> === $<actual> : failed.\n"\
|
202
219
|
" $<actual>: 500\n"\
|
203
220
|
" $<expected>: Float\n")
|
204
|
-
|
221
|
+
exc = test_exception? Oktest::FAIL_EXCEPTION do
|
205
222
|
JSON(actual) === {
|
206
223
|
"owner": {"name": String, "age": 0..100},
|
207
224
|
"item": {"id": 1..99999, "name": String, "price?": Float},
|
208
225
|
}
|
209
226
|
end
|
227
|
+
test_eq? exc.message, errmsg
|
210
228
|
end
|
211
|
-
|
229
|
+
test_subject "[!rkv0z] compares two hashes with converting keys into string." do
|
212
230
|
actual1 = {k1: "A", k2: "B"}
|
213
231
|
result = JSON(actual1) === {"k1"=>"A", "k2"=>"B"}
|
214
|
-
|
232
|
+
test_eq? result, true
|
215
233
|
#
|
216
234
|
actual2 = {"k1"=>"A", "k2"=>"B"}
|
217
235
|
result = JSON(actual2) === {k1: "A", k2: "B"}
|
218
|
-
|
236
|
+
test_eq? result, true
|
219
237
|
end
|
220
|
-
|
238
|
+
test_subject "[!jbyv6] key 'aaa?' represents optional key." do
|
221
239
|
actual1 = {"name": "alice", "birth": "2000-01-01"}
|
222
240
|
result = JSON(actual1) === {"name": "alice", "birth?": "2000-01-01"}
|
223
|
-
|
241
|
+
test_eq? result, true
|
224
242
|
#
|
225
243
|
actual2 = {"name": "alice"}
|
226
244
|
result = JSON(actual2) === {"name": "alice", "birth?": "2000-01-01"}
|
227
|
-
|
245
|
+
test_eq? result, true
|
228
246
|
#
|
229
247
|
actual3 = {"name": "alice", "birth": nil}
|
230
248
|
result = JSON(actual3) === {"name": "alice", "birth?": "2000-01-01"}
|
231
|
-
|
249
|
+
test_eq? result, true
|
232
250
|
#
|
233
251
|
actual4 = {"name": "alice", "birth?": "2000-01-01"} # TODO
|
234
252
|
result = JSON(actual4) === {"name": "alice", "birth?": "2000-01-01"}
|
235
|
-
|
253
|
+
test_eq? result, true
|
236
254
|
end
|
237
|
-
|
255
|
+
test_subject "[!mpbvu] fails when unexpected key exists in actual hash." do
|
238
256
|
actual = {"id": 101, "name": "Alice"}
|
239
257
|
errmsg = ("$<JSON>: key \"gender\" expected but not found.\n"\
|
240
258
|
" $<actual>.keys: \"id\", \"name\"\n"\
|
241
259
|
" $<expected>.keys: \"gender\", \"id\", \"name\"\n")
|
242
|
-
|
260
|
+
exc = test_exception? Oktest::FAIL_EXCEPTION do
|
243
261
|
JSON(actual) === {"id": Integer, "name": String, "gender": String}
|
244
262
|
end
|
263
|
+
test_eq? exc.message, errmsg
|
245
264
|
end
|
246
|
-
|
265
|
+
test_subject "[!4oasq] fails when expected key not exist in actual hash." do
|
247
266
|
actual = {"id": 101, "name": "Alice"}
|
248
267
|
errmsg = ("$<JSON>[\"id\"]: unexpected key.\n"\
|
249
268
|
" $<actual>: 101\n")
|
250
|
-
|
269
|
+
exc = test_exception? Oktest::FAIL_EXCEPTION do
|
251
270
|
JSON(actual) === {"name": String}
|
252
271
|
end
|
272
|
+
test_eq? exc.message, errmsg
|
253
273
|
end
|
254
|
-
|
274
|
+
test_subject "[!eqr3b] `OR()` matches to any of arguments." do
|
255
275
|
result = JSON({"val": 123}) === {"val": OR(String, Integer)}
|
256
|
-
|
276
|
+
test_eq? result, true
|
257
277
|
result = JSON({"val": "123"}) === {"val": OR(String, Integer)}
|
258
|
-
|
278
|
+
test_eq? result, true
|
259
279
|
#
|
260
280
|
errmsg = ("$<JSON>[\"val\"]: $<expected> === $<actual> : failed.\n"\
|
261
281
|
" $<actual>: 3.14\n"\
|
262
282
|
" $<expected>: OR(String, Integer)\n")
|
263
|
-
|
283
|
+
exc = test_exception? Oktest::FAIL_EXCEPTION do
|
264
284
|
JSON({"val": 3.14}) === {"val": OR(String, Integer)}
|
265
285
|
end
|
286
|
+
test_eq? exc.message, errmsg
|
266
287
|
end
|
267
|
-
|
288
|
+
test_subject "[!4hk96] `AND()` matches to all of arguments." do
|
268
289
|
result = JSON({"val": "alice"}) === {"val": AND(String, /^[a-z]+$/)}
|
269
|
-
|
290
|
+
test_eq? result, true
|
270
291
|
#
|
271
292
|
errmsg = ("$<JSON>[\"val\"]: $<expected> === $<actual> : failed.\n"\
|
272
293
|
" $<actual>: \"Alice\"\n"\
|
273
294
|
" $<expected>: AND(/^[a-z]+$/)\n")
|
274
|
-
|
295
|
+
exc = test_exception? Oktest::FAIL_EXCEPTION do
|
275
296
|
JSON({"val": "Alice"}) === {"val": AND(String, /^[a-z]+$/)}
|
276
297
|
end
|
298
|
+
test_eq? exc.message, errmsg
|
277
299
|
end
|
278
|
-
|
300
|
+
test_subject "[!5ybfg] `OR()` can contain `AND()`." do
|
279
301
|
expected = {"val": OR(AND(String, /^\d+$/), AND(Integer, 100..999))}
|
280
302
|
result = JSON({"val": "123"}) === expected
|
281
|
-
|
303
|
+
test_eq? result, true
|
282
304
|
result = JSON({"val": 123}) === expected
|
283
|
-
|
305
|
+
test_eq? result, true
|
284
306
|
#
|
285
307
|
errmsg = ("$<JSON>[\"val\"]: $<expected> === $<actual> : failed.\n"\
|
286
308
|
" $<actual>: \"abc\"\n"\
|
287
309
|
" $<expected>: OR(AND(String, /^\\d+$/), AND(Integer, 100..999))\n")
|
288
|
-
|
310
|
+
exc = test_exception? Oktest::FAIL_EXCEPTION do
|
289
311
|
JSON({"val": "abc"}) === expected
|
290
312
|
end
|
313
|
+
test_eq? exc.message, errmsg
|
291
314
|
errmsg = ("$<JSON>[\"val\"]: $<expected> === $<actual> : failed.\n"\
|
292
315
|
" $<actual>: 99\n"\
|
293
316
|
" $<expected>: OR(AND(String, /^\\d+$/), AND(Integer, 100..999))\n")
|
294
|
-
|
317
|
+
exc = test_exception? Oktest::FAIL_EXCEPTION do
|
295
318
|
JSON({"val": 99}) === expected
|
296
319
|
end
|
320
|
+
test_eq? exc.message, errmsg
|
297
321
|
end
|
298
|
-
|
322
|
+
test_subject "[!scx22] `AND()` can contain `OR()`." do
|
299
323
|
expected = {"val": AND(OR(String, Integer), OR(/^\d{3}$/, 100..999))}
|
300
324
|
result = JSON({"val": "123"}) === expected
|
301
|
-
|
325
|
+
test_eq? result, true
|
302
326
|
result = JSON({"val": 123}) === expected
|
303
|
-
|
327
|
+
test_eq? result, true
|
304
328
|
#
|
305
329
|
errmsg = ("$<JSON>[\"val\"]: $<expected> === $<actual> : failed.\n"\
|
306
330
|
" $<actual>: \"1\"\n"\
|
307
331
|
" $<expected>: AND(OR(/^\\d{3}$/, 100..999))\n")
|
308
|
-
|
332
|
+
exc = test_exception? Oktest::FAIL_EXCEPTION do
|
309
333
|
JSON({"val": "1"}) === expected
|
310
334
|
end
|
335
|
+
test_eq? exc.message, errmsg
|
311
336
|
errmsg = ("$<JSON>[\"val\"]: $<expected> === $<actual> : failed.\n"\
|
312
337
|
" $<actual>: 0\n"\
|
313
338
|
" $<expected>: AND(OR(/^\\d{3}$/, 100..999))\n")
|
314
|
-
|
339
|
+
exc = test_exception? Oktest::FAIL_EXCEPTION do
|
315
340
|
JSON({"val": 0}) === expected
|
316
341
|
end
|
342
|
+
test_eq? exc.message, errmsg
|
317
343
|
end
|
318
|
-
|
344
|
+
test_subject "[!uc4ag] key '*' matches to any key name." do
|
319
345
|
actual = {"name": "Alice", "age": 20}
|
320
346
|
result = JSON(actual) === {"name": String, "*": Integer}
|
321
|
-
|
347
|
+
test_eq? result, true
|
322
348
|
result = JSON(actual) === {"name": String, "*": ANY()}
|
323
|
-
|
349
|
+
test_eq? result, true
|
324
350
|
end
|
325
351
|
end
|
326
352
|
|
327
|
-
|
328
|
-
|
353
|
+
test_target 'Oktest::JsonMatcher#_compare?()' do
|
354
|
+
test_subject "[!nkvqo] returns true when nothing raised." do
|
329
355
|
result = JSON(nil).instance_eval { _compare?([], "abc", /^\w+$/) }
|
330
|
-
|
356
|
+
test_eq? result, true
|
331
357
|
end
|
332
|
-
|
358
|
+
test_subject "[!57m2j] returns false when assertion error raised." do
|
333
359
|
result = JSON(nil).instance_eval { _compare?([], "abc", /^\d+$/) }
|
334
|
-
|
360
|
+
test_eq? result, false
|
335
361
|
end
|
336
362
|
end
|
337
363
|
|
338
364
|
end
|
339
365
|
|
340
366
|
|
341
|
-
class
|
367
|
+
class JsonMatcher_OR__Test
|
368
|
+
extend NanoTest
|
342
369
|
|
343
|
-
|
344
|
-
|
370
|
+
test_target 'Oktest::JsonMatcher::OR#inspect()' do
|
371
|
+
test_subject "[!2mu33] returns 'OR(...)' string." do
|
345
372
|
o = Oktest::JsonMatcher::OR.new('A', 'B', 'C')
|
346
|
-
|
373
|
+
test_eq? o.inspect(), 'OR("A", "B", "C")'
|
347
374
|
end
|
348
375
|
end
|
349
376
|
|
350
377
|
end
|
351
378
|
|
352
379
|
|
353
|
-
class
|
380
|
+
class JsonMatcher_AND__Test
|
381
|
+
extend NanoTest
|
354
382
|
|
355
|
-
|
356
|
-
|
383
|
+
test_target 'Oktest::JsonMatcher::AND#inspect()' do
|
384
|
+
test_subject "[!w43ag] returns 'AND(...)' string." do
|
357
385
|
o = Oktest::JsonMatcher::AND.new('A', 'B', 'C')
|
358
|
-
|
386
|
+
test_eq? o.inspect(), 'AND("A", "B", "C")'
|
359
387
|
end
|
360
388
|
end
|
361
389
|
|
362
390
|
end
|
363
391
|
|
364
392
|
|
365
|
-
class
|
393
|
+
class JsonMatcher_Enum__Test
|
394
|
+
extend NanoTest
|
366
395
|
|
367
|
-
|
368
|
-
|
396
|
+
test_target 'Oktest::JsonMatcher::Enum#inspect()' do
|
397
|
+
test_subject "[!fam11] returns 'Enum(...)' string." do
|
369
398
|
o = Oktest::JsonMatcher::Enum.new(['A', 'B', 'C'])
|
370
|
-
|
399
|
+
test_eq? o.inspect(), 'Enum("A", "B", "C")'
|
371
400
|
end
|
372
401
|
end
|
373
402
|
|
374
403
|
end
|
375
404
|
|
376
405
|
|
377
|
-
class
|
406
|
+
class JsonMatcher_Length__Test
|
407
|
+
extend NanoTest
|
378
408
|
|
379
|
-
|
380
|
-
|
409
|
+
test_target 'Oktest::JsonMatcher::Length#===' do
|
410
|
+
test_subject "[!03ozi] compares length of actual value with expected value." do
|
381
411
|
o1 = Oktest::JsonMatcher::Length.new(3)
|
382
|
-
|
383
|
-
|
384
|
-
|
385
|
-
|
412
|
+
test_eq? (o1 === "abc"), true
|
413
|
+
test_eq? (o1 === "abcd"), false
|
414
|
+
test_eq? (o1 === [1,2,3]), true
|
415
|
+
test_eq? (o1 === [1, 2]), false
|
386
416
|
o2 = Oktest::JsonMatcher::Length.new(1..3)
|
387
|
-
|
388
|
-
|
389
|
-
|
390
|
-
|
417
|
+
test_eq? (o2 === "a"), true
|
418
|
+
test_eq? (o2 === "abc"), true
|
419
|
+
test_eq? (o2 === ""), false
|
420
|
+
test_eq? (o2 === "abcd"), false
|
391
421
|
end
|
392
422
|
end
|
393
423
|
|
394
|
-
|
395
|
-
|
424
|
+
test_target 'Oktest::JsonMatcher::Length#inspect()' do
|
425
|
+
test_subject "[!nwv3e] returns 'Length(n)' string." do
|
396
426
|
o = Oktest::JsonMatcher::Length.new(1..3)
|
397
|
-
|
427
|
+
test_eq? o.inspect, "Length(1..3)"
|
398
428
|
end
|
399
429
|
end
|
400
430
|
|
401
431
|
end
|
402
432
|
|
403
433
|
|
404
|
-
class
|
434
|
+
class JsonMatcher_Any__Test
|
435
|
+
extend NanoTest
|
405
436
|
|
406
|
-
|
407
|
-
|
437
|
+
test_target 'Oktest::JsonMatcher::Any#===' do
|
438
|
+
test_subject "[!mzion] returns true in any case." do
|
408
439
|
o = Oktest::JsonMatcher::Any.new()
|
409
|
-
|
410
|
-
|
411
|
-
|
412
|
-
|
413
|
-
|
440
|
+
test_eq? (o === nil) , true
|
441
|
+
test_eq? (o === true) , true
|
442
|
+
test_eq? (o === false), true
|
443
|
+
test_eq? (o === 123) , true
|
444
|
+
test_eq? (o === "abc"), true
|
414
445
|
end
|
415
446
|
end
|
416
447
|
|
417
|
-
|
418
|
-
|
448
|
+
test_target 'Oktest::JsonMatcher::Any#inspect()' do
|
449
|
+
test_subject "[!6f0yv] returns 'Any()' string." do
|
419
450
|
o = Oktest::JsonMatcher::Any.new()
|
420
|
-
|
451
|
+
test_eq? o.inspect, "Any()"
|
421
452
|
end
|
422
453
|
end
|
423
454
|
|