mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* eval_error.c (rb_print_undef_str): new function to raise
NameError for undefined method. * load.c (rb_mod_autoload_p), object.c (rb_mod_const_get), variable.c (rb_f_untrace_var, set_const_visibility), vm_method.c (rb_mod_{remove,undef,alias}_method, set_method_visibility): remove inadvertent symbol creation. based on the first patch by Jeremy Evans at [ruby-core:38447]. [Feature #5089] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32686 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
298349d03b
commit
8603c5934a
10 changed files with 121 additions and 10 deletions
|
@ -197,4 +197,37 @@ class TestSymbol < Test::Unit::TestCase
|
|||
assert !Symbol.all_symbols.any? {|sym| sym.to_s == str}, msg
|
||||
end
|
||||
end
|
||||
|
||||
def test_no_inadvertent_symbol_creation3
|
||||
feature5089 = '[ruby-core:38447]'
|
||||
c = Class.new do
|
||||
def self.alias_method(str)
|
||||
super(:puts, str)
|
||||
end
|
||||
end
|
||||
s = "gadzoooks"
|
||||
{:alias_method => ["#{s}1", NameError],
|
||||
:autoload? => ["#{s}2", nil],
|
||||
:const_get => ["A#{s}3", NameError],
|
||||
:private_class_method => ["#{s}4", NameError],
|
||||
:private_constant => ["#{s}5", NameError],
|
||||
:private => ["#{s}6", NameError],
|
||||
:protected => ["#{s}7", NameError],
|
||||
:public => ["#{s}8", NameError],
|
||||
:public_class_method => ["#{s}9", NameError],
|
||||
:public_constant => ["#{s}10", NameError],
|
||||
:remove_method => ["#{s}11", NameError],
|
||||
:undef_method => ["#{s}12", NameError],
|
||||
:untrace_var => ["#{s}13", NameError],
|
||||
}.each do |meth, arr|
|
||||
str, ret = arr
|
||||
msg = "#{meth}(#{str}) #{feature5089}"
|
||||
if ret.is_a?(Class) && (ret < Exception)
|
||||
assert_raises(ret){c.send(meth, str)}
|
||||
else
|
||||
assert(c.send(meth, str) == ret, msg)
|
||||
end
|
||||
assert !Symbol.all_symbols.any? {|sym| sym.to_s == str}, msg
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue