Skip to content

Commit

Permalink
Showing 1 changed file with 34 additions and 9 deletions.
43 changes: 34 additions & 9 deletions core/src/test/java/org/jruby/test/TestMethodFactories.java
Original file line number Diff line number Diff line change
@@ -30,8 +30,10 @@

import org.jruby.CompatVersion;
import org.jruby.Ruby;
import org.jruby.RubyMethod;
import org.jruby.RubyModule;
import org.jruby.anno.JRubyMethod;
import org.jruby.internal.runtime.methods.DynamicMethod;
import org.jruby.runtime.ThreadContext;
import org.jruby.runtime.builtin.IRubyObject;

@@ -55,15 +57,6 @@ public void testReflectionMethodFactory() {
confirmMethods(mod);
}

// #1194: ClassFormatError with Nokogiri 1.6.0
public void testVersionedMethods() {
RubyModule mod = runtime.defineModule("GH1194");

mod.defineAnnotatedMethods(VersionedMethods.class);

assertNotNull(mod.searchMethod("method"));
}

private void confirmMethods(RubyModule mod) {
ThreadContext context = runtime.getCurrentContext();

@@ -86,6 +79,29 @@ public static IRubyObject four_arg_method(IRubyObject self, IRubyObject[] obj) {
}
}

public static class GH3463Module {
@JRubyMethod(module = true)
public static IRubyObject a_module_method(IRubyObject self) {
return self;
}
}

// Module methods define a second copy on singleton with proper implClass
// jruby/jruby#3463
public void testModuleMethodOwner() {
RubyModule mod = runtime.defineModule("GH3463Module");

mod.defineAnnotatedMethods(GH3463Module.class);

DynamicMethod method = mod.getSingletonClass().searchMethod("a_module_method");

assertEquals(mod.getSingletonClass(), method.getImplementationClass());

RubyMethod rubyMethod = (RubyMethod)mod.method(runtime.newSymbol("a_module_method"));

assertEquals(mod.getSingletonClass(), rubyMethod.owner(runtime.getCurrentContext()));
}

public static class VersionedMethods {
@JRubyMethod(name = "method", compat = CompatVersion.RUBY1_8)
public static IRubyObject method18(IRubyObject self) {
@@ -96,4 +112,13 @@ public static IRubyObject method19(IRubyObject self) {
return self;
}
}

// #1194: ClassFormatError with Nokogiri 1.6.0
public void testVersionedMethods() {
RubyModule mod = runtime.defineModule("GH1194");

mod.defineAnnotatedMethods(VersionedMethods.class);

assertNotNull(mod.searchMethod("method"));
}
}

0 comments on commit 07d50d1

Please sign in to comment.