1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
require 'spec_helper'
describe Immutable::List do
describe '#tails' do
it 'is lazy' do
-> { Immutable.stream { fail }.tails }.should_not raise_error
end
[
[[], []],
[['A'], [L['A']]],
[%w[A B C], [L['A', 'B', 'C'], L['B', 'C'], L['C']]],
].each do |values, expected|
context "on #{values.inspect}" do
let(:list) { L[*values] }
it 'preserves the original' do
list.tails
list.should eql(L[*values])
end
it "returns #{expected.inspect}" do
list.tails.should eql(L[*expected])
end
end
end
end
end
|