Sha256: d7ecd06b37033fc51b0f67e07327caa84a99d3dfadf371737a5bcb84d9bda6ea

Contents?: true

Size: 965 Bytes

Versions: 7

Compression:

Stored size: 965 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
        expect(compiled).to be_a(Proc)
      end

      it 'should be the correct Proc' do
        expect(compiled.call(12)).to eq(true)
        expect(compiled.call(9)).to eq(false)
      end
    end

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

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

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

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

    context 's =~ /^(test)$/' do
      let(:input){ 's =~ /^(test)$/' }

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

  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
finitio-0.7.0.pre.rc2 spec/syntax/nodes/test_expression.rb
finitio-0.7.0.pre.rc1 spec/syntax/nodes/test_expression.rb
finitio-0.6.1 spec/syntax/nodes/test_expression.rb
finitio-0.6.0 spec/syntax/nodes/test_expression.rb
finitio-0.5.2 spec/syntax/nodes/test_expression.rb
finitio-0.5.1 spec/syntax/nodes/test_expression.rb
finitio-0.5.0 spec/syntax/nodes/test_expression.rb