ruby-changes:57591
From: Yusuke <ko1@a...>
Date: Fri, 6 Sep 2019 11:45:11 +0900 (JST)
Subject: [ruby-changes:57591] 437ff40879 (master): C method should accept a keyword hash (for compatibility with 2.6)
https://git.ruby-lang.org/ruby.git/commit/?id=437ff40879 From 437ff408790d5426e0ee03a4b22171bf745471a7 Mon Sep 17 00:00:00 2001 From: Yusuke Endoh <mame@r...> Date: Thu, 5 Sep 2019 16:54:43 +0900 Subject: C method should accept a keyword hash (for compatibility with 2.6) diff --git a/test/ruby/test_keyword.rb b/test/ruby/test_keyword.rb index 98e121f..5945a3b 100644 --- a/test/ruby/test_keyword.rb +++ b/test/ruby/test_keyword.rb @@ -261,7 +261,7 @@ class TestKeywordArguments < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_keyword.rb#L261 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) @@ -272,7 +272,7 @@ class TestKeywordArguments < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_keyword.rb#L272 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] } @@ -285,7 +285,7 @@ class TestKeywordArguments < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_keyword.rb#L285 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) @@ -311,7 +311,7 @@ class TestKeywordArguments < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_keyword.rb#L311 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) @@ -343,7 +343,7 @@ class TestKeywordArguments < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_keyword.rb#L343 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]) @@ -353,7 +353,7 @@ class TestKeywordArguments < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_keyword.rb#L353 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] } @@ -365,7 +365,7 @@ class TestKeywordArguments < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_keyword.rb#L365 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]) @@ -389,7 +389,7 @@ class TestKeywordArguments < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_keyword.rb#L389 [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]) diff --git a/vm_insnhelper.c b/vm_insnhelper.c index f8d68cc..8435948 100644 --- a/vm_insnhelper.c +++ b/vm_insnhelper.c @@ -2227,7 +2227,7 @@ vm_call_cfunc(rb_execution_context_t *ec, rb_control_frame_t *reg_cfp, struct rb https://github.com/ruby/ruby/blob/trunk/vm_insnhelper.c#L2227 { 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); } -- cgit v0.10.2 -- ML: ruby-changes@q... Info: http://www.atdot.net/~ko1/quickml/