summaryrefslogtreecommitdiff
path: root/test/ruby/test_array.rb
diff options
context:
space:
mode:
authorNobuyoshi Nakada <[email protected]>2021-05-22 14:32:22 +0900
committerNobuyoshi Nakada <[email protected]>2021-05-22 14:34:23 +0900
commitc4162a4cb82278b0674452304c96b5775d5b7d6d (patch)
treeec74f9073f01c757f5dd31e76eaec5b755162603 /test/ruby/test_array.rb
parent8b00bfb7c2c33827490c78a16c44b102cb0d724b (diff)
Refined portability of test for [Bug #17739]
The order of arguments to callback of qsort is not defined. That means `a` may not be 3 at all.
Diffstat (limited to 'test/ruby/test_array.rb')
-rw-r--r--test/ruby/test_array.rb5
1 files changed, 3 insertions, 2 deletions
diff --git a/test/ruby/test_array.rb b/test/ruby/test_array.rb
index 0a9ba90564..8f05f9cebd 100644
--- a/test/ruby/test_array.rb
+++ b/test/ruby/test_array.rb
@@ -1667,10 +1667,11 @@ class TestArray < Test::Unit::TestCase
array = [1, 2, 3, 4, 5]
frozen_array = nil
assert_raise(FrozenError) do
+ count = 0
array.sort! do |a, b|
- array.freeze if a == 3
+ array.freeze if (count += 1) == 6
frozen_array ||= array.map.to_a if array.frozen?
- 1
+ b <=> a
end
end
assert_equal(frozen_array, array)