Class RegexPathTest
In: lib/regex_path.rb
Parent: Test::Unit::TestCase

Methods

Constants

Seg = RegexPath::Segment

Public Instance methods

[Source]

# File lib/regex_path.rb, line 115
    def compare(str, tab)
      tab.collect! do |e|
        (e.is_a? Seg)? e : Seg.new(e)
      end
      desc = "Compare #{str} with #{tab}."
      assert_equal(tab, RegexPath.new(str).segments, desc)
    end

[Source]

# File lib/regex_path.rb, line 160
    def test_errors
      assert_raise(ArgumentError) { RegexPath.new(42) }
    end

[Source]

# File lib/regex_path.rb, line 138
    def test_final?
      assert(RegexPath.new('/foo/bar\Z').final?)
      assert(! RegexPath.new('/foo/barZ').final?)
      assert(! RegexPath.new('/foo/bar').final?)
    end

[Source]

# File lib/regex_path.rb, line 150
    def test_negative_path
      assert(RegexPath.new('\N/foo/bar\Z').negative?)
      assert(RegexPath.new('\Nfoo/bar').negative?)
      assert(! RegexPath.new('/foo/barZ').negative?)
      assert(! RegexPath.new('/\Nfoo/bar').negative?)
      assert(! RegexPath.new('foo/bar').negative?)
      assert(! RegexPath.new('\foo/bar').negative?)
      assert(! RegexPath.new('Nfoo/bar').negative?)
    end

[Source]

# File lib/regex_path.rb, line 144
    def test_root?
      assert(RegexPath.new('/foo/bar\Z').root?)
      assert(! RegexPath.new('\/foo/barZ').root?)
      assert(! RegexPath.new('foo/bar').root?)
    end

[Source]

# File lib/regex_path.rb, line 123
    def testit
      compare('mho', [ 'mho' ])
      compare('mho\\', [ 'mho' ])
      compare('/mho', [ 'mho' ])
      compare('/mho/42', [ 'mho', '42' ])
      compare('/mho/[0-9]+', [ 'mho', '[0-9]+' ])
      compare('m\/ho', [ 'm\/ho' ])
      compare('mho/foo', [ 'mho', 'foo' ])
      compare('mho/35/foo/test', [ 'mho', '35', 'foo' , 'test' ])
      compare('test/()status/PASS', [ 'test', Seg.new('status', true), 'PASS' ])
      compare('/()mho', [ Seg.new('mho', true) ])
      compare('mho/()', [ 'mho', Seg.new('', true) ])
      compare('/()mho/()', [ Seg.new('mho', true), Seg.new('', true) ])
    end

[Validate]