Sha256: 126fab2d3cf625fb9f5836b26c535cdf81aabb954d8e10122b32e62ce745cf00

Contents?: true

Size: 953 Bytes

Versions: 17

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 26, 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

17 entries across 17 versions & 1 rubygems

Version Path
regexp_parser-0.5.0 test/lexer/test_all.rb
regexp_parser-0.4.13 test/lexer/test_all.rb
regexp_parser-0.4.12 test/lexer/test_all.rb
regexp_parser-0.4.11 test/lexer/test_all.rb
regexp_parser-0.4.10 test/lexer/test_all.rb
regexp_parser-0.4.9 test/lexer/test_all.rb
regexp_parser-0.4.8 test/lexer/test_all.rb
regexp_parser-0.4.7 test/lexer/test_all.rb
regexp_parser-0.4.6 test/lexer/test_all.rb
regexp_parser-0.4.5 test/lexer/test_all.rb
regexp_parser-0.4.4 test/lexer/test_all.rb
regexp_parser-0.4.3 test/lexer/test_all.rb
regexp_parser-0.4.2 test/lexer/test_all.rb
regexp_parser-0.4.1 test/lexer/test_all.rb
regexp_parser-0.4.0 test/lexer/test_all.rb
regexp_parser-0.3.6 test/lexer/test_all.rb
regexp_parser-0.3.5 test/lexer/test_all.rb