Sha256: 7d2ed8cc00321c33b09350e6aad67725acf97939597537761028fdcebc8f13f5

Contents?: true

Size: 949 Bytes

Versions: 2

Compression:

Stored size: 949 Bytes

Contents

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

require 'hamster/list'

describe Hamster::List do

  describe "#zip" do

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

    [
      [[], [], []],
      [["A"], ["aye"], [Hamster.list("A", "aye")]],
      [["A"], [], [Hamster.list("A", nil)]],
      [[], ["A"], [Hamster.list(nil, "A")]],
      [["A", "B", "C"], ["aye", "bee", "see"], [Hamster.list("A", "aye"), Hamster.list("B", "bee"), Hamster.list("C", "see")]],
    ].each do |left, right, expected|

      describe "on #{left.inspect} and #{right.inspect}" do

        before do
          @left = Hamster.list(*left)
          @right = Hamster.list(*right)
          @result = @left.zip(@right)
        end

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

      end

    end

  end

end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
hamster-0.2.7 spec/hamster/list/zip_spec.rb
hamster-0.2.6 spec/hamster/list/zip_spec.rb