Sha256: 133c17e78ab1a73322edfd5a4d7441b85bcd970e145e563e3de2f9015e43debb

Contents?: true

Size: 1.13 KB

Versions: 3

Compression:

Stored size: 1.13 KB

Contents

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

require 'hamster/list'

describe Hamster::List do

  [:include?, :member?].each do |method|

    describe "##{method}" 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.send(method, nil)
        end

      end

      [
        [[], "A", false],
        [[], nil, false],
        [["A"], "A", true],
        [["A"], "B", false],
        [["A"], nil, false],
        [["A", "B", nil], "A", true],
        [["A", "B", nil], "B", true],
        [["A", "B", nil], nil, true],
        [["A", "B", nil], "C", false],
      ].each do |values, item, expected|

        describe "on #{values.inspect}" do

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

          it "returns #{expected.inspect}" do
            @list.send(method, item).should == expected
          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/include_spec.rb
hamster-0.1.18 spec/hamster/list/include_spec.rb
hamster-0.1.17 spec/hamster/list/include_spec.rb