Sha256: 43163db7da166294f5af7421f0d7cf93556c71f98b176bfbf37eac166b0f7bed

Contents?: true

Size: 836 Bytes

Versions: 19

Compression:

Stored size: 836 Bytes

Contents

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

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

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

    let(:ast){
      subject.to_ast("a")
    }

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

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

      it 'is anonymous' do
        expect(compiled).to be_anonymous
      end

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

      it 'has the expected AST' do
        expect(ast).to eq([
          :constraint,
          "default",
          [:fn, [:parameters, "a"], [:source, "a >= 10"]]
        ])
      end
    end

  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
finitio-0.12.0 spec/syntax/nodes/test_unnamed_constraint.rb
finitio-0.11.4 spec/syntax/nodes/test_unnamed_constraint.rb
finitio-0.11.3 spec/syntax/nodes/test_unnamed_constraint.rb
finitio-0.11.2 spec/syntax/nodes/test_unnamed_constraint.rb
finitio-0.11.1 spec/syntax/nodes/test_unnamed_constraint.rb
finitio-0.10.0 spec/syntax/nodes/test_unnamed_constraint.rb
finitio-0.9.1 spec/syntax/nodes/test_unnamed_constraint.rb
finitio-0.9.0 spec/syntax/nodes/test_unnamed_constraint.rb
finitio-0.8.0 spec/syntax/nodes/test_unnamed_constraint.rb
finitio-0.7.0 spec/syntax/nodes/test_unnamed_constraint.rb
finitio-0.7.0.pre.rc4 spec/syntax/nodes/test_unnamed_constraint.rb
finitio-0.7.0.pre.rc3 spec/syntax/nodes/test_unnamed_constraint.rb
finitio-0.7.0.pre.rc2 spec/syntax/nodes/test_unnamed_constraint.rb
finitio-0.7.0.pre.rc1 spec/syntax/nodes/test_unnamed_constraint.rb
finitio-0.6.1 spec/syntax/nodes/test_unnamed_constraint.rb
finitio-0.6.0 spec/syntax/nodes/test_unnamed_constraint.rb
finitio-0.5.2 spec/syntax/nodes/test_unnamed_constraint.rb
finitio-0.5.1 spec/syntax/nodes/test_unnamed_constraint.rb
finitio-0.5.0 spec/syntax/nodes/test_unnamed_constraint.rb