Skip to content

Commit

Permalink
Test for pre-singletonized procs gaining interfaces.
Browse files Browse the repository at this point in the history
This is a test that the fix for jrubyGH-4968 does not break existing
singleton procs' "attached" relationship. The self in the
singleton_method_added hook should still be the proc, rather than
a reattached value as in the fix.
  • Loading branch information
headius authored and Adithya Pentela committed Aug 25, 2019
1 parent ef3f1e3 commit 68e9b2f
Showing 1 changed file with 20 additions and 0 deletions.
20 changes: 20 additions & 0 deletions spec/java_integration/interfaces/implementation_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -342,6 +342,26 @@ def callIt

expect(interfaces).to include(SingleMethodInterface.java_class)
end

it "preserves singleton Proc behavior and callbacks" do
pr = proc { }
def pr.singleton_method_added(name)
(@names ||= []) << [name, self]
end

old_singleton_class = pr.singleton_class

r = Runnable.impl(&pr)

def pr.another_method; end

expect(pr.singleton_class).to eq old_singleton_class

expect(pr.instance_variable_get(:@names)).to eq [
[:singleton_method_added, pr],
[:another_method, pr]
]
end
end

describe "A bean-like Java interface" do
Expand Down

0 comments on commit 68e9b2f

Please sign in to comment.