Skip to content

Commit 5ebccee

Browse files
committed
check zeros
raise when assert_linear_performance measures only zeros to check the following error: ``` 1) Error: TestRegexp#test_linear_performance: Test::Unit::ProxyError: nil can't be coerced into Integer /home/opc/ruby/src/master/test/ruby/test_regexp.rb:2301:in 'TestRegexp#test_linear_performance' ```
1 parent f045a82 commit 5ebccee

1 file changed

Lines changed: 3 additions & 2 deletions

File tree

tool/lib/core_assertions.rb

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -911,10 +911,11 @@ def assert_linear_performance(seq, rehearsal: nil, pre: ->(n) {n})
911911

912912
first = seq.first
913913
*arg = pre.call(first)
914-
times = (0..(rehearsal || (2 * first))).map do
914+
raw_times = (0..(rehearsal || (2 * first))).map do
915915
measure[arg, "rehearsal"].nonzero?
916916
end
917-
times.compact!
917+
times = raw_times.compact
918+
raise "all measurements are zero: #{raw_times.inspect}" if times.empty?
918919
tmin, tmax = times.minmax
919920

920921
# safe_factor * tmax * rehearsal_time_variance_factor(equals to 1 when variance is small)

0 commit comments

Comments
 (0)