Sha256: 53f98bad16092f35308da4f448bde133fcf0db97609f8951e5294c9f927afc34

Contents?: true

Size: 1.08 KB

Versions: 7

Compression:

Stored size: 1.08 KB

Contents

require 'spec_helper'

require 'hamster/list'

describe Hamster::List do

  [:append, :concat, :cat, :+].each do |method|

    describe "##{method}" do

      it "is lazy" do
        lambda { Hamster.stream { fail }.append(Hamster.stream { fail }) }.should_not raise_error
      end

      [
        [[], [], []],
        [["A"], [], ["A"]],
        [[], ["A"], ["A"]],
        [["A", "B"], ["C", "D"], ["A", "B", "C", "D"]],
      ].each do |left_values, right_values, expected|

        describe "on #{left_values.inspect} and #{right_values.inspect}" do

          before do
            @left = Hamster.list(*left_values)
            @right = Hamster.list(*right_values)
            @result = @left.append(@right)
          end

          it "preserves the left" do
            @left.should == Hamster.list(*left_values)
          end

          it "preserves the right" do
            @right.should == Hamster.list(*right_values)
          end

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

        end

      end

    end

  end

end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
hamster-0.4.3 spec/hamster/list/append_spec.rb
hamster-0.4.2 spec/hamster/list/append_spec.rb
hamster-0.4.0 spec/hamster/list/append_spec.rb
hamster-0.3.10 spec/hamster/list/append_spec.rb
hamster-0.3.9 spec/hamster/list/append_spec.rb
hamster-0.3.8 spec/hamster/list/append_spec.rb
hamster-0.3.7 spec/hamster/list/append_spec.rb