From 62739518691b39c61a1360d596fac4d94a3af0c0 Mon Sep 17 00:00:00 2001 From: mame Date: Wed, 4 Mar 2009 19:33:14 +0000 Subject: * test/ruby/test_array.rb: add some tests for coverage. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22770 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_array.rb | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'test/ruby') diff --git a/test/ruby/test_array.rb b/test/ruby/test_array.rb index 1629c1abd0..9c6834dc9d 100644 --- a/test/ruby/test_array.rb +++ b/test/ruby/test_array.rb @@ -777,6 +777,8 @@ class TestArray < Test::Unit::TestCase assert_equal(4, a.index([1,2,3])) assert_nil(a.index('ca')) assert_nil(a.index([1,2])) + + assert_equal(1, a.index(99) {|x| x == 'cat' }) end def test_values_at @@ -1032,6 +1034,8 @@ class TestArray < Test::Unit::TestCase assert_equal(4, a.rindex([1,2,3])) assert_nil(a.rindex('ca')) assert_nil(a.rindex([1,2])) + + assert_equal(3, a.rindex(99) {|x| x == [1,2,3] }) end def test_shift @@ -1257,6 +1261,10 @@ class TestArray < Test::Unit::TestCase assert_equal(@cls[ "a:def", "b:abc", "c:jkl" ], c.uniq! {|s| s[/^\w+/]}) assert_equal(@cls[ "a:def", "b:abc", "c:jkl" ], c) + c = @cls["a:def", "b:abc", "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 @@ -1680,4 +1688,10 @@ class TestArray < Test::Unit::TestCase a.fill(:foo, 5, -3) assert_equal((1..10).to_a, a) end + + def test_slice_freezed_array + a = [1,2,3,4,5].freeze + assert_equal([1,2,3,4], a[0,4]) + assert_equal([2,3,4,5], a[1,4]) + end end -- cgit v1.2.3