Sha256: a472038170d846ff1db9d1d01adc6f0aad4fc0a88109f711ac708cd3ffef0fdb

Contents?: true

Size: 879 Bytes

Versions: 1

Compression:

Stored size: 879 Bytes

Contents

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

class ScannerConditionals < Test::Unit::TestCase

  tests = {
    /(?(1)Y|N)/         => [0, :conditional,  :open,        '(?(',  0,  3],
    /(?(2)Y|N)/         => [1, :conditional,  :condition,   '2',    3,  4],
    /(?(3)Y|N)/         => [2, :conditional,  :yes,         'Y',    5,  6],

    #"(?(<name>)Y|N)"    => [0, :conditional,  :condition, '(?(<name>)Y|N)',  0, 14],
    #"(?('name')Y|N)"    => [0, :conditional,  :yes,       "(?('name')Y|N)",  0, 14],
  }

  count = 0
  tests.each do |pattern, test|
    define_method "test_scan_#{test[1]}_#{test[2]}_#{count+=1}" do

      tokens = RS.scan(pattern)
      token = tokens[test[0]]
      assert_equal( test[1,5], token )

    end
  end

 #def test_scanner_quote
 #  tokens = RS.scan('a\QX\Eb\QX\Ec')
 #  puts tokens.inspect
 #  #assert_equal( tokens[0] )
 #end

end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
regexp_parser-0.1.5 test/scanner/test_conditionals.rb