Sha256: 7f3784fcda1248fbed17f493b3a007662a8f13feb1b8e22709dcdf63f721e0af

Contents?: true

Size: 812 Bytes

Versions: 11

Compression:

Stored size: 812 Bytes

Contents

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

class ScannerTypes < Test::Unit::TestCase

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

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

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

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

  tests.each do |pattern, test|
    [:type, :token, :text].each_with_index do |member, i|
      define_method "test_scan_#{test[0]}_#{test[1]}_#{member}" do

        token = RS.scan(pattern)[test[3]]
        assert_equal( test[i], token[i] )

      end
    end
  end

end

Version data entries

11 entries across 11 versions & 1 rubygems

Version Path
regexp_parser-0.3.4 test/scanner/test_types.rb
regexp_parser-0.3.3 test/scanner/test_types.rb
regexp_parser-0.3.2 test/scanner/test_types.rb
regexp_parser-0.3.1 test/scanner/test_types.rb
regexp_parser-0.3.0 test/scanner/test_types.rb
regexp_parser-0.2.1 test/scanner/test_types.rb
regexp_parser-0.2.0 test/scanner/test_types.rb
regexp_parser-0.1.6 test/scanner/test_types.rb
regexp_parser-0.1.5 test/scanner/test_types.rb
regexp_parser-0.1.1 test/scanner/test_types.rb
regexp_parser-0.1.0 test/scanner/test_types.rb