Sha256: 2ae1c29e9a2f7826ce679e787202093527df4d1f142afbd546c2425d454c4f36

Contents?: true

Size: 1.37 KB

Versions: 5

Compression:

Stored size: 1.37 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::Basic + Escape::ASCII + Escape::Meta + Escape::Control
      ].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

5 entries across 5 versions & 2 rubygems

Version Path
tdiary-5.0.13 vendor/bundle/gems/regexp_parser-1.3.0/test/syntax/versions/test_1.8.rb
regexp_parser-1.4.0 test/syntax/versions/test_1.8.rb
tdiary-5.0.12.1 vendor/bundle/gems/regexp_parser-1.3.0/test/syntax/versions/test_1.8.rb
tdiary-5.0.11 vendor/bundle/gems/regexp_parser-1.3.0/test/syntax/versions/test_1.8.rb
regexp_parser-1.3.0 test/syntax/versions/test_1.8.rb