Sha256: 5955cf9788bb1054cf304bac1afcba68a44ad5a2fabb6fda7276b1ba0010be2c

Contents?: true

Size: 953 Bytes

Versions: 8

Compression:

Stored size: 953 Bytes

Contents

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

%w{
  literals nesting refcalls
}.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 TestRegexpLexer < Test::Unit::TestCase

  def test_lexer_returns_an_array
    assert_instance_of Array, RL.lex('abc')
  end

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

    assert tokens.all?{ |token| token.kind_of?(Regexp::Token) },
          "Not all array members are tokens"

    assert tokens.all?{ |token| token.to_a.length == 8 },
          "Not all tokens have a length of 8"
  end

  def test_lexer_token_count
    tokens = RL.lex(/^(one|two){2,3}([^d\]efm-qz\,\-]*)(ghi)+$/i)

    assert_equal 28, tokens.length
  end

  def test_lexer_scan_alias
    assert_equal RL.lex(/a|b|c/), RL.scan(/a|b|c/)
  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/lexer/test_all.rb
regexp_parser-1.4.0 test/lexer/test_all.rb
tdiary-5.0.12.1 vendor/bundle/gems/regexp_parser-1.3.0/test/lexer/test_all.rb
tdiary-5.0.11 vendor/bundle/gems/regexp_parser-1.3.0/test/lexer/test_all.rb
regexp_parser-1.3.0 test/lexer/test_all.rb
regexp_parser-1.2.0 test/lexer/test_all.rb
regexp_parser-1.1.0 test/lexer/test_all.rb
regexp_parser-1.0.0 test/lexer/test_all.rb