summaryrefslogtreecommitdiff
path: root/spec/ruby/core/enumerator/lazy/filter_map_spec.rb
blob: 99dd59cebe2c704b40202d20a7eb12b64231c237 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
# -*- encoding: us-ascii -*-

require_relative '../../../spec_helper'
require_relative 'fixtures/classes'

describe "Enumerator::Lazy#filter_map" do
  it "maps only truthy results" do
    (1..Float::INFINITY).lazy.filter_map { |i| i if i.odd? }.first(4).should == [1, 3, 5, 7]
  end

  it "does not map false results" do
    (1..Float::INFINITY).lazy.filter_map { |i| i.odd? ? i : false }.first(4).should == [1, 3, 5, 7]
  end
end