Sha256: 9efb6d1289ab04864e858eeffe3735c8ddf2a9545e5cc9c3f32f0f46ecd145c1

Contents?: true

Size: 874 Bytes

Versions: 6

Compression:

Stored size: 874 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

6 entries across 6 versions & 2 rubygems

Version Path
treetop-1.6.5 spec/compiler/grammar_spec.rb
treetop-1.6.4 spec/compiler/grammar_spec.rb
swift-pyrite-0.1.1 vendor/bundle/ruby/2.0.0/gems/treetop-1.6.3/spec/compiler/grammar_spec.rb
swift-pyrite-0.1.0 vendor/bundle/ruby/2.0.0/gems/treetop-1.6.3/spec/compiler/grammar_spec.rb
treetop-1.6.3 spec/compiler/grammar_spec.rb
treetop-1.6.2 spec/compiler/grammar_spec.rb