minitest 5.12.0 → 5.22.2
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
- checksums.yaml.gz.sig +0 -0
- data/History.rdoc +262 -5
- data/Manifest.txt +3 -0
- data/README.rdoc +90 -17
- data/Rakefile +5 -16
- data/lib/hoe/minitest.rb +0 -4
- data/lib/minitest/assertions.rb +171 -37
- data/lib/minitest/benchmark.rb +7 -7
- data/lib/minitest/compress.rb +94 -0
- data/lib/minitest/expectations.rb +72 -35
- data/lib/minitest/mock.rb +123 -34
- data/lib/minitest/pride_plugin.rb +1 -1
- data/lib/minitest/spec.rb +24 -10
- data/lib/minitest/test.rb +44 -16
- data/lib/minitest/test_task.rb +301 -0
- data/lib/minitest/unit.rb +5 -8
- data/lib/minitest.rb +245 -70
- data/test/minitest/metametameta.rb +45 -11
- data/test/minitest/test_minitest_assertions.rb +357 -29
- data/test/minitest/test_minitest_benchmark.rb +2 -2
- data/test/minitest/test_minitest_mock.rb +287 -15
- data/test/minitest/test_minitest_reporter.rb +158 -17
- data/test/minitest/test_minitest_spec.rb +184 -59
- data/test/minitest/test_minitest_test.rb +362 -42
- data/test/minitest/test_minitest_test_task.rb +46 -0
- data.tar.gz.sig +2 -2
- metadata +28 -19
- metadata.gz.sig +0 -0
@@ -28,6 +28,9 @@ class TestMinitestAssertions < Minitest::Test
|
|
28
28
|
|
29
29
|
RUBY18 = !defined? Encoding
|
30
30
|
|
31
|
+
# not included in JRuby
|
32
|
+
RE_LEVELS = /\(\d+ levels\) /
|
33
|
+
|
31
34
|
class DummyTest
|
32
35
|
include Minitest::Assertions
|
33
36
|
# include Minitest::Reportable # TODO: why do I really need this?
|
@@ -77,6 +80,14 @@ class TestMinitestAssertions < Minitest::Test
|
|
77
80
|
self.send assert_msg, expected, msg
|
78
81
|
end
|
79
82
|
|
83
|
+
def assert_unexpected expected
|
84
|
+
expected = Regexp.new expected if String === expected
|
85
|
+
|
86
|
+
assert_triggered expected, Minitest::UnexpectedError do
|
87
|
+
yield
|
88
|
+
end
|
89
|
+
end
|
90
|
+
|
80
91
|
def clean s
|
81
92
|
s.gsub(/^ {6,10}/, "")
|
82
93
|
end
|
@@ -343,7 +354,7 @@ class TestMinitestAssertions < Minitest::Test
|
|
343
354
|
@@ -1,3 +1,3 @@
|
344
355
|
-# encoding: UTF-8
|
345
356
|
-# valid: false
|
346
|
-
+# encoding:
|
357
|
+
+# encoding: #{Encoding::BINARY.name}
|
347
358
|
+# valid: true
|
348
359
|
"bad-utf8-\\xF1.txt"
|
349
360
|
EOM
|
@@ -362,7 +373,7 @@ class TestMinitestAssertions < Minitest::Test
|
|
362
373
|
@@ -1,3 +1,3 @@
|
363
374
|
-# encoding: US-ASCII
|
364
375
|
-# valid: false
|
365
|
-
+# encoding:
|
376
|
+
+# encoding: #{Encoding::BINARY.name}
|
366
377
|
+# valid: true
|
367
378
|
"bad-utf8-\\xF1.txt"
|
368
379
|
EOM
|
@@ -397,7 +408,7 @@ class TestMinitestAssertions < Minitest::Test
|
|
397
408
|
end
|
398
409
|
|
399
410
|
def test_assert_in_delta_triggered
|
400
|
-
x =
|
411
|
+
x = "1.0e-06"
|
401
412
|
assert_triggered "Expected |0.0 - 0.001| (0.001) to be <= #{x}." do
|
402
413
|
@tc.assert_in_delta 0.0, 1.0 / 1000, 0.000001
|
403
414
|
end
|
@@ -428,7 +439,7 @@ class TestMinitestAssertions < Minitest::Test
|
|
428
439
|
|
429
440
|
def test_assert_in_epsilon_triggered_negative_case
|
430
441
|
x = (RUBY18 and not maglev?) ? "0.1" : "0.100000xxx"
|
431
|
-
y =
|
442
|
+
y = "0.1"
|
432
443
|
assert_triggered "Expected |-1.1 - -1| (#{x}) to be <= #{y}." do
|
433
444
|
@tc.assert_in_epsilon(-1.1, -1, 0.1)
|
434
445
|
end
|
@@ -473,7 +484,10 @@ class TestMinitestAssertions < Minitest::Test
|
|
473
484
|
|
474
485
|
def test_assert_match
|
475
486
|
@assertion_count = 2
|
476
|
-
@tc.assert_match(/\w+/, "blah blah blah")
|
487
|
+
m = @tc.assert_match(/\w+/, "blah blah blah")
|
488
|
+
|
489
|
+
assert_kind_of MatchData, m
|
490
|
+
assert_equal "blah", m[0]
|
477
491
|
end
|
478
492
|
|
479
493
|
def test_assert_match_matchee_to_str
|
@@ -603,12 +617,117 @@ class TestMinitestAssertions < Minitest::Test
|
|
603
617
|
end
|
604
618
|
end
|
605
619
|
|
606
|
-
def
|
620
|
+
def test_assert_output_no_block
|
607
621
|
assert_triggered "assert_output requires a block to capture output." do
|
608
622
|
@tc.assert_output "blah"
|
609
623
|
end
|
610
624
|
end
|
611
625
|
|
626
|
+
def test_assert_output_nested_assert_uncaught
|
627
|
+
@assertion_count = 1
|
628
|
+
|
629
|
+
assert_triggered "Epic Fail!" do
|
630
|
+
@tc.assert_output "blah\n" do
|
631
|
+
puts "blah"
|
632
|
+
@tc.flunk
|
633
|
+
end
|
634
|
+
end
|
635
|
+
end
|
636
|
+
|
637
|
+
def test_assert_output_nested_raise
|
638
|
+
@assertion_count = 2
|
639
|
+
|
640
|
+
@tc.assert_output "blah\n" do
|
641
|
+
@tc.assert_raises RuntimeError do
|
642
|
+
puts "blah"
|
643
|
+
raise "boom!"
|
644
|
+
end
|
645
|
+
end
|
646
|
+
end
|
647
|
+
|
648
|
+
def test_assert_output_nested_raise_bad
|
649
|
+
@assertion_count = 0
|
650
|
+
|
651
|
+
assert_unexpected "boom!" do
|
652
|
+
@tc.assert_raises do # 2) bypassed via UnexpectedError
|
653
|
+
@tc.assert_output "blah\n" do # 1) captures and raises UnexpectedError
|
654
|
+
puts "not_blah"
|
655
|
+
raise "boom!"
|
656
|
+
end
|
657
|
+
end
|
658
|
+
end
|
659
|
+
end
|
660
|
+
|
661
|
+
def test_assert_output_nested_raise_mismatch
|
662
|
+
# this test is redundant, but illustrative
|
663
|
+
@assertion_count = 0
|
664
|
+
|
665
|
+
assert_unexpected "boom!" do
|
666
|
+
@tc.assert_raises RuntimeError do # 2) bypassed via UnexpectedError
|
667
|
+
@tc.assert_output "blah\n" do # 1) captures and raises UnexpectedError
|
668
|
+
puts "not_blah"
|
669
|
+
raise ArgumentError, "boom!"
|
670
|
+
end
|
671
|
+
end
|
672
|
+
end
|
673
|
+
end
|
674
|
+
|
675
|
+
def test_assert_output_nested_throw_caught
|
676
|
+
@assertion_count = 2
|
677
|
+
|
678
|
+
@tc.assert_output "blah\n" do
|
679
|
+
@tc.assert_throws :boom! do
|
680
|
+
puts "blah"
|
681
|
+
throw :boom!
|
682
|
+
end
|
683
|
+
end
|
684
|
+
end
|
685
|
+
|
686
|
+
def test_assert_output_nested_throw_caught_bad
|
687
|
+
@assertion_count = 1 # want 0; can't prevent throw from escaping :(
|
688
|
+
|
689
|
+
@tc.assert_throws :boom! do # 2) captured via catch
|
690
|
+
@tc.assert_output "blah\n" do # 1) bypassed via throw
|
691
|
+
puts "not_blah"
|
692
|
+
throw :boom!
|
693
|
+
end
|
694
|
+
end
|
695
|
+
end
|
696
|
+
|
697
|
+
def test_assert_output_nested_throw_mismatch
|
698
|
+
@assertion_count = 0
|
699
|
+
|
700
|
+
assert_unexpected "uncaught throw :boom!" do
|
701
|
+
@tc.assert_throws :not_boom! do # 2) captured via assert_throws+rescue
|
702
|
+
@tc.assert_output "blah\n" do # 1) bypassed via throw
|
703
|
+
puts "not_blah"
|
704
|
+
throw :boom!
|
705
|
+
end
|
706
|
+
end
|
707
|
+
end
|
708
|
+
end
|
709
|
+
|
710
|
+
def test_assert_output_uncaught_raise
|
711
|
+
@assertion_count = 0
|
712
|
+
|
713
|
+
assert_unexpected "RuntimeError: boom!" do
|
714
|
+
@tc.assert_output "blah\n" do
|
715
|
+
puts "not_blah"
|
716
|
+
raise "boom!"
|
717
|
+
end
|
718
|
+
end
|
719
|
+
end
|
720
|
+
|
721
|
+
def test_assert_output_uncaught_throw
|
722
|
+
@assertion_count = 0
|
723
|
+
|
724
|
+
assert_unexpected "uncaught throw :boom!" do
|
725
|
+
@tc.assert_output "blah\n" do
|
726
|
+
puts "not_blah"
|
727
|
+
throw :boom!
|
728
|
+
end
|
729
|
+
end
|
730
|
+
end
|
612
731
|
def test_assert_predicate
|
613
732
|
@tc.assert_predicate "", :empty?
|
614
733
|
end
|
@@ -643,12 +762,12 @@ class TestMinitestAssertions < Minitest::Test
|
|
643
762
|
Class: <SomeError>
|
644
763
|
Message: <\"blah\">
|
645
764
|
---Backtrace---
|
646
|
-
FILE:LINE:in \`test_assert_raises_default_triggered\'
|
765
|
+
FILE:LINE:in \`block in test_assert_raises_default_triggered\'
|
647
766
|
---------------
|
648
767
|
EOM
|
649
768
|
|
650
769
|
actual = e.message.gsub(/^.+:\d+/, "FILE:LINE")
|
651
|
-
actual.gsub!(
|
770
|
+
actual.gsub!(RE_LEVELS, "") unless jruby?
|
652
771
|
|
653
772
|
assert_equal expected, actual
|
654
773
|
end
|
@@ -671,11 +790,24 @@ class TestMinitestAssertions < Minitest::Test
|
|
671
790
|
end
|
672
791
|
end
|
673
792
|
|
793
|
+
def test_assert_raises_throw_nested_bad
|
794
|
+
@assertion_count = 0
|
795
|
+
|
796
|
+
assert_unexpected "RuntimeError: boom!" do
|
797
|
+
@tc.assert_raises do
|
798
|
+
@tc.assert_throws :blah do
|
799
|
+
raise "boom!"
|
800
|
+
throw :not_blah
|
801
|
+
end
|
802
|
+
end
|
803
|
+
end
|
804
|
+
end
|
805
|
+
|
674
806
|
##
|
675
807
|
# *sigh* This is quite an odd scenario, but it is from real (albeit
|
676
808
|
# ugly) test code in ruby-core:
|
677
809
|
|
678
|
-
#
|
810
|
+
# https://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=29259
|
679
811
|
|
680
812
|
def test_assert_raises_skip
|
681
813
|
@assertion_count = 0
|
@@ -709,12 +841,12 @@ class TestMinitestAssertions < Minitest::Test
|
|
709
841
|
Class: <AnError>
|
710
842
|
Message: <\"some message\">
|
711
843
|
---Backtrace---
|
712
|
-
FILE:LINE:in \`test_assert_raises_subclass_triggered\'
|
844
|
+
FILE:LINE:in \`block in test_assert_raises_subclass_triggered\'
|
713
845
|
---------------
|
714
846
|
EOM
|
715
847
|
|
716
848
|
actual = e.message.gsub(/^.+:\d+/, "FILE:LINE")
|
717
|
-
actual.gsub!(
|
849
|
+
actual.gsub!(RE_LEVELS, "") unless jruby?
|
718
850
|
|
719
851
|
assert_equal expected.chomp, actual
|
720
852
|
end
|
@@ -731,12 +863,12 @@ class TestMinitestAssertions < Minitest::Test
|
|
731
863
|
Class: <SyntaxError>
|
732
864
|
Message: <\"icky\">
|
733
865
|
---Backtrace---
|
734
|
-
FILE:LINE:in \`test_assert_raises_triggered_different\'
|
866
|
+
FILE:LINE:in \`block in test_assert_raises_triggered_different\'
|
735
867
|
---------------
|
736
868
|
EOM
|
737
869
|
|
738
870
|
actual = e.message.gsub(/^.+:\d+/, "FILE:LINE")
|
739
|
-
actual.gsub!(
|
871
|
+
actual.gsub!(RE_LEVELS, "") unless jruby?
|
740
872
|
|
741
873
|
assert_equal expected, actual
|
742
874
|
end
|
@@ -754,12 +886,12 @@ class TestMinitestAssertions < Minitest::Test
|
|
754
886
|
Class: <SyntaxError>
|
755
887
|
Message: <\"icky\">
|
756
888
|
---Backtrace---
|
757
|
-
FILE:LINE:in \`test_assert_raises_triggered_different_msg\'
|
889
|
+
FILE:LINE:in \`block in test_assert_raises_triggered_different_msg\'
|
758
890
|
---------------
|
759
891
|
EOM
|
760
892
|
|
761
893
|
actual = e.message.gsub(/^.+:\d+/, "FILE:LINE")
|
762
|
-
actual.gsub!(
|
894
|
+
actual.gsub!(RE_LEVELS, "") unless jruby?
|
763
895
|
|
764
896
|
assert_equal expected.chomp, actual
|
765
897
|
end
|
@@ -804,6 +936,16 @@ class TestMinitestAssertions < Minitest::Test
|
|
804
936
|
end
|
805
937
|
end
|
806
938
|
|
939
|
+
def test_assert_respond_to__include_all
|
940
|
+
@tc.assert_respond_to @tc, :exit, include_all: true
|
941
|
+
end
|
942
|
+
|
943
|
+
def test_assert_respond_to__include_all_triggered
|
944
|
+
assert_triggered(/Expected .+::DummyTest. to respond to #exit\?/) do
|
945
|
+
@tc.assert_respond_to @tc, :exit?, include_all: true
|
946
|
+
end
|
947
|
+
end
|
948
|
+
|
807
949
|
def test_assert_same
|
808
950
|
@assertion_count = 3
|
809
951
|
|
@@ -869,13 +1011,25 @@ class TestMinitestAssertions < Minitest::Test
|
|
869
1011
|
end
|
870
1012
|
|
871
1013
|
def test_assert_throws
|
872
|
-
@tc.assert_throws :blah do
|
1014
|
+
v = @tc.assert_throws :blah do
|
873
1015
|
throw :blah
|
874
1016
|
end
|
1017
|
+
|
1018
|
+
assert_nil v
|
1019
|
+
end
|
1020
|
+
|
1021
|
+
def test_assert_throws_value
|
1022
|
+
v = @tc.assert_throws :blah do
|
1023
|
+
throw :blah, 42
|
1024
|
+
end
|
1025
|
+
|
1026
|
+
assert_equal 42, v
|
875
1027
|
end
|
876
1028
|
|
877
1029
|
def test_assert_throws_argument_exception
|
878
|
-
@
|
1030
|
+
@assertion_count = 0
|
1031
|
+
|
1032
|
+
assert_unexpected "ArgumentError" do
|
879
1033
|
@tc.assert_throws :blah do
|
880
1034
|
raise ArgumentError
|
881
1035
|
end
|
@@ -891,7 +1045,9 @@ class TestMinitestAssertions < Minitest::Test
|
|
891
1045
|
end
|
892
1046
|
|
893
1047
|
def test_assert_throws_name_error
|
894
|
-
@
|
1048
|
+
@assertion_count = 0
|
1049
|
+
|
1050
|
+
assert_unexpected "NameError" do
|
895
1051
|
@tc.assert_throws :blah do
|
896
1052
|
raise NameError
|
897
1053
|
end
|
@@ -906,6 +1062,76 @@ class TestMinitestAssertions < Minitest::Test
|
|
906
1062
|
end
|
907
1063
|
end
|
908
1064
|
|
1065
|
+
def test_assert_path_exists
|
1066
|
+
@tc.assert_path_exists __FILE__
|
1067
|
+
end
|
1068
|
+
|
1069
|
+
def test_assert_path_exists_triggered
|
1070
|
+
assert_triggered "Expected path 'blah' to exist." do
|
1071
|
+
@tc.assert_path_exists "blah"
|
1072
|
+
end
|
1073
|
+
end
|
1074
|
+
|
1075
|
+
def test_assert_pattern
|
1076
|
+
if RUBY_VERSION > "3" then
|
1077
|
+
@tc.assert_pattern do
|
1078
|
+
exp = if RUBY_VERSION.start_with? "3.0"
|
1079
|
+
"(eval):1: warning: One-line pattern matching is experimental, and the behavior may change in future versions of Ruby!\n"
|
1080
|
+
else
|
1081
|
+
""
|
1082
|
+
end
|
1083
|
+
assert_output nil, exp do
|
1084
|
+
eval "[1,2,3] => [Integer, Integer, Integer]" # eval to escape parser for ruby<3
|
1085
|
+
end
|
1086
|
+
end
|
1087
|
+
else
|
1088
|
+
@assertion_count = 0
|
1089
|
+
|
1090
|
+
assert_raises NotImplementedError do
|
1091
|
+
@tc.assert_pattern do
|
1092
|
+
# do nothing
|
1093
|
+
end
|
1094
|
+
end
|
1095
|
+
end
|
1096
|
+
end
|
1097
|
+
|
1098
|
+
def test_assert_pattern_traps_nomatchingpatternerror
|
1099
|
+
skip unless RUBY_VERSION > "3"
|
1100
|
+
exp = if RUBY_VERSION.start_with? "3.0" then
|
1101
|
+
"[1, 2, 3]" # terrible error message!
|
1102
|
+
else
|
1103
|
+
/length mismatch/
|
1104
|
+
end
|
1105
|
+
|
1106
|
+
assert_triggered exp do
|
1107
|
+
@tc.assert_pattern do
|
1108
|
+
capture_io do # 3.0 is noisy
|
1109
|
+
eval "[1,2,3] => [Integer, Integer]" # eval to escape parser for ruby<3
|
1110
|
+
end
|
1111
|
+
end
|
1112
|
+
end
|
1113
|
+
end
|
1114
|
+
|
1115
|
+
def test_assert_pattern_raises_other_exceptions
|
1116
|
+
skip unless RUBY_VERSION >= "3.0"
|
1117
|
+
|
1118
|
+
@assertion_count = 0
|
1119
|
+
|
1120
|
+
assert_raises RuntimeError do
|
1121
|
+
@tc.assert_pattern do
|
1122
|
+
raise "boom"
|
1123
|
+
end
|
1124
|
+
end
|
1125
|
+
end
|
1126
|
+
|
1127
|
+
def test_assert_pattern_with_no_block
|
1128
|
+
skip unless RUBY_VERSION >= "3.0"
|
1129
|
+
|
1130
|
+
assert_triggered "assert_pattern requires a block to capture errors." do
|
1131
|
+
@tc.assert_pattern
|
1132
|
+
end
|
1133
|
+
end
|
1134
|
+
|
909
1135
|
def test_capture_io
|
910
1136
|
@assertion_count = 0
|
911
1137
|
|
@@ -937,18 +1163,14 @@ class TestMinitestAssertions < Minitest::Test
|
|
937
1163
|
def test_class_asserts_match_refutes
|
938
1164
|
@assertion_count = 0
|
939
1165
|
|
940
|
-
methods = Minitest::Assertions.public_instance_methods
|
941
|
-
methods.map!(&:to_s) if Symbol === methods.first
|
1166
|
+
methods = Minitest::Assertions.public_instance_methods.map(&:to_s)
|
942
1167
|
|
943
1168
|
# These don't have corresponding refutes _on purpose_. They're
|
944
1169
|
# useless and will never be added, so don't bother.
|
945
1170
|
ignores = %w[assert_output assert_raises assert_send
|
946
1171
|
assert_silent assert_throws assert_mock]
|
947
1172
|
|
948
|
-
|
949
|
-
ignores += %w[assert_no_match assert_not_equal assert_not_nil
|
950
|
-
assert_not_same assert_nothing_raised
|
951
|
-
assert_nothing_thrown assert_raise]
|
1173
|
+
ignores += %w[assert_allocations] # for minitest-gcstats
|
952
1174
|
|
953
1175
|
asserts = methods.grep(/^assert/).sort - ignores
|
954
1176
|
refutes = methods.grep(/^refute/).sort - ignores
|
@@ -978,6 +1200,23 @@ class TestMinitestAssertions < Minitest::Test
|
|
978
1200
|
end
|
979
1201
|
end
|
980
1202
|
|
1203
|
+
def assert_fail_after t
|
1204
|
+
@tc.fail_after t.year, t.month, t.day, "remove the deprecations"
|
1205
|
+
end
|
1206
|
+
|
1207
|
+
def test_fail_after
|
1208
|
+
d0 = Time.now
|
1209
|
+
d1 = d0 + 86_400 # I am an idiot
|
1210
|
+
|
1211
|
+
assert_silent do
|
1212
|
+
assert_fail_after d1
|
1213
|
+
end
|
1214
|
+
|
1215
|
+
assert_triggered "remove the deprecations" do
|
1216
|
+
assert_fail_after d0
|
1217
|
+
end
|
1218
|
+
end
|
1219
|
+
|
981
1220
|
def test_flunk
|
982
1221
|
assert_triggered "Epic Fail!" do
|
983
1222
|
@tc.flunk
|
@@ -997,7 +1236,7 @@ class TestMinitestAssertions < Minitest::Test
|
|
997
1236
|
def test_refute
|
998
1237
|
@assertion_count = 2
|
999
1238
|
|
1000
|
-
@tc.assert_equal
|
1239
|
+
@tc.assert_equal true, @tc.refute(false), "returns true on success"
|
1001
1240
|
end
|
1002
1241
|
|
1003
1242
|
def test_refute_empty
|
@@ -1029,7 +1268,7 @@ class TestMinitestAssertions < Minitest::Test
|
|
1029
1268
|
end
|
1030
1269
|
|
1031
1270
|
def test_refute_in_delta_triggered
|
1032
|
-
x =
|
1271
|
+
x = "0.1"
|
1033
1272
|
assert_triggered "Expected |0.0 - 0.001| (0.001) to not be <= #{x}." do
|
1034
1273
|
@tc.refute_in_delta 0.0, 1.0 / 1000, 0.1
|
1035
1274
|
end
|
@@ -1141,6 +1380,56 @@ class TestMinitestAssertions < Minitest::Test
|
|
1141
1380
|
end
|
1142
1381
|
end
|
1143
1382
|
|
1383
|
+
def test_refute_pattern
|
1384
|
+
if RUBY_VERSION >= "3.0"
|
1385
|
+
@tc.refute_pattern do
|
1386
|
+
capture_io do # 3.0 is noisy
|
1387
|
+
eval "[1,2,3] => [Integer, Integer, String]"
|
1388
|
+
end
|
1389
|
+
end
|
1390
|
+
else
|
1391
|
+
@assertion_count = 0
|
1392
|
+
|
1393
|
+
assert_raises NotImplementedError do
|
1394
|
+
@tc.refute_pattern do
|
1395
|
+
eval "[1,2,3] => [Integer, Integer, String]"
|
1396
|
+
end
|
1397
|
+
end
|
1398
|
+
end
|
1399
|
+
end
|
1400
|
+
|
1401
|
+
def test_refute_pattern_expects_nomatchingpatternerror
|
1402
|
+
skip unless RUBY_VERSION > "3"
|
1403
|
+
|
1404
|
+
assert_triggered(/NoMatchingPatternError expected, but nothing was raised./) do
|
1405
|
+
@tc.refute_pattern do
|
1406
|
+
capture_io do # 3.0 is noisy
|
1407
|
+
eval "[1,2,3] => [Integer, Integer, Integer]"
|
1408
|
+
end
|
1409
|
+
end
|
1410
|
+
end
|
1411
|
+
end
|
1412
|
+
|
1413
|
+
def test_refute_pattern_raises_other_exceptions
|
1414
|
+
skip unless RUBY_VERSION >= "3.0"
|
1415
|
+
|
1416
|
+
@assertion_count = 0
|
1417
|
+
|
1418
|
+
assert_raises RuntimeError do
|
1419
|
+
@tc.refute_pattern do
|
1420
|
+
raise "boom"
|
1421
|
+
end
|
1422
|
+
end
|
1423
|
+
end
|
1424
|
+
|
1425
|
+
def test_refute_pattern_with_no_block
|
1426
|
+
skip unless RUBY_VERSION >= "3.0"
|
1427
|
+
|
1428
|
+
assert_triggered "refute_pattern requires a block to capture errors." do
|
1429
|
+
@tc.refute_pattern
|
1430
|
+
end
|
1431
|
+
end
|
1432
|
+
|
1144
1433
|
def test_refute_predicate
|
1145
1434
|
@tc.refute_predicate "42", :empty?
|
1146
1435
|
end
|
@@ -1161,6 +1450,16 @@ class TestMinitestAssertions < Minitest::Test
|
|
1161
1450
|
end
|
1162
1451
|
end
|
1163
1452
|
|
1453
|
+
def test_refute_respond_to__include_all
|
1454
|
+
@tc.refute_respond_to "blah", :missing, include_all: true
|
1455
|
+
end
|
1456
|
+
|
1457
|
+
def test_refute_respond_to__include_all_triggered
|
1458
|
+
assert_triggered(/Expected .*DummyTest.* to not respond to exit./) do
|
1459
|
+
@tc.refute_respond_to @tc, :exit, include_all: true
|
1460
|
+
end
|
1461
|
+
end
|
1462
|
+
|
1164
1463
|
def test_refute_same
|
1165
1464
|
@tc.refute_same 1, 2
|
1166
1465
|
end
|
@@ -1171,6 +1470,16 @@ class TestMinitestAssertions < Minitest::Test
|
|
1171
1470
|
end
|
1172
1471
|
end
|
1173
1472
|
|
1473
|
+
def test_refute_path_exists
|
1474
|
+
@tc.refute_path_exists "blah"
|
1475
|
+
end
|
1476
|
+
|
1477
|
+
def test_refute_path_exists_triggered
|
1478
|
+
assert_triggered "Expected path '#{__FILE__}' to not exist." do
|
1479
|
+
@tc.refute_path_exists __FILE__
|
1480
|
+
end
|
1481
|
+
end
|
1482
|
+
|
1174
1483
|
def test_skip
|
1175
1484
|
@assertion_count = 0
|
1176
1485
|
|
@@ -1179,6 +1488,25 @@ class TestMinitestAssertions < Minitest::Test
|
|
1179
1488
|
end
|
1180
1489
|
end
|
1181
1490
|
|
1491
|
+
def assert_skip_until t, msg
|
1492
|
+
@tc.skip_until t.year, t.month, t.day, msg
|
1493
|
+
end
|
1494
|
+
|
1495
|
+
def test_skip_until
|
1496
|
+
@assertion_count = 0
|
1497
|
+
|
1498
|
+
d0 = Time.now
|
1499
|
+
d1 = d0 + 86_400 # I am an idiot
|
1500
|
+
|
1501
|
+
assert_output "", /Stale skip_until \"not yet\" at .*?:\d+$/ do
|
1502
|
+
assert_skip_until d0, "not yet"
|
1503
|
+
end
|
1504
|
+
|
1505
|
+
assert_triggered "not ready yet", Minitest::Skip do
|
1506
|
+
assert_skip_until d1, "not ready yet"
|
1507
|
+
end
|
1508
|
+
end
|
1509
|
+
|
1182
1510
|
def util_msg exp, act, msg = nil
|
1183
1511
|
s = "Expected: #{exp.inspect}\n Actual: #{act.inspect}"
|
1184
1512
|
s = "#{msg}.\n#{s}" if msg
|
@@ -1329,14 +1657,14 @@ class TestMinitestAssertionHelpers < Minitest::Test
|
|
1329
1657
|
|
1330
1658
|
def test_mu_pp_for_diff_str_encoding
|
1331
1659
|
str = "A\nB".b
|
1332
|
-
exp = "# encoding:
|
1660
|
+
exp = "# encoding: #{Encoding::BINARY.name}\n# valid: true\n\"A\nB\""
|
1333
1661
|
|
1334
1662
|
assert_mu_pp_for_diff exp, str, :raw
|
1335
1663
|
end
|
1336
1664
|
|
1337
1665
|
def test_mu_pp_for_diff_str_encoding_both
|
1338
1666
|
str = "A\\n\nB".b
|
1339
|
-
exp = "# encoding:
|
1667
|
+
exp = "# encoding: #{Encoding::BINARY.name}\n# valid: true\n\"A\\\\n\\nB\""
|
1340
1668
|
|
1341
1669
|
assert_mu_pp_for_diff exp, str, :raw
|
1342
1670
|
end
|
@@ -1376,7 +1704,7 @@ class TestMinitestAssertionHelpers < Minitest::Test
|
|
1376
1704
|
|
1377
1705
|
def test_mu_pp_str_encoding
|
1378
1706
|
str = "A\nB".b
|
1379
|
-
exp = "# encoding:
|
1707
|
+
exp = "# encoding: #{Encoding::BINARY.name}\n# valid: true\n\"A\\nB\""
|
1380
1708
|
|
1381
1709
|
assert_mu_pp exp, str, :raw
|
1382
1710
|
end
|
@@ -3,7 +3,7 @@ require "minitest/benchmark"
|
|
3
3
|
|
4
4
|
##
|
5
5
|
# Used to verify data:
|
6
|
-
#
|
6
|
+
# https://www.wolframalpha.com/examples/RegressionAnalysis.html
|
7
7
|
|
8
8
|
class TestMinitestBenchmark < Minitest::Test
|
9
9
|
def test_cls_bench_exp
|
@@ -110,7 +110,7 @@ class TestMinitestBenchmark < Minitest::Test
|
|
110
110
|
assert_fit :power, x, y, 0.90, 2.6217, 1.4556
|
111
111
|
|
112
112
|
# income to % of households below income amount
|
113
|
-
#
|
113
|
+
# https://library.wolfram.com/infocenter/Conferences/6461/PowerLaws.nb
|
114
114
|
x = [15_000, 25_000, 35_000, 50_000, 75_000, 100_000]
|
115
115
|
y = [0.154, 0.283, 0.402, 0.55, 0.733, 0.843]
|
116
116
|
|