Project

General

Profile

Actions

Bug #13817

closed

test/unit breaks Hash

Added by rovf (Ronald Fischer) over 6 years ago. Updated over 6 years ago.

Status:
Closed
Target version:
-
ruby -v:
ruby 2.4.1p111 (2017-03-22 revision 58053) [x86_64-linux]
[ruby-core:82385]

Description

Consider the following program:

#!/usr/bin/env ruby
BEGIN {$VERBOSE = true}
require 'test/unit'
class Hash
  STDERR.puts method_defined?(:<<)
  alias << merge!
  STDERR.puts method_defined?(:<<)
end

In older Ruby versions (1.9.3, 2.3.3), the output of this program was:

false
true

In Ruby 2.4.1, the output is

false
~/work/stash/vp5/src/test/test_xx.rb:6: warning: method redefined; discarding old <<
true

Please note:

  1. The warning occurs, even though method_defined? tells us that no << method is in Hash.
  2. The warning disappears, when we do not require test/unit, which suggests that the problem is caused by test/unit
  3. Changing the offending line to alias :<< :merge! does not make any difference

Related issues 1 (0 open1 closed)

Related to Ruby master - Bug #11182: Refinement with alias causes strange behaviorClosedko1 (Koichi Sasada)Actions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0