Skip to content

Commit

Permalink
2.8 behaves differently for super + refinements
Browse files Browse the repository at this point in the history
  • Loading branch information
eregon committed Jul 27, 2020
1 parent f579cfc commit b0da11b
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions core/module/refine_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -980,6 +980,7 @@ def foo
result.should == [:B, :A, :LAST, :C]
end

ruby_version_is ""..."2.8" do
it "looks in the lexical scope refinements before other active refinements" do
refined_class = ModuleSpecs.build_refined_class(for_super: true)

Expand Down Expand Up @@ -1015,6 +1016,44 @@ def foo
end
end

ruby_version_is "2.8" do
# https://bugs.ruby-lang.org/issues/17007
it "does not look in the lexical scope refinements before other active refinements" do
refined_class = ModuleSpecs.build_refined_class(for_super: true)

refinement_local = Module.new do
refine refined_class do
def foo
[:LOCAL] + super
end
end
end

a = Module.new do
using refinement_local

def foo
[:A] + super
end
end

refinement = Module.new do
refine refined_class do
include a
end
end

result = nil
Module.new do
using refinement
result = refined_class.new.foo
end

result.should == [:A, :C]
end
end
end

it 'and alias aliases a method within a refinement module, but not outside it' do
Module.new do
using Module.new {
Expand Down

0 comments on commit b0da11b

Please sign in to comment.