Sha256: ec9e158b539de48b70aeb2548c76ce533ffdb3b191e77b0229b02f06538e4853

Contents?: true

Size: 1.67 KB

Versions: 22

Compression:

Stored size: 1.67 KB

Contents

require 'spec_helper'

RSpec.describe('Quantifier scanning') do
  include_examples 'scan', 'a?',       1 => [:quantifier,  :zero_or_one,             '?',     1, 2]
  include_examples 'scan', 'a??',      1 => [:quantifier,  :zero_or_one_reluctant,   '??',    1, 3]
  include_examples 'scan', 'a?+',      1 => [:quantifier,  :zero_or_one_possessive,  '?+',    1, 3]

  include_examples 'scan', 'a*',       1 => [:quantifier,  :zero_or_more,            '*',     1, 2]
  include_examples 'scan', 'a*?',      1 => [:quantifier,  :zero_or_more_reluctant,  '*?',    1, 3]
  include_examples 'scan', 'a*+',      1 => [:quantifier,  :zero_or_more_possessive, '*+',    1, 3]

  include_examples 'scan', 'a+',       1 => [:quantifier,  :one_or_more,             '+',     1, 2]
  include_examples 'scan', 'a+?',      1 => [:quantifier,  :one_or_more_reluctant,   '+?',    1, 3]
  include_examples 'scan', 'a++',      1 => [:quantifier,  :one_or_more_possessive,  '++',    1, 3]

  include_examples 'scan', 'a{2}',     1 => [:quantifier,  :interval,                '{2}',   1, 4]
  include_examples 'scan', 'a{2,}',    1 => [:quantifier,  :interval,                '{2,}',  1, 5]
  include_examples 'scan', 'a{,2}',    1 => [:quantifier,  :interval,                '{,2}',  1, 5]
  include_examples 'scan', 'a{2,4}',   1 => [:quantifier,  :interval,                '{2,4}', 1, 6]

  # special case: chained quantifiers
  include_examples 'scan', 'a+{2}{3}', 1 => [:quantifier,  :one_or_more,             '+',     1, 2]
  include_examples 'scan', 'a+{2}{3}', 2 => [:quantifier,  :interval,                '{2}',   2, 5]
  include_examples 'scan', 'a+{2}{3}', 3 => [:quantifier,  :interval,                '{3}',   5, 8]
end

Version data entries

22 entries across 16 versions & 6 rubygems

Version Path
phillipug-foodie-0.1.0 .vendor/ruby/3.0.0/gems/regexp_parser-2.2.0/spec/scanner/quantifiers_spec.rb
regexp_parser-2.2.0 spec/scanner/quantifiers_spec.rb
tdiary-5.2.0 vendor/bundle/ruby/2.7.0/gems/regexp_parser-2.1.1/spec/scanner/quantifiers_spec.rb
tdiary-5.2.0 vendor/bundle/ruby/3.0.0/gems/regexp_parser-2.1.1/spec/scanner/quantifiers_spec.rb
date_n_time_picker_activeadmin-0.1.2 vendor/bundle/ruby/2.6.0/gems/regexp_parser-2.1.1/spec/scanner/quantifiers_spec.rb
date_n_time_picker_activeadmin-0.1.1 vendor/bundle/ruby/2.6.0/gems/regexp_parser-2.1.1/spec/scanner/quantifiers_spec.rb
tdiary-5.1.7 vendor/bundle/ruby/3.0.0/gems/regexp_parser-2.1.1/spec/scanner/quantifiers_spec.rb
tdiary-5.1.7 vendor/bundle/ruby/2.7.0/gems/regexp_parser-2.1.1/spec/scanner/quantifiers_spec.rb
rails_mini_profiler-0.2.0 vendor/bundle/ruby/3.0.0/gems/regexp_parser-2.1.1/spec/scanner/quantifiers_spec.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/tdiary-5.1.5/vendor/bundle/ruby/3.0.0/gems/regexp_parser-2.0.3/spec/scanner/quantifiers_spec.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/regexp_parser-2.1.1/spec/scanner/quantifiers_spec.rb
tdiary-5.1.6 vendor/bundle/ruby/2.7.0/gems/tdiary-5.1.5/vendor/bundle/ruby/2.7.0/gems/regexp_parser-2.1.1/spec/scanner/quantifiers_spec.rb
tdiary-5.1.6 vendor/bundle/ruby/3.0.0/gems/regexp_parser-2.1.1/spec/scanner/quantifiers_spec.rb
cocRb-0.1.0 .bundle/ruby/3.0.0/gems/regexp_parser-2.1.1/spec/scanner/quantifiers_spec.rb
tdiary-5.1.5 vendor/bundle/ruby/3.0.0/gems/regexp_parser-2.0.3/spec/scanner/quantifiers_spec.rb
tdiary-5.1.5 vendor/bundle/ruby/2.7.0/gems/regexp_parser-2.1.1/spec/scanner/quantifiers_spec.rb
regexp_parser-2.1.1 spec/scanner/quantifiers_spec.rb
regexp_parser-2.1.0 spec/scanner/quantifiers_spec.rb
regexp_parser-2.0.3 spec/scanner/quantifiers_spec.rb
regexp_parser-2.0.2 spec/scanner/quantifiers_spec.rb