Sha256: c100801f459bdecb2997f3f3b8b5ef49f96ea28bbb9c26bef045fda0d498fb9f

Contents?: true

Size: 829 Bytes

Versions: 1

Compression:

Stored size: 829 Bytes

Contents

require 'spec_helper'
module Sexpr
  describe "the bool_expr grammar" do

    let(:g){ Sexpr.load(Path.dir/"bool_expr.yml") }

    it "allows checking validy of specific nodes" do
      (g[:bool_lit] === true).should be_true
      (g[:var_ref]  === [:var_ref, "x"]).should be_true
      (g[:bool_and] === [:bool_and, true, false]).should be_true
      (g[:bool_and] === [:bool_or, true, false]).should be_false
    end

    it 'allows checking the validity against the root rule' do
      (g === true).should be_true
      (g === false).should be_true
      (g === [:bool_not, true]).should be_true
      (g === [:var_ref, "x"]).should be_true
      (g === [:bool_not, [:var_ref, "x"]]).should be_true
    end

    it 'detects wrong matches' do
      (g === [:bool_not, [:something_else, "x"]]).should be_false
    end

  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sexpr-0.2.0 spec/test_bool_expr.rb