Sha256: 10b519a11742a2cc55e51722fe86a1d97d559f284ea9c26c5e46ffb68ee57b82
Contents?: true
Size: 1.01 KB
Versions: 27
Compression:
Stored size: 1.01 KB
Contents
require 'rspec' require 'abstractivator/cons' describe Abstractivator::Cons do include Abstractivator::Cons describe '#empty_list' do it 'is a singleton' do expect(empty_list).to eql empty_list end end describe '#cons' do it 'creates a cons cell' do expect(cons(1, 2)).to eql [1,2 ] end end describe '#head' do it 'returns the head' do cell = cons(1, 2) expect(cell.head).to eql 1 end end describe '#tail' do it 'returns the tail' do cell = cons(1, 2) expect(cell.tail).to eql 2 end end describe '#enum_to_list' do it 'returns the list form of an enumerable' do expect(enum_to_list([])).to eql empty_list expect(enum_to_list([1,2,3])).to eql [1, [2, [3, empty_list]]] end end describe '#list_to_enum' do it 'returns the enumerable form of a list' do expect(list_to_enum(empty_list).to_a).to eql [] expect(list_to_enum(cons(1, cons(2, cons(3, empty_list)))).to_a).to eql [1, 2, 3] end end end
Version data entries
27 entries across 27 versions & 1 rubygems