Sha256: 4f20597b0ed8cfae20226ea11726f5761b8237dea08d7c37f053258daf5d25f0

Contents?: true

Size: 888 Bytes

Versions: 3

Compression:

Stored size: 888 Bytes

Contents

require 'spec_helper'

module GrammarSpec
  module Bar
  end

  describe "a grammar" do
    testing_grammar %{
      grammar Foo
              # This comment should not cause a syntax error, nor should the following empty one
              #
        include GrammarSpec::Bar

        rule foo
          bar / baz
        end

        rule bar
          'bar' 'bar'
        end

        rule baz
          'baz' 'baz'
        end
      end
    }

    it "parses matching input" do
      parse('barbar').should_not be_nil
      parse('bazbaz').should_not be_nil
    end

    it "fails if it does not parse all input" do
      parse('barbarbazbaz') do |result|
        result.should be_nil
        parser.terminal_failures.size.should == 1
      end
    end

    it "mixes in included modules" do
      self.class.const_get(:Foo).ancestors.should include(GrammarSpec::Bar)
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
treetop-1.6.8 spec/compiler/grammar_spec.rb
treetop-1.6.7 spec/compiler/grammar_spec.rb
treetop-1.6.6 spec/compiler/grammar_spec.rb