-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathlog_examples.rb
1040 lines (807 loc) · 28.5 KB
/
log_examples.rb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
require 'set'
require_relative '../../test/common_requires'
require_relative '../../lib/helpers/test_helper'
# Class to show how to use the Log object.
# noinspection RubyTooManyMethodsInspection
class LogExamples < MiniTest::Test
# This is just a caller for the other, specific, example methods.
def test_log_examples
open_examples
@log_dir_path = TestHelper.create_app_log_dir('log')
def self.open_log(method)
file_name = format('%s.xml', method)
file_path = File.join(
@log_dir_path,
file_name,
)
Log.open(self, :file_path => file_path) do |log|
yield log
end
end
section_examples
put_element_examples
verdict_assert_examples
verdict_assert_empty_examples
verdict_assert_equal_examples
verdict_assert_in_delta_examples
verdict_assert_in_epsilon_examples
verdict_assert_includes_examples
verdict_assert_instance_of_examples
verdict_assert_kind_of_examples
verdict_assert_match_examples
verdict_assert_nil_examples
verdict_assert_operator_examples
verdict_assert_output_examples
verdict_assert_predicate_examples
verdict_assert_raises_examples
verdict_assert_respond_to_examples
verdict_assert_same_examples
verdict_assert_silent_examples
verdict_assert_throws_examples
verdict_refute_examples
verdict_refute_empty_examples
verdict_refute_equal_examples
verdict_refute_in_delta_examples
verdict_refute_in_epsilon_examples
verdict_refute_includes_examples
verdict_refute_instance_of_examples
verdict_refute_kind_of_examples
verdict_refute_match_examples
verdict_refute_nil_examples
verdict_refute_operator_examples
verdict_refute_predicate_examples
verdict_refute_respond_to_examples
verdict_refute_same_examples
puts 'The example logs may be seen at %s.' % File.absolute_path(@log_dir_path)
end
# <em>In the Rdoc, click the method name to toggle source.</em>
#
# Here we show method +Log.open+.
#
# The first argument must be an instance of Minitest::Test.
# The second argument is optional, and may specify options, as shown here.
#
# We've used a temporary directory for this because there's little need to see the created log.
def open_examples
dir_path = Dir.mktmpdir
file_path = File.join(dir_path, 'log.xml')
options = {
:file_path => file_path, # defaults to ''./log.xml'
:root_name => 'my_log', # defaults to 'log'
:xml_indentation => 2, # defaults to -1 (all on one line)
}
Log.open(self, options) do |_|
end
File.delete(file_path)
Dir.delete(File.dirname(file_path))
end
# <em>In the Rdoc, click the method name to toggle source.</em>
#
# Here we show method +section+:
#
# - With nested sections.
# - With +:timestamp+, +:duration+, and +:rescue+.
# - With custom attributes.
#
# You can also pass other objects in *+args+,
# and they will be rendered into the PCDATA for the section element.
def section_examples
self.open_log(__method__) do |log|
log.section('Section examples') do
# Nested sections.
log.section('Outer section') do
log.section('Inner section') do
# More logging can go here.
end
end
log.section('With timestamp', :timestamp) do
# More logging can go here.
end
log.section('With duration', :duration) do
sleep(1.5)
end
log.section('With rescue', :rescue) do
raise RuntimeError.new('Boo!')
end
log.section('With custom attributes', {:attr_name_0 => 'attr_value_0', :attr_name_1 => 'attr_value_1'}) do
# More logging can go here.
end
end
end
end
# <em>In the Rdoc, click the method name to toggle source.</em>
#
# Here we show method +put_element+:
#
# - With string arguments.
# - With other arguments.
# - With mixture of arguments.
#
# You can also pass +:duration+, +:timestamp+, and +:rescue+ to put_element,
# but that will usually not make much sense.
def put_element_examples
self.open_log(__method__) do |log|
log.section('Put element examples') do
log.section('Put element with strings, which are appended to PCDATA') do
log.put_element('strings', 'First string.', 'Second string.')
end
log.section('Put element with objects, whose .inspect values are appended to PCDATA') do
log.put_element('objects', Set.new([:a, :b]), Float(3.14159))
end
log.section('Put element with mix of arguments') do
log.put_element('mixture', 'First string.', Set.new([:a, :b]), 'Second string', Float(3.14159))
end
end
end
end
# <em>In the Rdoc, click the method name to toggle source.</em>
#
# Here we show:
#
# - Method verdict_assert? passing, failing, and with volatile: true.
# - Alias va? passing, failing, and with volatile: true.
def verdict_assert_examples
self.open_log(__method__) do |log|
log.section('Use verdict_assert?') do
log.verdict_assert?(:passing_verdict_assert, actual = true)
log.verdict_assert?(:failing_verdict_assert, actual = false)
log.verdict_assert?(:volatile_verdict_assert, actual = true, volatile: true)
end
log.section('Use alias va?') do
log.va?(:passing_va, actual = true)
log.va?(:failing_va, actual = false)
log.va?(:volatile_va, actual = true)
end
end
end
# <em>In the Rdoc, click the method name to toggle source.</em>
#
# Here we show:
#
# - Method verdict_assert_empty? passing and failing
# - Alias va_empty? passing and failing.
def verdict_assert_empty_examples
self.open_log(__method__) do |log|
log.section('Use verdict_assert_empty?') do
log.verdict_assert_empty?(:passing_verdict_assert_empty, actual = [])
log.verdict_assert_empty?(:failing_verdict_assert_empty, actual = [:a])
end
log.section('Use alias va_empty?') do
log.va_empty?(:passing_va_empty, actual = [])
log.va_empty?(:failing_va_empty, actual = [:a])
end
end
end
# <em>In the Rdoc, click the method name to toggle source.</em>
#
# Here we show:
#
# - Method verdict_assert_equal? passing and failing.
# - Method verdict_assert_equal? with sets and hashes.
#
# - Alias va_equal? passing and failing.
# - Alias va_equal? with sets and hashes.
#
# Failure for a set or hash puts detailed analysis into the log.
def verdict_assert_equal_examples
self.open_log(__method__) do |log|
# Differing sets are analyzed in the log: ok, missing, unexpected.
expected_set = Set.new([:a, :b, :c, :d])
actual_set = Set.new([:a, :b, :e, :f])
# Differing hashes are analyzed in the log: ok, missing, unexpected, changed.
expected_hash = {
:a => 0,
:b => 1,
:c => 2,
:d => 3,
:e => 4,
:f => 5,
}
actual_hash = {
:a => 0,
:b => 1,
:c => 3,
:d => 2,
:g => 6,
:h => 7,
}
log.section('Use verdict_assert_equal?') do
log.verdict_assert_equal?(:passing_verdict_assert_equal, 0, 0)
log.verdict_assert_equal?(:failing_verdict_assert_equal, 0, 1)
log.verdict_assert_equal?(:verdict_assert_equal_set, expected_set, actual_set)
log.verdict_assert_equal?(:verdict_assert_equal_hash, expected_hash, actual_hash)
end
log.section('Use va_equal?') do
log.va_equal?(:passing_va_equal, 0, 0)
log.va_equal?(:failing_va_equal, 0, 1)
log.va_equal?(:va_equal_set, expected_set, actual_set)
log.va_equal?(:va_equal_hash, expected_hash, actual_hash)
end
end
end
# <em>In the Rdoc, click the method name to toggle source.</em>
#
# Here we show:
#
# - Method verdict_assert_in_delta? passing and failing.
# - Alias va_in_delta? passing and failing.
def verdict_assert_in_delta_examples
self.open_log(__method__) do |log|
log.section('Use verdict_assert_in_delta?') do
log.verdict_assert_in_delta?(:passing_verdict_assert_in_delta, 1, 1.1, 0.2)
log.verdict_assert_in_delta?(:failing_verdict_assert_in_delta, 1, 1.2, 0.1)
end
log.section('Use va_in_delta?') do
log.va_in_delta?(:passing_va_in_delta, 1, 1.1, 0.2)
log.va_in_delta?(:failing_va_in_delta, 1, 1.2, 0.1)
end
end
end
# <em>In the Rdoc, click the method name to toggle source.</em>
#
# Here we show:
#
# - Method verdict_assert_in_epsilon? passing and failing.
# - Alias va_in_epsilon? passing and failing.
def verdict_assert_in_epsilon_examples
self.open_log(__method__) do |log|
log.section('Use verdict_assert_in_epsilon?') do
log.verdict_assert_in_epsilon?(:passing_verdict_assert_in_epsilon, 1, 1.1, 0.2)
log.verdict_assert_in_epsilon?(:failing_verdict_assert_in_epsilon, 1, 1.2, 0.1)
end
log.section('Use va_in_epsilon?') do
log.va_in_epsilon?(:passing_va_in_epsilon, 1, 1.1, 0.2)
log.va_in_epsilon?(:failing_va_in_epsilon, 1, 1.2, 0.1)
end
end
end
# <em>In the Rdoc, click the method name to toggle source.</em>
#
# Here we show:
#
# - Method verdict_assert_includes? passing and failing.
#
# - Alias va_includes? passing and failing.
#
def verdict_assert_includes_examples
self.open_log(__method__) do |log|
log.section('Use verdict_assert_includes?') do
log.verdict_assert_includes?(:passing_verdict_assert_includes, [:a], :a)
log.verdict_assert_includes?(:failing_verdict_assert_includes, [:b], :a)
end
log.section('Use va_includes?') do
log.va_includes?(:passing_va_includes, [:a], :a)
log.va_includes?(:failing_va_includes, [:b], :a)
end
end
end
# <em>In the Rdoc, click the method name to toggle source.</em>
#
# Here we show:
#
# - Method verdict_assert_instance_of? passing and failing.
#
# - Alias va_instance_of? passing and failing.
#
def verdict_assert_instance_of_examples
self.open_log(__method__) do |log|
log.section('Use verdict_assert_instance_of?') do
log.verdict_assert_instance_of?(:passing_verdict_assert_instance_of, String, 'Boo!')
log.verdict_assert_instance_of?(:failing_verdict_assert_instance_of, String, 0)
end
log.section('Use va_instance_of?') do
log.va_instance_of?(:passing_va_instance_of, String, 'Boo!')
log.va_instance_of?(:failing_va_instance_of, String, 0)
end
end
end
# <em>In the Rdoc, click the method name to toggle source.</em>
#
# Here we show:
#
# - Method verdict_assert_kind_of? passing and failing.
#
# - Alias va_kind_of? passing and failing.
#
def verdict_assert_kind_of_examples
self.open_log(__method__) do |log|
log.section('Use verdict_assert_kind_of?') do
log.verdict_assert_kind_of?(:passing_verdict_assert_kind_of, StandardError, RuntimeError.new)
log.verdict_assert_kind_of?(:failing_verdict_assert_kind_of, StandardError, 0)
end
log.section('Use va_kind_of?') do
log.va_kind_of?(:passing_va_kind_of, StandardError, RuntimeError.new)
log.va_kind_of?(:failing_va_kind_of, StandardError, 0)
end
end
end
# <em>In the Rdoc, click the method name to toggle source.</em>
#
# Here we show:
#
# - Method verdict_assert_match? passing and failing.
#
# - Alias va_match? passing and failing.
#
def verdict_assert_match_examples
self.open_log(__method__) do |log|
log.section('Use verdict_assert_match?') do
log.verdict_assert_match?(:passing_verdict_assert_match, /foo/, 'food')
log.verdict_assert_match?(:failing_verdict_assert_match, /foo/, 'good')
end
log.section('Use va_match?') do
log.va_match?(:passing_va_match, /foo/, 'food')
log.va_match?(:failing_va_match, /foo/, 'good')
end
end
end
# <em>In the Rdoc, click the method name to toggle source.</em>
#
# Here we show:
#
# - Method verdict_assert_nil? passing and failing
# - Alias va_nil? passing and failing.
def verdict_assert_nil_examples
self.open_log(__method__) do |log|
log.section('Use verdict_assert_nil?') do
log.verdict_assert_nil?(:passing_verdict_assert_nil, actual = nil)
log.verdict_assert_nil?(:failing_verdict_assert_nil, actual = false)
end
log.section('Use alias va_nil?') do
log.va_nil?(:passing_va_nil, actual = nil)
log.va_nil?(:failing_va_nil, actual = false)
end
end
end
# <em>In the Rdoc, click the method name to toggle source.</em>
#
# Here we show:
#
# - Method verdict_assert_operator? passing and failing.
# - Alias va_operator? passing and failing.
def verdict_assert_operator_examples
self.open_log(__method__) do |log|
log.section('Use verdict_assert_operator?') do
log.verdict_assert_operator?(:passing_verdict_assert_operator, 1, :<, 2)
log.verdict_assert_operator?(:failing_verdict_assert_operator, 2, :<, 1)
end
log.section('Use va_operator?') do
log.va_operator?(:passing_va_operator, 1, :<, 2)
log.va_operator?(:failing_va_operator, 2, :<, 1)
end
end
end
# <em>In the Rdoc, click the method name to toggle source.</em>
#
# Here we show:
#
# - Method verdict_assert_output? passing and failing.
# - Alias va_output? passing and failing.
def verdict_assert_output_examples
self.open_log(__method__) do |log|
log.section('Use verdict_assert_output?') do
log.verdict_assert_output?(:passing_verdict_assert_output, 'stdout', 'stderr') do
$stdout.print('stdout')
$stderr.print('stderr')
end
log.verdict_assert_output?(:failing_verdict_assert_output, 'stdout', 'stderr') do
$stdout.print('not stdout')
$stderr.print('not stderr')
end
end
log.section('Use va_output?') do
log.va_output?(:passing_va_output, 'stdout', 'stderr') do
$stdout.print('stdout')
$stderr.print('stderr')
end
log.va_output?(:failing_va_output, 'stdout', 'stderr') do
$stdout.print('not stdout')
$stderr.print('not stderr')
end
end
end
end
# <em>In the Rdoc, click the method name to toggle source.</em>
#
# Here we show:
#
# - Method verdict_assert_predicate? passing and failing
# - Alias va_predicate? passing and failing.
def verdict_assert_predicate_examples
self.open_log(__method__) do |log|
log.section('Use verdict_assert_predicate?') do
log.verdict_assert_predicate?(:passing_verdict_assert_predicate, '', :empty?)
log.verdict_assert_predicate?(:failing_verdict_assert_predicate, 'a', :empty?)
end
log.section('Use alias va_predicate?') do
log.va_predicate?(:passing_va_predicate, '', :empty?)
log.va_predicate?(:failing_va_predicate, 'a', :empty?)
end
end
end
# <em>In the Rdoc, click the method name to toggle source.</em>
#
# Here we show:
#
# - Method verdict_assert_raises? passing and failing.
# - Alias va_raises? passing and failing.
def verdict_assert_raises_examples
self.open_log(__method__) do |log|
log.section('Use verdict_assert_raises?') do
log.verdict_assert_raises?(:passing_verdict_assert_raises, RuntimeError) do
raise RuntimeError.new('Boo!')
end
log.verdict_assert_raises?(:failing_verdict_assert_raises, RuntimeError) do
# Nothing.
end
end
log.section('Use va_raises?') do
log.va_raises?(:passing_va_raises, RuntimeError) do
raise RuntimeError.new('Boo!')
end
log.va_raises?(:failing_va_raises, RuntimeError) do
# Nothing.
end
end
end
end
# <em>In the Rdoc, click the method name to toggle source.</em>
#
# Here we show:
#
# - Method verdict_assert_respond_to? passing and failing
# - Alias va_respond_to? passing and failing.
def verdict_assert_respond_to_examples
self.open_log(__method__) do |log|
log.section('Use verdict_assert_respond_to?') do
log.verdict_assert_respond_to?(:passing_verdict_assert_respond_to, 'foo', :empty?)
log.verdict_assert_respond_to?(:failing_verdict_assert_respond_to, 0, :empty?)
end
log.section('Use alias va_respond_to?') do
log.va_respond_to?(:passing_va_respond_to, 'foo', :empty?)
log.va_respond_to?(:failing_va_respond_to, 0, :empty?)
end
end
end
# <em>In the Rdoc, click the method name to toggle source.</em>
#
# Here we show:
#
# - Method verdict_assert_same? passing and failing.
#
# - Alias va_same? passing and failing.
#
def verdict_assert_same_examples
self.open_log(__method__) do |log|
object = Object.new
different_object = Object.new
log.section('Use verdict_assert_same?') do
log.verdict_assert_same?(:passing_verdict_assert_same, object, object)
log.verdict_assert_same?(:failing_verdict_assert_same, object, different_object)
end
log.section('Use va_same?') do
log.va_same?(:passing_va_same, object, object)
log.va_same?(:failing_va_same, object, different_object)
end
end
end
# <em>In the Rdoc, click the method name to toggle source.</em>
#
# Here we show:
#
# - Method verdict_assert_silent? passing and failing.
# - Alias va_silent? passing and failing.
def verdict_assert_silent_examples
self.open_log(__method__) do |log|
log.section('Use verdict_assert_silent?') do
log.verdict_assert_silent?(:passing_verdict_assert_silent) do
# Remain silent.
end
log.verdict_assert_silent?(:failing_verdict_assert_silent) do
$stdout.print('Boo!')
end
end
log.section('Use va_silent?') do
log.va_silent?(:passing_va_silent) do
# Remain silent.
end
log.va_silent?(:failing_va_silent) do
$stdout.print('Boo!')
end
end
end
end
# <em>In the Rdoc, click the method name to toggle source.</em>
#
# Here we show:
#
# - Method verdict_assert_throws? passing and failing.
# - Alias va_throws? passing and failing.
def verdict_assert_throws_examples
self.open_log(__method__) do |log|
log.section('Use verdict_assert_throws?') do
log.verdict_assert_throws?(:passing_verdict_assert_throws, Exception) do
throw Exception
end
log.verdict_assert_throws?(:failing_verdict_assert_throws, Exception) do
# Nothing.
end
end
log.section('Use va_throws?') do
log.va_throws?(:passing_va_throws, Exception) do
throw Exception
end
log.va_throws?(:failing_va_throws, Exception) do
# Nothing.
end
end
end
end
# <em>In the Rdoc, click the method name to toggle source.</em>
#
# Here we show:
#
# - Method verdict_refute? passing, failing, and with volatile: true.
# - Alias vr? passing, failing, and with volatile: true.
def verdict_refute_examples
self.open_log(__method__) do |log|
log.section('Use verdict_refute?') do
log.verdict_refute?(:passing_verdict_refute, actual = true)
log.verdict_refute?(:failing_verdict_refute, actual = false)
log.verdict_refute?(:volatile_verdict_refute, actual = true, volatile: true)
end
log.section('Use alias vr?') do
log.vr?(:passing_vr, actual = true, message: 'Passing vr?')
log.vr?(:failing_vr, actual = false, message: 'Failing vr?')
log.vr?(:volatile_vr, actual = true, message: 'Volatile vr?', volatile: true)
end
end
end
# <em>In the Rdoc, click the method name to toggle source.</em>
#
# Here we show:
#
# - Method verdict_refute_empty? passing and failing
# - Alias vr_empty? passing and failing.
def verdict_refute_empty_examples
self.open_log(__method__) do |log|
log.section('Use verdict_refute_empty?') do
log.verdict_refute_empty?(:passing_verdict_refute_empty, actual = [:a])
log.verdict_refute_empty?(:failing_verdict_refute_empty, actual = [])
end
log.section('Use alias vr_empty?') do
log.vr_empty?(:passing_vr_empty, actual = [:a])
log.vr_empty?(:failing_vr_empty, actual = [])
end
end
end
# <em>In the Rdoc, click the method name to toggle source.</em>
#
# Here we show:
#
# - Method verdict_refute_equal? passing and failing.
#
# - Alias vr_equal? passing and failing.
def verdict_refute_equal_examples
self.open_log(__method__) do |log|
log.section('Use verdict_refute_equal?') do
log.verdict_refute_equal?(:passing_verdict_refute_equal, 0, 1)
log.verdict_refute_equal?(:failing_verdict_refute_equal, 0, 0)
end
log.section('Use vr_equal?') do
log.vr_equal?(:passing_vr_equal, 0, 1)
log.vr_equal?(:failing_vr_equal, 0, 0)
end
end
end
# <em>In the Rdoc, click the method name to toggle source.</em>
#
# Here we show:
#
# - Method verdict_refute_in_delta? passing and failing.
# - Alias vr_in_delta? passing and failing.
def verdict_refute_in_delta_examples
self.open_log(__method__) do |log|
log.section('Use verdict_refute_in_delta?') do
log.verdict_refute_in_delta?(:passing_verdict_refute_in_delta, 1, 1.1, 0.2)
log.verdict_refute_in_delta?(:failing_verdict_refute_in_delta, 1, 1.2, 0.1)
end
log.section('Use vr_in_delta?') do
log.vr_in_delta?(:passing_vr_in_delta, 1, 1.2, 0.1)
log.vr_in_delta?(:failing_vr_in_delta, 1, 1.1, 0.2)
end
end
end
# <em>In the Rdoc, click the method name to toggle source.</em>
#
# Here we show:
#
# - Method verdict_refute_in_epsilon? passing and failing.
# - Alias vr_in_epsilon? passing and failing.
def verdict_refute_in_epsilon_examples
self.open_log(__method__) do |log|
log.section('Use verdict_refute_in_epsilon?') do
log.verdict_refute_in_epsilon?(:passing_verdict_refute_in_epsilon, 1, 1.2, 0.1)
log.verdict_refute_in_epsilon?(:failing_verdict_refute_in_epsilon, 1, 1.1, 0.2)
end
log.section('Use vr_in_epsilon?') do
log.vr_in_epsilon?(:passing_vr_in_epsilon, 1, 1.2, 0.1)
log.vr_in_epsilon?(:failing_vr_in_epsilon, 1, 1.1, 0.2)
end
end
end
# <em>In the Rdoc, click the method name to toggle source.</em>
#
# Here we show:
#
# - Method verdict_refute_includes? passing and failing.
#
# - Alias vr_includes? passing and failing.
#
def verdict_refute_includes_examples
self.open_log(__method__) do |log|
log.section('Use verdict_refute_includes?') do
log.verdict_refute_includes?(:passing_verdict_refute_includes, [:b], :a)
log.verdict_refute_includes?(:failing_verdict_refute_includes, [:a], :a)
end
log.section('Use vr_includes?') do
log.vr_includes?(:passing_vr_includes, [:b], :a)
log.vr_includes?(:failing_vr_includes, [:a], :a)
end
end
end
# <em>In the Rdoc, click the method name to toggle source.</em>
#
# Here we show:
#
# - Method verdict_refute_instance_of? passing and failing.
#
# - Alias vr_instance_of? passing and failing.
#
def verdict_refute_instance_of_examples
self.open_log(__method__) do |log|
log.section('Use verdict_refute_instance_of?') do
log.verdict_refute_instance_of?(:passing_verdict_refute_instance_of, String, 0)
log.verdict_refute_instance_of?(:failing_verdict_refute_instance_of, String, 'Boo!')
end
log.section('Use vr_instance_of?') do
log.vr_instance_of?(:passing_vr_instance_of, String, 0)
log.vr_instance_of?(:failing_vr_instance_of, String, 'Boo!')
end
end
end
# <em>In the Rdoc, click the method name to toggle source.</em>
#
# Here we show:
#
# - Method verdict_refute_kind_of? passing and failing.
#
# - Alias vr_kind_of? passing and failing.
#
def verdict_refute_kind_of_examples
self.open_log(__method__) do |log|
log.section('Use verdict_refute_kind_of?') do
log.verdict_refute_kind_of?(:passing_verdict_refute_kind_of, StandardError, 0)
log.verdict_refute_kind_of?(:failing_verdict_refute_kind_of, StandardError, RuntimeError.new)
end
log.section('Use vr_kind_of?') do
log.vr_kind_of?(:passing_vr_kind_of, StandardError, 0)
log.vr_kind_of?(:failing_vr_kind_of, StandardError, RuntimeError.new)
end
end
end
# <em>In the Rdoc, click the method name to toggle source.</em>
#
# Here we show:
#
# - Method verdict_refute_match? passing and failing.
#
# - Alias vr_match? passing and failing.
#
def verdict_refute_match_examples
self.open_log(__method__) do |log|
log.section('Use verdict_refute_match?') do
log.verdict_refute_match?(:passing_verdict_refute_match, /foo/, 'good',)
log.verdict_refute_match?(:failing_verdict_refute_match, /foo/, 'food')
end
log.section('Use vr_match?') do
log.vr_match?(:passing_vr_match, /foo/, 'good')
log.vr_match?(:failing_vr_match, /foo/, 'food')
end
end
end
# <em>In the Rdoc, click the method name to toggle source.</em>
#
# Here we show:
#
# - Method verdict_refute_nil? passing and failing
# - Alias vr_nil? passing and failing.
def verdict_refute_nil_examples
self.open_log(__method__) do |log|
log.section('Use verdict_refute_nil?') do
log.verdict_refute_nil?(:passing_verdict_refute_nil, actual = false)
log.verdict_refute_nil?(:failing_verdict_refute_nil, actual = nil)
end
log.section('Use alias vr_nil?') do
log.vr_nil?(:passing_vr_nil, actual = false)
log.vr_nil?(:failing_vr_nil, actual = nil)
end
end
end
# <em>In the Rdoc, click the method name to toggle source.</em>
#
# Here we show:
#
# - Method verdict_refute_operator? passing and failing.
# - Alias vr_operator? passing and failing.
def verdict_refute_operator_examples
self.open_log(__method__) do |log|
log.section('Use verdict_refute_operator?') do
log.verdict_refute_operator?(:passing_verdict_refute_operator, 1, :>, 2)
log.verdict_refute_operator?(:failing_verdict_refute_operator, 2, :>, 1)
end
log.section('Use vr_operator?') do
log.vr_operator?(:passing_vr_operator, 1, :>, 2)
log.vr_operator?(:failing_vr_operator, 2, :>, 1)
end
end
end
# <em>In the Rdoc, click the method name to toggle source.</em>
#
# Here we show:
#
# - Method verdict_refute_predicate? passing and failing
# - Alias vr_predicate? passing and failing.
def verdict_refute_predicate_examples
self.open_log(__method__) do |log|
log.section('Use verdict_refute_predicate?') do
log.verdict_refute_predicate?(:passing_verdict_refute_predicate, 'a', :empty?)
log.verdict_refute_predicate?(:failing_verdict_refute_predicate, '', :empty?,)
end
log.section('Use alias vr_predicate?') do
log.vr_predicate?(:passing_vr_predicate, 'a', :empty?)
log.vr_predicate?(:failing_vr_predicate, '', :empty?)
end
end
end
# <em>In the Rdoc, click the method name to toggle source.</em>
#
# Here we show:
#
# - Method verdict_refute_respond_to? passing and failing
# - Alias vr_respond_to? passing and failing.
def verdict_refute_respond_to_examples
self.open_log(__method__) do |log|
log.section('Use verdict_refute_respond_to?') do
log.verdict_refute_respond_to?(:passing_verdict_refute_respond_to, 0, :empty?,)
log.verdict_refute_respond_to?(:failing_verdict_refute_respond_to, 'foo', :empty?)
end