diff options
author | mame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-01-15 06:25:42 +0000 |
---|---|---|
committer | mame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2018-01-15 06:25:42 +0000 |
commit | c2052b027c8e4c8e95bb34e93b2e745a79eaaceb (patch) | |
tree | c8bbaef5cff6e85dddb35d2efe7ed254b4310126 /test | |
parent | 53c6960ddf6101f2711c5804a2842c3640a49c9c (diff) | |
download | ruby-c2052b027c8e4c8e95bb34e93b2e745a79eaaceb.tar.gz |
parse.y: Fix a bug of `obj[42, &blk] ||= foo bar`
Follow up of r28123 (!)
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@61841 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_parse.rb | 24 |
1 files changed, 24 insertions, 0 deletions
diff --git a/test/ruby/test_parse.rb b/test/ruby/test_parse.rb index 41aad0050d..e843c66242 100644 --- a/test/ruby/test_parse.rb +++ b/test/ruby/test_parse.rb @@ -457,6 +457,30 @@ class TestParse < Test::Unit::TestCase end end + def test_op_asgn1_with_block + t = Object.new + a = [] + blk = proc {|x| a << x } + def t.[](_) + yield(:aref) + nil + end + def t.[]=(_, _) + yield(:aset) + end + def t.dummy(_) + end + eval <<-END, nil, __FILE__, __LINE__+1 + t[42, &blk] ||= 42 + END + assert_equal([:aref, :aset], a) + a.clear + eval <<-END, nil, __FILE__, __LINE__+1 + t[42, &blk] ||= t.dummy 42 # command_asgn test + END + assert_equal([:aref, :aset], a) + end + def test_backquote t = Object.new |