summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-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 73044cdcc..d08c5f6dd 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 1629c1abd..9c6834dc9 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