Skip to content

Commit

Permalink
Add spec for overriding an optimized method through an already-prepen…
Browse files Browse the repository at this point in the history
…ded module
  • Loading branch information
eregon committed Apr 25, 2024
1 parent d33c6bb commit 507e968
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions spec/ruby/core/module/prepend_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,6 +75,26 @@ def foo
foo.call.should == 'm'
end

it "updates the optimized method when a prepended module is updated" do
out = ruby_exe(<<~RUBY)
module M; end
class Integer
prepend M
end
l = -> { 1 + 2 }
p l.call
M.module_eval do
def +(o)
$called = true
super(o)
end
end
p l.call
p $called
RUBY
out.should == "3\n3\ntrue\n"
end

it "updates the method when there is a base included method and the prepended module overrides it" do
base_module = Module.new do
def foo
Expand Down

0 comments on commit 507e968

Please sign in to comment.