~ubuntu-branches/ubuntu/trusty/ruby-parslet/trusty-proposed

« back to all changes in this revision

Viewing changes to spec/parslet/atoms/lookahead_spec.rb

  • Committer: Package Import Robot
  • Author(s): Axel Wagner
  • Date: 2014-01-25 19:05:00 UTC
  • Revision ID: package-import@ubuntu.com-20140125190500-teix25yb0dunago3
Tags: 1.5.0-1
Initial release (Closes: #735295)

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
require 'spec_helper'
 
2
 
 
3
describe Parslet::Atoms::Lookahead do
 
4
  include Parslet
 
5
  
 
6
  describe 'negative lookahead' do
 
7
    it "influences the error tree" do
 
8
      parser = str('f').absent? >> str('b')
 
9
      cause = catch_failed_parse { parser.parse('f') }
 
10
      
 
11
      cause.ascii_tree.should == "Failed to match sequence (!'f' 'b') at line 1 char 1.\n`- Input should not start with 'f' at line 1 char 1.\n"
 
12
    end 
 
13
  end
 
14
  describe 'positive lookahead' do
 
15
    it "influences the error tree" do
 
16
      parser = str('f').present? >> str('b')
 
17
      cause = catch_failed_parse { parser.parse('b') }
 
18
      
 
19
      cause.ascii_tree.should == "Failed to match sequence (&'f' 'b') at line 1 char 1.\n`- Input should start with 'f' at line 1 char 1.\n"
 
20
    end 
 
21
  end
 
22
end
 
 
b'\\ No newline at end of file'