variable.c: tmp_classpath

* variable.c: store anonymous class path in tmp_classpath but not in
  classpath.  [ruby-core:42865][Bug #6078]


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@36574 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
nobu 2012-07-30 05:24:24 +00:00
parent 48d7aa4ae9
commit 83940fc310
3 changed files with 61 additions and 11 deletions

View file

@ -363,6 +363,23 @@ class TestModule < Test::Unit::TestCase
assert_equal("TestModule::User", User.name)
end
def test_classpath
m = Module.new
n = Module.new
m.const_set(:N, n)
assert_nil(m.name)
assert_nil(n.name)
assert_equal([:N], m.constants)
m.module_eval("module O end")
assert_equal([:N, :O], m.constants)
assert_nil(m::N.name)
assert_match(/\A(?:#<Module:.*>::)?O\z/, m::O.name)
self.class.const_set(:M, m)
prefix = self.class.name + "::M::"
assert_equal(prefix+"N", m.const_get(:N).name)
assert_equal(prefix+"O", m.const_get(:O).name)
end
def test_private_class_method
assert_raise(ExpectedException) { AClass.cm1 }
assert_raise(ExpectedException) { AClass.cm3 }