Sha256: 3918aab8a3ed7a734bf6b94d630220aca91112eb53ced8859478787af0a6c2c8

Contents?: true

Size: 975 Bytes

Versions: 1

Compression:

Stored size: 975 Bytes

Contents

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

require 'hamster/list'

describe Hamster::List do

  describe "#take" do

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

      before do
        @interval = Hamster.interval(0, 10000)
      end

      it "stream" do
        @list = @interval
      end

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

      after do
        @list.take(10000)
      end

    end

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

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

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

        it "returns #{expected.inspect}" do
          @list.take(number).should == Hamster.list(*expected)
        end

      end

    end

  end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
hamster-0.1.16 spec/hamster/list/take_spec.rb