summaryrefslogtreecommitdiff
path: root/test
diff options
context:
space:
mode:
authoryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-11-27 02:54:02 +0000
committeryugui <yugui@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-11-27 02:54:02 +0000
commitdd1e757adb87340ac13354c3228a5c2e1c0b1bb4 (patch)
tree6f0977f9a84bc4d0ac8030c7458ff70a440b5485 /test
parentadc25ed110871abb5ba13fea789ee911dd8ce348 (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: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_1_9_1@25940 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r--test/ruby/test_assignment.rb8
-rw-r--r--test/ruby/test_basicinstructions.rb25
2 files changed, 33 insertions, 0 deletions
diff --git a/test/ruby/test_assignment.rb b/test/ruby/test_assignment.rb
index b82cee81d1..e38b20b285 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 90b034a90b..eab9afc50c 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 $~