oktest 1.4.0 → 1.5.0

Sign up to get free protection for your applications and to get access to all the features.
data/test/util_test.rb CHANGED
@@ -2,159 +2,158 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  ###
5
- ### $Release: 1.4.0 $
5
+ ### $Release: 1.5.0 $
6
6
  ### $Copyright: copyright(c) 2011-2024 kuwata-lab.com all rights reserved $
7
7
  ### $License: MIT License $
8
8
  ###
9
9
 
10
- require_relative './initialize'
10
+ require_relative './init'
11
11
 
12
12
 
13
- class Util_TC < TC
14
- include Oktest::Util
13
+ class Util__Test
14
+ extend NanoTest
15
+ extend Oktest::Util
15
16
 
16
- describe Oktest::Util do
17
-
18
- describe '.file_line()' do
19
- it "[!4z65g] returns nil if file not exist or not a file." do
20
- assert_eq Oktest::Util.file_line("not-exist-file", 1), nil
21
- assert_eq Oktest::Util.file_line(".", 1), nil
22
- end
23
- it "[!162e1] returns line string." do
24
- lineno = __LINE__ + 2
25
- _ = <<END
17
+ test_target 'Oktest::Util.file_line()' do
18
+ test_subject "[!4z65g] returns nil if file not exist or not a file." do
19
+ test_eq? Oktest::Util.file_line("not-exist-file", 1), nil
20
+ test_eq? Oktest::Util.file_line(".", 1), nil
21
+ end
22
+ test_subject "[!162e1] returns line string." do
23
+ lineno = __LINE__ + 2
24
+ _ = <<END
26
25
  U6XYR-SH08J
27
26
  END
28
- assert_eq Oktest::Util.file_line(__FILE__, lineno), "U6XYR-SH08J\n"
29
- end
30
- it "[!4a2ji] caches recent file content for performance reason." do
31
- _ = Oktest::Util.file_line(__FILE__, 1)
32
- c = Oktest::Util.instance_variable_get('@__cache')
33
- assert c.is_a?(Array), "array object expected."
34
- assert_eq c[0], __FILE__
35
- assert_eq c[1][0], "# -*- coding: utf-8 -*-\n"
36
- assert_eq c[1][12], "class Util_TC < TC\n"
37
- #
38
- data1 = c[1]
39
- _ = Oktest::Util.file_line(__FILE__, 1)
40
- c2 = Oktest::Util.instance_variable_get('@__cache')
41
- assert c2[1].equal?(data1), "cache object changed unexpectedly."
42
- end
43
- it "[!wtrl5] recreates cache data if other file requested." do
44
- _ = Oktest::Util.file_line(__FILE__, 1)
45
- c = Oktest::Util.instance_variable_get('@__cache')
46
- data1 = c[1]
47
- #
48
- otherfile = File.join(File.dirname(__FILE__), "initialize.rb")
49
- _ = Oktest::Util.file_line(otherfile, 1)
50
- c3 = Oktest::Util.instance_variable_get('@__cache')
51
- assert_eq c3[0], otherfile
52
- assert ! c3[1].equal?(data1), "cache object should be recreated, but not."
53
- end
27
+ test_eq? Oktest::Util.file_line(__FILE__, lineno), "U6XYR-SH08J\n"
28
+ end
29
+ test_subject "[!4a2ji] caches recent file content for performance reason." do
30
+ _ = Oktest::Util.file_line(__FILE__, 1)
31
+ c = Oktest::Util.instance_variable_get('@__cache')
32
+ test_ok? c.is_a?(Array), msg: "array object expected."
33
+ test_eq? c[0], __FILE__
34
+ test_eq? c[1][0], "# -*- coding: utf-8 -*-\n"
35
+ test_eq? c[1][16], " test_target 'Oktest::Util.file_line()' do\n"
36
+ #
37
+ data1 = c[1]
38
+ _ = Oktest::Util.file_line(__FILE__, 1)
39
+ c2 = Oktest::Util.instance_variable_get('@__cache')
40
+ test_ok? c2[1].equal?(data1), msg: "cache object changed unexpectedly."
41
+ end
42
+ test_subject "[!wtrl5] recreates cache data if other file requested." do
43
+ _ = Oktest::Util.file_line(__FILE__, 1)
44
+ c = Oktest::Util.instance_variable_get('@__cache')
45
+ data1 = c[1]
46
+ #
47
+ otherfile = File.join(File.dirname(__FILE__), "init.rb")
48
+ _ = Oktest::Util.file_line(otherfile, 1)
49
+ c3 = Oktest::Util.instance_variable_get('@__cache')
50
+ test_eq? c3[0], otherfile
51
+ test_ok? ! c3[1].equal?(data1), msg: "cache object should be recreated, but not."
54
52
  end
53
+ end
55
54
 
56
- describe '.required_param_names_of_block()' do
57
- it "[!a9n46] returns nil if argument is nil." do
58
- assert_eq required_param_names_of_block(nil), nil
59
- end
60
- it "[!7m81p] returns empty array if block has no parameters." do
61
- pr = proc { nil }
62
- assert_eq required_param_names_of_block(pr), []
63
- end
64
- it "[!n3g63] returns parameter names of block." do
65
- pr = proc {|x, y, z| nil }
66
- assert_eq required_param_names_of_block(pr), [:x, :y, :z]
67
- end
68
- it "[!d5kym] collects only normal parameter names." do
69
- pr = proc {|x, y, z=1, *rest, a: 1, b: 2, &blk| nil }
70
- assert_eq required_param_names_of_block(pr), [:x, :y]
71
- pr = proc {|a: 1, b: 2, &blk| nil }
72
- assert_eq required_param_names_of_block(pr), []
73
- pr = proc {|*rest, &blk| nil }
74
- assert_eq required_param_names_of_block(pr), []
75
- end
55
+ test_target 'Oktest::Util.required_param_names_of_block()' do
56
+ test_subject "[!a9n46] returns nil if argument is nil." do
57
+ test_eq? required_param_names_of_block(nil), nil
58
+ end
59
+ test_subject "[!7m81p] returns empty array if block has no parameters." do
60
+ pr = proc { nil }
61
+ test_eq? required_param_names_of_block(pr), []
62
+ end
63
+ test_subject "[!n3g63] returns parameter names of block." do
64
+ pr = proc {|x, y, z| nil }
65
+ test_eq? required_param_names_of_block(pr), [:x, :y, :z]
66
+ end
67
+ test_subject "[!d5kym] collects only normal parameter names." do
68
+ pr = proc {|x, y, z=1, *rest, a: 1, b: 2, &blk| nil }
69
+ test_eq? required_param_names_of_block(pr), [:x, :y]
70
+ pr = proc {|a: 1, b: 2, &blk| nil }
71
+ test_eq? required_param_names_of_block(pr), []
72
+ pr = proc {|*rest, &blk| nil }
73
+ test_eq? required_param_names_of_block(pr), []
76
74
  end
75
+ end
77
76
 
78
- describe '.keyword_param_names_of_block()' do
79
- it "[!p6qqp] returns keyword param names of proc object." do
80
- pr = proc {|a, b=nil, c: nil, d: 1| nil }
81
- assert_eq keyword_param_names_of_block(pr), [:c, :d]
82
- pr = proc {|a, b=nil| nil }
83
- assert_eq keyword_param_names_of_block(pr), []
84
- end
77
+ test_target 'Oktest::Util.keyword_param_names_of_block()' do
78
+ test_subject "[!p6qqp] returns keyword param names of proc object." do
79
+ pr = proc {|a, b=nil, c: nil, d: 1| nil }
80
+ test_eq? keyword_param_names_of_block(pr), [:c, :d]
81
+ pr = proc {|a, b=nil| nil }
82
+ test_eq? keyword_param_names_of_block(pr), []
85
83
  end
84
+ end
86
85
 
87
- describe '.strfold()' do
88
- it "[!wb7m8] returns string as it is if string is not long." do
89
- s = "*" * 79
90
- assert_eq strfold(s, 80), s
91
- s = "*" * 80
92
- assert_eq strfold(s, 80), s
93
- end
94
- it "[!a2igb] shorten string if it is enough long." do
95
- expected = "*" * 77 + "..."
96
- s = "*" * 81
97
- assert_eq strfold(s, 80), expected
98
- end
99
- it "[!0gjye] supports non-ascii characters." do
100
- expected = "あ" * 38 + "..."
101
- s = "あ" * 41
102
- assert_eq strfold(s, 80), expected
103
- #
104
- expected = "x" + "あ" * 37 + "..."
105
- s = "x" + "あ" * 40
106
- assert_eq strfold(s, 80), expected
107
- end
86
+ test_target 'Oktest::Util.strfold()' do
87
+ test_subject "[!wb7m8] returns string as test_subject is if string is not long." do
88
+ s = "*" * 79
89
+ test_eq? strfold(s, 80), s
90
+ s = "*" * 80
91
+ test_eq? strfold(s, 80), s
92
+ end
93
+ test_subject "[!a2igb] shorten string if test_subject is enough long." do
94
+ expected = "*" * 77 + "..."
95
+ s = "*" * 81
96
+ test_eq? strfold(s, 80), expected
97
+ end
98
+ test_subject "[!0gjye] supports non-ascii characters." do
99
+ expected = "あ" * 38 + "..."
100
+ s = "あ" * 41
101
+ test_eq? strfold(s, 80), expected
102
+ #
103
+ expected = "x" + "あ" * 37 + "..."
104
+ s = "x" + "あ" * 40
105
+ test_eq? strfold(s, 80), expected
108
106
  end
107
+ end
109
108
 
110
- describe '.hhmmss()' do
111
- it "[!shyl1] converts 400953.444 into '111:22:33.4'." do
112
- x = 111*60*60 + 22*60 + 33.444
113
- assert_eq x, 400953.444
114
- assert_eq hhmmss(x), "111:22:33.4"
115
- end
116
- it "[!vyi2v] converts 5025.678 into '1:23:45.7'." do
117
- x = 1*60*60 + 23*60 + 45.678
118
- assert_eq x, 5025.678
119
- assert_eq hhmmss(x), "1:23:45.7"
120
- end
121
- it "[!pm4xf] converts 754.888 into '12:34.9'." do
122
- x = 12*60 + 34.888
123
- assert_eq x, 754.888
124
- assert_eq hhmmss(x), "12:34.9"
125
- end
126
- it "[!lwewr] converts 83.444 into '1:23.4'." do
127
- x = 1*60 + 23.444
128
- assert_eq x, 83.444
129
- assert_eq hhmmss(x), "1:23.4"
130
- end
131
- it "[!ijx52] converts 56.8888 into '56.9'." do
132
- x = 56.8888
133
- assert_eq hhmmss(x), "56.9"
134
- end
135
- it "[!2kra2] converts 9.777 into '9.78'." do
136
- x = 9.777
137
- assert_eq hhmmss(x), "9.78"
138
- end
139
- it "[!4aomb] converts 0.7777 into '0.778'." do
140
- x = 0.7777
141
- assert_eq hhmmss(x), "0.778"
142
- end
109
+ test_target 'Oktest::Util.hhmmss()' do
110
+ test_subject "[!shyl1] converts 400953.444 into '111:22:33.4'." do
111
+ x = 111*60*60 + 22*60 + 33.444
112
+ test_eq? x, 400953.444
113
+ test_eq? hhmmss(x), "111:22:33.4"
114
+ end
115
+ test_subject "[!vyi2v] converts 5025.678 into '1:23:45.7'." do
116
+ x = 1*60*60 + 23*60 + 45.678
117
+ test_eq? x, 5025.678
118
+ test_eq? hhmmss(x), "1:23:45.7"
119
+ end
120
+ test_subject "[!pm4xf] converts 754.888 into '12:34.9'." do
121
+ x = 12*60 + 34.888
122
+ test_eq? x, 754.888
123
+ test_eq? hhmmss(x), "12:34.9"
124
+ end
125
+ test_subject "[!lwewr] converts 83.444 into '1:23.4'." do
126
+ x = 1*60 + 23.444
127
+ test_eq? x, 83.444
128
+ test_eq? hhmmss(x), "1:23.4"
143
129
  end
130
+ test_subject "[!ijx52] converts 56.8888 into '56.9'." do
131
+ x = 56.8888
132
+ test_eq? hhmmss(x), "56.9"
133
+ end
134
+ test_subject "[!2kra2] converts 9.777 into '9.78'." do
135
+ x = 9.777
136
+ test_eq? hhmmss(x), "9.78"
137
+ end
138
+ test_subject "[!4aomb] converts 0.7777 into '0.778'." do
139
+ x = 0.7777
140
+ test_eq? hhmmss(x), "0.778"
141
+ end
142
+ end
144
143
 
145
- describe '.hhmmss()' do
146
- it "[!wf4ns] calculates unified diff from two text strings." do
147
- s1 = <<'END'
144
+ test_target 'Oktest::Util.hhmmss()' do
145
+ test_subject "[!wf4ns] calculates unified diff from two text strings." do
146
+ s1 = <<'END'
148
147
  Haruhi
149
148
  Mikuru
150
149
  Yuki
151
150
  END
152
- s2 = <<'END'
151
+ s2 = <<'END'
153
152
  Haruhi
154
153
  Michiru
155
154
  Yuki
156
155
  END
157
- expected = <<'END'
156
+ expected = <<'END'
158
157
  --- old
159
158
  +++ new
160
159
  @@ -1,4 +1,4 @@
@@ -163,21 +162,21 @@ END
163
162
  +Michiru
164
163
  Yuki
165
164
  END
166
- diff = Oktest::Util.unified_diff(s1, s2)
167
- assert_eq diff, expected
168
- end
165
+ diff = Oktest::Util.unified_diff(s1, s2)
166
+ test_eq? diff, expected
169
167
  end
168
+ end
170
169
 
171
- describe '.unified_diff()' do
172
- it "[!rnx4f] checks whether text string ends with newline char." do
173
- s1 = <<'END'
170
+ test_target 'Oktest::Util.unified_diff()' do
171
+ test_subject "[!rnx4f] checks whether text string ends with newline char." do
172
+ s1 = <<'END'
174
173
  Haruhi
175
174
  Mikuru
176
175
  Yuki
177
176
  END
178
- s2 = s1
179
- #
180
- expected1 = <<'END'
177
+ s2 = s1
178
+ #
179
+ expected1 = <<'END'
181
180
  --- old
182
181
  +++ new
183
182
  @@ -1,4 +1,4 @@
@@ -186,10 +185,10 @@ END
186
185
  -Yuki\ No newline at end of string
187
186
  +Yuki
188
187
  END
189
- diff = Oktest::Util.unified_diff(s1.chomp, s2)
190
- assert_eq diff, expected1
191
- #
192
- expected2 = <<'END'
188
+ diff = Oktest::Util.unified_diff(s1.chomp, s2)
189
+ test_eq? diff, expected1
190
+ #
191
+ expected2 = <<'END'
193
192
  --- old
194
193
  +++ new
195
194
  @@ -1,4 +1,4 @@
@@ -198,24 +197,24 @@ END
198
197
  -Yuki
199
198
  +Yuki\ No newline at end of string
200
199
  END
201
- diff = Oktest::Util.unified_diff(s1, s2.chomp)
202
- assert_eq diff, expected2
203
- end
200
+ diff = Oktest::Util.unified_diff(s1, s2.chomp)
201
+ test_eq? diff, expected2
204
202
  end
203
+ end
205
204
 
206
- describe '.diff_unified()' do
207
- it "[!ulyq5] returns unified diff string of two text strings." do
208
- s1 = <<'END'
205
+ test_target 'Oktest::Util.diff_unified()' do
206
+ test_subject "[!ulyq5] returns unified diff string of two text strings." do
207
+ s1 = <<'END'
209
208
  Haruhi
210
209
  Mikuru
211
210
  Yuki
212
211
  END
213
- s2 = <<'END'
212
+ s2 = <<'END'
214
213
  Haruhi
215
214
  Michiru
216
215
  Yuki
217
216
  END
218
- expected = <<'END'
217
+ expected = <<'END'
219
218
  --- old
220
219
  +++ new
221
220
  @@ -1,3 +1,3 @@
@@ -224,18 +223,18 @@ END
224
223
  +Michiru
225
224
  Yuki
226
225
  END
227
- diff = Oktest::Util.diff_unified(s1, s2)
228
- assert_eq diff, expected
229
- end
230
- it "[!6tgum] detects whether char at end of file is newline or not." do
231
- s1 = <<'END'
226
+ diff = Oktest::Util.diff_unified(s1, s2)
227
+ test_eq? diff, expected
228
+ end
229
+ test_subject "[!6tgum] detects whether char at end of file is newline or not." do
230
+ s1 = <<'END'
232
231
  Haruhi
233
232
  Mikuru
234
233
  Yuki
235
234
  END
236
- s2 = s1
237
- #
238
- expected1 = <<'END'
235
+ s2 = s1
236
+ #
237
+ expected1 = <<'END'
239
238
  --- old
240
239
  +++ new
241
240
  @@ -1,3 +1,3 @@
@@ -245,10 +244,10 @@ END
245
244
 
246
245
  +Yuki
247
246
  END
248
- diff = Oktest::Util.diff_unified(s1.chomp, s2)
249
- assert_eq diff, expected1
250
- #
251
- expected2 = <<'END'
247
+ diff = Oktest::Util.diff_unified(s1.chomp, s2)
248
+ test_eq? diff, expected1
249
+ #
250
+ expected2 = <<'END'
252
251
  --- old
253
252
  +++ new
254
253
  @@ -1,3 +1,3 @@
@@ -258,71 +257,75 @@ END
258
257
  +Yuki
259
258
 
260
259
  END
261
- diff = Oktest::Util.diff_unified(s1, s2.chomp)
262
- assert_eq diff, expected2
263
- end
260
+ diff = Oktest::Util.diff_unified(s1, s2.chomp)
261
+ test_eq? diff, expected2
264
262
  end
263
+ end
265
264
 
266
- describe '.partial_regexp!()' do
267
- it "[!peyu4] returns PartialRegexp object which inspect string is function call styel." do
265
+ test_target 'Oktest::Util.partial_regexp!()' do
266
+ test_subject "[!peyu4] returns PartialRegexp object which inspect string is function call styel." do
268
267
  pattern_str = <<'HEREDOC'
269
268
  * [Date] {== \d\d\d\d-\d\d-\d\d ==}
270
269
  * [Secret] {== [0-9a-f]{8} ==}
271
270
  HEREDOC
272
- prexp = Oktest::Util.partial_regexp!(pattern_str)
273
- assert_eq prexp.class, Oktest::Util::PartialRegexp
274
- assert_eq prexp.pattern_string, pattern_str
275
- end
271
+ prexp = Oktest::Util.partial_regexp!(pattern_str)
272
+ test_eq? prexp.class, Oktest::Util::PartialRegexp
273
+ test_eq? prexp.pattern_string, pattern_str
276
274
  end
275
+ end
277
276
 
278
- describe '.partial_regexp()' do
279
- it "[!ostkw] raises error if mark has no space or has more than two spaces." do
280
- assert_exc(ArgumentError, "\"{====}\": mark should contain only one space (ex: `{== ==}`).") do
281
- Oktest::Util.partial_regexp("xxx", '\A', '\z', "{====}")
282
- end
283
- assert_exc(ArgumentError, "\"{= == =}\": mark should contain only one space (ex: `{== ==}`).") do
284
- Oktest::Util.partial_regexp("xxx", '', '', "{= == =}")
285
- end
277
+ test_target 'Oktest::Util.partial_regexp()' do
278
+ test_subject "[!ostkw] raises error if mark has no space or has more than two spaces." do
279
+ exc = test_exception? ArgumentError do
280
+ Oktest::Util.partial_regexp("xxx", '\A', '\z', "{====}")
286
281
  end
287
- it "[!wn524] returns PartialRegexp object which inspect string is regexp literal style." do
288
- pattern_str = <<'HEREDOC'
282
+ test_eq? exc.message, "\"{====}\": mark should contain only one space (ex: `{== ==}`)."
283
+ exc = test_exception? ArgumentError do
284
+ Oktest::Util.partial_regexp("xxx", '', '', "{= == =}")
285
+ end
286
+ test_eq? exc.message, "\"{= == =}\": mark should contain only one space (ex: `{== ==}`)."
287
+ end
288
+ test_subject "[!wn524] returns PartialRegexp object which inspect string is regexp literal style." do
289
+ pattern_str = <<'HEREDOC'
289
290
  * [Date] {== \d\d\d\d-\d\d-\d\d ==}
290
291
  * [Secret] {== [0-9a-f]{8} ==}
291
292
  HEREDOC
292
- prexp = Oktest::Util.partial_regexp(pattern_str)
293
- assert_eq prexp.class, Oktest::Util::PartialRegexp
294
- assert_eq prexp.pattern_string, nil
295
- end
293
+ prexp = Oktest::Util.partial_regexp(pattern_str)
294
+ test_eq? prexp.class, Oktest::Util::PartialRegexp
295
+ test_eq? prexp.pattern_string, nil
296
296
  end
297
-
298
297
  end
299
298
 
300
- describe Oktest::Util::PartialRegexp do
301
- describe '#inspect()' do
302
- it "[!uyh31] returns function call style string if @pattern_string is set." do
303
- prexp = Oktest::Util.partial_regexp!(<<'HEREHERE')
299
+ end
300
+
301
+
302
+ class Util_PartialRegexp__Test
303
+ extend NanoTest
304
+
305
+ test_target 'Oktest::Util::PartialRegexp#inspect()' do
306
+ test_subject "[!uyh31] returns function call style string if @pattern_string is set." do
307
+ prexp = Oktest::Util.partial_regexp!(<<'HEREHERE')
304
308
  * [Date] {== \d\d\d\d-\d\d-\d\d ==}
305
309
  * [Secret] {== [0-9a-f]{8} ==}
306
310
  HEREHERE
307
- assert_eq prexp.inspect, <<'HEREHERE'
311
+ test_eq? prexp.inspect, <<'HEREHERE'
308
312
  partial_regexp(<<PREXP, '\A', '\z')
309
313
  * [Date] {== \d\d\d\d-\d\d-\d\d ==}
310
314
  * [Secret] {== [0-9a-f]{8} ==}
311
315
  PREXP
312
316
  HEREHERE
313
- end
314
- it "[!ts9v4] returns regexp literal style string if @pattern_string is not set." do
315
- prexp = Oktest::Util.partial_regexp(<<'HEREHERE')
317
+ end
318
+ test_subject "[!ts9v4] returns regexp literal style string if @pattern_string is not set." do
319
+ prexp = Oktest::Util.partial_regexp(<<'HEREHERE')
316
320
  * [Date] {== \d\d\d\d-\d\d-\d\d ==}
317
321
  * [Secret] {== [0-9a-f]{8} ==}
318
322
  HEREHERE
319
- assert_eq prexp.inspect, <<'HEREHERE'.chomp
323
+ test_eq? prexp.inspect, <<'HEREHERE'.chomp
320
324
  /\A
321
325
  \*\ \[Date\]\ \ \ \ \d\d\d\d-\d\d-\d\d\n
322
326
  \*\ \[Secret\]\ \ [0-9a-f]{8}\n
323
327
  \z/x
324
328
  HEREHERE
325
- end
326
329
  end
327
330
  end
328
331
 
@@ -2,84 +2,81 @@
2
2
  # frozen_string_literal: true
3
3
 
4
4
  ###
5
- ### $Release: 1.4.0 $
5
+ ### $Release: 1.5.0 $
6
6
  ### $Copyright: copyright(c) 2011-2024 kuwata-lab.com all rights reserved $
7
7
  ### $License: MIT License $
8
8
  ###
9
9
 
10
- require_relative './initialize'
10
+ require_relative './init'
11
11
 
12
12
 
13
- class UtilHelper_TC < TC
13
+ class UtilHelper__Test
14
+ extend NanoTest
14
15
 
15
- describe Oktest::UtilHelper do
16
-
17
- describe '#partial_regexp!()' do
18
- pat = <<'END'
16
+ test_target 'Oktest::UtilHelper#partial_regexp!()' do
17
+ pat = <<'END'
19
18
  * [Date] {== \d\d\d\d-\d\d-\d\d ==}
20
19
  * [Secret] {== [0-9a-f]{12} ==}
21
20
  END
22
- it "[!9drtn] is available in both topic and spec blocks." do
23
- r1 = nil; r2 = nil
24
- Oktest.scope do
25
- topic "topic" do
26
- r1 = partial_regexp!(pat, '\A', '\z')
27
- spec "spec" do
28
- r2 = partial_regexp!(pat, "", "")
29
- end
21
+ test_subject "[!9drtn] is available in both topic and spec blocks." do
22
+ r1 = nil; r2 = nil
23
+ Oktest.scope do
24
+ topic "topic" do
25
+ r1 = partial_regexp!(pat, '\A', '\z')
26
+ spec "spec" do
27
+ r2 = partial_regexp!(pat, "", "")
30
28
  end
31
29
  end
32
- capture { Oktest.run() }
33
- assert_eq r1.class, Oktest::Util::PartialRegexp
34
- assert_eq r2.class, Oktest::Util::PartialRegexp
35
- assert_eq r1.inspect, <<'END'
30
+ end
31
+ capture_output! { Oktest.run() }
32
+ test_eq? r1.class, Oktest::Util::PartialRegexp
33
+ test_eq? r2.class, Oktest::Util::PartialRegexp
34
+ test_eq? r1.inspect, <<'END'
36
35
  partial_regexp(<<PREXP, '\A', '\z')
37
36
  * [Date] {== \d\d\d\d-\d\d-\d\d ==}
38
37
  * [Secret] {== [0-9a-f]{12} ==}
39
38
  PREXP
40
39
  END
41
- assert_eq r2.inspect, <<'END'
40
+ test_eq? r2.inspect, <<'END'
42
41
  partial_regexp(<<PREXP, "", "")
43
42
  * [Date] {== \d\d\d\d-\d\d-\d\d ==}
44
43
  * [Secret] {== [0-9a-f]{12} ==}
45
44
  PREXP
46
45
  END
47
- end
48
46
  end
47
+ end
49
48
 
50
- describe '#partial_regexp()' do
51
- it "[!wo4hp] is available in both topic and spec blocks." do
52
- pat = <<'END'
49
+ test_target 'Oktest::UtilHelper#partial_regexp()' do
50
+ test_subject "[!wo4hp] is available in both topic and spec blocks." do
51
+ pat = <<'END'
53
52
  * [Date] {== \d\d\d\d-\d\d-\d\d ==}
54
53
  * [Secret] {== [0-9a-f]{12} ==}
55
54
  END
56
- r1 = nil; r2 = nil
57
- Oktest.scope do
58
- topic "topic" do
59
- r1 = partial_regexp(pat, '\A', '\z')
60
- spec "spec" do
61
- r2 = partial_regexp(pat, "", "")
62
- end
55
+ r1 = nil; r2 = nil
56
+ Oktest.scope do
57
+ topic "topic" do
58
+ r1 = partial_regexp(pat, '\A', '\z')
59
+ spec "spec" do
60
+ r2 = partial_regexp(pat, "", "")
63
61
  end
64
62
  end
65
- capture { Oktest.run() }
66
- assert_eq r1.class, Oktest::Util::PartialRegexp
67
- assert_eq r2.class, Oktest::Util::PartialRegexp
68
- assert_eq r1.inspect, <<'END'.chomp
63
+ end
64
+ capture_output! { Oktest.run() }
65
+ test_eq? r1.class, Oktest::Util::PartialRegexp
66
+ test_eq? r2.class, Oktest::Util::PartialRegexp
67
+ test_eq? r1.inspect, <<'END'.chomp
69
68
  /\A
70
69
  \*\ \[Date\]\ \ \ \ \d\d\d\d-\d\d-\d\d\n
71
70
  \*\ \[Secret\]\ \ [0-9a-f]{12}\n
72
71
  \z/x
73
72
  END
74
- assert_eq r2.inspect, <<'END'.chomp
73
+ test_eq? r2.inspect, <<'END'.chomp
75
74
  /
76
75
  \*\ \[Date\]\ \ \ \ \d\d\d\d-\d\d-\d\d\n
77
76
  \*\ \[Secret\]\ \ [0-9a-f]{12}\n
78
77
  /x
79
78
  END
80
- end
81
79
  end
82
-
83
80
  end
84
81
 
85
82
  end