Sha256: 72a238a6d955ac1211b5cfb1a4f9a30df11c8f7a3cea97ded1f05bb3bdc867e0
Contents?: true
Size: 792 Bytes
Versions: 2
Compression:
Stored size: 792 Bytes
Contents
require 'spec_helper' module Finitio describe Syntax, "constraint_def" do subject{ Syntax.parse(input, root: "constraint_def") } let(:compiled){ subject.compile(type_factory) } let(:ast){ subject.to_ast } context '(i | i >= 0)' do let(:input){ '(i | i >= 0)' } it 'compiles to an Hash' do compiled.should be_a(Hash) end it 'compiled to the correct proc' do compiled[:predicate].call(12).should be_true compiled[:predicate].call(-12).should be_false end it 'has the expected AST' do ast.should eq([ [ :constraint, "default", [:fn, [:parameters, "i"], [:source, "i >= 0"]] ] ]) 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_constraint_def.rb |
finitio-0.4.0 | spec/unit/syntax/nodes/test_constraint_def.rb |