diff options
Diffstat (limited to 'test/ruby/test_class.rb')
| -rw-r--r-- | test/ruby/test_class.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/test/ruby/test_class.rb b/test/ruby/test_class.rb index 3f18294e0f..55940a8891 100644 --- a/test/ruby/test_class.rb +++ b/test/ruby/test_class.rb @@ -240,4 +240,22 @@ class TestClass < Test::Unit::TestCase def test_nested_class_removal assert_normal_exit('File.__send__(:remove_const, :Stat); at_exit{File.stat(".")}; GC.start') end + + class PrivateClass + end + private_constant :PrivateClass + + def test_redefine_private_class + assert_raise(NameError) do + eval("class ::TestClass::PrivateClass; end") + end + eval <<-END + class ::TestClass + class PrivateClass + def foo; 42; end + end + end + END + assert_equal(42, PrivateClass.new.foo) + end end |
