Sha256: 51889c70ca500c06aa33fba1876f2e57f88d15935b65199b19ceee4f9b6cf63c

Contents?: true

Size: 927 Bytes

Versions: 7

Compression:

Stored size: 927 Bytes

Contents

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

%w[
  anchors errors escapes free_space groups literals meta
  properties quantifiers refcalls scripts sets types unicode_blocks
].each do |tc|
  require File.expand_path("../test_#{tc}", __FILE__)
end

if RUBY_VERSION >= '2.0.0'
  %w{conditionals keep}.each do|tc|
    require File.expand_path("../test_#{tc}", __FILE__)
  end
end

class TestRegexpScanner < Test::Unit::TestCase

  def test_scanner_returns_an_array
    assert_instance_of Array, RS.scan('abc')
  end

  def test_scanner_returns_tokens_as_arrays
    tokens = RS.scan('^abc+[^one]{2,3}\b\d\\\C-C$')

    all_arrays = tokens.all? do |token|
      token.kind_of?(Array) and token.length == 5
    end

    assert all_arrays, 'Not all tokens are arrays of 5 elements'
  end

  def test_scanner_token_count
    re = /^(one|two){2,3}([^d\]efm-qz\,\-]*)(ghi)+$/i

    assert_equal 28, RS.scan(re).length
  end

end

Version data entries

7 entries across 7 versions & 2 rubygems

Version Path
tdiary-5.0.13 vendor/bundle/gems/regexp_parser-1.3.0/test/scanner/test_all.rb
regexp_parser-1.4.0 test/scanner/test_all.rb
tdiary-5.0.12.1 vendor/bundle/gems/regexp_parser-1.3.0/test/scanner/test_all.rb
tdiary-5.0.11 vendor/bundle/gems/regexp_parser-1.3.0/test/scanner/test_all.rb
regexp_parser-1.3.0 test/scanner/test_all.rb
regexp_parser-1.2.0 test/scanner/test_all.rb
regexp_parser-1.1.0 test/scanner/test_all.rb