diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-02-14 15:45:43 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2009-02-14 15:45:43 +0000 |
commit | 766df600db46f3cc8a2bd0c0af2dfceeec2d8fb3 (patch) | |
tree | 8bb6919bce8e548a62a4ce323c5075f97af91305 /test/ruby/test_array.rb | |
parent | e1646e639a14f8430046dd424c1b745bea7f9840 (diff) | |
download | ruby-766df600db46f3cc8a2bd0c0af2dfceeec2d8fb3.tar.gz |
* array.c (rb_ary_uniq_bang, rb_ary_uniq): unique by the result of
given block. [ruby-dev:37998]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22307 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby/test_array.rb')
-rw-r--r-- | test/ruby/test_array.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/test/ruby/test_array.rb b/test/ruby/test_array.rb index 1cd018be85..1629c1abd0 100644 --- a/test/ruby/test_array.rb +++ b/test/ruby/test_array.rb @@ -1240,6 +1240,11 @@ class TestArray < Test::Unit::TestCase assert_equal(@cls[1, 2, 3, 4, nil], a.uniq) assert_equal(b, a) + c = @cls["a:def", "a:xyz", "b:abc", "b:xyz", "c:jkl"] + d = c.dup + assert_equal(@cls[ "a:def", "b:abc", "c:jkl" ], c.uniq {|s| s[/^\w+/]}) + assert_equal(d, c) + assert_equal(@cls[1, 2, 3], @cls[1, 2, 3].uniq) end @@ -1248,6 +1253,10 @@ class TestArray < Test::Unit::TestCase assert_equal(@cls[1, 2, 3, 4, nil], a.uniq!) assert_equal(@cls[1, 2, 3, 4, nil], a) + c = @cls["a:def", "a:xyz", "b:abc", "b:xyz", "c:jkl"] + assert_equal(@cls[ "a:def", "b:abc", "c:jkl" ], c.uniq! {|s| s[/^\w+/]}) + assert_equal(@cls[ "a:def", "b:abc", "c:jkl" ], c) + assert_nil(@cls[1, 2, 3].uniq!) end |