oktest 1.3.1 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +114 -13
- data/Rakefile.rb +1 -1
- data/benchmark/run_all.rb +1 -0
- data/bin/oktest +3 -0
- data/lib/oktest.rb +223 -136
- data/oktest.gemspec +3 -2
- data/test/assertion_test.rb +19 -6
- data/test/filter_test.rb +2 -1
- data/test/fixture_test.rb +2 -1
- data/test/generator_test.rb +7 -4
- data/test/helper_test.rb +180 -8
- data/test/initialize.rb +2 -1
- data/test/mainapp_test.rb +85 -39
- data/test/matcher_test.rb +2 -1
- data/test/misc_test.rb +2 -1
- data/test/node_test.rb +36 -1
- data/test/reporter_test.rb +2 -1
- data/test/run_all.rb +1 -0
- data/test/runner_test.rb +2 -1
- data/test/tc.rb +1 -0
- data/test/util_test.rb +3 -2
- data/test/utilhelper_test.rb +2 -1
- data/test/visitor_test.rb +2 -1
- metadata +20 -6
data/test/helper_test.rb
CHANGED
@@ -1,5 +1,8 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
1
4
|
###
|
2
|
-
### $Release: 1.
|
5
|
+
### $Release: 1.4.0 $
|
3
6
|
### $Copyright: copyright(c) 2011-2024 kuwata-lab.com all rights reserved $
|
4
7
|
### $License: MIT License $
|
5
8
|
###
|
@@ -181,9 +184,9 @@ END
|
|
181
184
|
end
|
182
185
|
end
|
183
186
|
|
184
|
-
describe '#
|
187
|
+
describe '#capture_stdio()' do
|
185
188
|
it "[!1kbnj] captures $stdio and $stderr." do
|
186
|
-
sout, serr =
|
189
|
+
sout, serr = capture_stdio() do
|
187
190
|
puts "fooo"
|
188
191
|
$stderr.puts "baaa"
|
189
192
|
end
|
@@ -192,7 +195,7 @@ END
|
|
192
195
|
end
|
193
196
|
it "[!53mai] takes $stdin data." do
|
194
197
|
data = nil
|
195
|
-
sout, serr =
|
198
|
+
sout, serr = capture_stdio("blabla") do
|
196
199
|
data = $stdin.read()
|
197
200
|
end
|
198
201
|
data = "blabla"
|
@@ -201,7 +204,7 @@ END
|
|
201
204
|
stdin_, stdout_, stderr_ = $stdin, $stdout, $stderr
|
202
205
|
exception = nil
|
203
206
|
begin
|
204
|
-
sout, serr =
|
207
|
+
sout, serr = capture_stdio() do
|
205
208
|
puts "fooo"
|
206
209
|
$stderr.puts "baaa"
|
207
210
|
assert stdin_ != $stdin , "stdin should be replaced"
|
@@ -219,7 +222,7 @@ END
|
|
219
222
|
assert stderr_ == $stderr, "stderr should be recovered"
|
220
223
|
end
|
221
224
|
it "[!4j494] returns outpouts of stdout and stderr." do
|
222
|
-
sout, serr =
|
225
|
+
sout, serr = capture_stdio() do
|
223
226
|
puts "foo"
|
224
227
|
$stderr.puts "bar"
|
225
228
|
end
|
@@ -227,17 +230,186 @@ END
|
|
227
230
|
assert_eq serr, "bar\n"
|
228
231
|
end
|
229
232
|
it "[!6ik8b] can simulate tty." do
|
230
|
-
sout, serr =
|
233
|
+
sout, serr = capture_stdio() do
|
231
234
|
assert_eq $stdin.tty?, false
|
232
235
|
assert_eq $stdout.tty?, false
|
233
236
|
assert_eq $stderr.tty?, false
|
234
237
|
end
|
235
238
|
#
|
236
|
-
sout, serr =
|
239
|
+
sout, serr = capture_stdio(tty: true) do
|
240
|
+
assert_eq $stdin.tty?, true
|
241
|
+
assert_eq $stdout.tty?, true
|
242
|
+
assert_eq $stderr.tty?, true
|
243
|
+
end
|
244
|
+
end
|
245
|
+
end
|
246
|
+
|
247
|
+
describe '#capture_sio()' do
|
248
|
+
it "[!qjmaa] 'capture_sio()' is an alias of 'capture_stdio()'." do
|
249
|
+
sin = nil
|
250
|
+
sout, serr = capture_sio("INPUT", tty: true) do
|
251
|
+
sin = $stdin.read()
|
252
|
+
puts "OUTPUT"
|
253
|
+
$stderr.puts "ERROR"
|
254
|
+
assert_eq $stdin.tty?, true
|
255
|
+
assert_eq $stdout.tty?, true
|
256
|
+
assert_eq $stdout.tty?, true
|
257
|
+
end
|
258
|
+
assert_eq sin, "INPUT"
|
259
|
+
assert_eq sout, "OUTPUT\n"
|
260
|
+
assert_eq serr, "ERROR\n"
|
261
|
+
end
|
262
|
+
end
|
263
|
+
|
264
|
+
describe '#capture_stdout()' do
|
265
|
+
it "[!4agii] same as `sout, serr = capture_stdio(); ok {serr} == ''`." do
|
266
|
+
sin = nil
|
267
|
+
sout = capture_stdout("INPUT", tty: true) do
|
268
|
+
sin = $stdin.read()
|
269
|
+
puts "OUTPUT"
|
237
270
|
assert_eq $stdin.tty?, true
|
238
271
|
assert_eq $stdout.tty?, true
|
239
272
|
assert_eq $stderr.tty?, true
|
240
273
|
end
|
274
|
+
assert_eq sin, "INPUT"
|
275
|
+
assert_eq sout, "OUTPUT\n"
|
276
|
+
end
|
277
|
+
it "[!may84] fails when stderr is not empty." do
|
278
|
+
assert_exc(Oktest::AssertionFailed, "Output of $stderr expected to be empty, but got: \"ERROR\"") do
|
279
|
+
capture_stdout() do
|
280
|
+
$stderr.print "ERROR"
|
281
|
+
end
|
282
|
+
end
|
283
|
+
end
|
284
|
+
it "[!5n04e] returns output of stdout." do
|
285
|
+
sout = capture_stdout() do
|
286
|
+
print "OUTPUT"
|
287
|
+
end
|
288
|
+
assert_eq sout, "OUTPUT"
|
289
|
+
end
|
290
|
+
end
|
291
|
+
|
292
|
+
describe '#capture_stderr()' do
|
293
|
+
it "[!46tj4] same as `sout, serr = capture_stdio(); ok {sout} == ''`." do
|
294
|
+
sin = nil
|
295
|
+
serr = capture_stderr("INPUT", tty: true) do
|
296
|
+
sin = $stdin.read()
|
297
|
+
$stderr.puts "ERROR"
|
298
|
+
assert_eq $stdin.tty?, true
|
299
|
+
assert_eq $stdout.tty?, true
|
300
|
+
assert_eq $stderr.tty?, true
|
301
|
+
end
|
302
|
+
assert_eq sin, "INPUT"
|
303
|
+
assert_eq serr, "ERROR\n"
|
304
|
+
end
|
305
|
+
it "[!3zh32] fails when stdout is not empty." do
|
306
|
+
assert_exc(Oktest::AssertionFailed, "Output of $stdout expected to be empty, but got: \"OUTPUT\"") do
|
307
|
+
capture_stderr() do
|
308
|
+
print "OUTPUT"
|
309
|
+
end
|
310
|
+
end
|
311
|
+
end
|
312
|
+
it "[!5vs64] returns output of stderr." do
|
313
|
+
serr = capture_stderr() do
|
314
|
+
$stderr.print "ERROR"
|
315
|
+
end
|
316
|
+
assert_eq serr, "ERROR"
|
317
|
+
end
|
318
|
+
end
|
319
|
+
|
320
|
+
describe '#capture_command()' do
|
321
|
+
it "[!wyp17] executes command with stdin data." do
|
322
|
+
sout, serr = capture_command("cat -n", "AAA\nBBB\n")
|
323
|
+
assert_eq sout, " 1\tAAA\n 2\tBBB\n"
|
324
|
+
assert_eq serr, ""
|
325
|
+
end
|
326
|
+
it "[!jd63p] raises error if command failed." do
|
327
|
+
begin
|
328
|
+
capture_command("ls *not*exist*")
|
329
|
+
rescue => exc
|
330
|
+
assert_eq exc.class, RuntimeError
|
331
|
+
assert_eq exc.message, "Command failed with status (1): `ls *not*exist*`"
|
332
|
+
else
|
333
|
+
assert false, "Exception should be raised but not."
|
334
|
+
end
|
335
|
+
end
|
336
|
+
it "[!lsmgq] calls error handler block if command failed." do
|
337
|
+
called = nil
|
338
|
+
sout, serr = capture_command("ls *not*exist*") do |pstat|
|
339
|
+
called = pstat
|
340
|
+
end
|
341
|
+
assert called.is_a?(Process::Status)
|
342
|
+
assert called.exitstatus == 1
|
343
|
+
assert_eq sout, ""
|
344
|
+
assert_eq serr, "ls: *not*exist*: No such file or directory\n"
|
345
|
+
end
|
346
|
+
it "[!vivq3] doesn't call error handler block if command finished successfully." do
|
347
|
+
called = false
|
348
|
+
sout, serr = capture_command("cat -n", "AAA\nBBB\n") do
|
349
|
+
called = true
|
350
|
+
end
|
351
|
+
assert_eq called, false
|
352
|
+
assert_eq sout, " 1\tAAA\n 2\tBBB\n"
|
353
|
+
assert_eq serr, ""
|
354
|
+
end
|
355
|
+
it "[!nxw59] not raise error if command failed and error handler specified." do
|
356
|
+
begin
|
357
|
+
sout, serr = capture_command("ls *not*exist*") do end
|
358
|
+
rescue => exc
|
359
|
+
assert false, "Exception should not raised, but raised #{exc.inspect}"
|
360
|
+
end
|
361
|
+
assert_eq sout, ""
|
362
|
+
assert_eq serr, "ls: *not*exist*: No such file or directory\n"
|
363
|
+
end
|
364
|
+
it "[!h5994] returns output of stdin and stderr." do
|
365
|
+
sout, serr = capture_command("cat -n", "AAA\nBBB\n")
|
366
|
+
assert_eq sout, " 1\tAAA\n 2\tBBB\n"
|
367
|
+
assert_eq serr, ""
|
368
|
+
#
|
369
|
+
sout, serr = capture_command("echo ERR >&2")
|
370
|
+
assert_eq sout, ""
|
371
|
+
assert_eq serr, "ERR\n"
|
372
|
+
end
|
373
|
+
end
|
374
|
+
|
375
|
+
describe '#capture_command!()' do
|
376
|
+
it "[!vlbpo] executes command with stdin data." do
|
377
|
+
sout, serr = capture_command!("cat -n", "AAA\nBBB\n")
|
378
|
+
assert_eq sout, " 1\tAAA\n 2\tBBB\n"
|
379
|
+
assert_eq serr, ""
|
380
|
+
end
|
381
|
+
it "[!yfohb] not raise error even if command failed." do
|
382
|
+
sout, serr = capture_command!("ls *not*exist*")
|
383
|
+
assert_eq sout, ""
|
384
|
+
assert_eq serr, "ls: *not*exist*: No such file or directory\n"
|
385
|
+
end
|
386
|
+
it "[!andyj] calls error handler block if command failed." do
|
387
|
+
called = nil
|
388
|
+
sout, serr = capture_command!("ls *not*exist*") do |pstat|
|
389
|
+
called = pstat
|
390
|
+
end
|
391
|
+
assert called.is_a?(Process::Status)
|
392
|
+
assert called.exitstatus == 1
|
393
|
+
assert_eq sout, ""
|
394
|
+
assert_eq serr, "ls: *not*exist*: No such file or directory\n"
|
395
|
+
end
|
396
|
+
it "[!xnkqc] doesn't call error handler block if command finished successfully." do
|
397
|
+
called = false
|
398
|
+
sout, serr = capture_command!("cat -n", "AAA\nBBB\n") do
|
399
|
+
called = true
|
400
|
+
end
|
401
|
+
assert_eq called, false
|
402
|
+
assert_eq sout, " 1\tAAA\n 2\tBBB\n"
|
403
|
+
assert_eq serr, ""
|
404
|
+
end
|
405
|
+
it "[!3xdgo] returns output of stdin and stderr." do
|
406
|
+
sout, serr = capture_command!("cat -n", "AAA\nBBB\n")
|
407
|
+
assert_eq sout, " 1\tAAA\n 2\tBBB\n"
|
408
|
+
assert_eq serr, ""
|
409
|
+
#
|
410
|
+
sout, serr = capture_command!("echo ERR >&2")
|
411
|
+
assert_eq sout, ""
|
412
|
+
assert_eq serr, "ERR\n"
|
241
413
|
end
|
242
414
|
end
|
243
415
|
|
data/test/initialize.rb
CHANGED
data/test/mainapp_test.rb
CHANGED
@@ -1,5 +1,8 @@
|
|
1
|
+
# -*- coding: utf-8 -*-
|
2
|
+
# frozen_string_literal: true
|
3
|
+
|
1
4
|
###
|
2
|
-
### $Release: 1.
|
5
|
+
### $Release: 1.4.0 $
|
3
6
|
### $Copyright: copyright(c) 2011-2024 kuwata-lab.com all rights reserved $
|
4
7
|
### $License: MIT License $
|
5
8
|
###
|
@@ -108,37 +111,37 @@ END
|
|
108
111
|
it "[!d5mql] returns 1 when a certain error raised." do
|
109
112
|
ret, sout, serr = main(["-U"])
|
110
113
|
assert_eq ret, 1
|
111
|
-
assert_eq serr, "
|
114
|
+
assert_eq serr, "[ERROR] -U: Unknown option.\n"
|
112
115
|
end
|
113
116
|
|
114
117
|
it "[!jr49p] reports error when unknown option specified." do
|
115
118
|
ret, sout, serr = main(["-X"])
|
116
119
|
assert_eq ret, 1
|
117
|
-
assert_eq serr, "
|
120
|
+
assert_eq serr, "[ERROR] -X: Unknown option.\n"
|
118
121
|
#
|
119
122
|
ret, sout, serr = main(["--foobar"])
|
120
123
|
assert_eq ret, 1
|
121
|
-
assert_eq serr, "
|
124
|
+
assert_eq serr, "[ERROR] --foobar: Unknown long option.\n"
|
122
125
|
end
|
123
126
|
|
124
127
|
it "[!uqomj] reports error when required argument is missing." do
|
125
128
|
ret, sout, serr = main(["-s"])
|
126
129
|
assert_eq ret, 1
|
127
|
-
assert_eq serr, "
|
130
|
+
assert_eq serr, "[ERROR] -s: Argument required.\n"
|
128
131
|
end
|
129
132
|
|
130
133
|
it "[!8i755] reports error when argument is invalid." do
|
131
134
|
ret, sout, serr = main(["-s", "foobar"])
|
132
135
|
assert_eq ret, 1
|
133
|
-
assert_eq serr, "
|
136
|
+
assert_eq serr, "[ERROR] -s foobar: Expected one of verbose/simple/compact/plain/quiet/v/s/c/p/q.\n"
|
134
137
|
#
|
135
138
|
ret, sout, serr = main(["-F", "aaa=*pat*"])
|
136
139
|
assert_eq ret, 1
|
137
|
-
assert_eq serr, "
|
140
|
+
assert_eq serr, "[ERROR] -F aaa=*pat*: Pattern unmatched.\n"
|
138
141
|
#
|
139
|
-
ret, sout, serr = main(["--color=
|
142
|
+
ret, sout, serr = main(["--color=abc"])
|
140
143
|
assert_eq ret, 1
|
141
|
-
assert_eq serr, "
|
144
|
+
assert_eq serr, "[ERROR] --color=abc: Boolean expected.\n"
|
142
145
|
end
|
143
146
|
|
144
147
|
end
|
@@ -163,6 +166,13 @@ END
|
|
163
166
|
assert edit_actual(sout).end_with?(edit_expected(expected)), "invalid status line"
|
164
167
|
end
|
165
168
|
|
169
|
+
it "[!k402d] raises error if file not found." do
|
170
|
+
filename = "not-exist-file"
|
171
|
+
assert_exc(Benry::CmdOpt::OptionError, "#{filename}: not found.") do
|
172
|
+
run(filename)
|
173
|
+
end
|
174
|
+
end
|
175
|
+
|
166
176
|
it "[!bim36] changes auto-running to off." do
|
167
177
|
Oktest::Config.auto_run = true
|
168
178
|
_ = run(@testfile)
|
@@ -213,25 +223,38 @@ END
|
|
213
223
|
end
|
214
224
|
end
|
215
225
|
|
226
|
+
it "[!tt2gj] parses command options even after filenames." do
|
227
|
+
ret, sout, serr = run(@testfile, "--version")
|
228
|
+
assert_eq ret, 0
|
229
|
+
assert_eq sout, Oktest::VERSION+"\n"
|
230
|
+
assert_eq serr, ""
|
231
|
+
end
|
232
|
+
|
216
233
|
#HELP_MESSAGE = Oktest::MainApp::HELP_MESSAGE % {command: File.basename($0)}
|
217
|
-
HELP_MESSAGE = <<"END"
|
218
|
-
|
219
|
-
|
220
|
-
|
221
|
-
|
222
|
-
|
223
|
-
|
224
|
-
-
|
225
|
-
|
226
|
-
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
|
234
|
-
|
234
|
+
HELP_MESSAGE = (<<"END") % {command: File.basename($0)}
|
235
|
+
\e[1mOktest\e[0m (#{Oktest::VERSION}) -- New style testing library
|
236
|
+
|
237
|
+
\e[36mUsage:\e[0m
|
238
|
+
$ \e[1m%{command}\e[0m [<options>] [<file|directory>...]
|
239
|
+
|
240
|
+
\e[36mOptions:\e[0m
|
241
|
+
-h, --help : show help
|
242
|
+
--version : print version
|
243
|
+
-s <reporting-style> : verbose/simple/compact/plain/quiet, or v/s/c/p/q
|
244
|
+
-F <key>=<pattern> : filter topic or spec with pattern (see below)
|
245
|
+
--color[=<on|off>] : enable/disable output coloring forcedly
|
246
|
+
-S, --skeleton : print test code skeleton
|
247
|
+
-G, --generate[=<style>] : generate test code skeleton from ruby file
|
248
|
+
|
249
|
+
\e[36mFilter Examples:\e[0m
|
250
|
+
$ %{command} -F topic=Hello # filter by topic
|
251
|
+
$ %{command} -F spec='*hello*' # filter by spec
|
252
|
+
$ %{command} -F tag=name # filter by tag name
|
253
|
+
$ %{command} -F tag!=name # negative filter by tag name
|
254
|
+
$ %{command} -F tag='{name1,name2}' # filter by multiple tag names
|
255
|
+
|
256
|
+
\e[36mDocument:\e[0m
|
257
|
+
https://github.com/kwatch/oktest/blob/ruby/ruby/README.md
|
235
258
|
END
|
236
259
|
|
237
260
|
it "[!65vdx] prints help message if no arguments specified." do
|
@@ -256,8 +279,18 @@ END
|
|
256
279
|
assert_eq serr, ""
|
257
280
|
end
|
258
281
|
|
282
|
+
it "[!v938d] help message will be colored only when stdout is a tty." do
|
283
|
+
ret, sout, serr = run("-h", tty: true)
|
284
|
+
assert sout =~ /\e\[1mOktest\e\[0m/
|
285
|
+
assert sout =~ /\e\[36mOptions:\e\[0m/
|
286
|
+
#
|
287
|
+
ret, sout, serr = run("-h", tty: false)
|
288
|
+
assert sout !~ /\e\[1mOktest\e\[0m/
|
289
|
+
assert sout !~ /\e\[36mOptions:\e\[0m/
|
290
|
+
end
|
291
|
+
|
259
292
|
it "[!qqizl] '--version' option prints version number." do
|
260
|
-
expected = '$Release: 1.
|
293
|
+
expected = '$Release: 1.4.0 $'.split()[1] + "\n"
|
261
294
|
#
|
262
295
|
ret, sout, serr = run("--version")
|
263
296
|
assert_eq ret, 0
|
@@ -445,7 +478,7 @@ END
|
|
445
478
|
end
|
446
479
|
|
447
480
|
it "[!71h2x] '-F ...' option will be error." do
|
448
|
-
assert_exc(
|
481
|
+
assert_exc(Benry::CmdOpt::OptionError, "-F *pat*: Pattern unmatched.") do
|
449
482
|
run("-F", "*pat*", @testfile)
|
450
483
|
end
|
451
484
|
end
|
@@ -500,16 +533,10 @@ END
|
|
500
533
|
end
|
501
534
|
end
|
502
535
|
|
503
|
-
it "[!9nr94] '--color=true' option raises error." do
|
504
|
-
assert_exc(OptionParser::InvalidArgument, "invalid argument: --color=true") do
|
505
|
-
run("--color=true", @testfile)
|
506
|
-
end
|
507
|
-
end
|
508
|
-
|
509
536
|
it "[!dk8eg] '-S' or '--skeleton' option prints test code skeleton." do
|
510
537
|
ret, sout, serr = run("-S")
|
511
538
|
assert_eq ret, 0
|
512
|
-
assert_eq sout, Oktest::MainApp
|
539
|
+
assert_eq sout, Oktest::MainApp.new.__send__(:skeleton)
|
513
540
|
assert_eq serr, ""
|
514
541
|
end
|
515
542
|
|
@@ -547,7 +574,7 @@ Oktest.scope do
|
|
547
574
|
|
548
575
|
spec "returns greeting message."
|
549
576
|
|
550
|
-
end
|
577
|
+
end
|
551
578
|
|
552
579
|
|
553
580
|
end # Hello
|
@@ -592,7 +619,7 @@ Oktest.scope do
|
|
592
619
|
|
593
620
|
- spec("returns greeting message.")
|
594
621
|
|
595
|
-
end
|
622
|
+
end
|
596
623
|
|
597
624
|
|
598
625
|
end # Hello
|
@@ -602,7 +629,7 @@ end
|
|
602
629
|
END
|
603
630
|
#
|
604
631
|
begin
|
605
|
-
ret, sout, serr = run("-
|
632
|
+
ret, sout, serr = run("-Gunaryop", filename)
|
606
633
|
assert_eq ret, 0
|
607
634
|
assert_eq sout, expected
|
608
635
|
assert_eq serr, ""
|
@@ -675,4 +702,23 @@ END
|
|
675
702
|
|
676
703
|
end
|
677
704
|
|
705
|
+
describe '#skeleton()' do
|
706
|
+
it "[!s2i1p] returns skeleton string of test script." do
|
707
|
+
str = Oktest::MainApp.new.__send__(:skeleton)
|
708
|
+
assert str =~ /^require 'oktest'$/
|
709
|
+
assert str =~ /^Oktest\.scope do$/
|
710
|
+
end
|
711
|
+
it "[!opvik] skeleton string is valid ruby code." do
|
712
|
+
str = Oktest::MainApp.new.__send__(:skeleton)
|
713
|
+
filename = "tmp.skeleten.rb"
|
714
|
+
File.write(filename, str, encoding: 'utf-8')
|
715
|
+
begin
|
716
|
+
result = `ruby -wc #{filename}`
|
717
|
+
assert_eq result, "Syntax OK\n"
|
718
|
+
ensure
|
719
|
+
File.unlink filename
|
720
|
+
end
|
721
|
+
end
|
722
|
+
end
|
723
|
+
|
678
724
|
end
|
data/test/matcher_test.rb
CHANGED
data/test/misc_test.rb
CHANGED
data/test/node_test.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
4
|
###
|
4
|
-
### $Release: 1.
|
5
|
+
### $Release: 1.4.0 $
|
5
6
|
### $Copyright: copyright(c) 2011-2024 kuwata-lab.com all rights reserved $
|
6
7
|
### $License: MIT License $
|
7
8
|
###
|
@@ -496,6 +497,21 @@ class Context_TC < TC
|
|
496
497
|
to = node.each_child.first
|
497
498
|
assert_eq to.target, "When condition..."
|
498
499
|
end
|
500
|
+
it "[!53qxv] not add 'When ' if description starts with it." do
|
501
|
+
node = new_node_with() do
|
502
|
+
case_when "when condition..." do
|
503
|
+
end
|
504
|
+
end
|
505
|
+
to = node.each_child.first
|
506
|
+
assert_eq to.target, "when condition..."
|
507
|
+
#
|
508
|
+
node = new_node_with() do
|
509
|
+
case_when "[""!abc] when..." do
|
510
|
+
end
|
511
|
+
end
|
512
|
+
to = node.each_child.first
|
513
|
+
assert_eq to.target, "[""!abc] when..."
|
514
|
+
end
|
499
515
|
end
|
500
516
|
|
501
517
|
describe '#case_else()' do
|
@@ -521,6 +537,25 @@ class Context_TC < TC
|
|
521
537
|
assert_eq to.class, Oktest::TopicNode
|
522
538
|
assert_eq to.target, "Else"
|
523
539
|
end
|
540
|
+
it "[!3nn8d] not add 'Else ' if description starts with it." do
|
541
|
+
node = new_node_with() do
|
542
|
+
case_else "else (x < 0)" do
|
543
|
+
end
|
544
|
+
end
|
545
|
+
assert_eq node.each_child.to_a.length, 1
|
546
|
+
to = node.each_child.first
|
547
|
+
assert_eq to.class, Oktest::TopicNode
|
548
|
+
assert_eq to.target, "else (x < 0)"
|
549
|
+
#
|
550
|
+
node = new_node_with() do
|
551
|
+
case_else "[""!abc] else..." do
|
552
|
+
end
|
553
|
+
end
|
554
|
+
assert_eq node.each_child.to_a.length, 1
|
555
|
+
to = node.each_child.first
|
556
|
+
assert_eq to.class, Oktest::TopicNode
|
557
|
+
assert_eq to.target, "[""!abc] else..."
|
558
|
+
end
|
524
559
|
it "[!hs1to] 1st parameter is optional." do
|
525
560
|
node = new_node_with() do
|
526
561
|
case_else "(x < 0)" do
|
data/test/reporter_test.rb
CHANGED
data/test/run_all.rb
CHANGED
data/test/runner_test.rb
CHANGED
data/test/tc.rb
CHANGED
data/test/util_test.rb
CHANGED
@@ -1,7 +1,8 @@
|
|
1
1
|
# -*- coding: utf-8 -*-
|
2
|
+
# frozen_string_literal: true
|
2
3
|
|
3
4
|
###
|
4
|
-
### $Release: 1.
|
5
|
+
### $Release: 1.4.0 $
|
5
6
|
### $Copyright: copyright(c) 2011-2024 kuwata-lab.com all rights reserved $
|
6
7
|
### $License: MIT License $
|
7
8
|
###
|
@@ -32,7 +33,7 @@ END
|
|
32
33
|
assert c.is_a?(Array), "array object expected."
|
33
34
|
assert_eq c[0], __FILE__
|
34
35
|
assert_eq c[1][0], "# -*- coding: utf-8 -*-\n"
|
35
|
-
assert_eq c[1][
|
36
|
+
assert_eq c[1][12], "class Util_TC < TC\n"
|
36
37
|
#
|
37
38
|
data1 = c[1]
|
38
39
|
_ = Oktest::Util.file_line(__FILE__, 1)
|
data/test/utilhelper_test.rb
CHANGED
data/test/visitor_test.rb
CHANGED
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oktest
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- kwatch
|
8
|
-
autorequire:
|
8
|
+
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2024-
|
11
|
+
date: 2024-10-04 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: diff-lcs
|
@@ -24,6 +24,20 @@ dependencies:
|
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
26
|
version: '1.0'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: benry-cmdopt
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: '2.3'
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: '2.3'
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: benry-recorder
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -83,7 +97,7 @@ homepage: https://github.com/kwatch/oktest/tree/ruby/ruby
|
|
83
97
|
licenses:
|
84
98
|
- MIT
|
85
99
|
metadata: {}
|
86
|
-
post_install_message:
|
100
|
+
post_install_message:
|
87
101
|
rdoc_options: []
|
88
102
|
require_paths:
|
89
103
|
- lib
|
@@ -98,8 +112,8 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
98
112
|
- !ruby/object:Gem::Version
|
99
113
|
version: '0'
|
100
114
|
requirements: []
|
101
|
-
rubygems_version: 3.
|
102
|
-
signing_key:
|
115
|
+
rubygems_version: 3.0.3.1
|
116
|
+
signing_key:
|
103
117
|
specification_version: 4
|
104
118
|
summary: a new style testing library
|
105
119
|
test_files:
|