From c76e698fd8c086930f2b3092b1685d1521d148f4 Mon Sep 17 00:00:00 2001 From: nobu Date: Sat, 5 Sep 2009 06:21:15 +0000 Subject: * 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 --- test/ruby/test_basicinstructions.rb | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) (limited to 'test') 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 $~ -- cgit v1.2.3