Sha256: e40d40b103781aee9bad53d16a01f728094cfc3526c5594799141d96db7ce49e

Contents?: true

Size: 1.04 KB

Versions: 3

Compression:

Stored size: 1.04 KB

Contents

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

require 'hamster/list'

describe Hamster::List do

  describe "#drop_while" do

    describe "doesn't run out of stack space on a really big" do

      it "stream" do
        @list = Hamster.interval(0, 10000)
      end

      it "list" do
        @list = (0..10000).reduce(Hamster.list) { |list, i| list.cons(i) }
      end

      after do
        @list.drop_while { true }
      end

    end

    [
      [[], []],
      [["A"], []],
      [["A", "B", "C"], ["C"]],
    ].each do |values, expected|

      describe "on #{values.inspect}" do

        before do
          @list = Hamster.list(*values)
        end

        describe "with a block" do

          it "returns #{expected.inspect}" do
            @list.drop_while { |item| item < "C" }.should == Hamster.list(*expected)
          end

        end

        describe "without a block" do

          it "returns self" do
            @list.drop_while.should equal(@list)
          end

        end

      end

    end

  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
hamster-0.1.19 spec/hamster/list/drop_while_spec.rb
hamster-0.1.18 spec/hamster/list/drop_while_spec.rb
hamster-0.1.17 spec/hamster/list/drop_while_spec.rb