summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authornobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-09-05 06:21:15 +0000
committernobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-09-05 06:21:15 +0000
commitc76e698fd8c086930f2b3092b1685d1521d148f4 (patch)
treebde483db81575d91c3c2766fcb5815b75fc2a389 /test
parent7a05e1ead3088b1b5be3cd497432cdc93c8f5352 (diff)
* compile.c (iseq_compile_each): op_asgn to aref should return rhs.
[ruby-core:25387] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@24761 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_basicinstructions.rb25
1 files changed, 25 insertions, 0 deletions
diff --git a/test/ruby/test_basicinstructions.rb b/test/ruby/test_basicinstructions.rb
index 5329828c18..36a3b2b51d 100644
--- a/test/ruby/test_basicinstructions.rb
+++ b/test/ruby/test_basicinstructions.rb
@@ -505,6 +505,14 @@ class TestBasicInstructions < Test::Unit::TestCase
:Bug1996
end
Bug1996 = '[ruby-dev:39163], [ruby-core:25143]'
+ def [](i)
+ @x
+ end
+ def []=(i, x)
+ @x = x
+ :Bug2050
+ end
+ Bug2050 = '[ruby-core:25387]'
end
def test_opassign2_1
@@ -575,6 +583,23 @@ class TestBasicInstructions < Test::Unit::TestCase
assert_equal 4, a[0]
end
+ def test_opassign1_2
+ x = OP.new
+ x[0] = nil
+ assert_equal 1, x[0] ||= 1, OP::Bug2050
+ assert_equal 1, x[0]
+ assert_equal 2, x[0] &&= 2, OP::Bug2050
+ assert_equal 2, x[0]
+ assert_equal 2, x[0] ||= 3, OP::Bug2050
+ assert_equal 2, x[0]
+ assert_equal 4, x[0] &&= 4, OP::Bug2050
+ assert_equal 4, x[0]
+ assert_equal 5, x[0] += 1, OP::Bug2050
+ assert_equal 5, x[0]
+ assert_equal 4, x[0] -= 1, OP::Bug2050
+ assert_equal 4, x[0]
+ end
+
def test_backref
/re/ =~ 'not match'
assert_nil $~