Sha256: ae741071c703635d132875617ed983e40fe88b4dc29bd995915d5f02b122f869

Contents?: true

Size: 1.31 KB

Versions: 3

Compression:

Stored size: 1.31 KB

Contents

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

class TestSyntaxV1_8 < 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::V1_8_6].flatten,
      quantifier:   [
          Quantifier::Greedy + Quantifier::Reluctant +
          Quantifier::Interval + Quantifier::IntervalReluctant
      ].flatten,
    },

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

      backref: [
        Backreference::All - [:number] + SubexpressionCall::All
      ].flatten,

      quantifier: [
        Quantifier::Possessive
      ].flatten
    },
  }

  tests.each do |method, types|
    expected = method == :excludes ? false : true

    types.each do |type, tokens|
      if tokens.nil? or tokens.empty?
        define_method "test_syntax_V1_8_#{method}_#{type}" do
          assert_equal expected, @syntax.implements?(type, nil)
        end
      else
        tokens.each do |token|
          define_method "test_syntax_V1_8_#{method}_#{type}_#{token}" do
            assert_equal expected, @syntax.implements?(type, token)
          end
        end
      end
    end
  end

end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
regexp_parser-1.2.0 test/syntax/versions/test_1.8.rb
regexp_parser-1.1.0 test/syntax/versions/test_1.8.rb
regexp_parser-1.0.0 test/syntax/versions/test_1.8.rb