Sha256: 333d69e1ab7ca8aebfe507d77b1f86d5bbd7e80d5bc7b43aca8a300ac4475cbd

Contents?: true

Size: 1018 Bytes

Versions: 6

Compression:

Stored size: 1018 Bytes

Contents

require File.join(File.dirname(__FILE__), '..', 'test_helper')

describe "An optional terminal symbol", :extend => CompilerTestCase do
  testing_expression '"foo"?'
  
  it "parses input matching the terminal" do
    parse('foo').should be_success
  end
  
  it "parses epsilon, with a nested failure" do
    parse('') do |result|
      result.should be_success
      result.interval.should == (0...0)
      result.nested_failures.size.should == 1
      nested_failure = result.nested_failures.first
      nested_failure.index.should == 0
      nested_failure.expected_string.should == 'foo'
    end
  end
  
  it "parses input not matching the terminal, returning an epsilon result with a nested failure" do
    parse('bar') do |result|
      result.should be_success
      result.interval.should == (0...0)
      result.nested_failures.size.should == 1
      nested_failure = result.nested_failures.first
      nested_failure.index.should == 0
      nested_failure.expected_string.should == 'foo'
    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
treetop-1.1.0 test/compiler/optional_test.rb
treetop-1.0.0 test/compiler/optional_test.rb
treetop-1.0.2 test/compiler/optional_test.rb
treetop-1.0.1 test/compiler/optional_test.rb
treetop-1.1.1 test/compiler/optional_test.rb
treetop-1.1.2 test/compiler/optional_test.rb