aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authormame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-03-04 19:33:14 +0000
committermame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-03-04 19:33:14 +0000
commit62739518691b39c61a1360d596fac4d94a3af0c0 (patch)
tree836d1bbd84a9f71a18c5cea58b40e61d6d5fed9b
parent00305d36f015cae4c4c5e8a0999ade8599a2d5eb (diff)
downloadruby-62739518691b39c61a1360d596fac4d94a3af0c0.tar.gz
* 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
-rw-r--r--ChangeLog4
-rw-r--r--test/ruby/test_array.rb14
2 files changed, 18 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 73044cdcc2..d08c5f6ddb 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Thu Mar 5 04:32:38 2009 Yusuke Endoh <mame@tsg.ne.jp>
+
+ * test/ruby/test_array.rb: add some tests for coverage.
+
Thu Mar 5 00:06:37 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
* win32/README.win32 (Requirement): added unicows.lib and dll.
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