Sha256: 6f6792a4650cfc970784959951b0b62aa1e2256b653aafff89c8bb369077f4f0

Contents?: true

Size: 1.33 KB

Versions: 5

Compression:

Stored size: 1.33 KB

Contents

# -*- encoding : utf-8 -*-
require 'spec_helper'

describe 'lambda' do
  describe '#compose' do
    subject { lambda{|x| x.to_s} }

    it_should_behave_like 'composable'
  end

  describe '#compose_with_lifting' do
    subject { lambda{|x| x.mzero? ? x : x.to_s} }

    it_should_behave_like 'liftable'
  end

  describe '#with_args' do
    subject { lambda{|x, y, *z| [x, y] + z.to_a } }
    it_should_behave_like 'with_args'
  end

  describe '#flip' do
    context 'arity = 1' do
      subject { lambda{|x| [x] } }

      it_should_behave_like 'flip(arity=1)'
    end

    context 'arity > 1' do
      subject { lambda{|x, y| [x, y] } }

      it_should_behave_like 'flip'
    end

    context 'varargs' do
      subject { lambda{|*x| x } }

      it_should_behave_like 'flip(varargs)'
    end
  end

  describe '#curry' do
    subject { lambda{|x, y| [x, y] } }

    it_should_behave_like 'curry'

    context 'varargs' do
      subject { lambda{|*x| x } }

      it_should_behave_like 'curry(varargs)'
    end
  end

  describe '#call' do
    subject { lambda{|x| x.to_s + "_f"} }

    it_should_behave_like 'call'
    it_should_behave_like 'call(<)'
  end

  describe 'ailases' do
    subject { lambda{|x| x.to_s + "_f"} }

    it_should_behave_like 'aliases'
    it_should_behave_like 'aliases(varargs)' do
      subject { lambda{|*x| x } }
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
lambda_driver-1.3.0 spec/lambda_spec.rb
lambda_driver-1.2.4 spec/lambda_spec.rb
lambda_driver-1.2.3 spec/lambda_spec.rb
lambda_driver-1.2.2 spec/lambda_spec.rb
lambda_driver-1.2.1 spec/lambda_spec.rb