diff options
| author | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-11-27 02:54:02 +0000 |
|---|---|---|
| committer | yugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-11-27 02:54:02 +0000 |
| commit | 2f1d6e714a7478e9c4af4452e35a27b9a3f0c333 (patch) | |
| tree | 6f0977f9a84bc4d0ac8030c7458ff70a440b5485 /test/ruby | |
| parent | 06c11c287b48da6fab8974296530d2eaee93b5e5 (diff) | |
merges r24761 and r24999 from trunk into ruby_1_9_1.
--
* compile.c (iseq_compile_each): op_asgn to aref should return rhs.
[ruby-core:25387]
--
* compile.c (iseq_compile_each), parse.y (stmt, arg): arg_concat()
on op_asgn was inversed. [ruby-core:25629] [Bug #2050]
git-svn-id: http://svn.ruby-lang.org/repos/ruby/branches/ruby_1_9_1@25940 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby')
| -rw-r--r-- | test/ruby/test_assignment.rb | 8 | ||||
| -rw-r--r-- | test/ruby/test_basicinstructions.rb | 25 |
2 files changed, 33 insertions, 0 deletions
diff --git a/test/ruby/test_assignment.rb b/test/ruby/test_assignment.rb index b82cee81d..e38b20b28 100644 --- a/test/ruby/test_assignment.rb +++ b/test/ruby/test_assignment.rb @@ -77,6 +77,14 @@ class TestAssignment < Test::Unit::TestCase a,b,*c = *[*[]]; assert_equal([nil,nil,[]], [a,b,c]) a,b,*c = *[*[1]]; assert_equal([1,nil,[]], [a,b,c]) a,b,*c = *[*[1,2]]; assert_equal([1,2,[]], [a,b,c]) + + bug2050 = '[ruby-core:25629]' + a = Hash.new {[]} + b = [1, 2] + assert_equal([1, 2, 3], a[:x] += [*b, 3], bug2050) + assert_equal([1, 2, 3], a[:x], bug2050) + assert_equal([1, 2, 3, [1, 2, 3]], a[:x] <<= [*b, 3], bug2050) + assert_equal([1, 2, 3, [1, 2, 3]], a[:x], bug2050) end def test_yield diff --git a/test/ruby/test_basicinstructions.rb b/test/ruby/test_basicinstructions.rb index 90b034a90..eab9afc50 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 $~ |
