Sha256: ba440a83b574b431ec131efe1bcc8347c27fe1005bc660a548a49fbb932d3ae3

Contents?: true

Size: 778 Bytes

Versions: 2

Compression:

Stored size: 778 Bytes

Contents

require 'spec_helper'
module Finitio
  describe Syntax, "expression" do

    subject{
      Syntax.parse(input, root: "expression")
    }

    let(:compiled){
      subject.compile("a")
    }

    context 'a >= 10' do
      let(:input){ 'a >= 10' }

      it 'compiles to an Proc' do
        compiled.should be_a(Proc)
      end

      it 'should be the correct Proc' do
        compiled.call(12).should be_true
        compiled.call(9).should be_false
      end
    end

    context '(a >= 10)' do
      let(:input){ '(a >= 10)' }

      it 'compiles to an Proc' do
        compiled.should be_a(Proc)
      end
    end

    context 'acall(a)' do
      let(:input){ 'acall(a)' }

      it 'compiles to an Proc' do
        compiled.should be_a(Proc)
      end
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
finitio-0.4.1 spec/unit/syntax/nodes/test_expression.rb
finitio-0.4.0 spec/unit/syntax/nodes/test_expression.rb