Sha256: a316327b32ef7592ff59427dc39bcd306a1a531e426cbae5f52a80419099a970

Contents?: true

Size: 1.22 KB

Versions: 4

Compression:

Stored size: 1.22 KB

Contents

# Copyright: Copyright (c) 2004  Nicolas Despres. All rights reserved.
# Author: Nicolas Despres  <polrop@lrde.epita.fr>.
# License: Gnu General Public License.

# $LastChangedBy: polrop $
# $Id: const_regexp.rb 83 2004-12-16 13:06:42Z polrop $


module ConstRegexp

  RB_INST_VAR = /^@[A-Za-z_][A-Za-z0-9_]*$/
  RB_CLASS_VAR = /^@@[A-Za-z_][A-Za-z0-9_]*$/ #FIXME: concat with RB_INST_VAR
  RB_LOCAL_VAR = /^[a-z_][A-Za-z0-9_]*$/
  RB_METHOD = /^[a-z_][A-Za-z0-9_]*[=?!]?$/
  RB_REGEXP = /^\/([^\\]|\\.)*\/$/
  RB_CONST = /^[A-Z][a-zA-Z0-9_]*$/

  CRYPTED_STRING = /^[A-Za-z0-9.\/]{13}$/

  DRB_URI = /^([^:]+):\/\/([^:]+):(\d+)$/



end # module ConstRegexp


#
# Unit test suite
#
if defined? TEST_MODE or $0 == __FILE__


require 'test/unit/ui/yaml/testrunner'


class ConstRegexpTest < Test::Unit::TestCase

  include ConstRegexp

  #
  # Tests
  #
  def test_rb_regexp
    assert_match(RB_REGEXP, '//')
    assert_no_match(RB_REGEXP, '')
    assert_match(RB_REGEXP, '/\//')
    assert_match(RB_REGEXP, '/\/\//')
    assert_match(RB_REGEXP, '/reg\/e/')
    assert_no_match(RB_REGEXP, '/\\/')
    assert_match(RB_REGEXP, '/\\\\/')
    assert_match(RB_REGEXP, '/\e/')
    assert_no_match(RB_REGEXP, '/\/')
  end

end # class ConstRegexpTest


end

Version data entries

4 entries across 4 versions & 2 rubygems

Version Path
ttk-0.1.576 ruby_ex/const_regexp.rb
ttk-0.1.580 ruby_ex/const_regexp.rb
ttk-0.1.579 ruby_ex/const_regexp.rb
vcs-0.2.148 ruby_ex/const_regexp.rb