Sha256: e0525b286653a4b0c9c92bd693ec3611ba4ee845d0e30028fd8a8bc8c027320f

Contents?: true

Size: 1.38 KB

Versions: 17

Compression:

Stored size: 1.38 KB

Contents

require File.expand_path("../../helpers", __FILE__)

class ScannerMeta < Test::Unit::TestCase

  tests = {
    'abc??|def*+|ghi+' => {
      0   => [:literal,     :literal,                 'abc',  0, 3],
      1   => [:quantifier,  :zero_or_one_reluctant,   '??',   3, 5],
      2   => [:meta,        :alternation,             '|',    5, 6],
      3   => [:literal,     :literal,                 'def',  6, 9],
      4   => [:quantifier,  :zero_or_more_possessive, '*+',   9, 11],
      5   => [:meta,        :alternation,             '|',    11, 12],
    },

    '(a\|b)|(c|d)\|(e[|]f)' => {
      2   => [:escape,      :alternation,             '\|',   2, 4],
      5   => [:meta,        :alternation,             '|',    6, 7],
      8   => [:meta,        :alternation,             '|',    9, 10],
      11  => [:escape,      :alternation,             '\|',   12, 14],
      15  => [:set,         :member,                  '|',    17, 18],
    },
  }

  tests.each_with_index do |(pattern, checks), count|
    define_method "test_scanner_meta_alternation_#{count}" do
      tokens = RS.scan(pattern)

      checks.each do |index, (type, token, text, ts, te)|
        result = tokens.at(index)

        assert_equal type,  result[0]
        assert_equal token, result[1]
        assert_equal text,  result[2]
        assert_equal ts,    result[3]
        assert_equal te,    result[4]
      end
    end
  end

end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
regexp_parser-0.5.0 test/scanner/test_meta.rb
regexp_parser-0.4.13 test/scanner/test_meta.rb
regexp_parser-0.4.12 test/scanner/test_meta.rb
regexp_parser-0.4.11 test/scanner/test_meta.rb
regexp_parser-0.4.10 test/scanner/test_meta.rb
regexp_parser-0.4.9 test/scanner/test_meta.rb
regexp_parser-0.4.8 test/scanner/test_meta.rb
regexp_parser-0.4.7 test/scanner/test_meta.rb
regexp_parser-0.4.6 test/scanner/test_meta.rb
regexp_parser-0.4.5 test/scanner/test_meta.rb
regexp_parser-0.4.4 test/scanner/test_meta.rb
regexp_parser-0.4.3 test/scanner/test_meta.rb
regexp_parser-0.4.2 test/scanner/test_meta.rb
regexp_parser-0.4.1 test/scanner/test_meta.rb
regexp_parser-0.4.0 test/scanner/test_meta.rb
regexp_parser-0.3.6 test/scanner/test_meta.rb
regexp_parser-0.3.5 test/scanner/test_meta.rb