summaryrefslogtreecommitdiff
path: root/test/ruby
diff options
context:
space:
mode:
authorJeremy Evans <code@jeremyevans.net>2020-06-01 15:54:47 -0700
committerJeremy Evans <code@jeremyevans.net>2020-06-18 08:22:40 -0700
commitb6d6b896159390014020caac69fa465029af5460 (patch)
tree174526655d9b2e690822e4ba1c925c158a0e1202 /test/ruby
parent95dc9c07f3a895f45cfb5dab235cd78f157a9e51 (diff)
Allow refining a frozen class
Doing so modifies the class's method table, but not in a way that should be detectable from Ruby, so it may be safe to avoid checking if the class is frozen. Fixes [Bug #11669]
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/3175
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_refinement.rb33
1 files changed, 33 insertions, 0 deletions
diff --git a/test/ruby/test_refinement.rb b/test/ruby/test_refinement.rb
index 51231bd56c..dd443b7945 100644
--- a/test/ruby/test_refinement.rb
+++ b/test/ruby/test_refinement.rb
@@ -2405,6 +2405,39 @@ class TestRefinement < Test::Unit::TestCase
end
end
+ def test_refine_frozen_class
+ singleton_class.instance_variable_set(:@x, self)
+ class << self
+ c = Class.new do
+ def foo
+ :cfoo
+ end
+ end
+ foo = Module.new do
+ refine c do
+ def foo
+ :rfoo
+ end
+ end
+ end
+ using foo
+ @x.assert_equal(:rfoo, c.new.foo)
+ c.freeze
+ foo.module_eval do
+ refine c do
+ def foo
+ :rfoo2
+ end
+ def bar
+ :rbar
+ end
+ end
+ end
+ @x.assert_equal(:rfoo2, c.new.foo)
+ @x.assert_equal(:rbar, c.new.bar, '[ruby-core:71391] [Bug #11669]')
+ end
+ end
+
private
def eval_using(mod, s)