Sha256: 50350b21d43ea8a7a1f9eb7e43efbf4aabd94cb4d3c545d8a740e1a01dd60c0a

Contents?: true

Size: 1.18 KB

Versions: 76

Compression:

Stored size: 1.18 KB

Contents

require File.expand_path("#{File.dirname(__FILE__)}/../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

76 entries across 76 versions & 7 rubygems

Version Path
cloudhead-less-1.0.1 lib/vendor/treetop/spec/compiler/and_predicate_spec.rb
cloudhead-less-1.0.10 lib/vendor/treetop/spec/compiler/and_predicate_spec.rb
cloudhead-less-1.0.13 lib/vendor/treetop/spec/compiler/and_predicate_spec.rb
cloudhead-less-1.0.16 lib/vendor/treetop/spec/compiler/and_predicate_spec.rb
cloudhead-less-1.0.2 lib/vendor/treetop/spec/compiler/and_predicate_spec.rb
cloudhead-less-1.0.3 lib/vendor/treetop/spec/compiler/and_predicate_spec.rb
cloudhead-less-1.0.4 lib/vendor/treetop/spec/compiler/and_predicate_spec.rb
cloudhead-less-1.0.5 lib/vendor/treetop/spec/compiler/and_predicate_spec.rb
cloudhead-less-1.0.6 lib/vendor/treetop/spec/compiler/and_predicate_spec.rb
cloudhead-less-1.0.8 lib/vendor/treetop/spec/compiler/and_predicate_spec.rb
cloudhead-less-1.0.9 lib/vendor/treetop/spec/compiler/and_predicate_spec.rb
cloudhead-less-1.1.0 lib/vendor/treetop/spec/compiler/and_predicate_spec.rb
cloudhead-less-1.1.1 lib/vendor/treetop/spec/compiler/and_predicate_spec.rb
cloudhead-less-1.1.10 lib/vendor/treetop/spec/compiler/and_predicate_spec.rb
cloudhead-less-1.1.11 lib/vendor/treetop/spec/compiler/and_predicate_spec.rb
cloudhead-less-1.1.12 lib/vendor/treetop/spec/compiler/and_predicate_spec.rb
cloudhead-less-1.1.13 lib/vendor/treetop/spec/compiler/and_predicate_spec.rb
cloudhead-less-1.1.2 lib/vendor/treetop/spec/compiler/and_predicate_spec.rb
cloudhead-less-1.1.3 lib/vendor/treetop/spec/compiler/and_predicate_spec.rb
cloudhead-less-1.1.4 lib/vendor/treetop/spec/compiler/and_predicate_spec.rb