Sha256: 4c14423b40cb08063abb2ab024b6c957317819b44a1d09123f023d11fdd04492

Contents?: true

Size: 1001 Bytes

Versions: 1

Compression:

Stored size: 1001 Bytes

Contents

# encoding: utf-8

require 'spec_helper'

describe Optimizer::Function::Binary::ConstantOperands, '#optimizable?' do
  subject { object.optimizable? }

  let(:described_class) { Class.new(Optimizer) { include Optimizer::Function::Binary }       }
  let(:function)        { Class.new(Function)  { include Function::Binary }.new(left, right) }
  let(:object)          { described_class.new(function)                                      }

  before do
    described_class.class_eval { include Optimizer::Function::Binary::ConstantOperands }
  end

  context 'when left and right are constants' do
    let(:left)  { 1 }
    let(:right) { 1 }

    it { should be(true) }
  end

  context 'when left is a constant, and right is not a constant' do
    let(:left)  { 1        }
    let(:right) { proc {}  }

    it { should be(false) }
  end

  context 'when left is not a constant, and right is a constant' do
    let(:left)  { proc {}  }
    let(:right) { 1        }

    it { should be(false) }
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
axiom-optimizer-0.2.0 spec/unit/axiom/optimizer/function/binary/constant_operands/optimizable_predicate_spec.rb