Sha256: 00ec2bf82b0a1e76c547d1dca4b1b948a1de067e44124104837c941dd99aacec

Contents?: true

Size: 927 Bytes

Versions: 3

Compression:

Stored size: 927 Bytes

Contents

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

require 'hamster/list'

describe Hamster::List do

  describe "#drop" 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(10000)
      end

    end

    [
      [[], 10, []],
      [["A"], 10, []],
      [["A"], -1, ["A"]],
      [["A", "B", "C"], 0, ["A", "B", "C"]],
      [["A", "B", "C"], 2, ["C"]],
    ].each do |values, number, expected|

      describe "#{number} from #{values.inspect}" do

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

        it "returns #{expected.inspect}" do
          @list.drop(number).should == Hamster.list(*expected)
        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_spec.rb
hamster-0.1.18 spec/hamster/list/drop_spec.rb
hamster-0.1.17 spec/hamster/list/drop_spec.rb