File::Spec::Cygwin more tests and silence warning
Reini Urban [Wed, 20 Jun 2007 21:10:05 +0000 (23:10 +0200)]
Message-ID: <46797B8D.8040002@x-ray.at>

p4raw-id: //depot/perl@31440

lib/File/Spec/Cygwin.pm
lib/File/Spec/t/Spec.t

index 9423eec..e2744f0 100644 (file)
@@ -53,7 +53,7 @@ sub catdir {
     my $self = shift;
 
     # Don't create something that looks like a //network/path
-    if ($_[0] eq '/' or $_[0] eq '\\') {
+    if ($_[0] and ($_[0] eq '/' or $_[0] eq '\\')) {
         shift;
         return $self->SUPER::catdir('', @_);
     }
index 5ca4caf..a39779f 100644 (file)
@@ -620,8 +620,81 @@ if ($^O eq 'MacOS') {
 #[ "Epoc->canonpath('/.')",                                    '/'         ],
 
 [ "Cygwin->case_tolerant()",         '1'  ],
+[ "Cygwin->catfile('a','b','c')",         'a/b/c'  ],
+[ "Cygwin->catfile('a','b','./c')",       'a/b/c'  ],
+[ "Cygwin->catfile('./a','b','c')",       'a/b/c'  ],
+[ "Cygwin->catfile('c')",                 'c' ],
+[ "Cygwin->catfile('./c')",               'c' ],
+
+[ "Cygwin->splitpath('file')",            ',,file'            ],
+[ "Cygwin->splitpath('/d1/d2/d3/')",      ',/d1/d2/d3/,'      ],
+[ "Cygwin->splitpath('d1/d2/d3/')",       ',d1/d2/d3/,'       ],
+[ "Cygwin->splitpath('/d1/d2/d3/.')",     ',/d1/d2/d3/.,'     ],
+[ "Cygwin->splitpath('/d1/d2/d3/..')",    ',/d1/d2/d3/..,'    ],
+[ "Cygwin->splitpath('/d1/d2/d3/.file')", ',/d1/d2/d3/,.file' ],
+[ "Cygwin->splitpath('d1/d2/d3/file')",   ',d1/d2/d3/,file'   ],
+[ "Cygwin->splitpath('/../../d1/')",      ',/../../d1/,'      ],
+[ "Cygwin->splitpath('/././d1/')",        ',/././d1/,'        ],
+
+[ "Cygwin->catpath('','','file')",            'file'            ],
+[ "Cygwin->catpath('','/d1/d2/d3/','')",      '/d1/d2/d3/'      ],
+[ "Cygwin->catpath('','d1/d2/d3/','')",       'd1/d2/d3/'       ],
+[ "Cygwin->catpath('','/d1/d2/d3/.','')",     '/d1/d2/d3/.'     ],
+[ "Cygwin->catpath('','/d1/d2/d3/..','')",    '/d1/d2/d3/..'    ],
+[ "Cygwin->catpath('','/d1/d2/d3/','.file')", '/d1/d2/d3/.file' ],
+[ "Cygwin->catpath('','d1/d2/d3/','file')",   'd1/d2/d3/file'   ],
+[ "Cygwin->catpath('','/../../d1/','')",      '/../../d1/'      ],
+[ "Cygwin->catpath('','/././d1/','')",        '/././d1/'        ],
+[ "Cygwin->catpath('d1','d2/d3/','')",        'd2/d3/'          ],
+[ "Cygwin->catpath('d1','d2','d3/')",         'd2/d3/'          ],
+
+[ "Cygwin->splitdir('')",           ''           ],
+[ "Cygwin->splitdir('/d1/d2/d3/')", ',d1,d2,d3,' ],
+[ "Cygwin->splitdir('d1/d2/d3/')",  'd1,d2,d3,'  ],
+[ "Cygwin->splitdir('/d1/d2/d3')",  ',d1,d2,d3'  ],
+[ "Cygwin->splitdir('d1/d2/d3')",   'd1,d2,d3'   ],
+
+[ "Cygwin->catdir()",                     ''          ],
+[ "Cygwin->catdir('/')",                  '/'         ],
+[ "Cygwin->catdir('','d1','d2','d3','')", '/d1/d2/d3' ],
+[ "Cygwin->catdir('d1','d2','d3','')",    'd1/d2/d3'  ],
+[ "Cygwin->catdir('','d1','d2','d3')",    '/d1/d2/d3' ],
+[ "Cygwin->catdir('d1','d2','d3')",       'd1/d2/d3'  ],
 [ "Cygwin->catdir('/','d2/d3')",     '/d2/d3'  ],
 
+[ "Cygwin->canonpath('///../../..//./././a//b/.././c/././')",   '/a/b/../c' ],
+[ "Cygwin->canonpath('')",                       ''               ],
+[ "Cygwin->canonpath('a/../../b/c')",            'a/../../b/c'    ],
+[ "Cygwin->canonpath('/.')",                     '/'              ],
+[ "Cygwin->canonpath('/./')",                    '/'              ],
+[ "Cygwin->canonpath('/a/./')",                  '/a'             ],
+[ "Cygwin->canonpath('/a/.')",                   '/a'             ],
+[ "Cygwin->canonpath('/../../')",                '/'              ],
+[ "Cygwin->canonpath('/../..')",                 '/'              ],
+
+[  "Cygwin->abs2rel('/t1/t2/t3','/t1/t2/t3')",          '.'                  ],
+[  "Cygwin->abs2rel('/t1/t2/t4','/t1/t2/t3')",          '../t4'              ],
+[  "Cygwin->abs2rel('/t1/t2','/t1/t2/t3')",             '..'                 ],
+[  "Cygwin->abs2rel('/t1/t2/t3/t4','/t1/t2/t3')",       't4'                 ],
+[  "Cygwin->abs2rel('/t4/t5/t6','/t1/t2/t3')",          '../../../t4/t5/t6'  ],
+#[ "Cygwin->abs2rel('../t4','/t1/t2/t3')",              '../t4'              ],
+[  "Cygwin->abs2rel('/','/t1/t2/t3')",                  '../../..'           ],
+[  "Cygwin->abs2rel('///','/t1/t2/t3')",                '../../..'           ],
+[  "Cygwin->abs2rel('/.','/t1/t2/t3')",                 '../../..'           ],
+[  "Cygwin->abs2rel('/./','/t1/t2/t3')",                '../../..'           ],
+#[ "Cygwin->abs2rel('../t4','/t1/t2/t3')",              '../t4'              ],
+[  "Cygwin->abs2rel('/t1/t2/t3', '/')",                 't1/t2/t3'           ],
+[  "Cygwin->abs2rel('/t1/t2/t3', '/t1')",               't2/t3'              ],
+[  "Cygwin->abs2rel('t1/t2/t3', 't1')",                 't2/t3'              ],
+[  "Cygwin->abs2rel('t1/t2/t3', 't4')",                 '../t1/t2/t3'        ],
+
+[ "Cygwin->rel2abs('t4','/t1/t2/t3')",             '/t1/t2/t3/t4'    ],
+[ "Cygwin->rel2abs('t4/t5','/t1/t2/t3')",          '/t1/t2/t3/t4/t5' ],
+[ "Cygwin->rel2abs('.','/t1/t2/t3')",              '/t1/t2/t3'       ],
+[ "Cygwin->rel2abs('..','/t1/t2/t3')",             '/t1/t2/t3/..'    ],
+[ "Cygwin->rel2abs('../t4','/t1/t2/t3')",          '/t1/t2/t3/../t4' ],
+[ "Cygwin->rel2abs('/t1','/t1/t2/t3')",            '/t1'             ],
+
 ) ;