Sha256: 73f03a665ca5aaf93a2bde83a4bbe407bc69415a80a40f9e863b7155df40a0b0

Contents?: true

Size: 1.14 KB

Versions: 9

Compression:

Stored size: 1.14 KB

Contents

require 'spec_helper'

module AndPredicateSpec
  describe "An &-predicated terminal symbol" do
    testing_expression '&"foo"'

    it "successfully parses input matching the terminal symbol, returning an epsilon syntax node" do
      parse('foo', :consume_all_input => false) do |result|
        result.should_not be_nil
        result.interval.should == (0...0)
      end
    end
  end

  describe "A sequence of a terminal and an and another &-predicated terminal" do
    testing_expression '"foo" &"bar"'

    it "matches input matching both terminals, but only consumes the first" do
      parse('foobar', :consume_all_input => false) do |result|
        result.should_not be_nil
        result.text_value.should == 'foo'
      end
    end
  
    it "fails to parse input matching only the first terminal, with a terminal failure recorded at index 3" do
      parse('foo') do |result|
        result.should be_nil
        terminal_failures = parser.terminal_failures
        terminal_failures.size.should == 1
        failure = terminal_failures[0]
        failure.index.should == 3
        failure.expected_string.should == '"bar"'
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 2 rubygems

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