Sha256: 5d6219857c5bda1451cb23f55f26682f26fe922a6f84ea8447f26fd37deb0647

Contents?: true

Size: 736 Bytes

Versions: 3

Compression:

Stored size: 736 Bytes

Contents

require "spec_helper"
require "hamster/list"

describe Hamster::List do
  describe "#at" do
    context "on a really big list" do
      let(:list) { Hamster.interval(0, STACK_OVERFLOW_DEPTH) }

      it "doesn't run out of stack" do
        -> { list.at(STACK_OVERFLOW_DEPTH) }.should_not raise_error
      end
    end

    [
      [[], 10, nil],
      [["A"], 10, nil],
      [%w[A B C], 0, "A"],
      [%w[A B C], 2, "C"],
      [%w[A B C], -1, "C"],
      [%w[A B C], -2, "B"],
      [%w[A B C], -4, nil]
    ].each do |values, number, expected|
      describe "#{values.inspect} with #{number}" do
        it "returns #{expected.inspect}" do
          L[*values].at(number).should == expected
        end
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 2 rubygems

Version Path
files.com-1.0.55 docs/vendor/bundle/ruby/2.5.0/gems/hamster-3.0.0/spec/lib/hamster/list/at_spec.rb
hamster-3.0.0 spec/lib/hamster/list/at_spec.rb
hamster-2.0.0 spec/lib/hamster/list/at_spec.rb