Skip to content

Commit

Permalink
Showing 2 changed files with 21 additions and 9 deletions.
10 changes: 1 addition & 9 deletions core/src/main/java/org/jruby/ext/timeout/Timeout.java
Original file line number Diff line number Diff line change
@@ -85,15 +85,7 @@ public void load(Ruby runtime, boolean wrap) throws IOException {
public static class TimeoutToplevel {
@JRubyMethod(required = 1, optional = 1, visibility = PRIVATE)
public static IRubyObject timeout(ThreadContext context, IRubyObject self, IRubyObject[] args, Block block) {
switch (args.length) {
case 1:
return Timeout.timeout(context, self, args[0], block);
case 2:
return Timeout.timeout(context, self, args[0], args[1], block);
default:
Arity.raiseArgumentError(context.runtime, args.length, 1, 2);
return context.runtime.getNil();
}
return Helpers.invoke(context, context.runtime.getModule("Timeout"), "timeout", args, block);
}
}

Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
require 'timeout'

describe "Kernel#timeout" do
it "dynamically dispatches to Timeout::timeout" do
begin
old_verbose = $VERBOSE
$VERBOSE = nil
old_timeout = Timeout
new_timeout = Module.new do
def self.timeout(*); "foo"; end
end
Object.const_set :Timeout, new_timeout

expect(Kernel.send(:timeout, 0)).to eq "foo"
ensure
Object.const_set :Timeout, old_timeout
$VERBOSE = old_verbose
end
end
end

0 comments on commit 5f175de

Please sign in to comment.