Skip to content
Permalink

Comparing changes

Choose two branches to see what’s changed or to start a new pull request. If you need to, you can also or learn more about diff comparisons.

Open a pull request

Create a new pull request by comparing changes across two branches. If you need to, you can also . Learn more about diff comparisons here.
base repository: jruby/jruby
Failed to load repositories. Confirm that selected base ref is valid, then try again.
Loading
base: 935553d19c65
Choose a base ref
...
head repository: jruby/jruby
Failed to load repositories. Confirm that selected head ref is valid, then try again.
Loading
compare: 1d90f9fe8817
Choose a head ref
  • 2 commits
  • 2 files changed
  • 1 contributor

Commits on Jul 15, 2015

  1. spec for regression in proc to iface optimization

    complements commit a741a82
    kares committed Jul 15, 2015
    Copy the full SHA
    c79610c View commit details
  2. Copy the full SHA
    1d90f9f View commit details
Showing with 34 additions and 7 deletions.
  1. +14 −0 spec/java_integration/fixtures/iface/SingleMethodInterfaceWithArg.java
  2. +20 −7 spec/java_integration/interfaces/implementation_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
package java_integration.fixtures.iface;

public interface SingleMethodInterfaceWithArg {
public static class Caller {
public static void call(SingleMethodInterfaceWithArg iface) {
call(42, iface);
}
public static <V> void call(V arg, SingleMethodInterfaceWithArg iface) {
iface.doSome(arg);
}
}

<V> void doSome(final V arg) ;
}
27 changes: 20 additions & 7 deletions spec/java_integration/interfaces/implementation_spec.rb
Original file line number Diff line number Diff line change
@@ -174,23 +174,36 @@ def callIt
end

it "should be implementable with .impl" do
impl = SingleMethodInterface.impl {|name| name}
impl = SingleMethodInterface.impl { |name| name }
impl.should be_kind_of(SingleMethodInterface)
SingleMethodInterface.should === impl

UsesSingleMethodInterface.callIt(impl).should == :callIt
end

it "should allow assignable equivalents to be passed to a method" do
impl = DescendantOfSingleMethodInterface.impl {|name| name}
impl = DescendantOfSingleMethodInterface.impl { |name| name }
impl.should be_kind_of(SingleMethodInterface)
DescendantOfSingleMethodInterface.should === impl
UsesSingleMethodInterface.callIt(impl).should == :callIt
UsesSingleMethodInterface.new.callIt2(impl).should == :callIt
end

it "passes correct arguments to proc .impl" do
Java::java.io.File.new('.').list do |dir, name| # FilenameFilter
dir.should be_kind_of(java.io.File)
name.should be_kind_of(String)
true # boolean accept(File dir, String name)
end

caller = Java::java_integration.fixtures.iface.SingleMethodInterfaceWithArg::Caller

caller.call { |arg| arg.should == 42 }
caller.call('x') { |arg| arg.should == 'x' }
end

it "should maintain Ruby object equality when passed through Java and back" do
result = SingleMethodInterface.impl {|name| name}
result = SingleMethodInterface.impl { |name| name }
callable = mock "callable"
callable.should_receive(:call).and_return result
UsesSingleMethodInterface.new.callIt3(callable).should == result
@@ -210,7 +223,7 @@ def callIt
interfaces.concat(cls.interfaces)
cls = cls.superclass
end

interfaces.should include(SingleMethodInterface.java_class)
end
end
@@ -688,15 +701,15 @@ def bar
lambda {c2.new}.should_not raise_error
end
end

it "returns the Java class implementing the interface for .java_class" do
cls = Class.new do
include java.lang.Runnable
end
obj = cls.new

java_cls = obj.java_class

java_cls.interfaces.should include(java.lang.Runnable.java_class)
end
end