diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-06-06 08:07:13 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2014-06-06 08:07:13 +0000 |
commit | 199f814f32e97b2fed528801c0ad2c84c1e5f8a6 (patch) | |
tree | 891c580dfbc7836a0aa774dbc84e838296c83175 /test/ruby | |
parent | 7342e78ea6650a6a58f8ad448df01d448383496d (diff) | |
download | ruby-199f814f32e97b2fed528801c0ad2c84c1e5f8a6.tar.gz |
compile.c, parse.y: private op assign
* compile.c (iseq_compile_each), parse.y (new_attr_op_assign_gen):
allow op assign to a private attribute.
[ruby-core:62949] [Bug #9907]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@46365 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby')
-rw-r--r-- | test/ruby/test_assignment.rb | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/test/ruby/test_assignment.rb b/test/ruby/test_assignment.rb index 604464bbd3..c6f1cd1bc7 100644 --- a/test/ruby/test_assignment.rb +++ b/test/ruby/test_assignment.rb @@ -102,8 +102,12 @@ class TestAssignment < Test::Unit::TestCase end def test_assign_private_self + bug9907 = '[ruby-core:62949] [Bug #9907]' + o = Object.new class << o + def foo; 42; end + def [](i); 42; end private def foo=(a); 42; end def []=(i, a); 42; end @@ -122,6 +126,20 @@ class TestAssignment < Test::Unit::TestCase assert_nothing_raised(NoMethodError) { assert_equal(1, o.instance_eval {self[0] = 1}) } + + assert_nothing_raised(NoMethodError, bug9907) { + assert_equal(43, o.instance_eval {self.foo += 1}) + } + assert_nothing_raised(NoMethodError, bug9907) { + assert_equal(1, o.instance_eval {self.foo &&= 1}) + } + + assert_nothing_raised(NoMethodError, bug9907) { + assert_equal(43, o.instance_eval {self[0] += 1}) + } + assert_nothing_raised(NoMethodError, bug9907) { + assert_equal(1, o.instance_eval {self[0] &&= 1}) + } end def test_yield |