ruby-changes:66294
From: Nobuyoshi <ko1@a...>
Date: Sat, 22 May 2021 14:35:28 +0900 (JST)
Subject: [ruby-changes:66294] c4162a4cb8 (master): Refined portability of test for [Bug #17739]
https://git.ruby-lang.org/ruby.git/commit/?id=c4162a4cb8 From c4162a4cb82278b0674452304c96b5775d5b7d6d Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada <nobu@r...> Date: Sat, 22 May 2021 14:32:22 +0900 Subject: 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. --- test/ruby/test_array.rb | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/test/ruby/test_array.rb b/test/ruby/test_array.rb index 0a9ba90..8f05f9c 100644 --- a/test/ruby/test_array.rb +++ b/test/ruby/test_array.rb @@ -1667,10 +1667,11 @@ class TestArray < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_array.rb#L1667 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) -- cgit v1.1 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/