mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* enumerator.c (lazy_flat_map): add Enumerable::Lazy#flat_map.
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@34956 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
5452b18f99
commit
a21d0f72c2
3 changed files with 40 additions and 0 deletions
|
@ -80,6 +80,14 @@ class TestLazyEnumerator < Test::Unit::TestCase
|
|||
assert_equal(1, a.current)
|
||||
end
|
||||
|
||||
def test_flat_map
|
||||
a = Step.new(1..3)
|
||||
assert_equal(2, a.flat_map {|x| [x * 2]}.first)
|
||||
assert_equal(3, a.current)
|
||||
assert_equal(2, a.lazy.flat_map {|x| [x * 2]}.first)
|
||||
assert_equal(1, a.current)
|
||||
end
|
||||
|
||||
def test_reject
|
||||
a = Step.new(1..6)
|
||||
assert_equal(4, a.reject {|x| x < 4}.first)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue