Sha256: f3b34400bb6654fec765568e4c4780186fabace3ce6ccdfa02f64bf63403ae9f

Contents?: true

Size: 810 Bytes

Versions: 15

Compression:

Stored size: 810 Bytes

Contents

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

describe 'Functor' do

    it 'should create a new functor' do
      fc = Functor.new do |op, *a, &b|
        [op, a, b]
      end
      expect(fc+1).to eq([:+, [1], nil])
    end

    it 'should support class method' do
      fc = Functor.new do |op, *a, &b|
        [op, a, b]
      end
      expect( fc.__class__).to eq(Functor)
    end

    it 'should support to proc' do
      f = Functor.new do |op, *a|
        [op, *a]
      end
      p = f.to_proc
      expect(p.class).to eq(Proc)
      expect(p.call(:+,1,2,3)).to eq([:+,1,2,3])
    end

    it 'should cache a new functor' do
      Functor.cache(:cached) do |op, *a, &b|
          [op, a, b]
        end
      expect(Functor.cache(:cached) + 1).to eq([:+, [1], nil])
     end

end

Version data entries

15 entries across 15 versions & 1 rubygems

Version Path
totally_lazy-0.0.20 spec/functor_spec.rb
totally_lazy-0.0.19 spec/functor_spec.rb
totally_lazy-0.0.18 spec/functor_spec.rb
totally_lazy-0.0.16 spec/functor_spec.rb
totally_lazy-0.0.15 spec/functor_spec.rb
totally_lazy-0.0.14 spec/functor_spec.rb
totally_lazy-0.0.13 spec/functor_spec.rb
totally_lazy-0.0.12 spec/functor_spec.rb
totally_lazy-0.0.11 spec/functor_spec.rb
totally_lazy-0.0.10 spec/functor_spec.rb
totally_lazy-0.0.9 spec/functor_spec.rb
totally_lazy-0.0.8 spec/functor_spec.rb
totally_lazy-0.0.7 spec/functor_spec.rb
totally_lazy-0.0.6 spec/functor_spec.rb
totally_lazy-0.0.5 spec/functor_spec.rb