diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2019-06-21 16:28:39 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2019-06-21 16:28:39 +0900 |
commit | 06a622b76e20b8996cd6d66c11ac7819a0996fae (patch) | |
tree | 4876d7dd948f43d3d0185000034a337bb6cb7e40 /test | |
parent | 4149fd60786527121d42e3d6f12d1447505d22fa (diff) |
Lazy filter_map
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_lazy_enumerator.rb | 9 |
1 files changed, 9 insertions, 0 deletions
diff --git a/test/ruby/test_lazy_enumerator.rb b/test/ruby/test_lazy_enumerator.rb index d42c8d3261..e76a53e650 100644 --- a/test/ruby/test_lazy_enumerator.rb +++ b/test/ruby/test_lazy_enumerator.rb @@ -578,4 +578,13 @@ EOS assert_equal([1, 2, 3, 4, 5, 10], u.first(6)) assert_equal([1, 2, 3, 4, 5, 10], u.first(6)) end + + def test_filter_map + e = (1..Float::INFINITY).lazy.filter_map do |x| + raise "too big" if x > 10000 + (x**2) % 10 if x.even? + end + assert_equal([4, 6, 6, 4, 0, 4], e.first(6)) + assert_equal([4, 6, 6, 4, 0, 4], e.first(6)) + end end |