Sha256: b1358da775d4acfa4ffefd00c7c2ff4f9f4c93bfef23a563a17958a6cd2fd814

Contents?: true

Size: 1.09 KB

Versions: 9

Compression:

Stored size: 1.09 KB

Contents

require 'spec_helper'

module OptionalSpec
  describe "An optional terminal symbol" do
    testing_expression '"foo"?'
  
    it "parses input matching the terminal" do
      parse('foo').should_not be_nil
    end
  
    it "parses epsilon, recording a failure" do
      parse('') do |result|
        result.should_not be_nil
        result.interval.should == (0...0)
        
        terminal_failures = parser.terminal_failures
        terminal_failures.size.should == 1
        failure = terminal_failures.first
        failure.index.should == 0
        failure.expected_string.should == '"foo"'
      end
    end
  
    it "parses input not matching the terminal, returning an epsilon result and recording a failure" do
      parse('bar', :consume_all_input => false) do |result|
        result.should_not be_nil
        result.interval.should == (0...0)
        
        terminal_failures = parser.terminal_failures
        terminal_failures.size.should == 1
        failure = terminal_failures.first
        failure.index.should == 0
        failure.expected_string.should == '"foo"'
      end
    end
  end
end

Version data entries

9 entries across 9 versions & 2 rubygems

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