From 7dd52f895f8271be242ff549668d825295f12ccf Mon Sep 17 00:00:00 2001 From: shugo Date: Mon, 14 Jan 2013 08:36:15 +0000 Subject: * enumerator.c (lazy_flat_map_func): flat_map should call each only when the value of a block returns a forcable object. [ruby-core:51401] [Bug #7690] * enumerator.c (lazy_flat_map): add documentation. * test/ruby/test_lazy_enumerator.rb: related test. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@38812 b2dd03c8-39d4-4d8f-98ff-823fe69b080e --- test/ruby/test_lazy_enumerator.rb | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'test/ruby/test_lazy_enumerator.rb') diff --git a/test/ruby/test_lazy_enumerator.rb b/test/ruby/test_lazy_enumerator.rb index 30677291f4..f04d26ecbe 100644 --- a/test/ruby/test_lazy_enumerator.rb +++ b/test/ruby/test_lazy_enumerator.rb @@ -132,6 +132,11 @@ class TestLazyEnumerator < Test::Unit::TestCase assert_equal(["1", "2", "3"], [1, 2, 3].lazy.flat_map {|x| x.to_s}.force) end + def test_flat_map_hash + assert_equal([{?a=>97}, {?b=>98}, {?c=>99}], [?a, ?b, ?c].flat_map {|x| {x=>x.ord}}) + assert_equal([{?a=>97}, {?b=>98}, {?c=>99}], [?a, ?b, ?c].lazy.flat_map {|x| {x=>x.ord}}.force) + end + def test_reject a = Step.new(1..6) assert_equal(4, a.reject {|x| x < 4}.first) -- cgit v1.2.3