jruby
jruby copied to clipboard
Keyword arguments arity error in drb tests
There's an arity error in the drb tests when running on JRuby 10 (have not tested 9.4):
$ bundle exec ruby -Ilib:test/lib test/drb/test_drb.rb -n test_bug16634
Loaded suite test/drb/test_drb
Started
E
===========================================================================================================================================================================================================================================================================================================================================
Error: test_bug16634(DRbTests::TestBug16634): ArgumentError: wrong number of arguments (given 1, expected 0)
(druby://localhost:51803) /Users/headius/work/drb/test/drb/ut_drb.rb:151:in 'keyword_test1'
(druby://localhost:51803) /Users/headius/work/drb/lib/drb/drb.rb:1713:in 'perform_without_block'
(druby://localhost:51803) /Users/headius/work/drb/lib/drb/drb.rb:1669:in 'perform'
(druby://localhost:51803) /Users/headius/work/drb/lib/drb/drb.rb:1758:in 'block in main_loop'
(druby://localhost:51803) org/jruby/RubyKernel.java:1658:in 'loop'
(druby://localhost:51803) /Users/headius/work/drb/lib/drb/drb.rb:1754:in 'block in main_loop'
test/drb/test_drb.rb:364:in 'test_bug16634'
361: end
362:
363: def test_bug16634
=> 364: assert_equal(42, @there.keyword_test1(a: 42))
365: assert_equal("default", @there.keyword_test2)
366: assert_equal(42, @there.keyword_test2(b: 42))
367: assert_equal({:a=>42, :b=>42}, @there.keyword_test3(a: 42, b: 42))
I have not investigated this yet but it may be a method generated by drb as a remote binding, and that could be a clue about why it sees this as a mismatched arity.
It seems that Marshal.load(Marshal.dump(ruby2_keywords_hash)) loses ruby2_keywords information:
class DRbEx
def keyword_test1(a:)
a
end
end
class Wrapper
def initialize(object)
@object = object
end
ruby2_keywords def method_missing(method, *args, &block)
args = args.collect {|arg| Marshal.load(Marshal.dump(arg))}
p Hash.ruby2_keywords_hash?(args[0]) # This is true with CRuby but false with JRuby
@object.__send__(method, *args, &block)
end
end
Wrapper.new(DRbEx.new).keyword_test1(a: 42)
@kou Thanks for that help. Hopefully we can fix for 10.0.1.0.
Fixed with specs in #8905!