Sha256: 95890078d77adf678da2d42dd95f57ac8fd68cab59c2e520dff8bcee80715609

Contents?: true

Size: 1.69 KB

Versions: 8

Compression:

Stored size: 1.69 KB

Contents

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

class TestSyntax < Test::Unit::TestCase

  def test_syntax_unknown_name
    assert_raise( Regexp::Syntax::UnknownSyntaxNameError ) {
      Regexp::Syntax.new('ruby/1.0')
    }
  end

  def test_syntax_new
    assert_instance_of Regexp::Syntax::V1_9_3,
                       Regexp::Syntax.new('ruby/1.9.3')
  end

  def test_syntax_new_any
    assert_instance_of Regexp::Syntax::Any,
                       Regexp::Syntax.new('any')
    assert_instance_of Regexp::Syntax::Any,
                       Regexp::Syntax.new('*')
  end

  def test_syntax_not_implemented
    assert_raise( Regexp::Syntax::NotImplementedError ) {
      RP.parse('\p{alpha}', 'ruby/1.8')
    }
  end

  def test_syntax_supported?
    assert_equal false, Regexp::Syntax.supported?('ruby/1.1.1')
    assert_equal true, Regexp::Syntax.supported?('ruby/2.4.3')
    assert_equal true, Regexp::Syntax.supported?('ruby/2.5')
  end

  def test_syntax_invalid_version
    assert_raise( Regexp::Syntax::InvalidVersionNameError ) {
      Regexp::Syntax.version_class('2.0.0')
    }

    assert_raise( Regexp::Syntax::InvalidVersionNameError ) {
      Regexp::Syntax.version_class('ruby/20')
    }
  end

  def test_syntax_version_class_tiny_version
    assert_equal Regexp::Syntax::V1_9_3,
                 Regexp::Syntax.version_class('ruby/1.9.3')

    assert_equal Regexp::Syntax::V2_3_1,
                 Regexp::Syntax.version_class('ruby/2.3.1')
  end

  def test_syntax_version_class_minor_version
    assert_equal Regexp::Syntax::V1_9,
                 Regexp::Syntax.version_class('ruby/1.9')

    assert_equal Regexp::Syntax::V2_3,
                 Regexp::Syntax.version_class('ruby/2.3')
  end

end

Version data entries

8 entries across 8 versions & 2 rubygems

Version Path
tdiary-5.0.13 vendor/bundle/gems/regexp_parser-1.3.0/test/syntax/test_syntax.rb
regexp_parser-1.4.0 test/syntax/test_syntax.rb
tdiary-5.0.12.1 vendor/bundle/gems/regexp_parser-1.3.0/test/syntax/test_syntax.rb
tdiary-5.0.11 vendor/bundle/gems/regexp_parser-1.3.0/test/syntax/test_syntax.rb
regexp_parser-1.3.0 test/syntax/test_syntax.rb
regexp_parser-1.2.0 test/syntax/test_syntax.rb
regexp_parser-1.1.0 test/syntax/test_syntax.rb
regexp_parser-1.0.0 test/syntax/test_syntax.rb