Sha256: 16e4069fbdaa73369bbfe3dd90d986cbb3896637e252705a7cc47a26a219ba0a

Contents?: true

Size: 1.61 KB

Versions: 4

Compression:

Stored size: 1.61 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::Ruby::V193,
                       Regexp::Syntax.new('ruby/1.9.3')
  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')

    Regexp::Syntax::VERSIONS.each do |version|
      assert_equal true, Regexp::Syntax.supported?(version)
    end
  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::Ruby::V193,
                 Regexp::Syntax.version_class('ruby/1.9.3')

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

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

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

end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
regexp_parser-0.4.13 test/syntax/test_syntax.rb
regexp_parser-0.4.12 test/syntax/test_syntax.rb
regexp_parser-0.4.11 test/syntax/test_syntax.rb
regexp_parser-0.4.10 test/syntax/test_syntax.rb