mirror of
https://github.com/ruby/ruby.git
synced 2025-09-21 03:24:00 +02:00
vm_method.c: preserve encodings
* vm_method.c (rb_method_entry_make): preserve encodings of constant names in warning messages. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@48573 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
5d4aad2b1b
commit
f2fc80cebe
2 changed files with 13 additions and 9 deletions
|
@ -49,11 +49,15 @@ class TestConst < Test::Unit::TestCase
|
|||
|
||||
def test_redefinition
|
||||
c = Class.new
|
||||
c.const_set(:X, 1)
|
||||
assert_output(nil, <<-WARNING) {c.const_set(:X, 2)}
|
||||
#{__FILE__}:#{__LINE__-1}: warning: already initialized constant #{c}::X
|
||||
#{__FILE__}:#{__LINE__-3}: warning: previous definition of X was here
|
||||
name = "X\u{5b9a 6570}"
|
||||
c.const_set(name, 1)
|
||||
prev_line = __LINE__ - 1
|
||||
EnvUtil.with_default_internal(Encoding::UTF_8) do
|
||||
assert_output(nil, <<-WARNING) {c.const_set(name, 2)}
|
||||
#{__FILE__}:#{__LINE__-1}: warning: already initialized constant #{c}::#{name}
|
||||
#{__FILE__}:#{prev_line}: warning: previous definition of #{name} was here
|
||||
WARNING
|
||||
end
|
||||
code = <<-PRE
|
||||
olderr = $stderr.dup
|
||||
$stderr.reopen(File::NULL, "wb")
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue