Sha256: 9f4858e352e4185995f1b8c433636250ddc5511b167defcc17063058df030879

Contents?: true

Size: 1.08 KB

Versions: 12

Compression:

Stored size: 1.08 KB

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

      it 'is equal to itself' do
        j = Syntax.parse(input, root: "expression").compile("a")
        expect(j).to eq(compiled)
      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

12 entries across 12 versions & 1 rubygems

Version Path
finitio-0.12.0 spec/syntax/nodes/test_expression.rb
finitio-0.11.4 spec/syntax/nodes/test_expression.rb
finitio-0.11.3 spec/syntax/nodes/test_expression.rb
finitio-0.11.2 spec/syntax/nodes/test_expression.rb
finitio-0.11.1 spec/syntax/nodes/test_expression.rb
finitio-0.10.0 spec/syntax/nodes/test_expression.rb
finitio-0.9.1 spec/syntax/nodes/test_expression.rb
finitio-0.9.0 spec/syntax/nodes/test_expression.rb
finitio-0.8.0 spec/syntax/nodes/test_expression.rb
finitio-0.7.0 spec/syntax/nodes/test_expression.rb
finitio-0.7.0.pre.rc4 spec/syntax/nodes/test_expression.rb
finitio-0.7.0.pre.rc3 spec/syntax/nodes/test_expression.rb