File: lookbehind_spec.rb

package info (click to toggle)
ruby-ecma-re-validator 0.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 188 kB
  • sloc: ruby: 297; makefile: 4; sh: 3
file content (29 lines) | stat: -rw-r--r-- 675 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# frozen_string_literal: true

require 'spec_helper'

describe 'EcmaReValidator::Lookbehind' do
  it 'should fail if regexp has a positive lookbehind' do
    re = '(?<=a)b'

    expect(EcmaReValidator.valid?(re)).to eql(false)
  end

  it 'should pass if regexp has an escaped positive lookbehind' do
    re = '\\(?<=a\\)b'

    expect(EcmaReValidator.valid?(re)).to eql(true)
  end

  it 'should fail if regexp has a negative lookbehind' do
    re = '(?<!a)b'

    expect(EcmaReValidator.valid?(re)).to eql(false)
  end

  it 'should pass if regexp has an escaped negative lookbehind' do
    re = '\\(?<!a\\)b'

    expect(EcmaReValidator.valid?(re)).to eql(true)
  end
end