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

Version Path
abstractivator-0.8.0 spec/lib/abstractivator/cons_spec.rb
abstractivator-0.7.0 spec/lib/abstractivator/cons_spec.rb
abstractivator-0.6.0 spec/lib/abstractivator/cons_spec.rb
abstractivator-0.5.0 spec/lib/abstractivator/cons_spec.rb
abstractivator-0.4.1 spec/lib/abstractivator/cons_spec.rb
abstractivator-0.4.0 spec/lib/abstractivator/cons_spec.rb
abstractivator-0.3.1 spec/lib/abstractivator/cons_spec.rb
abstractivator-0.3.0 spec/lib/abstractivator/cons_spec.rb
abstractivator-0.2.0 spec/lib/abstractivator/cons_spec.rb
abstractivator-0.1.1 spec/lib/abstractivator/cons_spec.rb
abstractivator-0.1.0 spec/lib/abstractivator/cons_spec.rb
abstractivator-0.0.31 spec/lib/abstractivator/cons_spec.rb
abstractivator-0.0.30 spec/lib/abstractivator/cons_spec.rb
abstractivator-0.0.29 spec/lib/abstractivator/cons_spec.rb
abstractivator-0.0.28 spec/lib/abstractivator/cons_spec.rb
abstractivator-0.0.27 spec/lib/abstractivator/cons_spec.rb
abstractivator-0.0.26 spec/lib/abstractivator/cons_spec.rb
abstractivator-0.0.25 spec/lib/abstractivator/cons_spec.rb
abstractivator-0.0.24 spec/lib/abstractivator/cons_spec.rb
abstractivator-0.0.23 spec/lib/abstractivator/cons_spec.rb