From 06a622b76e20b8996cd6d66c11ac7819a0996fae Mon Sep 17 00:00:00 2001 From: Nobuyoshi Nakada Date: Fri, 21 Jun 2019 16:28:39 +0900 Subject: Lazy filter_map --- test/ruby/test_lazy_enumerator.rb | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'test') 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 -- cgit v1.2.3