summaryrefslogtreecommitdiff
path: root/ext/Cwd
diff options
context:
space:
mode:
authorCraig A. Berry <craigberry@mac.com>2004-07-03 09:10:34 -0500
committerNicholas Clark <nick@ccl4.org>2004-07-04 16:39:07 +0000
commit9d7d97294754b044f4b4bee93dbdfb1d82ffe0d7 (patch)
treef395dcdc2920657b8430294491e8584f91bda2d5 /ext/Cwd
parentd281a6ac99b66dc149fbd56ba67cd73e3e87afb9 (diff)
downloadperl-9d7d97294754b044f4b4bee93dbdfb1d82ffe0d7.tar.gz
_vms_abs_path on non-directories
From: "Craig A. Berry" <craigberry@mac.com> Message-ID: <40E704AA.4090801@mac.com> Date: Sat, 03 Jul 2004 14:10:34 -0500 p4raw-id: //depot/perl@23029
Diffstat (limited to 'ext/Cwd')
-rw-r--r--ext/Cwd/t/cwd.t34
1 files changed, 24 insertions, 10 deletions
diff --git a/ext/Cwd/t/cwd.t b/ext/Cwd/t/cwd.t
index 816775e6e3..8064346464 100644
--- a/ext/Cwd/t/cwd.t
+++ b/ext/Cwd/t/cwd.t
@@ -145,30 +145,44 @@ SKIP: {
unlink "linktest";
}
-chdir '../ext/Cwd/t' if $ENV{PERL_CORE};
+if ($ENV{PERL_CORE}) {
+ chdir '../ext/Cwd/t';
+ unshift @INC, '../../../lib';
+}
# Make sure we can run abs_path() on files, not just directories
my $path = 'cwd.t';
-dir_ends_with(Cwd::abs_path($path), 'cwd.t', 'abs_path() can be invoked on a file');
-dir_ends_with(Cwd::fast_abs_path($path), 'cwd.t', 'fast_abs_path() can be invoked on a file');
+path_ends_with(Cwd::abs_path($path), 'cwd.t', 'abs_path() can be invoked on a file');
+path_ends_with(Cwd::fast_abs_path($path), 'cwd.t', 'fast_abs_path() can be invoked on a file');
$path = File::Spec->catfile(File::Spec->updir, 't', $path);
-dir_ends_with(Cwd::abs_path($path), 'cwd.t', 'abs_path() can be invoked on a file');
-dir_ends_with(Cwd::fast_abs_path($path), 'cwd.t', 'fast_abs_path() can be invoked on a file');
+path_ends_with(Cwd::abs_path($path), 'cwd.t', 'abs_path() can be invoked on a file');
+path_ends_with(Cwd::fast_abs_path($path), 'cwd.t', 'fast_abs_path() can be invoked on a file');
#############################################
-# These two routines give us sort of a poor-man's cross-platform
-# directory comparison routine.
+# These routines give us sort of a poor-man's cross-platform
+# directory or path comparison capability.
-sub bracketed_form {
+sub bracketed_form_dir {
return join '', map "[$_]",
grep length, File::Spec->splitdir(File::Spec->canonpath( shift() ));
}
sub dir_ends_with {
my ($dir, $expect) = (shift, shift);
- my $bracketed_expect = quotemeta bracketed_form($expect);
- like( bracketed_form($dir), qr|$bracketed_expect$|i, (@_ ? shift : ()) );
+ my $bracketed_expect = quotemeta bracketed_form_dir($expect);
+ like( bracketed_form_dir($dir), qr|$bracketed_expect$|i, (@_ ? shift : ()) );
+}
+
+sub bracketed_form_path {
+ return join '', map "[$_]",
+ grep length, File::Spec->splitpath(File::Spec->canonpath( shift() ));
+}
+
+sub path_ends_with {
+ my ($dir, $expect) = (shift, shift);
+ my $bracketed_expect = quotemeta bracketed_form_path($expect);
+ like( bracketed_form_path($dir), qr|$bracketed_expect$|i, (@_ ? shift : ()) );
}