pathname2 1.6.4-x86-mingw32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGES +129 -0
 - data/MANIFEST +11 -0
 - data/README +99 -0
 - data/Rakefile +43 -0
 - data/benchmarks/bench_pathname.rb +127 -0
 - data/benchmarks/bench_plus.rb +34 -0
 - data/examples/example_pathname.rb +25 -0
 - data/lib/pathname2.rb +1124 -0
 - data/pathname2.gemspec +37 -0
 - data/test/test_pathname.rb +480 -0
 - data/test/test_pathname_windows.rb +678 -0
 - metadata +126 -0
 
| 
         @@ -0,0 +1,678 @@ 
     | 
|
| 
      
 1 
     | 
    
         
            +
            ##########################################################################
         
     | 
| 
      
 2 
     | 
    
         
            +
            # test_pathname_win.rb
         
     | 
| 
      
 3 
     | 
    
         
            +
            #
         
     | 
| 
      
 4 
     | 
    
         
            +
            # MS Windows test suite for the Pathname class. To test explicitly
         
     | 
| 
      
 5 
     | 
    
         
            +
            # against the C extension pass the letter 'c' as an argument. You should
         
     | 
| 
      
 6 
     | 
    
         
            +
            # use the 'rake test' task to run this test suite.
         
     | 
| 
      
 7 
     | 
    
         
            +
            ###########################################################################
         
     | 
| 
      
 8 
     | 
    
         
            +
            require 'rubygems'
         
     | 
| 
      
 9 
     | 
    
         
            +
            gem 'test-unit'
         
     | 
| 
      
 10 
     | 
    
         
            +
             
     | 
| 
      
 11 
     | 
    
         
            +
            require 'facade'
         
     | 
| 
      
 12 
     | 
    
         
            +
            require 'pathname2'
         
     | 
| 
      
 13 
     | 
    
         
            +
            require 'test/unit'
         
     | 
| 
      
 14 
     | 
    
         
            +
            require 'windows/system_info'
         
     | 
| 
      
 15 
     | 
    
         
            +
             
     | 
| 
      
 16 
     | 
    
         
            +
            class MyPathname < Pathname; end
         
     | 
| 
      
 17 
     | 
    
         
            +
             
     | 
| 
      
 18 
     | 
    
         
            +
            class TC_Pathname_MSWin < Test::Unit::TestCase
         
     | 
| 
      
 19 
     | 
    
         
            +
              include Windows::SystemInfo
         
     | 
| 
      
 20 
     | 
    
         
            +
             
     | 
| 
      
 21 
     | 
    
         
            +
              def setup
         
     | 
| 
      
 22 
     | 
    
         
            +
                @fpath = Pathname.new("C:/Program Files/Windows NT/Accessories")
         
     | 
| 
      
 23 
     | 
    
         
            +
                @bpath = Pathname.new("C:\\Program Files\\Windows NT\\Accessories")
         
     | 
| 
      
 24 
     | 
    
         
            +
                @dpath = Pathname.new("C:\\Program Files\\File[5].txt")
         
     | 
| 
      
 25 
     | 
    
         
            +
                @spath = Pathname.new("C:\\PROGRA~1\\WINDOW~1\\ACCESS~1")
         
     | 
| 
      
 26 
     | 
    
         
            +
                @upath = Pathname.new("\\\\foo\\bar\\baz")
         
     | 
| 
      
 27 
     | 
    
         
            +
                @npath = Pathname.new("foo\\bar\\baz")
         
     | 
| 
      
 28 
     | 
    
         
            +
                @rpath = Pathname.new("Z:\\")
         
     | 
| 
      
 29 
     | 
    
         
            +
                @xpath = Pathname.new("\\\\foo\\bar")
         
     | 
| 
      
 30 
     | 
    
         
            +
                @ypath = Pathname.new("\\\\foo")
         
     | 
| 
      
 31 
     | 
    
         
            +
                @zpath = Pathname.new("\\\\")
         
     | 
| 
      
 32 
     | 
    
         
            +
                @epath = Pathname.new("")
         
     | 
| 
      
 33 
     | 
    
         
            +
                @ppath = Pathname.new("C:\\foo\\bar\\")
         
     | 
| 
      
 34 
     | 
    
         
            +
                @cpath = Pathname.new("C:\\foo\\..\\bar\\.\\baz")
         
     | 
| 
      
 35 
     | 
    
         
            +
                @tpath = Pathname.new("C:\\foo\\bar")
         
     | 
| 
      
 36 
     | 
    
         
            +
             
     | 
| 
      
 37 
     | 
    
         
            +
                @url_path = Pathname.new("file:///C:/Documents%20and%20Settings")
         
     | 
| 
      
 38 
     | 
    
         
            +
                @cur_path = Pathname.new(Dir.pwd)
         
     | 
| 
      
 39 
     | 
    
         
            +
             
     | 
| 
      
 40 
     | 
    
         
            +
                @mypath = MyPathname.new("C:\\Program Files")
         
     | 
| 
      
 41 
     | 
    
         
            +
             
     | 
| 
      
 42 
     | 
    
         
            +
                @abs_array = []
         
     | 
| 
      
 43 
     | 
    
         
            +
                @rel_array = []
         
     | 
| 
      
 44 
     | 
    
         
            +
                @unc_array = []
         
     | 
| 
      
 45 
     | 
    
         
            +
              end
         
     | 
| 
      
 46 
     | 
    
         
            +
             
     | 
| 
      
 47 
     | 
    
         
            +
              def test_aref_with_range
         
     | 
| 
      
 48 
     | 
    
         
            +
                assert_equal("C:\\Program Files", @fpath[0..1])
         
     | 
| 
      
 49 
     | 
    
         
            +
                assert_equal("C:\\Program Files\\Windows NT", @fpath[0..2])
         
     | 
| 
      
 50 
     | 
    
         
            +
                assert_equal("Program Files\\Windows NT", @fpath[1..2])
         
     | 
| 
      
 51 
     | 
    
         
            +
                assert_equal(@fpath, @fpath[0..-1])
         
     | 
| 
      
 52 
     | 
    
         
            +
              end
         
     | 
| 
      
 53 
     | 
    
         
            +
             
     | 
| 
      
 54 
     | 
    
         
            +
              def test_aref_with_index_and_length
         
     | 
| 
      
 55 
     | 
    
         
            +
                assert_equal("C:", @fpath[0,1])
         
     | 
| 
      
 56 
     | 
    
         
            +
                assert_equal("C:\\Program Files", @fpath[0,2])
         
     | 
| 
      
 57 
     | 
    
         
            +
                assert_equal("Program Files\\Windows NT", @fpath[1,2])
         
     | 
| 
      
 58 
     | 
    
         
            +
              end
         
     | 
| 
      
 59 
     | 
    
         
            +
             
     | 
| 
      
 60 
     | 
    
         
            +
              def test_aref_with_index
         
     | 
| 
      
 61 
     | 
    
         
            +
                assert_equal("C:", @fpath[0])
         
     | 
| 
      
 62 
     | 
    
         
            +
                assert_equal("Program Files", @fpath[1])
         
     | 
| 
      
 63 
     | 
    
         
            +
                assert_equal("Accessories", @fpath[-1])
         
     | 
| 
      
 64 
     | 
    
         
            +
                assert_equal(nil, @fpath[10])
         
     | 
| 
      
 65 
     | 
    
         
            +
              end
         
     | 
| 
      
 66 
     | 
    
         
            +
             
     | 
| 
      
 67 
     | 
    
         
            +
              def test_version
         
     | 
| 
      
 68 
     | 
    
         
            +
                assert_equal('1.6.4', Pathname::VERSION)
         
     | 
| 
      
 69 
     | 
    
         
            +
              end
         
     | 
| 
      
 70 
     | 
    
         
            +
             
     | 
| 
      
 71 
     | 
    
         
            +
              # Convenience method for test_plus
         
     | 
| 
      
 72 
     | 
    
         
            +
              def assert_pathname_plus(a, b, c)
         
     | 
| 
      
 73 
     | 
    
         
            +
                a = Pathname.new(a)
         
     | 
| 
      
 74 
     | 
    
         
            +
                b = Pathname.new(b)
         
     | 
| 
      
 75 
     | 
    
         
            +
                c = Pathname.new(c)
         
     | 
| 
      
 76 
     | 
    
         
            +
                assert_equal(a, b + c)
         
     | 
| 
      
 77 
     | 
    
         
            +
              end
         
     | 
| 
      
 78 
     | 
    
         
            +
             
     | 
| 
      
 79 
     | 
    
         
            +
              # Convenience method for test_spaceship operator
         
     | 
| 
      
 80 
     | 
    
         
            +
              def assert_pathname_cmp(int, s1, s2)
         
     | 
| 
      
 81 
     | 
    
         
            +
                p1 = Pathname.new(s1)
         
     | 
| 
      
 82 
     | 
    
         
            +
                p2 = Pathname.new(s2)
         
     | 
| 
      
 83 
     | 
    
         
            +
                result = p1 <=> p2
         
     | 
| 
      
 84 
     | 
    
         
            +
                assert_equal(int, result)
         
     | 
| 
      
 85 
     | 
    
         
            +
              end
         
     | 
| 
      
 86 
     | 
    
         
            +
             
     | 
| 
      
 87 
     | 
    
         
            +
              # Convenience method for test_relative_path_from
         
     | 
| 
      
 88 
     | 
    
         
            +
              def assert_relpath(result, dest, base)
         
     | 
| 
      
 89 
     | 
    
         
            +
                assert_equal(result, Pathname.new(dest).relative_path_from(base))
         
     | 
| 
      
 90 
     | 
    
         
            +
              end
         
     | 
| 
      
 91 
     | 
    
         
            +
             
     | 
| 
      
 92 
     | 
    
         
            +
              # Convenience method for test_relative_path_from_expected_errors
         
     | 
| 
      
 93 
     | 
    
         
            +
              def assert_relative_path_error(to, from)
         
     | 
| 
      
 94 
     | 
    
         
            +
                assert_raise(ArgumentError){
         
     | 
| 
      
 95 
     | 
    
         
            +
                  Pathname.new(to).relative_path_from(from)
         
     | 
| 
      
 96 
     | 
    
         
            +
                }
         
     | 
| 
      
 97 
     | 
    
         
            +
              end
         
     | 
| 
      
 98 
     | 
    
         
            +
             
     | 
| 
      
 99 
     | 
    
         
            +
              def test_file_urls
         
     | 
| 
      
 100 
     | 
    
         
            +
                assert_equal("C:\\Documents and Settings", @url_path)
         
     | 
| 
      
 101 
     | 
    
         
            +
                assert_raises(Pathname::Error){ Pathname.new('http://rubyforge.org') }
         
     | 
| 
      
 102 
     | 
    
         
            +
              end
         
     | 
| 
      
 103 
     | 
    
         
            +
             
     | 
| 
      
 104 
     | 
    
         
            +
              def test_realpath
         
     | 
| 
      
 105 
     | 
    
         
            +
                assert_respond_to(@fpath, :realpath)
         
     | 
| 
      
 106 
     | 
    
         
            +
                assert_equal(@cur_path, Pathname.new('.').realpath)
         
     | 
| 
      
 107 
     | 
    
         
            +
                assert_raises(Errno::ENOENT){ Pathname.new('../bogus').realpath }
         
     | 
| 
      
 108 
     | 
    
         
            +
              end
         
     | 
| 
      
 109 
     | 
    
         
            +
             
     | 
| 
      
 110 
     | 
    
         
            +
              def test_relative_path_from
         
     | 
| 
      
 111 
     | 
    
         
            +
                assert_relpath("..\\a", "a", "b")
         
     | 
| 
      
 112 
     | 
    
         
            +
                assert_relpath("..\\a", "a", "b\\")
         
     | 
| 
      
 113 
     | 
    
         
            +
                assert_relpath("..\\a", "a\\", "b")
         
     | 
| 
      
 114 
     | 
    
         
            +
                assert_relpath("..\\a", "a\\", "b\\")
         
     | 
| 
      
 115 
     | 
    
         
            +
                assert_relpath("..\\a", "c:\\a", "c:\\b")
         
     | 
| 
      
 116 
     | 
    
         
            +
                assert_relpath("..\\a", "c:\\a", "c:\\b\\")
         
     | 
| 
      
 117 
     | 
    
         
            +
                assert_relpath("..\\a", "c:\\a\\", "c:\\b")
         
     | 
| 
      
 118 
     | 
    
         
            +
                assert_relpath("..\\a", "c:\\a\\", "c:\\b\\")
         
     | 
| 
      
 119 
     | 
    
         
            +
             
     | 
| 
      
 120 
     | 
    
         
            +
                assert_relpath("..\\b", "a\\b", "a\\c")
         
     | 
| 
      
 121 
     | 
    
         
            +
                assert_relpath("..\\a", "..\\a", "..\\b")
         
     | 
| 
      
 122 
     | 
    
         
            +
             
     | 
| 
      
 123 
     | 
    
         
            +
                assert_relpath("a", "a", ".")
         
     | 
| 
      
 124 
     | 
    
         
            +
                assert_relpath("..", ".", "a")
         
     | 
| 
      
 125 
     | 
    
         
            +
             
     | 
| 
      
 126 
     | 
    
         
            +
                assert_relpath(".", ".", ".")
         
     | 
| 
      
 127 
     | 
    
         
            +
                assert_relpath(".", "..", "..")
         
     | 
| 
      
 128 
     | 
    
         
            +
                assert_relpath("..", "..", ".")
         
     | 
| 
      
 129 
     | 
    
         
            +
             
     | 
| 
      
 130 
     | 
    
         
            +
                assert_relpath("c\\d", "c:\\a\\b\\c\\d", "c:\\a\\b")
         
     | 
| 
      
 131 
     | 
    
         
            +
                assert_relpath("..\\..", "c:\\a\\b", "c:\\a\\b\\c\\d")
         
     | 
| 
      
 132 
     | 
    
         
            +
                assert_relpath("..\\..\\..\\..\\e", "c:\\e", "c:\\a\\b\\c\\d")
         
     | 
| 
      
 133 
     | 
    
         
            +
                assert_relpath("..\\b\\c", "a\\b\\c", "a\\d")
         
     | 
| 
      
 134 
     | 
    
         
            +
             
     | 
| 
      
 135 
     | 
    
         
            +
                assert_relpath("..\\a", "c:\\..\\a", "c:\\b")
         
     | 
| 
      
 136 
     | 
    
         
            +
                #assert_relpath("..\\..\\a", "..\\a", "b") # fails
         
     | 
| 
      
 137 
     | 
    
         
            +
                assert_relpath(".", "c:\\a\\..\\..\\b", "c:\\b")
         
     | 
| 
      
 138 
     | 
    
         
            +
                assert_relpath("..", "a\\..", "a")
         
     | 
| 
      
 139 
     | 
    
         
            +
                assert_relpath(".", "a\\..\\b", "b")
         
     | 
| 
      
 140 
     | 
    
         
            +
             
     | 
| 
      
 141 
     | 
    
         
            +
                assert_relpath("a", "a", "b\\..")
         
     | 
| 
      
 142 
     | 
    
         
            +
                assert_relpath("b\\c", "b\\c", "b\\..")
         
     | 
| 
      
 143 
     | 
    
         
            +
              end
         
     | 
| 
      
 144 
     | 
    
         
            +
             
     | 
| 
      
 145 
     | 
    
         
            +
              def test_relative_path_from_expected_errors
         
     | 
| 
      
 146 
     | 
    
         
            +
                assert_relative_path_error("c:\\", ".")
         
     | 
| 
      
 147 
     | 
    
         
            +
                assert_relative_path_error(".", "c:\\")
         
     | 
| 
      
 148 
     | 
    
         
            +
                assert_relative_path_error("a", "..")
         
     | 
| 
      
 149 
     | 
    
         
            +
                assert_relative_path_error(".", "..")
         
     | 
| 
      
 150 
     | 
    
         
            +
                assert_relative_path_error("C:\\Temp", "D:\\Temp")
         
     | 
| 
      
 151 
     | 
    
         
            +
                assert_relative_path_error("\\\\Server\\Temp", "D:\\Temp")
         
     | 
| 
      
 152 
     | 
    
         
            +
              end
         
     | 
| 
      
 153 
     | 
    
         
            +
             
     | 
| 
      
 154 
     | 
    
         
            +
              # Convenience method to verify that the receiver was not modified
         
     | 
| 
      
 155 
     | 
    
         
            +
              # except perhaps slashes
         
     | 
| 
      
 156 
     | 
    
         
            +
              def assert_non_destructive
         
     | 
| 
      
 157 
     | 
    
         
            +
                assert_equal("C:\\Program Files\\Windows NT\\Accessories", @fpath)
         
     | 
| 
      
 158 
     | 
    
         
            +
                assert_equal("C:\\Program Files\\Windows NT\\Accessories", @bpath)
         
     | 
| 
      
 159 
     | 
    
         
            +
                assert_equal("C:\\Program Files\\File[5].txt", @dpath)
         
     | 
| 
      
 160 
     | 
    
         
            +
                assert_equal("C:\\PROGRA~1\\WINDOW~1\\ACCESS~1", @spath)
         
     | 
| 
      
 161 
     | 
    
         
            +
                assert_equal("\\\\foo\\bar\\baz", @upath)
         
     | 
| 
      
 162 
     | 
    
         
            +
                assert_equal("foo\\bar\\baz", @npath)
         
     | 
| 
      
 163 
     | 
    
         
            +
                assert_equal("Z:\\", @rpath)
         
     | 
| 
      
 164 
     | 
    
         
            +
                assert_equal("\\\\foo\\bar", @xpath)
         
     | 
| 
      
 165 
     | 
    
         
            +
                assert_equal("\\\\foo", @ypath)
         
     | 
| 
      
 166 
     | 
    
         
            +
                assert_equal("\\\\", @zpath)
         
     | 
| 
      
 167 
     | 
    
         
            +
                assert_equal("", @epath)
         
     | 
| 
      
 168 
     | 
    
         
            +
                assert_equal("C:\\foo\\bar\\", @ppath)
         
     | 
| 
      
 169 
     | 
    
         
            +
                assert_equal("C:\\foo\\..\\bar\\.\\baz", @cpath)
         
     | 
| 
      
 170 
     | 
    
         
            +
              end
         
     | 
| 
      
 171 
     | 
    
         
            +
             
     | 
| 
      
 172 
     | 
    
         
            +
              def test_parent
         
     | 
| 
      
 173 
     | 
    
         
            +
                assert_respond_to(@bpath, :parent)
         
     | 
| 
      
 174 
     | 
    
         
            +
                assert_equal("C:\\Program Files\\Windows NT", @bpath.parent)
         
     | 
| 
      
 175 
     | 
    
         
            +
                assert_equal("foo\\bar", @npath.parent)
         
     | 
| 
      
 176 
     | 
    
         
            +
                assert_equal("Z:\\", @rpath.parent)
         
     | 
| 
      
 177 
     | 
    
         
            +
              end
         
     | 
| 
      
 178 
     | 
    
         
            +
             
     | 
| 
      
 179 
     | 
    
         
            +
              def test_short_path
         
     | 
| 
      
 180 
     | 
    
         
            +
                assert_respond_to(@bpath, :short_path)
         
     | 
| 
      
 181 
     | 
    
         
            +
                assert_nothing_raised{ @bpath.short_path }
         
     | 
| 
      
 182 
     | 
    
         
            +
                assert_kind_of(Pathname, @bpath.short_path)
         
     | 
| 
      
 183 
     | 
    
         
            +
                assert_match(/C:\\PROGRA~1\\WINDOW~\d\\ACCESS~\d/, @bpath.short_path)
         
     | 
| 
      
 184 
     | 
    
         
            +
                assert_equal("C:\\Program Files\\Windows NT\\Accessories", @bpath)
         
     | 
| 
      
 185 
     | 
    
         
            +
              end
         
     | 
| 
      
 186 
     | 
    
         
            +
             
     | 
| 
      
 187 
     | 
    
         
            +
              test "long_path basic functionality" do
         
     | 
| 
      
 188 
     | 
    
         
            +
                assert_respond_to(@spath, :long_path)
         
     | 
| 
      
 189 
     | 
    
         
            +
                assert_nothing_raised{ @spath.long_path }
         
     | 
| 
      
 190 
     | 
    
         
            +
                assert_kind_of(Pathname, @spath.long_path)
         
     | 
| 
      
 191 
     | 
    
         
            +
              end
         
     | 
| 
      
 192 
     | 
    
         
            +
             
     | 
| 
      
 193 
     | 
    
         
            +
              test "long_path returns expected result" do
         
     | 
| 
      
 194 
     | 
    
         
            +
                if windows_7?
         
     | 
| 
      
 195 
     | 
    
         
            +
                  spath = Pathname.new("C:\\PROGRA~1\\Window~2\\ACCESS~1")
         
     | 
| 
      
 196 
     | 
    
         
            +
                  lpath = "C:\\Program Files\\Windows NT\\Accessories"
         
     | 
| 
      
 197 
     | 
    
         
            +
                  assert_equal("C:\\Program Files\\Windows NT\\Accessories", spath.long_path)
         
     | 
| 
      
 198 
     | 
    
         
            +
                  assert_match(/C:\\PROGRA~1\\WINDOW~\d\\ACCESS~\d/i, spath)
         
     | 
| 
      
 199 
     | 
    
         
            +
                else
         
     | 
| 
      
 200 
     | 
    
         
            +
                  assert_equal("C:\\Program Files\\Windows NT\\Accessories", @spath.long_path)
         
     | 
| 
      
 201 
     | 
    
         
            +
                  assert_match(/C:\\PROGRA~1\\WINDOW~\d\\ACCESS~\d/i, @spath)
         
     | 
| 
      
 202 
     | 
    
         
            +
                end
         
     | 
| 
      
 203 
     | 
    
         
            +
              end
         
     | 
| 
      
 204 
     | 
    
         
            +
             
     | 
| 
      
 205 
     | 
    
         
            +
              test "undecorate basic functionality" do
         
     | 
| 
      
 206 
     | 
    
         
            +
                assert_respond_to(@dpath, :undecorate)
         
     | 
| 
      
 207 
     | 
    
         
            +
                assert_nothing_raised{ @dpath.undecorate }
         
     | 
| 
      
 208 
     | 
    
         
            +
                assert_kind_of(Pathname, @dpath.undecorate)
         
     | 
| 
      
 209 
     | 
    
         
            +
              end
         
     | 
| 
      
 210 
     | 
    
         
            +
             
     | 
| 
      
 211 
     | 
    
         
            +
              test "undecorate returns expected results" do
         
     | 
| 
      
 212 
     | 
    
         
            +
                assert_equal('C:\Program Files\File.txt', @dpath.undecorate)
         
     | 
| 
      
 213 
     | 
    
         
            +
                assert_equal('C:\Path\File', Pathname.new('C:\Path\File').undecorate)
         
     | 
| 
      
 214 
     | 
    
         
            +
                assert_equal('C:\Path\File', Pathname.new('C:\Path\File[12]').undecorate)
         
     | 
| 
      
 215 
     | 
    
         
            +
                assert_equal('C:\Path\[3].txt', Pathname.new('C:\Path\[3].txt').undecorate)
         
     | 
| 
      
 216 
     | 
    
         
            +
                assert_equal('\\foo\bar.txt',Pathname.new('\\foo\bar[5].txt').undecorate)
         
     | 
| 
      
 217 
     | 
    
         
            +
                assert_equal('\\foo\bar', Pathname.new('\\foo\bar[5]').undecorate)
         
     | 
| 
      
 218 
     | 
    
         
            +
                assert_equal('\\foo\bar', Pathname.new('\\foo\bar').undecorate)
         
     | 
| 
      
 219 
     | 
    
         
            +
                assert_equal("C:\\Program Files\\File[5].txt", @dpath)
         
     | 
| 
      
 220 
     | 
    
         
            +
              end
         
     | 
| 
      
 221 
     | 
    
         
            +
             
     | 
| 
      
 222 
     | 
    
         
            +
              test "undecorate_bang basic functionality" do
         
     | 
| 
      
 223 
     | 
    
         
            +
                assert_respond_to(@dpath, :undecorate!)
         
     | 
| 
      
 224 
     | 
    
         
            +
                assert_nothing_raised{ @dpath.undecorate! }
         
     | 
| 
      
 225 
     | 
    
         
            +
                assert_kind_of(Pathname, @dpath.undecorate!)
         
     | 
| 
      
 226 
     | 
    
         
            +
              end
         
     | 
| 
      
 227 
     | 
    
         
            +
             
     | 
| 
      
 228 
     | 
    
         
            +
              test "undecorate_bang returns expected results" do
         
     | 
| 
      
 229 
     | 
    
         
            +
                assert_equal('C:\Program Files\File.txt', @dpath.undecorate!)
         
     | 
| 
      
 230 
     | 
    
         
            +
                assert_equal('C:\Path\File', Pathname.new('C:\Path\File').undecorate!)
         
     | 
| 
      
 231 
     | 
    
         
            +
                assert_equal('C:\Path\File', Pathname.new('C:\Path\File[12]').undecorate!)
         
     | 
| 
      
 232 
     | 
    
         
            +
                assert_equal('C:\Path\[3].txt', Pathname.new('C:\Path\[3].txt').undecorate!)
         
     | 
| 
      
 233 
     | 
    
         
            +
                assert_equal('\\foo\bar.txt',Pathname.new('\\foo\bar[5].txt').undecorate!)
         
     | 
| 
      
 234 
     | 
    
         
            +
                assert_equal('\\foo\bar', Pathname.new('\\foo\bar[5]').undecorate!)
         
     | 
| 
      
 235 
     | 
    
         
            +
                assert_equal('\\foo\bar', Pathname.new('\\foo\bar').undecorate!)
         
     | 
| 
      
 236 
     | 
    
         
            +
                assert_equal('C:\Program Files\File.txt', @dpath)
         
     | 
| 
      
 237 
     | 
    
         
            +
              end
         
     | 
| 
      
 238 
     | 
    
         
            +
             
     | 
| 
      
 239 
     | 
    
         
            +
              test "unc basic functionality" do
         
     | 
| 
      
 240 
     | 
    
         
            +
                assert_respond_to(@upath, :unc?)
         
     | 
| 
      
 241 
     | 
    
         
            +
                assert_nothing_raised{ @upath.unc? }
         
     | 
| 
      
 242 
     | 
    
         
            +
              end
         
     | 
| 
      
 243 
     | 
    
         
            +
             
     | 
| 
      
 244 
     | 
    
         
            +
              test "unc returns expected results" do
         
     | 
| 
      
 245 
     | 
    
         
            +
                assert_true(@upath.unc?)
         
     | 
| 
      
 246 
     | 
    
         
            +
                assert_true(@xpath.unc?)
         
     | 
| 
      
 247 
     | 
    
         
            +
                assert_true(@ypath.unc?)
         
     | 
| 
      
 248 
     | 
    
         
            +
                assert_true(@zpath.unc?)
         
     | 
| 
      
 249 
     | 
    
         
            +
                assert_false(@fpath.unc?)
         
     | 
| 
      
 250 
     | 
    
         
            +
                assert_false(@bpath.unc?)
         
     | 
| 
      
 251 
     | 
    
         
            +
                assert_false(@dpath.unc?)
         
     | 
| 
      
 252 
     | 
    
         
            +
                assert_false(@spath.unc?)
         
     | 
| 
      
 253 
     | 
    
         
            +
                assert_false(@epath.unc?)
         
     | 
| 
      
 254 
     | 
    
         
            +
             
     | 
| 
      
 255 
     | 
    
         
            +
                # Arguably a bug in the PathIsUNC() function since drive letters
         
     | 
| 
      
 256 
     | 
    
         
            +
                # are, in fact, a legal part of a UNC path (for historical reasons).
         
     | 
| 
      
 257 
     | 
    
         
            +
                assert_false(Pathname.new("C:\\\\foo\\bar\\baz").unc?)
         
     | 
| 
      
 258 
     | 
    
         
            +
             
     | 
| 
      
 259 
     | 
    
         
            +
                assert_non_destructive
         
     | 
| 
      
 260 
     | 
    
         
            +
              end
         
     | 
| 
      
 261 
     | 
    
         
            +
             
     | 
| 
      
 262 
     | 
    
         
            +
              def test_pstrip
         
     | 
| 
      
 263 
     | 
    
         
            +
                assert_respond_to(@ppath, :pstrip)
         
     | 
| 
      
 264 
     | 
    
         
            +
                assert_nothing_raised{ @ppath.pstrip }
         
     | 
| 
      
 265 
     | 
    
         
            +
                assert_nothing_raised{ @fpath.pstrip }
         
     | 
| 
      
 266 
     | 
    
         
            +
                assert_kind_of(Pathname, @ppath.pstrip)
         
     | 
| 
      
 267 
     | 
    
         
            +
             
     | 
| 
      
 268 
     | 
    
         
            +
                assert_equal('C:\foo', Pathname.new("C:\\foo\\").pstrip)
         
     | 
| 
      
 269 
     | 
    
         
            +
                assert_equal('C:\foo', Pathname.new("C:\\foo").pstrip)
         
     | 
| 
      
 270 
     | 
    
         
            +
                assert_equal("", Pathname.new("").pstrip)
         
     | 
| 
      
 271 
     | 
    
         
            +
             
     | 
| 
      
 272 
     | 
    
         
            +
                assert_equal("C:\\foo\\bar\\", @ppath)
         
     | 
| 
      
 273 
     | 
    
         
            +
              end
         
     | 
| 
      
 274 
     | 
    
         
            +
             
     | 
| 
      
 275 
     | 
    
         
            +
              def test_pstrip_bang
         
     | 
| 
      
 276 
     | 
    
         
            +
                assert_respond_to(@ppath, :pstrip!)
         
     | 
| 
      
 277 
     | 
    
         
            +
                assert_nothing_raised{ @ppath.pstrip! }
         
     | 
| 
      
 278 
     | 
    
         
            +
                assert_nothing_raised{ @fpath.pstrip! }
         
     | 
| 
      
 279 
     | 
    
         
            +
                assert_kind_of(Pathname, @ppath.pstrip!)
         
     | 
| 
      
 280 
     | 
    
         
            +
             
     | 
| 
      
 281 
     | 
    
         
            +
                assert_equal('C:\foo', Pathname.new("C:\\foo\\").pstrip!)
         
     | 
| 
      
 282 
     | 
    
         
            +
                assert_equal('C:\foo', Pathname.new("C:\\foo").pstrip!)
         
     | 
| 
      
 283 
     | 
    
         
            +
                assert_equal("", Pathname.new("").pstrip!)
         
     | 
| 
      
 284 
     | 
    
         
            +
             
     | 
| 
      
 285 
     | 
    
         
            +
                assert_equal("C:\\foo\\bar", @ppath)
         
     | 
| 
      
 286 
     | 
    
         
            +
              end
         
     | 
| 
      
 287 
     | 
    
         
            +
             
     | 
| 
      
 288 
     | 
    
         
            +
              def test_exists
         
     | 
| 
      
 289 
     | 
    
         
            +
                assert_respond_to(@fpath, :exists?)
         
     | 
| 
      
 290 
     | 
    
         
            +
                assert_nothing_raised{ @fpath.exists? }
         
     | 
| 
      
 291 
     | 
    
         
            +
                assert_true(Pathname.new("C:\\").exists?)
         
     | 
| 
      
 292 
     | 
    
         
            +
                assert_false(Pathname.new("X:\\foo\\bar\\baz").exists?)
         
     | 
| 
      
 293 
     | 
    
         
            +
              end
         
     | 
| 
      
 294 
     | 
    
         
            +
             
     | 
| 
      
 295 
     | 
    
         
            +
              def test_each
         
     | 
| 
      
 296 
     | 
    
         
            +
                array = []
         
     | 
| 
      
 297 
     | 
    
         
            +
             
     | 
| 
      
 298 
     | 
    
         
            +
                assert_respond_to(@fpath, :each)
         
     | 
| 
      
 299 
     | 
    
         
            +
                assert_nothing_raised{ @fpath.each{ |e| array.push(e) } }
         
     | 
| 
      
 300 
     | 
    
         
            +
                assert_equal(["C:", "Program Files", "Windows NT", "Accessories"], array)
         
     | 
| 
      
 301 
     | 
    
         
            +
              end
         
     | 
| 
      
 302 
     | 
    
         
            +
             
     | 
| 
      
 303 
     | 
    
         
            +
              def test_descend
         
     | 
| 
      
 304 
     | 
    
         
            +
                assert_respond_to(@bpath, :descend)
         
     | 
| 
      
 305 
     | 
    
         
            +
                assert_nothing_raised{ @bpath.descend{} }
         
     | 
| 
      
 306 
     | 
    
         
            +
             
     | 
| 
      
 307 
     | 
    
         
            +
                @bpath.descend{ |path| @abs_array.push(path) }
         
     | 
| 
      
 308 
     | 
    
         
            +
                @npath.descend{ |path| @rel_array.push(path) }
         
     | 
| 
      
 309 
     | 
    
         
            +
                @upath.descend{ |path| @unc_array.push(path) }
         
     | 
| 
      
 310 
     | 
    
         
            +
             
     | 
| 
      
 311 
     | 
    
         
            +
                assert_equal("C:", @abs_array[0])
         
     | 
| 
      
 312 
     | 
    
         
            +
                assert_equal("C:\\Program Files", @abs_array[1])
         
     | 
| 
      
 313 
     | 
    
         
            +
                assert_equal("C:\\Program Files\\Windows NT", @abs_array[2])
         
     | 
| 
      
 314 
     | 
    
         
            +
                assert_equal("C:\\Program Files\\Windows NT\\Accessories", @abs_array[3])
         
     | 
| 
      
 315 
     | 
    
         
            +
             
     | 
| 
      
 316 
     | 
    
         
            +
                assert_equal("foo", @rel_array[0])
         
     | 
| 
      
 317 
     | 
    
         
            +
                assert_equal("foo\\bar", @rel_array[1])
         
     | 
| 
      
 318 
     | 
    
         
            +
                assert_equal("foo\\bar\\baz", @rel_array[2])
         
     | 
| 
      
 319 
     | 
    
         
            +
             
     | 
| 
      
 320 
     | 
    
         
            +
                assert_equal("\\\\foo\\bar", @unc_array[0])
         
     | 
| 
      
 321 
     | 
    
         
            +
                assert_equal("\\\\foo\\bar\\baz", @unc_array[1])
         
     | 
| 
      
 322 
     | 
    
         
            +
             
     | 
| 
      
 323 
     | 
    
         
            +
                assert_non_destructive
         
     | 
| 
      
 324 
     | 
    
         
            +
              end
         
     | 
| 
      
 325 
     | 
    
         
            +
             
     | 
| 
      
 326 
     | 
    
         
            +
              def test_ascend
         
     | 
| 
      
 327 
     | 
    
         
            +
                assert_respond_to(@bpath, :ascend)
         
     | 
| 
      
 328 
     | 
    
         
            +
                assert_nothing_raised{ @bpath.ascend{} }
         
     | 
| 
      
 329 
     | 
    
         
            +
             
     | 
| 
      
 330 
     | 
    
         
            +
                @bpath.ascend{ |path| @abs_array.push(path) }
         
     | 
| 
      
 331 
     | 
    
         
            +
                @npath.ascend{ |path| @rel_array.push(path) }
         
     | 
| 
      
 332 
     | 
    
         
            +
                @upath.ascend{ |path| @unc_array.push(path) }
         
     | 
| 
      
 333 
     | 
    
         
            +
             
     | 
| 
      
 334 
     | 
    
         
            +
                assert_equal("C:\\Program Files\\Windows NT\\Accessories", @abs_array[0])
         
     | 
| 
      
 335 
     | 
    
         
            +
                assert_equal("C:\\Program Files\\Windows NT", @abs_array[1])
         
     | 
| 
      
 336 
     | 
    
         
            +
                assert_equal("C:\\Program Files", @abs_array[2])
         
     | 
| 
      
 337 
     | 
    
         
            +
                assert_equal("C:", @abs_array[3])
         
     | 
| 
      
 338 
     | 
    
         
            +
                assert_equal(4, @abs_array.length)
         
     | 
| 
      
 339 
     | 
    
         
            +
             
     | 
| 
      
 340 
     | 
    
         
            +
                assert_equal("foo\\bar\\baz", @rel_array[0])
         
     | 
| 
      
 341 
     | 
    
         
            +
                assert_equal("foo\\bar", @rel_array[1])
         
     | 
| 
      
 342 
     | 
    
         
            +
                assert_equal("foo", @rel_array[2])
         
     | 
| 
      
 343 
     | 
    
         
            +
                assert_equal(3, @rel_array.length)
         
     | 
| 
      
 344 
     | 
    
         
            +
             
     | 
| 
      
 345 
     | 
    
         
            +
                assert_equal("\\\\foo\\bar\\baz", @unc_array[0])
         
     | 
| 
      
 346 
     | 
    
         
            +
                assert_equal("\\\\foo\\bar", @unc_array[1])
         
     | 
| 
      
 347 
     | 
    
         
            +
                assert_equal(2, @unc_array.length)
         
     | 
| 
      
 348 
     | 
    
         
            +
             
     | 
| 
      
 349 
     | 
    
         
            +
                assert_non_destructive
         
     | 
| 
      
 350 
     | 
    
         
            +
              end
         
     | 
| 
      
 351 
     | 
    
         
            +
             
     | 
| 
      
 352 
     | 
    
         
            +
              def test_immutability
         
     | 
| 
      
 353 
     | 
    
         
            +
                path = "C:\\Program Files\\foo\\bar".freeze
         
     | 
| 
      
 354 
     | 
    
         
            +
                assert_true(path.frozen?)
         
     | 
| 
      
 355 
     | 
    
         
            +
                assert_nothing_raised{ Pathname.new(path) }
         
     | 
| 
      
 356 
     | 
    
         
            +
                assert_nothing_raised{ Pathname.new(path).root }
         
     | 
| 
      
 357 
     | 
    
         
            +
              end
         
     | 
| 
      
 358 
     | 
    
         
            +
             
     | 
| 
      
 359 
     | 
    
         
            +
              def test_plus_operator
         
     | 
| 
      
 360 
     | 
    
         
            +
                # Standard stuff
         
     | 
| 
      
 361 
     | 
    
         
            +
                assert_pathname_plus("C:\\a\\b", "C:\\a", "b")
         
     | 
| 
      
 362 
     | 
    
         
            +
                assert_pathname_plus("C:\\b", "a", "C:\\b")
         
     | 
| 
      
 363 
     | 
    
         
            +
                assert_pathname_plus("a\\b", "a", "b")
         
     | 
| 
      
 364 
     | 
    
         
            +
                assert_pathname_plus("C:\\b", "C:\\a", "..\\b")
         
     | 
| 
      
 365 
     | 
    
         
            +
                assert_pathname_plus("C:\\a\\b", "C:\\a\\.", "\\b")
         
     | 
| 
      
 366 
     | 
    
         
            +
                assert_pathname_plus("C:\\a\\b.txt", "C:\\a", "b.txt")
         
     | 
| 
      
 367 
     | 
    
         
            +
             
     | 
| 
      
 368 
     | 
    
         
            +
                # UNC paths
         
     | 
| 
      
 369 
     | 
    
         
            +
                assert_pathname_plus("\\\\foo\\bar", "\\\\foo", "bar")
         
     | 
| 
      
 370 
     | 
    
         
            +
                assert_pathname_plus("\\\\foo", "\\\\", "foo")
         
     | 
| 
      
 371 
     | 
    
         
            +
                assert_pathname_plus("\\\\", "\\\\", "")
         
     | 
| 
      
 372 
     | 
    
         
            +
                assert_pathname_plus("\\\\foo\\baz", "\\\\foo\\bar", "\\..\\baz")
         
     | 
| 
      
 373 
     | 
    
         
            +
                assert_pathname_plus("\\\\", "\\\\", "..\\..\\..\\..")
         
     | 
| 
      
 374 
     | 
    
         
            +
             
     | 
| 
      
 375 
     | 
    
         
            +
                # Pathname + String
         
     | 
| 
      
 376 
     | 
    
         
            +
                assert_nothing_raised{ @tpath + "bar" }
         
     | 
| 
      
 377 
     | 
    
         
            +
                assert_equal('C:\foo\bar\baz', @tpath + 'baz')
         
     | 
| 
      
 378 
     | 
    
         
            +
                assert_equal('C:\foo\bar', @tpath)
         
     | 
| 
      
 379 
     | 
    
         
            +
             
     | 
| 
      
 380 
     | 
    
         
            +
                # Ensure neither left nor right operand are modified
         
     | 
| 
      
 381 
     | 
    
         
            +
                assert_nothing_raised{ @tpath + @npath }
         
     | 
| 
      
 382 
     | 
    
         
            +
                assert_equal('C:\foo\bar\foo\bar\baz', @tpath + @npath)
         
     | 
| 
      
 383 
     | 
    
         
            +
                assert_equal('C:\foo\bar', @tpath)
         
     | 
| 
      
 384 
     | 
    
         
            +
                assert_equal('foo\bar\baz', @npath)
         
     | 
| 
      
 385 
     | 
    
         
            +
              end
         
     | 
| 
      
 386 
     | 
    
         
            +
             
     | 
| 
      
 387 
     | 
    
         
            +
              def test_clean
         
     | 
| 
      
 388 
     | 
    
         
            +
                assert_respond_to(@cpath, :clean)
         
     | 
| 
      
 389 
     | 
    
         
            +
                assert_nothing_raised{ @cpath.clean }
         
     | 
| 
      
 390 
     | 
    
         
            +
                assert_kind_of(Pathname, @cpath.clean)
         
     | 
| 
      
 391 
     | 
    
         
            +
             
     | 
| 
      
 392 
     | 
    
         
            +
                # Our preset stuff
         
     | 
| 
      
 393 
     | 
    
         
            +
                assert_equal("C:\\Program Files\\Windows NT\\Accessories", @fpath.clean)
         
     | 
| 
      
 394 
     | 
    
         
            +
                assert_equal("C:\\Program Files\\Windows NT\\Accessories", @bpath.clean)
         
     | 
| 
      
 395 
     | 
    
         
            +
                assert_equal("\\\\foo\\bar\\baz", @upath.clean)
         
     | 
| 
      
 396 
     | 
    
         
            +
                assert_equal("foo\\bar\\baz", @npath.clean)
         
     | 
| 
      
 397 
     | 
    
         
            +
                assert_equal("Z:\\", @rpath.clean)
         
     | 
| 
      
 398 
     | 
    
         
            +
                assert_equal("\\\\foo\\bar", @xpath.clean)
         
     | 
| 
      
 399 
     | 
    
         
            +
                assert_equal("\\\\foo", @ypath.clean)
         
     | 
| 
      
 400 
     | 
    
         
            +
                assert_equal("\\\\", @zpath.clean)
         
     | 
| 
      
 401 
     | 
    
         
            +
                assert_equal("", @epath.clean)
         
     | 
| 
      
 402 
     | 
    
         
            +
                assert_equal("C:\\bar\\baz", @cpath.clean)
         
     | 
| 
      
 403 
     | 
    
         
            +
             
     | 
| 
      
 404 
     | 
    
         
            +
                # Standard stuff
         
     | 
| 
      
 405 
     | 
    
         
            +
                assert_equal("C:\\a\\c", Pathname.new("C:\\a\\.\\b\\..\\c").clean)
         
     | 
| 
      
 406 
     | 
    
         
            +
                assert_equal("C:\\a", Pathname.new("C:\\.\\a").clean)
         
     | 
| 
      
 407 
     | 
    
         
            +
                assert_equal("C:\\a\\b", Pathname.new("C:\\a\\.\\b").clean)
         
     | 
| 
      
 408 
     | 
    
         
            +
                assert_equal("C:\\b", Pathname.new("C:\\a\\..\\b").clean)
         
     | 
| 
      
 409 
     | 
    
         
            +
                assert_equal("C:\\a", Pathname.new("C:\\a\\.").clean)
         
     | 
| 
      
 410 
     | 
    
         
            +
                assert_equal("C:\\d", Pathname.new("C:\\..\\..\\..\\d").clean)
         
     | 
| 
      
 411 
     | 
    
         
            +
                assert_equal("C:\\a\\", Pathname.new("C:\\a\\").clean)
         
     | 
| 
      
 412 
     | 
    
         
            +
             
     | 
| 
      
 413 
     | 
    
         
            +
                # Edge cases
         
     | 
| 
      
 414 
     | 
    
         
            +
                assert_equal("\\", Pathname.new(".").clean)
         
     | 
| 
      
 415 
     | 
    
         
            +
                assert_equal("\\", Pathname.new("..").clean)
         
     | 
| 
      
 416 
     | 
    
         
            +
             
     | 
| 
      
 417 
     | 
    
         
            +
                assert_non_destructive
         
     | 
| 
      
 418 
     | 
    
         
            +
              end
         
     | 
| 
      
 419 
     | 
    
         
            +
             
     | 
| 
      
 420 
     | 
    
         
            +
              def test_clean_bang
         
     | 
| 
      
 421 
     | 
    
         
            +
                assert_respond_to(@cpath, :clean!)
         
     | 
| 
      
 422 
     | 
    
         
            +
                assert_nothing_raised{ @cpath.clean! }
         
     | 
| 
      
 423 
     | 
    
         
            +
                assert_kind_of(Pathname, @cpath.clean!)
         
     | 
| 
      
 424 
     | 
    
         
            +
             
     | 
| 
      
 425 
     | 
    
         
            +
                # Our preset stuff
         
     | 
| 
      
 426 
     | 
    
         
            +
                assert_equal("C:\\Program Files\\Windows NT\\Accessories", @fpath.clean!)
         
     | 
| 
      
 427 
     | 
    
         
            +
                assert_equal("C:\\Program Files\\Windows NT\\Accessories", @bpath.clean!)
         
     | 
| 
      
 428 
     | 
    
         
            +
                assert_equal("\\\\foo\\bar\\baz", @upath.clean!)
         
     | 
| 
      
 429 
     | 
    
         
            +
                assert_equal("foo\\bar\\baz", @npath.clean!)
         
     | 
| 
      
 430 
     | 
    
         
            +
                assert_equal("Z:\\", @rpath.clean!)
         
     | 
| 
      
 431 
     | 
    
         
            +
                assert_equal("\\\\foo\\bar", @xpath.clean!)
         
     | 
| 
      
 432 
     | 
    
         
            +
                assert_equal("\\\\foo", @ypath.clean!)
         
     | 
| 
      
 433 
     | 
    
         
            +
                assert_equal("\\\\", @zpath.clean!)
         
     | 
| 
      
 434 
     | 
    
         
            +
                assert_equal("", @epath.clean!)
         
     | 
| 
      
 435 
     | 
    
         
            +
                assert_equal("C:\\bar\\baz", @cpath.clean!)
         
     | 
| 
      
 436 
     | 
    
         
            +
             
     | 
| 
      
 437 
     | 
    
         
            +
                # Standard stuff
         
     | 
| 
      
 438 
     | 
    
         
            +
                assert_equal("C:\\a\\c", Pathname.new("C:\\a\\.\\b\\..\\c").clean!)
         
     | 
| 
      
 439 
     | 
    
         
            +
                assert_equal("C:\\a", Pathname.new("C:\\.\\a").clean!)
         
     | 
| 
      
 440 
     | 
    
         
            +
                assert_equal("C:\\a\\b", Pathname.new("C:\\a\\.\\b").clean!)
         
     | 
| 
      
 441 
     | 
    
         
            +
                assert_equal("C:\\b", Pathname.new("C:\\a\\..\\b").clean!)
         
     | 
| 
      
 442 
     | 
    
         
            +
                assert_equal("C:\\a", Pathname.new("C:\\a\\.").clean!)
         
     | 
| 
      
 443 
     | 
    
         
            +
                assert_equal("C:\\d", Pathname.new("C:\\..\\..\\..\\d").clean!)
         
     | 
| 
      
 444 
     | 
    
         
            +
                assert_equal("C:\\a\\", Pathname.new("C:\\a\\").clean!)
         
     | 
| 
      
 445 
     | 
    
         
            +
             
     | 
| 
      
 446 
     | 
    
         
            +
                # Edge cases
         
     | 
| 
      
 447 
     | 
    
         
            +
                assert_equal("\\", Pathname.new(".").clean!)
         
     | 
| 
      
 448 
     | 
    
         
            +
                assert_equal("\\", Pathname.new("..").clean!)
         
     | 
| 
      
 449 
     | 
    
         
            +
             
     | 
| 
      
 450 
     | 
    
         
            +
                assert_equal("C:\\bar\\baz", @cpath)
         
     | 
| 
      
 451 
     | 
    
         
            +
              end
         
     | 
| 
      
 452 
     | 
    
         
            +
             
     | 
| 
      
 453 
     | 
    
         
            +
              def test_absolute
         
     | 
| 
      
 454 
     | 
    
         
            +
                assert_true(@fpath.absolute?)
         
     | 
| 
      
 455 
     | 
    
         
            +
                assert_true(@bpath.absolute?)
         
     | 
| 
      
 456 
     | 
    
         
            +
                assert_true(@upath.absolute?)
         
     | 
| 
      
 457 
     | 
    
         
            +
                assert_false(@npath.absolute?)
         
     | 
| 
      
 458 
     | 
    
         
            +
                assert_true(@rpath.absolute?)
         
     | 
| 
      
 459 
     | 
    
         
            +
                assert_true(@xpath.absolute?)
         
     | 
| 
      
 460 
     | 
    
         
            +
                assert_true(@ypath.absolute?)
         
     | 
| 
      
 461 
     | 
    
         
            +
                assert_true(@zpath.absolute?)
         
     | 
| 
      
 462 
     | 
    
         
            +
                assert_false(@epath.absolute?)
         
     | 
| 
      
 463 
     | 
    
         
            +
             
     | 
| 
      
 464 
     | 
    
         
            +
                assert_non_destructive
         
     | 
| 
      
 465 
     | 
    
         
            +
              end
         
     | 
| 
      
 466 
     | 
    
         
            +
             
     | 
| 
      
 467 
     | 
    
         
            +
              def test_relative
         
     | 
| 
      
 468 
     | 
    
         
            +
                assert_false(@fpath.relative?)
         
     | 
| 
      
 469 
     | 
    
         
            +
                assert_false(@bpath.relative?)
         
     | 
| 
      
 470 
     | 
    
         
            +
                assert_false(@upath.relative?)
         
     | 
| 
      
 471 
     | 
    
         
            +
                assert_true(@npath.relative?)
         
     | 
| 
      
 472 
     | 
    
         
            +
                assert_false(@rpath.relative?)
         
     | 
| 
      
 473 
     | 
    
         
            +
                assert_false(@xpath.relative?)
         
     | 
| 
      
 474 
     | 
    
         
            +
                assert_false(@ypath.relative?)
         
     | 
| 
      
 475 
     | 
    
         
            +
                assert_false(@zpath.relative?)
         
     | 
| 
      
 476 
     | 
    
         
            +
                assert_true(@epath.relative?)
         
     | 
| 
      
 477 
     | 
    
         
            +
                assert_non_destructive
         
     | 
| 
      
 478 
     | 
    
         
            +
              end
         
     | 
| 
      
 479 
     | 
    
         
            +
             
     | 
| 
      
 480 
     | 
    
         
            +
              def test_root
         
     | 
| 
      
 481 
     | 
    
         
            +
                assert_equal("C:\\", @fpath.root)
         
     | 
| 
      
 482 
     | 
    
         
            +
                assert_equal("C:\\", @bpath.root)
         
     | 
| 
      
 483 
     | 
    
         
            +
                assert_equal("\\\\foo\\bar", @upath.root)
         
     | 
| 
      
 484 
     | 
    
         
            +
                assert_equal(".", @npath.root)
         
     | 
| 
      
 485 
     | 
    
         
            +
                assert_equal("Z:\\", @rpath.root)
         
     | 
| 
      
 486 
     | 
    
         
            +
                assert_equal("\\\\foo\\bar", @xpath.root)
         
     | 
| 
      
 487 
     | 
    
         
            +
                assert_equal("\\\\foo", @ypath.root)
         
     | 
| 
      
 488 
     | 
    
         
            +
                assert_equal("\\\\", @zpath.root)
         
     | 
| 
      
 489 
     | 
    
         
            +
                assert_equal(".", @epath.root)
         
     | 
| 
      
 490 
     | 
    
         
            +
             
     | 
| 
      
 491 
     | 
    
         
            +
                # Edge cases
         
     | 
| 
      
 492 
     | 
    
         
            +
                assert_equal(".", Pathname.new("..").root)
         
     | 
| 
      
 493 
     | 
    
         
            +
                assert_equal(".", Pathname.new(".").root)
         
     | 
| 
      
 494 
     | 
    
         
            +
             
     | 
| 
      
 495 
     | 
    
         
            +
                assert_non_destructive
         
     | 
| 
      
 496 
     | 
    
         
            +
              end
         
     | 
| 
      
 497 
     | 
    
         
            +
             
     | 
| 
      
 498 
     | 
    
         
            +
              def test_drive_number
         
     | 
| 
      
 499 
     | 
    
         
            +
                assert_equal(2, @fpath.drive_number)
         
     | 
| 
      
 500 
     | 
    
         
            +
                assert_equal(2, @bpath.drive_number)
         
     | 
| 
      
 501 
     | 
    
         
            +
                assert_equal(nil, @upath.drive_number)
         
     | 
| 
      
 502 
     | 
    
         
            +
                assert_equal(nil, @npath.drive_number)
         
     | 
| 
      
 503 
     | 
    
         
            +
                assert_equal(25, @rpath.drive_number)
         
     | 
| 
      
 504 
     | 
    
         
            +
                assert_equal(nil, @xpath.drive_number)
         
     | 
| 
      
 505 
     | 
    
         
            +
                assert_equal(nil, @ypath.drive_number)
         
     | 
| 
      
 506 
     | 
    
         
            +
                assert_equal(nil, @zpath.drive_number)
         
     | 
| 
      
 507 
     | 
    
         
            +
                assert_equal(nil, @epath.drive_number)
         
     | 
| 
      
 508 
     | 
    
         
            +
             
     | 
| 
      
 509 
     | 
    
         
            +
                # Edge cases
         
     | 
| 
      
 510 
     | 
    
         
            +
                assert_equal(nil, Pathname.new("..").drive_number)
         
     | 
| 
      
 511 
     | 
    
         
            +
                assert_equal(nil, Pathname.new(".").drive_number)
         
     | 
| 
      
 512 
     | 
    
         
            +
             
     | 
| 
      
 513 
     | 
    
         
            +
                assert_non_destructive
         
     | 
| 
      
 514 
     | 
    
         
            +
              end
         
     | 
| 
      
 515 
     | 
    
         
            +
             
     | 
| 
      
 516 
     | 
    
         
            +
              def test_to_a
         
     | 
| 
      
 517 
     | 
    
         
            +
                expected = ["C:", "Program Files", "Windows NT", "Accessories"]
         
     | 
| 
      
 518 
     | 
    
         
            +
                assert_equal(expected, @fpath.to_a)
         
     | 
| 
      
 519 
     | 
    
         
            +
                assert_equal(expected, @bpath.to_a)
         
     | 
| 
      
 520 
     | 
    
         
            +
                assert_equal(["foo","bar","baz"], @upath.to_a)
         
     | 
| 
      
 521 
     | 
    
         
            +
                assert_equal(["foo","bar","baz"], @npath.to_a)
         
     | 
| 
      
 522 
     | 
    
         
            +
                assert_equal(["Z:"], @rpath.to_a)
         
     | 
| 
      
 523 
     | 
    
         
            +
                assert_equal(["foo","bar"], @xpath.to_a)
         
     | 
| 
      
 524 
     | 
    
         
            +
                assert_equal(["foo"], @ypath.to_a)
         
     | 
| 
      
 525 
     | 
    
         
            +
                assert_equal([], @zpath.to_a)
         
     | 
| 
      
 526 
     | 
    
         
            +
                assert_equal([], @epath.to_a)
         
     | 
| 
      
 527 
     | 
    
         
            +
                assert_equal(["C:", "foo", "bar"], @ppath.to_a)
         
     | 
| 
      
 528 
     | 
    
         
            +
             
     | 
| 
      
 529 
     | 
    
         
            +
                assert_non_destructive
         
     | 
| 
      
 530 
     | 
    
         
            +
              end
         
     | 
| 
      
 531 
     | 
    
         
            +
             
     | 
| 
      
 532 
     | 
    
         
            +
              def test_is_root
         
     | 
| 
      
 533 
     | 
    
         
            +
                assert_false(@fpath.root?)
         
     | 
| 
      
 534 
     | 
    
         
            +
                assert_false(@bpath.root?)
         
     | 
| 
      
 535 
     | 
    
         
            +
                assert_false(@upath.root?)
         
     | 
| 
      
 536 
     | 
    
         
            +
                assert_false(@npath.root?)
         
     | 
| 
      
 537 
     | 
    
         
            +
                assert_true(@rpath.root?)
         
     | 
| 
      
 538 
     | 
    
         
            +
                assert_true(@xpath.root?)
         
     | 
| 
      
 539 
     | 
    
         
            +
                assert_true(@ypath.root?)
         
     | 
| 
      
 540 
     | 
    
         
            +
                assert_true(@zpath.root?)
         
     | 
| 
      
 541 
     | 
    
         
            +
                assert_false(@epath.root?)
         
     | 
| 
      
 542 
     | 
    
         
            +
                assert_false(@ppath.root?)
         
     | 
| 
      
 543 
     | 
    
         
            +
             
     | 
| 
      
 544 
     | 
    
         
            +
                assert_non_destructive
         
     | 
| 
      
 545 
     | 
    
         
            +
              end
         
     | 
| 
      
 546 
     | 
    
         
            +
             
     | 
| 
      
 547 
     | 
    
         
            +
              # These are the methods from IO we have to explicitly define since
         
     | 
| 
      
 548 
     | 
    
         
            +
              # they aren't handled by Facade.
         
     | 
| 
      
 549 
     | 
    
         
            +
              def test_facade_io
         
     | 
| 
      
 550 
     | 
    
         
            +
                assert_respond_to(@fpath, :foreach)
         
     | 
| 
      
 551 
     | 
    
         
            +
                assert_respond_to(@fpath, :read)
         
     | 
| 
      
 552 
     | 
    
         
            +
                assert_respond_to(@fpath, :readlines)
         
     | 
| 
      
 553 
     | 
    
         
            +
                assert_respond_to(@fpath, :sysopen)
         
     | 
| 
      
 554 
     | 
    
         
            +
              end
         
     | 
| 
      
 555 
     | 
    
         
            +
             
     | 
| 
      
 556 
     | 
    
         
            +
              def test_facade_file
         
     | 
| 
      
 557 
     | 
    
         
            +
                File.methods(false).each{ |method|
         
     | 
| 
      
 558 
     | 
    
         
            +
                  assert_respond_to(@fpath, method.to_sym)
         
     | 
| 
      
 559 
     | 
    
         
            +
                }
         
     | 
| 
      
 560 
     | 
    
         
            +
              end
         
     | 
| 
      
 561 
     | 
    
         
            +
             
     | 
| 
      
 562 
     | 
    
         
            +
              def test_facade_dir
         
     | 
| 
      
 563 
     | 
    
         
            +
                Dir.methods(false).each{ |method|
         
     | 
| 
      
 564 
     | 
    
         
            +
                  assert_respond_to(@fpath, method.to_sym)
         
     | 
| 
      
 565 
     | 
    
         
            +
                }
         
     | 
| 
      
 566 
     | 
    
         
            +
              end
         
     | 
| 
      
 567 
     | 
    
         
            +
             
     | 
| 
      
 568 
     | 
    
         
            +
              def test_facade_fileutils
         
     | 
| 
      
 569 
     | 
    
         
            +
                methods = FileUtils.public_instance_methods
         
     | 
| 
      
 570 
     | 
    
         
            +
                methods -= File.methods(false)
         
     | 
| 
      
 571 
     | 
    
         
            +
                methods -= Dir.methods(false)
         
     | 
| 
      
 572 
     | 
    
         
            +
                methods.delete_if{ |m| m =~ /stream/ }
         
     | 
| 
      
 573 
     | 
    
         
            +
                methods.delete_if{ |m| m =~ /^ln/ }
         
     | 
| 
      
 574 
     | 
    
         
            +
                methods.delete("identical?")
         
     | 
| 
      
 575 
     | 
    
         
            +
             
     | 
| 
      
 576 
     | 
    
         
            +
                methods.each{ |method|
         
     | 
| 
      
 577 
     | 
    
         
            +
                  assert_respond_to(@fpath, method.to_sym)
         
     | 
| 
      
 578 
     | 
    
         
            +
                }
         
     | 
| 
      
 579 
     | 
    
         
            +
              end
         
     | 
| 
      
 580 
     | 
    
         
            +
             
     | 
| 
      
 581 
     | 
    
         
            +
              def test_facade_find
         
     | 
| 
      
 582 
     | 
    
         
            +
                assert_respond_to(@fpath, :find)
         
     | 
| 
      
 583 
     | 
    
         
            +
                assert_nothing_raised{ @fpath.find{} }
         
     | 
| 
      
 584 
     | 
    
         
            +
             
     | 
| 
      
 585 
     | 
    
         
            +
                Pathname.new(Dir.pwd).find{ |f|
         
     | 
| 
      
 586 
     | 
    
         
            +
                  Find.prune if f.match("CVS")
         
     | 
| 
      
 587 
     | 
    
         
            +
                  assert_kind_of(Pathname, f)
         
     | 
| 
      
 588 
     | 
    
         
            +
                }
         
     | 
| 
      
 589 
     | 
    
         
            +
              end
         
     | 
| 
      
 590 
     | 
    
         
            +
             
     | 
| 
      
 591 
     | 
    
         
            +
              def test_children
         
     | 
| 
      
 592 
     | 
    
         
            +
                assert_respond_to(@cur_path, :children)
         
     | 
| 
      
 593 
     | 
    
         
            +
                assert_nothing_raised{ @cur_path.children }
         
     | 
| 
      
 594 
     | 
    
         
            +
                assert_kind_of(Array, @cur_path.children)
         
     | 
| 
      
 595 
     | 
    
         
            +
             
     | 
| 
      
 596 
     | 
    
         
            +
                # Delete Eclipse related files
         
     | 
| 
      
 597 
     | 
    
         
            +
                children = @cur_path.children
         
     | 
| 
      
 598 
     | 
    
         
            +
                children.delete_if{ |e| File.basename(e) == "CVS" }
         
     | 
| 
      
 599 
     | 
    
         
            +
                children.delete_if{ |e| File.basename(e) == ".git" }
         
     | 
| 
      
 600 
     | 
    
         
            +
                children.delete_if{ |e| File.basename(e) == ".gitignore" }
         
     | 
| 
      
 601 
     | 
    
         
            +
                children.delete_if{ |e| File.basename(e) == ".cvsignore" }
         
     | 
| 
      
 602 
     | 
    
         
            +
                children.delete_if{ |e| File.basename(e) == ".project" }
         
     | 
| 
      
 603 
     | 
    
         
            +
                children.delete_if{ |e| File.basename(e) == ".loadpath" }
         
     | 
| 
      
 604 
     | 
    
         
            +
             
     | 
| 
      
 605 
     | 
    
         
            +
                assert_equal(
         
     | 
| 
      
 606 
     | 
    
         
            +
                  [
         
     | 
| 
      
 607 
     | 
    
         
            +
                    Dir.pwd + "/benchmarks",
         
     | 
| 
      
 608 
     | 
    
         
            +
                    Dir.pwd + "/CHANGES",
         
     | 
| 
      
 609 
     | 
    
         
            +
                    Dir.pwd + "/examples",
         
     | 
| 
      
 610 
     | 
    
         
            +
                    Dir.pwd + "/lib",
         
     | 
| 
      
 611 
     | 
    
         
            +
                    Dir.pwd + "/MANIFEST",
         
     | 
| 
      
 612 
     | 
    
         
            +
                    Dir.pwd + "/pathname2.gemspec",
         
     | 
| 
      
 613 
     | 
    
         
            +
                    Dir.pwd + "/Rakefile",
         
     | 
| 
      
 614 
     | 
    
         
            +
                    Dir.pwd + "/README",
         
     | 
| 
      
 615 
     | 
    
         
            +
                    Dir.pwd + "/test"
         
     | 
| 
      
 616 
     | 
    
         
            +
                  ].map{ |e| e.tr("/", "\\") },
         
     | 
| 
      
 617 
     | 
    
         
            +
                  children
         
     | 
| 
      
 618 
     | 
    
         
            +
                )
         
     | 
| 
      
 619 
     | 
    
         
            +
             
     | 
| 
      
 620 
     | 
    
         
            +
                # Delete Eclipse related files
         
     | 
| 
      
 621 
     | 
    
         
            +
                children = @cur_path.children(false)
         
     | 
| 
      
 622 
     | 
    
         
            +
                children.delete("CVS")
         
     | 
| 
      
 623 
     | 
    
         
            +
                children.delete(".git")
         
     | 
| 
      
 624 
     | 
    
         
            +
                children.delete(".gitignore")
         
     | 
| 
      
 625 
     | 
    
         
            +
                children.delete(".cvsignore")
         
     | 
| 
      
 626 
     | 
    
         
            +
                children.delete(".project")
         
     | 
| 
      
 627 
     | 
    
         
            +
                children.delete(".loadpath")
         
     | 
| 
      
 628 
     | 
    
         
            +
             
     | 
| 
      
 629 
     | 
    
         
            +
                assert_equal(
         
     | 
| 
      
 630 
     | 
    
         
            +
                  [
         
     | 
| 
      
 631 
     | 
    
         
            +
                    "benchmarks", "CHANGES", "examples", "lib", "MANIFEST",
         
     | 
| 
      
 632 
     | 
    
         
            +
                    "pathname2.gemspec", "Rakefile", "README", "test"
         
     | 
| 
      
 633 
     | 
    
         
            +
                  ],
         
     | 
| 
      
 634 
     | 
    
         
            +
                  children
         
     | 
| 
      
 635 
     | 
    
         
            +
                )
         
     | 
| 
      
 636 
     | 
    
         
            +
              end
         
     | 
| 
      
 637 
     | 
    
         
            +
             
     | 
| 
      
 638 
     | 
    
         
            +
              # Ensures that subclasses return the subclass as the class, not a hard
         
     | 
| 
      
 639 
     | 
    
         
            +
              # coded Pathname.
         
     | 
| 
      
 640 
     | 
    
         
            +
              def test_subclasses
         
     | 
| 
      
 641 
     | 
    
         
            +
                assert_kind_of(MyPathname, @mypath)
         
     | 
| 
      
 642 
     | 
    
         
            +
                assert_kind_of(MyPathname, @mypath + MyPathname.new('foo'))
         
     | 
| 
      
 643 
     | 
    
         
            +
                assert_kind_of(MyPathname, @mypath.realpath)
         
     | 
| 
      
 644 
     | 
    
         
            +
                assert_kind_of(MyPathname, @mypath.children.first)
         
     | 
| 
      
 645 
     | 
    
         
            +
              end
         
     | 
| 
      
 646 
     | 
    
         
            +
             
     | 
| 
      
 647 
     | 
    
         
            +
              # Test to ensure that the pn{ } shortcut works
         
     | 
| 
      
 648 
     | 
    
         
            +
              #
         
     | 
| 
      
 649 
     | 
    
         
            +
              def test_kernel_method
         
     | 
| 
      
 650 
     | 
    
         
            +
                assert_respond_to(Kernel, :pn)
         
     | 
| 
      
 651 
     | 
    
         
            +
                assert_nothing_raised{ pn{'c:\foo'} }
         
     | 
| 
      
 652 
     | 
    
         
            +
                assert_kind_of(Pathname, pn{'c:\foo'})
         
     | 
| 
      
 653 
     | 
    
         
            +
                assert_equal('c:\foo', pn{'c:\foo'})
         
     | 
| 
      
 654 
     | 
    
         
            +
              end
         
     | 
| 
      
 655 
     | 
    
         
            +
             
     | 
| 
      
 656 
     | 
    
         
            +
              def teardown
         
     | 
| 
      
 657 
     | 
    
         
            +
                @fpath = nil
         
     | 
| 
      
 658 
     | 
    
         
            +
                @bpath = nil
         
     | 
| 
      
 659 
     | 
    
         
            +
                @dpath = nil
         
     | 
| 
      
 660 
     | 
    
         
            +
                @spath = nil
         
     | 
| 
      
 661 
     | 
    
         
            +
                @upath = nil
         
     | 
| 
      
 662 
     | 
    
         
            +
                @npath = nil
         
     | 
| 
      
 663 
     | 
    
         
            +
                @rpath = nil
         
     | 
| 
      
 664 
     | 
    
         
            +
                @xpath = nil
         
     | 
| 
      
 665 
     | 
    
         
            +
                @ypath = nil
         
     | 
| 
      
 666 
     | 
    
         
            +
                @zpath = nil
         
     | 
| 
      
 667 
     | 
    
         
            +
                @epath = nil
         
     | 
| 
      
 668 
     | 
    
         
            +
                @ppath = nil
         
     | 
| 
      
 669 
     | 
    
         
            +
                @cpath = nil
         
     | 
| 
      
 670 
     | 
    
         
            +
                @tpath = nil
         
     | 
| 
      
 671 
     | 
    
         
            +
             
     | 
| 
      
 672 
     | 
    
         
            +
                @cur_path = nil
         
     | 
| 
      
 673 
     | 
    
         
            +
             
     | 
| 
      
 674 
     | 
    
         
            +
                @abs_array.clear
         
     | 
| 
      
 675 
     | 
    
         
            +
                @rel_array.clear
         
     | 
| 
      
 676 
     | 
    
         
            +
                @unc_array.clear
         
     | 
| 
      
 677 
     | 
    
         
            +
              end
         
     | 
| 
      
 678 
     | 
    
         
            +
            end
         
     |