Sha256: d6d98e0b000a0e8b347c8831dab9d9be3854384a2c3b180a01782b926e37e584

Contents?: true

Size: 630 Bytes

Versions: 4

Compression:

Stored size: 630 Bytes

Contents

require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')

describe Hamster::List do

  describe "#reduce" do

    it "initially returns memo" do
      Hamster::List.new.reduce(0).should == 0
    end
    
    describe "with values" do

      before do
        @list = Hamster::List.new.cons(1).cons(2).cons(3).cons(4)
      end

      it "works with an initial value" do
        @list.reduce(0) { |memo, i| memo + i }.should == 10
      end

      it "defaults to the first item in the list" do
        pending do
          @list.reduce { |memo, i| memo + i }.should == 10
        end
      end

    end

  end

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
hamster-0.1.8 spec/hamster/list/reduce_spec.rb
hamster-0.1.7 spec/hamster/list/reduce_spec.rb
hamster-0.1.6 spec/hamster/list/reduce_spec.rb
hamster-0.1.5 spec/hamster/list/reduce_spec.rb