Sha256: 118b11d8bcb9f2abb687bfee17c3ba44154a7565d4b0e018c4f61f2de73eed05

Contents?: true

Size: 979 Bytes

Versions: 2

Compression:

Stored size: 979 Bytes

Contents

require 'spec_helper'
module Gisele::Language::Syntax
  describe BoolExpr, "to_ast" do

    it 'returns expected ast on simple expressions' do
      expected = \
        [:bool_expr, [:bool_and, [:var_ref, "diagKnown"], [:var_ref, "platLow"]]]
      ast("diagKnown and platLow", :bool_expr).should eq(expected)
    end

    it 'respects priorities' do
      expected = [:bool_expr,
        [:bool_or, [:bool_and, [:var_ref, "diagKnown"], [:var_ref, "platLow"]], [:var_ref, "platHigh"]]]
      ast("diagKnown and platLow or platHigh", :bool_expr).should eq(expected)
    end

    it 'supports double negations' do
      expected = [:bool_expr, [:bool_not, [:bool_not, [:var_ref, "diagKnown"]]]]
      ast("not not(diagKnown)", :bool_expr).should eq(expected)
    end

    it 'makes boolean literals explicit' do
      ast("true",  :bool_expr).should eq([:bool_expr, [:bool_lit, true]])
      ast("false", :bool_expr).should eq([:bool_expr, [:bool_lit, false]])
    end

  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
gisele-0.4.0 spec/unit/language/syntax/to_ast/test_bool_expr.rb
gisele-0.3.0 spec/unit/language/syntax/to_ast/test_bool_expr.rb