Sha256: 6fb9e6d0a37e67b58ea92407be90cfbea25d8c804b93be883457c2f7e0c28e91

Contents?: true

Size: 921 Bytes

Versions: 8

Compression:

Stored size: 921 Bytes

Contents

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

class ScannerTypes < Test::Unit::TestCase

  tests = {
   'a\dc' => [1, :type,  :digit,       '\d',  1, 3],
   'a\Dc' => [1, :type,  :nondigit,    '\D',  1, 3],

   'a\hc' => [1, :type,  :hex,         '\h',  1, 3],
   'a\Hc' => [1, :type,  :nonhex,      '\H',  1, 3],

   'a\sc' => [1, :type,  :space,       '\s',  1, 3],
   'a\Sc' => [1, :type,  :nonspace,    '\S',  1, 3],

   'a\wc' => [1, :type,  :word,        '\w',  1, 3],
   'a\Wc' => [1, :type,  :nonword,     '\W',  1, 3],
  }

  tests.each do |(pattern, (index, type, token, text, ts, te))|
    define_method "test_scanner_#{type}_#{token}" do
      tokens = RS.scan(pattern)
      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

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
regexp_parser-0.4.5 test/scanner/test_types.rb
regexp_parser-0.4.4 test/scanner/test_types.rb
regexp_parser-0.4.3 test/scanner/test_types.rb
regexp_parser-0.4.2 test/scanner/test_types.rb
regexp_parser-0.4.1 test/scanner/test_types.rb
regexp_parser-0.4.0 test/scanner/test_types.rb
regexp_parser-0.3.6 test/scanner/test_types.rb
regexp_parser-0.3.5 test/scanner/test_types.rb