Sha256: bd54789d1136193c0cf1d4e1c01b34c1c8ce8c2ec667ab103ab570c611fb6fe6

Contents?: true

Size: 1.44 KB

Versions: 9

Compression:

Stored size: 1.44 KB

Contents

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

class TestSyntaxRuby_V18 < Test::Unit::TestCase
  include Regexp::Syntax::Token

  def setup
    @syntax = Regexp::Syntax.new 'ruby/1.8'
  end

  tests = {
    :implements => {
      :assertion    => [Assertion::Lookahead].flatten,
      :backref      => [:number],
      :escape       => [Escape::All].flatten,
      :group        => [Group::All].flatten,
      :quantifier   => [
          Quantifier::Greedy + Quantifier::Reluctant +
          Quantifier::Interval + Quantifier::IntervalReluctant
      ].flatten,
    },

    :excludes => {
      :assertion    => [Assertion::Lookbehind].flatten,

      :backref => [
        Backreference::All + SubexpressionCall::All
      ].flatten,

      :quantifier => [
        Quantifier::Possessive
      ].flatten,

      :subset => nil
    },
  }

  tests.each do |method, types|
    types.each do |type, tokens|
      if tokens.nil? or tokens.empty?
        define_method "test_syntax_ruby_v18_#{method}_#{type}" do
          assert_equal(
            method == :excludes ? false : true,
            @syntax.implements?(type, nil)
          )
        end
      else
        tokens.each do |token|
          define_method "test_syntax_ruby_v18_#{method}_#{type}_#{token}" do
            assert_equal(
              method == :excludes ? false : true,
              @syntax.implements?(type, token)
            )
          end
        end
      end
    end
  end

end

Version data entries

9 entries across 9 versions & 1 rubygems

Version Path
regexp_parser-0.3.4 test/syntax/ruby/test_1.8.rb
regexp_parser-0.3.3 test/syntax/ruby/test_1.8.rb
regexp_parser-0.3.2 test/syntax/ruby/test_1.8.rb
regexp_parser-0.3.1 test/syntax/ruby/test_1.8.rb
regexp_parser-0.3.0 test/syntax/ruby/test_1.8.rb
regexp_parser-0.2.1 test/syntax/ruby/test_1.8.rb
regexp_parser-0.2.0 test/syntax/ruby/test_1.8.rb
regexp_parser-0.1.6 test/syntax/ruby/test_1.8.rb
regexp_parser-0.1.5 test/syntax/ruby/test_1.8.rb