File: test_lookahead.rb

package info (click to toggle)
ruby-rsec 0.4.2-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 272 kB
  • sloc: ruby: 2,130; lisp: 13; makefile: 3
file content (22 lines) | stat: -rw-r--r-- 452 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
require "#{File.dirname(__FILE__)}/helpers.rb"

class TestLookAhead < TC
  def test_lookahead
    p1 = 'a'.r & 'b'
    p2 = /\w/.r
    p = seq(p1, p2)
    ase ['a', 'b'], p.parse('ab')
    ase INVALID, p.parse('ac')
    
    p1 = 'a'.r ^ 'b'
    p = seq(p1, p2)
    ase ['a', 'c'], p.parse('ac')
    ase INVALID, p.parse('ab')
  end

  def test_negative_lookahead
    p = 'a'.r ^ 'b'
    ase 'a', p.parse('ac')
    ase INVALID, p.parse('ab')
  end
end