aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--ChangeLog4
-rw-r--r--test/ruby/test_enum.rb9
2 files changed, 13 insertions, 0 deletions
diff --git a/ChangeLog b/ChangeLog
index 3606316eee..a53c16b3c0 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,7 @@
+Mon Mar 9 01:38:00 2009 Yusuke Endoh <mame@tsg.ne.jp>
+
+ * test/ruby/test_enum.rb: add some tests.
+
Mon Mar 9 01:12:37 2009 Yusuke Endoh <mame@tsg.ne.jp>
* test/ruby/test_object.rb: add a test for Object#method_missing.
diff --git a/test/ruby/test_enum.rb b/test/ruby/test_enum.rb
index a8a88640bd..8d22b12f03 100644
--- a/test/ruby/test_enum.rb
+++ b/test/ruby/test_enum.rb
@@ -48,6 +48,7 @@ class TestEnumerable < Test::Unit::TestCase
assert_equal(1, @obj.find_index {|x| x % 2 == 0 })
assert_equal(nil, @obj.find_index {|x| false })
assert_raise(ArgumentError) { @obj.find_index(0, 1) }
+ assert_equal(1, @obj.find_index(2) {|x| x == 1 })
end
def test_find_all
@@ -212,6 +213,10 @@ class TestEnumerable < Test::Unit::TestCase
@obj.zip([:a, :b, :c]) {|x,y| a << [x, y] }
assert_equal([[1,:a],[2,:b],[3,:c],[1,nil],[2,nil]], a)
+ a = []
+ @obj.zip({a: "A", b: "B", c: "C"}) {|x,y| a << [x, y] }
+ assert_equal([[1,[:a,"A"]],[2,[:b,"B"]],[3,[:c,"C"]],[1,nil],[2,nil]], a)
+
ary = Object.new
def ary.to_a; [1, 2]; end
assert_raise(NoMethodError){ %w(a b).zip(ary) }
@@ -274,4 +279,8 @@ class TestEnumerable < Test::Unit::TestCase
c.call
end
end
+
+ def test_reverse_each
+ assert_equal([2,1,3,2,1], @obj.reverse_each.to_a)
+ end
end