diff options
author | nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-01-17 15:59:36 +0000 |
---|---|---|
committer | nagachika <nagachika@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-01-17 15:59:36 +0000 |
commit | 2054417ec66ffce4cd9b06cd2077f49487a3cd77 (patch) | |
tree | 7bce1d349ec08a7cec8acfbb23fe30975a34fc1a /test | |
parent | 9c6779f53eb485b4653fb750a01447155b9e8fe4 (diff) |
merge revision(s) 53164: [Backport #11657]
* vm_insnhelper.c (vm_call_method_each_type): should not set fastpath
with keyword arguments for VM_METHOD_TYPE_ATTRSET type methods.
Normally, we can not use keyword arguments for this kind of methods,
(obj.foo = 1), but we can set alias names for them.
[Bug #11657]
* test/ruby/test_keyword.rb: add a test for this fix.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_2@53567 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_keyword.rb | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/test/ruby/test_keyword.rb b/test/ruby/test_keyword.rb index 9c76e15c38..764bd959b1 100644 --- a/test/ruby/test_keyword.rb +++ b/test/ruby/test_keyword.rb @@ -576,4 +576,24 @@ class TestKeywordArguments < Test::Unit::TestCase h = method_for_test_to_hash_call_during_setup_complex_parameters k1: "foo", k2: "bar", sym => "baz" assert_equal ["foo", "bar", {sym => "baz"}], h, '[Bug #11027]' end + + class AttrSetTest + attr_accessor :foo + alias set_foo :foo= + end + + def test_attr_set_method_cache + obj = AttrSetTest.new + h = {a: 1, b: 2} + 2.times{ + obj.foo = 1 + assert_equal(1, obj.foo) + obj.set_foo 2 + assert_equal(2, obj.foo) + obj.set_foo(x: 1, y: 2) + assert_equal({x: 1, y: 2}, obj.foo) + obj.set_foo(x: 1, y: 2, **h) + assert_equal({x: 1, y: 2, **h}, obj.foo) + } + end end |