Sha256: fecdf0d10bec34e5f372a518d8e4c500ebb29cac9a532235482eaf9813c63d29

Contents?: true

Size: 921 Bytes

Versions: 3

Compression:

Stored size: 921 Bytes

Contents

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

require 'hamster/list'

describe Hamster do

  describe "#cycle" 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.cycle
      end

    end

    describe "with an empty list" do

      before do
        @list = Hamster.list.cycle
      end

      it "returns the empty list" do
        @list.should equal(Hamster.list)
      end

    end

    describe "with a non-empty list" do

      before do
        @list = Hamster.list("A", "B", "C").cycle
      end

      it "infinitely cycles through all values" do
        @list.take(7).should == Hamster.list("A", "B", "C", "A", "B", "C", "A")
      end

    end

  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

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