minitest 5.24.1 → 5.25.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- checksums.yaml.gz.sig +0 -0
- data/History.rdoc +21 -0
- data/lib/hoe/minitest.rb +2 -1
- data/lib/minitest/assertions.rb +64 -69
- data/lib/minitest/benchmark.rb +6 -9
- data/lib/minitest/compress.rb +10 -10
- data/lib/minitest/error_on_warning.rb +3 -3
- data/lib/minitest/mock.rb +13 -13
- data/lib/minitest/parallel.rb +4 -4
- data/lib/minitest/pride_plugin.rb +10 -14
- data/lib/minitest/spec.rb +5 -5
- data/lib/minitest/test.rb +10 -22
- data/lib/minitest/test_task.rb +9 -9
- data/lib/minitest.rb +59 -52
- data/test/minitest/metametameta.rb +6 -9
- data/test/minitest/test_minitest_assertions.rb +113 -113
- data/test/minitest/test_minitest_benchmark.rb +1 -1
- data/test/minitest/test_minitest_mock.rb +67 -64
- data/test/minitest/test_minitest_reporter.rb +11 -15
- data/test/minitest/test_minitest_spec.rb +35 -38
- data/test/minitest/test_minitest_test.rb +80 -99
- data/test/minitest/test_minitest_test_task.rb +11 -8
- data.tar.gz.sig +0 -0
- metadata +3 -3
- metadata.gz.sig +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6e090130753c1fb650b32bb10042b89b676ce100ceba25021cd3a7351d9114df
|
4
|
+
data.tar.gz: 729687628f500bc5b2153864f723491b72a98afcc6fd50da27fc48a5ed952def
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 9a0d599badcfe81e3cf63bc030b39cfa6ff0388f9d732ab145002c8e5c1b1b83dbeb8d51878d977a717528afefb4616ce9ba23922795b05bcc4d30983bbbc577
|
7
|
+
data.tar.gz: c3693a94e10968dd1f0a89a0217d83612978baf5471d9b37e184a0fd3e8ba0ee513f79c51f99fee0af468539d636d9aa8f4724de629fc02599c5a8141ee74c1c
|
checksums.yaml.gz.sig
CHANGED
Binary file
|
data/History.rdoc
CHANGED
@@ -1,3 +1,24 @@
|
|
1
|
+
=== 5.25.0 / 2024-08-13
|
2
|
+
|
3
|
+
* 2 minor enhancements:
|
4
|
+
|
5
|
+
* Fixed some inefficiencies filtering and matching (mostly backtraces).
|
6
|
+
* Refactored siginfo handler to reduce runtime costs. Saved ~30%!
|
7
|
+
|
8
|
+
* 5 bug fixes:
|
9
|
+
|
10
|
+
* Added missing rdoc to get back to 100% coverage.
|
11
|
+
* Cleaning up ancient code checking for defined?(Encoding) and the like.
|
12
|
+
* Disambiguated some shadowed variables in minitest/compress.
|
13
|
+
* Fixed an ironic bug if using string-literals AND Werror.
|
14
|
+
* Improve description of test:slow task. (stomar)
|
15
|
+
|
16
|
+
=== 5.24.1 / 2024-06-29
|
17
|
+
|
18
|
+
* 1 bug fix:
|
19
|
+
|
20
|
+
* Fix the error message when an extension is invalid value. (y-yagi)
|
21
|
+
|
1
22
|
=== 5.24.0 / 2024-06-18
|
2
23
|
|
3
24
|
* 2 minor enhancements:
|
data/lib/hoe/minitest.rb
CHANGED
@@ -1,6 +1,7 @@
|
|
1
1
|
# :stopdoc:
|
2
2
|
|
3
3
|
class Hoe
|
4
|
+
# empty
|
4
5
|
end
|
5
6
|
|
6
7
|
module Hoe::Minitest
|
@@ -16,7 +17,7 @@ module Hoe::Minitest
|
|
16
17
|
|
17
18
|
gem "minitest"
|
18
19
|
require "minitest"
|
19
|
-
version = Minitest::VERSION.split(
|
20
|
+
version = Minitest::VERSION.split(".").first(2).join "."
|
20
21
|
|
21
22
|
dependency "minitest", "~> #{version}", :development unless
|
22
23
|
minitest? or ENV["MT_NO_ISOLATE"]
|
data/lib/minitest/assertions.rb
CHANGED
@@ -1,5 +1,3 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
1
|
require "rbconfig"
|
4
2
|
require "tempfile"
|
5
3
|
require "stringio"
|
@@ -29,12 +27,12 @@ module Minitest
|
|
29
27
|
def self.diff
|
30
28
|
return @diff if defined? @diff
|
31
29
|
|
32
|
-
@diff = if (RbConfig::CONFIG["host_os"] =~ /mswin|mingw/
|
33
|
-
system
|
30
|
+
@diff = if (RbConfig::CONFIG["host_os"] =~ /mswin|mingw/ and
|
31
|
+
system "diff.exe", __FILE__, __FILE__) then
|
34
32
|
"diff.exe -u"
|
35
|
-
elsif system
|
33
|
+
elsif system "gdiff", __FILE__, __FILE__ then
|
36
34
|
"gdiff -u" # solaris and kin suck
|
37
|
-
elsif system
|
35
|
+
elsif system "diff", __FILE__, __FILE__ then
|
38
36
|
"diff -u"
|
39
37
|
else
|
40
38
|
nil
|
@@ -59,16 +57,16 @@ module Minitest
|
|
59
57
|
def diff exp, act
|
60
58
|
result = nil
|
61
59
|
|
62
|
-
expect, butwas = things_to_diff
|
60
|
+
expect, butwas = things_to_diff exp, act
|
63
61
|
|
64
62
|
return "Expected: #{mu_pp exp}\n Actual: #{mu_pp act}" unless
|
65
63
|
expect
|
66
64
|
|
67
|
-
Tempfile.open
|
65
|
+
Tempfile.open "expect" do |a|
|
68
66
|
a.puts expect
|
69
67
|
a.flush
|
70
68
|
|
71
|
-
Tempfile.open
|
69
|
+
Tempfile.open "butwas" do |b|
|
72
70
|
b.puts butwas
|
73
71
|
b.flush
|
74
72
|
|
@@ -79,10 +77,10 @@ module Minitest
|
|
79
77
|
if result.empty? then
|
80
78
|
klass = exp.class
|
81
79
|
result = [
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
80
|
+
"No visible difference in the #{klass}#inspect output.\n",
|
81
|
+
"You should look at the implementation of #== on ",
|
82
|
+
"#{klass} or its members.\n",
|
83
|
+
expect,
|
86
84
|
].join
|
87
85
|
end
|
88
86
|
end
|
@@ -127,20 +125,15 @@ module Minitest
|
|
127
125
|
# See Minitest::Test.make_my_diffs_pretty!
|
128
126
|
|
129
127
|
def mu_pp obj
|
130
|
-
s = obj.inspect
|
128
|
+
s = obj.inspect.encode Encoding.default_external
|
131
129
|
|
132
|
-
|
133
|
-
|
130
|
+
return s unless String === obj &&
|
131
|
+
(obj.encoding != Encoding.default_external || !obj.valid_encoding?)
|
134
132
|
|
135
|
-
|
136
|
-
|
137
|
-
enc = "# encoding: #{obj.encoding}"
|
138
|
-
val = "# valid: #{obj.valid_encoding?}"
|
139
|
-
s = "#{enc}\n#{val}\n#{s}"
|
140
|
-
end
|
141
|
-
end
|
133
|
+
enc = "# encoding: #{obj.encoding}"
|
134
|
+
val = "# valid: #{obj.valid_encoding?}"
|
142
135
|
|
143
|
-
s
|
136
|
+
[enc, val, s].join "\n"
|
144
137
|
end
|
145
138
|
|
146
139
|
##
|
@@ -153,8 +146,8 @@ module Minitest
|
|
153
146
|
str = mu_pp obj
|
154
147
|
|
155
148
|
# both '\n' & '\\n' (_after_ mu_pp (aka inspect))
|
156
|
-
single =
|
157
|
-
double =
|
149
|
+
single = str.match?(/(?<!\\|^)\\n/)
|
150
|
+
double = str.match?(/(?<=\\|^)\\n/)
|
158
151
|
|
159
152
|
process =
|
160
153
|
if single ^ double then
|
@@ -167,9 +160,9 @@ module Minitest
|
|
167
160
|
:itself # leave it alone
|
168
161
|
end
|
169
162
|
|
170
|
-
str
|
171
|
-
gsub(/\\?\\n/, &process)
|
172
|
-
gsub(/:0x[a-fA-F0-9]{4,}/m, ":0xXXXXXX") # anonymize hex values
|
163
|
+
str
|
164
|
+
.gsub(/\\?\\n/, &process)
|
165
|
+
.gsub(/:0x[a-fA-F0-9]{4,}/m, ":0xXXXXXX") # anonymize hex values
|
173
166
|
end
|
174
167
|
|
175
168
|
##
|
@@ -193,14 +186,14 @@ module Minitest
|
|
193
186
|
# Fails unless +obj+ is empty.
|
194
187
|
|
195
188
|
def assert_empty obj, msg = nil
|
196
|
-
msg = message(msg) { "Expected #{mu_pp
|
189
|
+
msg = message(msg) { "Expected #{mu_pp obj} to be empty" }
|
197
190
|
assert_respond_to obj, :empty?
|
198
191
|
assert obj.empty?, msg
|
199
192
|
end
|
200
193
|
|
201
194
|
def _where # :nodoc:
|
202
|
-
|
203
|
-
|
195
|
+
Minitest.filter_backtrace(caller).first
|
196
|
+
.split(":in ", 2).first # clean up noise
|
204
197
|
end
|
205
198
|
|
206
199
|
E = "" # :nodoc:
|
@@ -223,7 +216,7 @@ module Minitest
|
|
223
216
|
result = assert exp == act, msg
|
224
217
|
|
225
218
|
if nil == exp then
|
226
|
-
if Minitest::VERSION
|
219
|
+
if Minitest::VERSION >= "6" then
|
227
220
|
refute_nil exp, "Use assert_nil if expecting nil."
|
228
221
|
else
|
229
222
|
warn "DEPRECATED: Use assert_nil if expecting nil from #{_where}. This will fail in Minitest 6."
|
@@ -260,7 +253,7 @@ module Minitest
|
|
260
253
|
|
261
254
|
def assert_includes collection, obj, msg = nil
|
262
255
|
msg = message(msg) {
|
263
|
-
"Expected #{mu_pp
|
256
|
+
"Expected #{mu_pp collection} to include #{mu_pp obj}"
|
264
257
|
}
|
265
258
|
assert_respond_to collection, :include?
|
266
259
|
assert collection.include?(obj), msg
|
@@ -271,7 +264,7 @@ module Minitest
|
|
271
264
|
|
272
265
|
def assert_instance_of cls, obj, msg = nil
|
273
266
|
msg = message(msg) {
|
274
|
-
"Expected #{mu_pp
|
267
|
+
"Expected #{mu_pp obj} to be an instance of #{cls}, not #{obj.class}"
|
275
268
|
}
|
276
269
|
|
277
270
|
assert obj.instance_of?(cls), msg
|
@@ -282,7 +275,8 @@ module Minitest
|
|
282
275
|
|
283
276
|
def assert_kind_of cls, obj, msg = nil
|
284
277
|
msg = message(msg) {
|
285
|
-
"Expected #{mu_pp
|
278
|
+
"Expected #{mu_pp obj} to be a kind of #{cls}, not #{obj.class}"
|
279
|
+
}
|
286
280
|
|
287
281
|
assert obj.kind_of?(cls), msg
|
288
282
|
end
|
@@ -292,7 +286,7 @@ module Minitest
|
|
292
286
|
|
293
287
|
def assert_match matcher, obj, msg = nil
|
294
288
|
msg = message(msg) { "Expected #{mu_pp matcher} to match #{mu_pp obj}" }
|
295
|
-
assert_respond_to matcher,
|
289
|
+
assert_respond_to matcher, :=~
|
296
290
|
matcher = Regexp.new Regexp.escape matcher if String === matcher
|
297
291
|
assert matcher =~ obj, msg
|
298
292
|
|
@@ -303,7 +297,7 @@ module Minitest
|
|
303
297
|
# Fails unless +obj+ is nil
|
304
298
|
|
305
299
|
def assert_nil obj, msg = nil
|
306
|
-
msg = message(msg) { "Expected #{mu_pp
|
300
|
+
msg = message(msg) { "Expected #{mu_pp obj} to be nil" }
|
307
301
|
assert obj.nil?, msg
|
308
302
|
end
|
309
303
|
|
@@ -314,7 +308,7 @@ module Minitest
|
|
314
308
|
|
315
309
|
def assert_operator o1, op, o2 = UNDEFINED, msg = nil
|
316
310
|
return assert_predicate o1, op, msg if UNDEFINED == o2
|
317
|
-
msg = message(msg) { "Expected #{mu_pp
|
311
|
+
msg = message(msg) { "Expected #{mu_pp o1} to be #{op} #{mu_pp o2}" }
|
318
312
|
assert o1.__send__(op, o2), msg
|
319
313
|
end
|
320
314
|
|
@@ -395,7 +389,7 @@ module Minitest
|
|
395
389
|
# str.must_be :empty?
|
396
390
|
|
397
391
|
def assert_predicate o1, op, msg = nil
|
398
|
-
msg = message(msg) { "Expected #{mu_pp
|
392
|
+
msg = message(msg) { "Expected #{mu_pp o1} to be #{op}" }
|
399
393
|
assert o1.__send__(op), msg
|
400
394
|
end
|
401
395
|
|
@@ -440,13 +434,13 @@ module Minitest
|
|
440
434
|
raise
|
441
435
|
rescue Exception => e
|
442
436
|
flunk proc {
|
443
|
-
exception_details(e, "#{msg}#{mu_pp
|
437
|
+
exception_details(e, "#{msg}#{mu_pp exp} exception expected, not")
|
444
438
|
}
|
445
439
|
end
|
446
440
|
|
447
441
|
exp = exp.first if exp.size == 1
|
448
442
|
|
449
|
-
flunk "#{msg}#{mu_pp
|
443
|
+
flunk "#{msg}#{mu_pp exp} expected but nothing was raised."
|
450
444
|
end
|
451
445
|
|
452
446
|
##
|
@@ -455,7 +449,7 @@ module Minitest
|
|
455
449
|
|
456
450
|
def assert_respond_to obj, meth, msg = nil, include_all: false
|
457
451
|
msg = message(msg) {
|
458
|
-
"Expected #{mu_pp
|
452
|
+
"Expected #{mu_pp obj} (#{obj.class}) to respond to ##{meth}"
|
459
453
|
}
|
460
454
|
assert obj.respond_to?(meth, include_all), msg
|
461
455
|
end
|
@@ -481,7 +475,8 @@ module Minitest
|
|
481
475
|
|
482
476
|
recv, msg, *args = send_ary
|
483
477
|
m = message(m) {
|
484
|
-
"Expected #{mu_pp
|
478
|
+
"Expected #{mu_pp recv}.#{msg}(*#{mu_pp args}) to return true"
|
479
|
+
}
|
485
480
|
assert recv.__send__(msg, *args), m
|
486
481
|
end
|
487
482
|
|
@@ -500,15 +495,15 @@ module Minitest
|
|
500
495
|
# Fails unless the block throws +sym+
|
501
496
|
|
502
497
|
def assert_throws sym, msg = nil
|
503
|
-
default = "Expected #{mu_pp
|
498
|
+
default = "Expected #{mu_pp sym} to have been thrown"
|
504
499
|
caught = true
|
505
|
-
value = catch
|
500
|
+
value = catch sym do
|
506
501
|
begin
|
507
502
|
yield
|
508
503
|
rescue ThreadError => e # wtf?!? 1.8 + threads == suck
|
509
|
-
default += ", not
|
504
|
+
default += ", not :#{e.message[/uncaught throw \`(\w+?)\'/, 1]}"
|
510
505
|
rescue ArgumentError => e # 1.9 exception
|
511
|
-
raise e unless e.message.include?
|
506
|
+
raise e unless e.message.include? "uncaught throw"
|
512
507
|
default += ", not #{e.message.split(/ /).last}"
|
513
508
|
rescue NameError => e # 1.8 exception
|
514
509
|
raise e unless e.name == sym
|
@@ -607,12 +602,12 @@ module Minitest
|
|
607
602
|
|
608
603
|
def exception_details e, msg
|
609
604
|
[
|
610
|
-
|
611
|
-
|
612
|
-
|
613
|
-
|
614
|
-
|
615
|
-
|
605
|
+
msg,
|
606
|
+
"Class: <#{e.class}>",
|
607
|
+
"Message: <#{e.message.inspect}>",
|
608
|
+
"---Backtrace---",
|
609
|
+
Minitest.filter_backtrace(e.backtrace),
|
610
|
+
"---------------",
|
616
611
|
].join "\n"
|
617
612
|
end
|
618
613
|
|
@@ -621,7 +616,7 @@ module Minitest
|
|
621
616
|
# you to put time-bombs in your tests if you need to keep
|
622
617
|
# something around until a later date lest you forget about it.
|
623
618
|
|
624
|
-
def fail_after y,m,d,msg
|
619
|
+
def fail_after y, m, d, msg
|
625
620
|
flunk msg if Time.now > Time.local(y, m, d)
|
626
621
|
end
|
627
622
|
|
@@ -655,7 +650,7 @@ module Minitest
|
|
655
650
|
# Fails if +test+ is truthy.
|
656
651
|
|
657
652
|
def refute test, msg = nil
|
658
|
-
msg ||= message { "Expected #{mu_pp
|
653
|
+
msg ||= message { "Expected #{mu_pp test} to not be truthy" }
|
659
654
|
assert !test, msg
|
660
655
|
end
|
661
656
|
|
@@ -663,7 +658,7 @@ module Minitest
|
|
663
658
|
# Fails if +obj+ is empty.
|
664
659
|
|
665
660
|
def refute_empty obj, msg = nil
|
666
|
-
msg = message(msg) { "Expected #{mu_pp
|
661
|
+
msg = message(msg) { "Expected #{mu_pp obj} to not be empty" }
|
667
662
|
assert_respond_to obj, :empty?
|
668
663
|
refute obj.empty?, msg
|
669
664
|
end
|
@@ -675,7 +670,7 @@ module Minitest
|
|
675
670
|
|
676
671
|
def refute_equal exp, act, msg = nil
|
677
672
|
msg = message(msg) {
|
678
|
-
"Expected #{mu_pp
|
673
|
+
"Expected #{mu_pp act} to not be equal to #{mu_pp exp}"
|
679
674
|
}
|
680
675
|
refute exp == act, msg
|
681
676
|
end
|
@@ -706,7 +701,7 @@ module Minitest
|
|
706
701
|
|
707
702
|
def refute_includes collection, obj, msg = nil
|
708
703
|
msg = message(msg) {
|
709
|
-
"Expected #{mu_pp
|
704
|
+
"Expected #{mu_pp collection} to not include #{mu_pp obj}"
|
710
705
|
}
|
711
706
|
assert_respond_to collection, :include?
|
712
707
|
refute collection.include?(obj), msg
|
@@ -717,7 +712,7 @@ module Minitest
|
|
717
712
|
|
718
713
|
def refute_instance_of cls, obj, msg = nil
|
719
714
|
msg = message(msg) {
|
720
|
-
"Expected #{mu_pp
|
715
|
+
"Expected #{mu_pp obj} to not be an instance of #{cls}"
|
721
716
|
}
|
722
717
|
refute obj.instance_of?(cls), msg
|
723
718
|
end
|
@@ -726,7 +721,7 @@ module Minitest
|
|
726
721
|
# Fails if +obj+ is a kind of +cls+.
|
727
722
|
|
728
723
|
def refute_kind_of cls, obj, msg = nil
|
729
|
-
msg = message(msg) { "Expected #{mu_pp
|
724
|
+
msg = message(msg) { "Expected #{mu_pp obj} to not be a kind of #{cls}" }
|
730
725
|
refute obj.kind_of?(cls), msg
|
731
726
|
end
|
732
727
|
|
@@ -735,7 +730,7 @@ module Minitest
|
|
735
730
|
|
736
731
|
def refute_match matcher, obj, msg = nil
|
737
732
|
msg = message(msg) { "Expected #{mu_pp matcher} to not match #{mu_pp obj}" }
|
738
|
-
assert_respond_to matcher,
|
733
|
+
assert_respond_to matcher, :=~
|
739
734
|
matcher = Regexp.new Regexp.escape matcher if String === matcher
|
740
735
|
refute matcher =~ obj, msg
|
741
736
|
end
|
@@ -744,7 +739,7 @@ module Minitest
|
|
744
739
|
# Fails if +obj+ is nil.
|
745
740
|
|
746
741
|
def refute_nil obj, msg = nil
|
747
|
-
msg = message(msg) { "Expected #{mu_pp
|
742
|
+
msg = message(msg) { "Expected #{mu_pp obj} to not be nil" }
|
748
743
|
refute obj.nil?, msg
|
749
744
|
end
|
750
745
|
|
@@ -766,7 +761,7 @@ module Minitest
|
|
766
761
|
|
767
762
|
begin
|
768
763
|
yield
|
769
|
-
flunk
|
764
|
+
flunk "NoMatchingPatternError expected, but nothing was raised."
|
770
765
|
rescue NoMatchingPatternError
|
771
766
|
pass
|
772
767
|
end
|
@@ -780,7 +775,7 @@ module Minitest
|
|
780
775
|
|
781
776
|
def refute_operator o1, op, o2 = UNDEFINED, msg = nil
|
782
777
|
return refute_predicate o1, op, msg if UNDEFINED == o2
|
783
|
-
msg = message(msg) { "Expected #{mu_pp
|
778
|
+
msg = message(msg) { "Expected #{mu_pp o1} to not be #{op} #{mu_pp o2}" }
|
784
779
|
refute o1.__send__(op, o2), msg
|
785
780
|
end
|
786
781
|
|
@@ -802,7 +797,7 @@ module Minitest
|
|
802
797
|
# str.wont_be :empty?
|
803
798
|
|
804
799
|
def refute_predicate o1, op, msg = nil
|
805
|
-
msg = message(msg) { "Expected #{mu_pp
|
800
|
+
msg = message(msg) { "Expected #{mu_pp o1} to not be #{op}" }
|
806
801
|
refute o1.__send__(op), msg
|
807
802
|
end
|
808
803
|
|
@@ -811,7 +806,7 @@ module Minitest
|
|
811
806
|
# include_all defaults to false to match Object#respond_to?
|
812
807
|
|
813
808
|
def refute_respond_to obj, meth, msg = nil, include_all: false
|
814
|
-
msg = message(msg) { "Expected #{mu_pp
|
809
|
+
msg = message(msg) { "Expected #{mu_pp obj} to not respond to #{meth}" }
|
815
810
|
|
816
811
|
refute obj.respond_to?(meth, include_all), msg
|
817
812
|
end
|
@@ -844,9 +839,9 @@ module Minitest
|
|
844
839
|
# date, but still holds you accountable and prevents you from
|
845
840
|
# forgetting it.
|
846
841
|
|
847
|
-
def skip_until y,m,d,msg
|
842
|
+
def skip_until y, m, d, msg
|
848
843
|
skip msg if Time.now < Time.local(y, m, d)
|
849
|
-
where = caller.first.rpartition(
|
844
|
+
where = caller(1..1).first.rpartition(":in").reject(&:empty?).first
|
850
845
|
warn "Stale skip_until %p at %s" % [msg, where]
|
851
846
|
end
|
852
847
|
|
data/lib/minitest/benchmark.rb
CHANGED
@@ -47,8 +47,6 @@ module Minitest
|
|
47
47
|
|
48
48
|
def self.bench_linear min, max, step = 10
|
49
49
|
(min..max).step(step).to_a
|
50
|
-
rescue LocalJumpError # 1.8.6
|
51
|
-
r = []; (min..max).step(step) { |n| r << n }; r
|
52
50
|
end
|
53
51
|
|
54
52
|
##
|
@@ -83,7 +81,7 @@ module Minitest
|
|
83
81
|
def assert_performance validation, &work
|
84
82
|
range = self.class.bench_range
|
85
83
|
|
86
|
-
io.print
|
84
|
+
io.print self.name
|
87
85
|
|
88
86
|
times = []
|
89
87
|
|
@@ -236,7 +234,7 @@ module Minitest
|
|
236
234
|
|
237
235
|
def fit_exponential xs, ys
|
238
236
|
n = xs.size
|
239
|
-
xys = xs.zip
|
237
|
+
xys = xs.zip ys
|
240
238
|
sxlny = sigma(xys) { |x, y| x * Math.log(y) }
|
241
239
|
slny = sigma(xys) { |_, y| Math.log(y) }
|
242
240
|
sx2 = sigma(xys) { |x, _| x * x }
|
@@ -258,7 +256,7 @@ module Minitest
|
|
258
256
|
|
259
257
|
def fit_logarithmic xs, ys
|
260
258
|
n = xs.size
|
261
|
-
xys = xs.zip
|
259
|
+
xys = xs.zip ys
|
262
260
|
slnx2 = sigma(xys) { |x, _| Math.log(x) ** 2 }
|
263
261
|
slnx = sigma(xys) { |x, _| Math.log(x) }
|
264
262
|
sylnx = sigma(xys) { |x, y| y * Math.log(x) }
|
@@ -280,7 +278,7 @@ module Minitest
|
|
280
278
|
|
281
279
|
def fit_linear xs, ys
|
282
280
|
n = xs.size
|
283
|
-
xys = xs.zip
|
281
|
+
xys = xs.zip ys
|
284
282
|
sx = sigma xs
|
285
283
|
sy = sigma ys
|
286
284
|
sx2 = sigma(xs) { |x| x ** 2 }
|
@@ -302,7 +300,7 @@ module Minitest
|
|
302
300
|
|
303
301
|
def fit_power xs, ys
|
304
302
|
n = xs.size
|
305
|
-
xys = xs.zip
|
303
|
+
xys = xs.zip ys
|
306
304
|
slnxlny = sigma(xys) { |x, y| Math.log(x) * Math.log(y) }
|
307
305
|
slnx = sigma(xs) { |x | Math.log(x) }
|
308
306
|
slny = sigma(ys) { | y| Math.log(y) }
|
@@ -323,7 +321,7 @@ module Minitest
|
|
323
321
|
|
324
322
|
def sigma enum, &block
|
325
323
|
enum = enum.map(&block) if block
|
326
|
-
enum.
|
324
|
+
enum.sum
|
327
325
|
end
|
328
326
|
|
329
327
|
##
|
@@ -419,7 +417,6 @@ module Minitest
|
|
419
417
|
end
|
420
418
|
end
|
421
419
|
|
422
|
-
|
423
420
|
##
|
424
421
|
# Create a benchmark that verifies that the performance is logarithmic.
|
425
422
|
#
|
data/lib/minitest/compress.rb
CHANGED
@@ -11,12 +11,12 @@ module Minitest
|
|
11
11
|
def compress orig
|
12
12
|
ary = orig
|
13
13
|
|
14
|
-
eswo = ->(
|
14
|
+
eswo = ->(a, n, off) { # each_slice_with_offset
|
15
15
|
if off.zero? then
|
16
|
-
|
16
|
+
a.each_slice n
|
17
17
|
else
|
18
18
|
# [ ...off... [...n...] [...n...] ... ]
|
19
|
-
front, back =
|
19
|
+
front, back = a.take(off), a.drop(off)
|
20
20
|
[front].chain back.each_slice n
|
21
21
|
end
|
22
22
|
}
|
@@ -29,16 +29,16 @@ module Minitest
|
|
29
29
|
|
30
30
|
order = index
|
31
31
|
.reject { |k, v| v.size == 1 } # { b: [1 3 5], c: [2 4 6] }
|
32
|
-
.sort_by { |k,
|
33
|
-
d =
|
34
|
-
[-d,
|
32
|
+
.sort_by { |k, a1| ### sort by max dist + min offset
|
33
|
+
d = a1.each_cons(2).sum { |a2, b| b-a2 }
|
34
|
+
[-d, a1.first]
|
35
35
|
} # b: [1 3 5] c: [2 4 6]
|
36
36
|
|
37
37
|
ranges = order
|
38
|
-
.map { |k,
|
39
|
-
|
38
|
+
.map { |k, a1| # [[1..2 3..4] [2..3 4..5]]
|
39
|
+
a1
|
40
40
|
.each_cons(2)
|
41
|
-
.map { |
|
41
|
+
.map { |a2, b| a2..b-1 }
|
42
42
|
}
|
43
43
|
|
44
44
|
big_ranges = ranges
|
@@ -50,7 +50,7 @@ module Minitest
|
|
50
50
|
culprits = big_ranges
|
51
51
|
.map { |r|
|
52
52
|
eswo[ary, r.size, r.begin] # [o1 s1 s1 s2 s2]
|
53
|
-
.chunk_while { |a,b| a == b }
|
53
|
+
.chunk_while { |a, b| a == b } # [[o1] [s1 s1] [s2 s2]]
|
54
54
|
.map { |a| [a.size, a.first] } # [[1 o1] [2 s1] [2 s2]]
|
55
55
|
}
|
56
56
|
.select { |chunks|
|
@@ -1,11 +1,11 @@
|
|
1
1
|
module Minitest
|
2
2
|
|
3
|
-
module ErrorOnWarning
|
4
|
-
def warn
|
3
|
+
module ErrorOnWarning # :nodoc:
|
4
|
+
def warn message, category: nil
|
5
5
|
message = "[#{category}] #{message}" if category
|
6
6
|
raise UnexpectedWarning, message
|
7
7
|
end
|
8
8
|
end
|
9
9
|
|
10
|
-
::Warning.singleton_class.prepend
|
10
|
+
::Warning.singleton_class.prepend ErrorOnWarning
|
11
11
|
end
|
data/lib/minitest/mock.rb
CHANGED
@@ -8,7 +8,7 @@ module Minitest # :nodoc:
|
|
8
8
|
# All mock objects are an instance of Mock
|
9
9
|
|
10
10
|
class Mock
|
11
|
-
alias
|
11
|
+
alias __respond_to? respond_to?
|
12
12
|
|
13
13
|
overridden_methods = %i[
|
14
14
|
===
|
@@ -93,7 +93,7 @@ module Minitest # :nodoc:
|
|
93
93
|
def expect name, retval, args = [], **kwargs, &blk
|
94
94
|
name = name.to_sym
|
95
95
|
|
96
|
-
if
|
96
|
+
if blk then
|
97
97
|
raise ArgumentError, "args ignored when block given" unless args.empty?
|
98
98
|
raise ArgumentError, "kwargs ignored when block given" unless kwargs.empty?
|
99
99
|
@expected_calls[name] << { :retval => retval, :block => blk }
|
@@ -106,7 +106,7 @@ module Minitest # :nodoc:
|
|
106
106
|
kwargs = args.pop
|
107
107
|
else
|
108
108
|
unless @@KW_WARNED then
|
109
|
-
from = caller.first
|
109
|
+
from = caller(1..1).first
|
110
110
|
warn "Using MT_KWARGS_HAC\K yet passing kwargs. From #{from}"
|
111
111
|
@@KW_WARNED = true
|
112
112
|
end
|
@@ -141,7 +141,7 @@ module Minitest # :nodoc:
|
|
141
141
|
|
142
142
|
def verify
|
143
143
|
@expected_calls.each do |name, expected|
|
144
|
-
actual = @actual_calls.fetch
|
144
|
+
actual = @actual_calls.fetch name, nil # defaults to []
|
145
145
|
raise MockExpectationError, "expected #{__call name, expected[0]}" unless actual
|
146
146
|
raise MockExpectationError, "expected #{__call name, expected[actual.size]}, got [#{__call name, actual}]" if
|
147
147
|
actual.size < expected.size
|
@@ -150,7 +150,7 @@ module Minitest # :nodoc:
|
|
150
150
|
end
|
151
151
|
|
152
152
|
def method_missing sym, *args, **kwargs, &block # :nodoc:
|
153
|
-
unless @expected_calls.key?
|
153
|
+
unless @expected_calls.key? sym then
|
154
154
|
if @delegator && @delegator.respond_to?(sym)
|
155
155
|
if kwargs.empty? then # FIX: drop this after 2.7 dead
|
156
156
|
return @delegator.public_send(sym, *args, &block)
|
@@ -172,9 +172,9 @@ module Minitest # :nodoc:
|
|
172
172
|
end
|
173
173
|
|
174
174
|
expected_args, expected_kwargs, retval, val_block =
|
175
|
-
expected_call.values_at
|
175
|
+
expected_call.values_at :args, :kwargs, :retval, :block
|
176
176
|
|
177
|
-
expected_kwargs = kwargs.
|
177
|
+
expected_kwargs = kwargs.to_h { |ak, av| [ak, Object] } if
|
178
178
|
Hash == expected_kwargs
|
179
179
|
|
180
180
|
if val_block then
|
@@ -197,7 +197,7 @@ module Minitest # :nodoc:
|
|
197
197
|
[sym, expected_kwargs.size, kwargs]
|
198
198
|
end
|
199
199
|
|
200
|
-
zipped_args = expected_args.zip
|
200
|
+
zipped_args = expected_args.zip args
|
201
201
|
fully_matched = zipped_args.all? { |mod, a|
|
202
202
|
mod === a or mod == a
|
203
203
|
}
|
@@ -212,10 +212,10 @@ module Minitest # :nodoc:
|
|
212
212
|
raise MockExpectationError, fmt % [sym, expected_kwargs.keys, kwargs.keys]
|
213
213
|
end
|
214
214
|
|
215
|
-
zipped_kwargs = expected_kwargs.
|
215
|
+
zipped_kwargs = expected_kwargs.to_h { |ek, ev|
|
216
216
|
av = kwargs[ek]
|
217
217
|
[ek, [ev, av]]
|
218
|
-
}
|
218
|
+
}
|
219
219
|
|
220
220
|
fully_matched = zipped_kwargs.all? { |ek, (ev, av)|
|
221
221
|
ev === av or ev == av
|
@@ -228,8 +228,8 @@ module Minitest # :nodoc:
|
|
228
228
|
|
229
229
|
@actual_calls[sym] << {
|
230
230
|
:retval => retval,
|
231
|
-
:args
|
232
|
-
:kwargs => zipped_kwargs.
|
231
|
+
:args => zipped_args.map { |e, a| e === a ? e : a },
|
232
|
+
:kwargs => zipped_kwargs.to_h { |k, (e, a)| [k, e === a ? e : a] },
|
233
233
|
}
|
234
234
|
|
235
235
|
retval
|
@@ -238,7 +238,7 @@ module Minitest # :nodoc:
|
|
238
238
|
def respond_to? sym, include_private = false # :nodoc:
|
239
239
|
return true if @expected_calls.key? sym.to_sym
|
240
240
|
return true if @delegator && @delegator.respond_to?(sym, include_private)
|
241
|
-
__respond_to?
|
241
|
+
__respond_to? sym, include_private
|
242
242
|
end
|
243
243
|
end
|
244
244
|
end
|