diff options
author | glass <glass@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-12-03 04:55:51 +0000 |
---|---|---|
committer | glass <glass@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2013-12-03 04:55:51 +0000 |
commit | 95f983f6d0e5f1b2c9c26950cbfaa7cf323d3f1c (patch) | |
tree | 24b206ffb4466083cce931b783cc3c4ac61f5e70 /test/ruby | |
parent | 6edaf997e36f9d5b64f0e1349c987432c521f408 (diff) | |
download | ruby-95f983f6d0e5f1b2c9c26950cbfaa7cf323d3f1c.tar.gz |
* array.c (ary_add_hash): set and return values because string keys
will be frozen. [ruby-core:58809] [Bug #9202]
* array.c (rb_ary_uniq_bang): ditto.
* array.c (rb_ary_or): ditto.
* array.c (rb_ary_uniq): ditto.
* test/ruby/test_array.rb: tests for above.
The patch is from normalperson (Eric Wong).
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@43969 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby')
-rw-r--r-- | test/ruby/test_array.rb | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/test/ruby/test_array.rb b/test/ruby/test_array.rb index 9411c6a088..45013df412 100644 --- a/test/ruby/test_array.rb +++ b/test/ruby/test_array.rb @@ -1507,6 +1507,13 @@ class TestArray < Test::Unit::TestCase assert_equal(d, c) assert_equal(@cls[1, 2, 3], @cls[1, 2, 3].uniq) + + a = %w(a a) + b = a.uniq + assert_equal(%w(a a), a) + assert(a.none?(&:frozen?)) + assert_equal(%w(a), b) + assert(b.none?(&:frozen?)) end def test_uniq_with_block @@ -1527,6 +1534,13 @@ class TestArray < Test::Unit::TestCase assert_equal([1,3], a) assert_equal([1], b) assert_not_same(a, b) + + a = %w(a a) + b = a.uniq {|v| v } + assert_equal(%w(a a), a) + assert(a.none?(&:frozen?)) + assert_equal(%w(a), b) + assert(b.none?(&:frozen?)) end def test_uniq! @@ -1573,6 +1587,13 @@ class TestArray < Test::Unit::TestCase a.sort_by!{|e| e[:c]} a.uniq! {|e| e[:c]} end + + a = %w(a a) + b = a.uniq + assert_equal(%w(a a), a) + assert(a.none?(&:frozen?)) + assert_equal(%w(a), b) + assert(b.none?(&:frozen?)) end def test_uniq_bang_with_block @@ -1594,6 +1615,12 @@ class TestArray < Test::Unit::TestCase b = a.uniq! {|v| v.even? } assert_equal([1,2], a) assert_equal(nil, b) + + a = %w(a a) + b = a.uniq! {|v| v } + assert_equal(%w(a), b) + assert_same(a, b) + assert b.none?(&:frozen?) end def test_uniq_bang_with_freeze @@ -1622,6 +1649,17 @@ class TestArray < Test::Unit::TestCase assert_equal(@cls[1,2], @cls[1] | @cls[2]) assert_equal(@cls[1,2], @cls[1, 1] | @cls[2, 2]) assert_equal(@cls[1,2], @cls[1, 2] | @cls[1, 2]) + + a = %w(a b c) + b = %w(a b c d e) + c = a | b + assert_equal(c, b) + assert_not_same(c, b) + assert_equal(%w(a b c), a) + assert_equal(%w(a b c d e), b) + assert(a.none?(&:frozen?)) + assert(b.none?(&:frozen?)) + assert(c.none?(&:frozen?)) end def test_combination |