- or download this
use strict;
use warnings;
...
# Get back to the starting point
chdir $initial_dir;
- or download this
ok 1 - changed to new directory
ok 2 - changed back to original directory
1..2
- or download this
not ok 1 - changed to new directory
# Failed test (cwd_post1.pl at line 26)
...
ok 2 - changed back to original directory
1..2
# Looks like you failed 1 test of 2.
- or download this
- is( cwd(), $new_dir, "changed to new directory" );
+ is( File::Spec->canonpath( cwd() ), $new_dir, "changed to new dir
+ectory" );
- or download this
- my $new_dir = pushd( 't' );
+ my $new_dir = pushd( File::Spec->rootdir );
- or download this
not ok 1 - changed to new directory
# Failed test (cwd_post3.pl at line 26)
...
ok 2 - changed back to original directory
1..2
# Looks like you failed 1 test of 2.
- or download this
- is( File::Spec->canonpath( cwd() ), $new_dir, "changed to new dir
+ectory" );
+ is( File::Spec->abs2rel( cwd(), $new_dir), File::Spec->curdir,
+ "changed to new directory"
+ );
- or download this
not ok 1 - changed to new directory
# Failed test (cwd_post4.pl at line 26)
# got: ''
# expected: '.'
ok 2 - changed back to original directory
- or download this
$ perl -MFile::Spec -e 'print File::Spec->catdir(".","t")'
t
$ perl -MFile::Spec -e 'print File::Spec->catdir("","t")'
/t
- or download this
not ok 1 - changed to new directory
# Failed test (cwd_post4.pl at line 26)
...
ok 2 - changed back to original directory
1..2
# Looks like you failed 1 test of 2.
- or download this
use File::Spec;
+use File::Spec::Functions qw( canonpath splitpath );
- or download this
- is( File::Spec->abs2rel( cwd(), $new_dir), q{.},
+ is( canonpath( [ splitpath( cwd(), 1 ) ]->[1] ),
+ $new_dir,
"changed to new directory"
);
- or download this
- my $new_dir = pushd( File::Spec->rootdir );
+ my $new_dir = pushd( "t" );
- or download this
- is( canonpath( [ splitpath( cwd(), 1 ) ]->[1] ),
- $new_dir,
...
+ canonpath( [ splitpath( $new_dir, 1 ) ]->[1] ),
"changed to new directory"
);
- or download this
-use Cwd;
+use Cwd qw( cwd abs_path );
use File::Spec;
-use File::Spec::Functions qw( canonpath splitpath );
- or download this
- is( canonpath( [ splitpath( cwd(), 1 ) ]->[1] ),
- canonpath( [ splitpath( $new_dir, 1 ) ]->[1] ),
- "changed to new directory"
- );
+ is( cwd(), abs_path( $new_dir ), "changed to new directory" );
- or download this
- my $new_dir = pushd( "t" );
+ my $new_dir = pushd( File::Spec->rootdir );