Skip to content

Commit

Permalink
C method should accept a keyword hash (for compatibility with 2.6)
Browse files Browse the repository at this point in the history
  • Loading branch information
mame authored and jeremyevans committed Sep 6, 2019
1 parent c5555e2 commit 437ff40
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 9 deletions.
16 changes: 8 additions & 8 deletions test/ruby/test_keyword.rb
Expand Up @@ -261,7 +261,7 @@ def initialize(*args)
end
end
assert_equal([], c[**{}].args)
assert_equal([], c[**kw].args)
assert_equal([{}], c[**kw].args)
assert_equal([h], c[**h].args)
assert_equal([h], c[a: 1].args)
assert_equal([h2], c[**h2].args)
Expand All @@ -272,7 +272,7 @@ def initialize(*args)
def initialize; end
end
assert_nil(c[**{}].args)
assert_nil(c[**kw].args)
assert_raise(ArgumentError) { c[**kw] }
assert_raise(ArgumentError) { c[**h] }
assert_raise(ArgumentError) { c[a: 1] }
assert_raise(ArgumentError) { c[**h2] }
Expand All @@ -285,7 +285,7 @@ def initialize(args)
end
end
assert_raise(ArgumentError) { c[**{}] }
assert_raise(ArgumentError) { c[**kw] }
assert_equal(kw, c[**kw].args)
assert_equal(h, c[**h].args)
assert_equal(h, c[a: 1].args)
assert_equal(h2, c[**h2].args)
Expand All @@ -311,7 +311,7 @@ def initialize(arg, **args)
end
end
assert_raise(ArgumentError) { c[**{}] }
assert_raise(ArgumentError) { c[**kw] }
assert_equal([kw, kw], c[**kw].args)
assert_equal([h, kw], c[**h].args)
assert_equal([h, kw], c[a: 1].args)
assert_equal([h2, kw], c[**h2].args)
Expand Down Expand Up @@ -343,7 +343,7 @@ def c.m(*args)
args
end
assert_equal([], c.method(:m)[**{}])
assert_equal([], c.method(:m)[**kw])
assert_equal([{}], c.method(:m)[**kw])
assert_equal([h], c.method(:m)[**h])
assert_equal([h], c.method(:m)[a: 1])
assert_equal([h2], c.method(:m)[**h2])
Expand All @@ -353,7 +353,7 @@ def c.m(*args)
c.singleton_class.remove_method(:m)
def c.m; end
assert_nil(c.method(:m)[**{}])
assert_nil(c.method(:m)[**kw])
assert_raise(ArgumentError) { c.method(:m)[**kw] }
assert_raise(ArgumentError) { c.method(:m)[**h] }
assert_raise(ArgumentError) { c.method(:m)[a: 1] }
assert_raise(ArgumentError) { c.method(:m)[**h2] }
Expand All @@ -365,7 +365,7 @@ def c.m(args)
args
end
assert_raise(ArgumentError) { c.method(:m)[**{}] }
assert_raise(ArgumentError) { c.method(:m)[**kw] }
assert_equal(kw, c.method(:m)[**kw])
assert_equal(h, c.method(:m)[**h])
assert_equal(h, c.method(:m)[a: 1])
assert_equal(h2, c.method(:m)[**h2])
Expand All @@ -389,7 +389,7 @@ def c.m(arg, **args)
[arg, args]
end
assert_raise(ArgumentError) { c.method(:m)[**{}] }
assert_raise(ArgumentError) { c.method(:m)[**kw] }
assert_equal([kw, kw], c.method(:m)[**kw])
assert_equal([h, kw], c.method(:m)[**h])
assert_equal([h, kw], c.method(:m)[a: 1])
assert_equal([h2, kw], c.method(:m)[**h2])
Expand Down
2 changes: 1 addition & 1 deletion vm_insnhelper.c
Expand Up @@ -2227,7 +2227,7 @@ vm_call_cfunc(rb_execution_context_t *ec, rb_control_frame_t *reg_cfp, struct rb
{
RB_DEBUG_COUNTER_INC(ccf_cfunc);

CALLER_SETUP_ARG(reg_cfp, calling, ci, 1);
CALLER_SETUP_ARG(reg_cfp, calling, ci, 0);
return vm_call_cfunc_with_frame(ec, reg_cfp, calling, ci, cc);
}

Expand Down

0 comments on commit 437ff40

Please sign in to comment.