Sha256: 1fba396051c3d713d24267bc988821b4bb0729f0328b9720af8b6f5460d40de8

Contents?: true

Size: 1.02 KB

Versions: 8

Compression:

Stored size: 1.02 KB

Contents

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

class TestParserTypes < Test::Unit::TestCase

  tests = {
    /a\dc/    => [1, :type,   :digit,     CharacterType::Digit],
    /a\Dc/    => [1, :type,   :nondigit,  CharacterType::NonDigit],

    /a\sc/    => [1, :type,   :space,     CharacterType::Space],
    /a\Sc/    => [1, :type,   :nonspace,  CharacterType::NonSpace],

    /a\hc/    => [1, :type,   :hex,       CharacterType::Hex],
    /a\Hc/    => [1, :type,   :nonhex,    CharacterType::NonHex],

    /a\wc/    => [1, :type,   :word,      CharacterType::Word],
    /a\Wc/    => [1, :type,   :nonword,   CharacterType::NonWord],
  }

  tests.each_with_index do |(pattern, (index, type, token, klass)), count|
    define_method "test_parse_type_#{token}_#{count}" do
      root = RP.parse(pattern, 'ruby/1.9')
      exp  = root.expressions.at(index)

      assert exp.is_a?( klass ),
             "Expected #{klass}, but got #{exp.class.name}"

      assert_equal type,  exp.type
      assert_equal token, exp.token
    end
  end

end

Version data entries

8 entries across 8 versions & 1 rubygems

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