* object.c (rb_mod_{const,cvar}_defined, rb_obj_ivar_defined):

avoid inadvertent symbol creation in reflection methods.  based
  on a patch by Jeremy Evans at [ruby-core:38367].  [Feature #5072]
* vm_method.c (rb_mod_method_defined)
  (rb_mod_{public,private,protected}_method_defined)
  (obj_respond_to): ditto.
* parse.y (rb_check_id): new function returns already interned ID
  or 0.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@32621 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2011-07-22 12:06:42 +00:00
parent c276b73804
commit 34918aa832
8 changed files with 178 additions and 26 deletions

View file

@ -495,6 +495,9 @@ class TestModule < Test::Unit::TestCase
def test_const_get_invalid_name
c1 = Class.new
assert_raise(NameError) { c1.const_defined?(:foo) }
name = "gadzooks"
assert !Symbol.all_symbols.any? {|sym| sym.to_s == name}
assert_raise(NameError) { c1.const_defined?(name) }
end
def test_const_get_no_inherited