summaryrefslogtreecommitdiff
path: root/dist
diff options
context:
space:
mode:
authorNicholas Clark <nick@ccl4.org>2011-01-22 19:56:41 +0000
committerNicholas Clark <nick@ccl4.org>2011-01-22 19:56:41 +0000
commitcba0911763351f6338999a8dd3e16f1c5f27cc5d (patch)
tree11f756efc1aa1f4a66a7b260b2fb6c6d5024c8ef /dist
parente5247eacc7226a157f4a1ba116696a270c05484c (diff)
downloadperl-cba0911763351f6338999a8dd3e16f1c5f27cc5d.tar.gz
Convert File::Spec's remaining tests to Test::More from Test.
Diffstat (limited to 'dist')
-rw-r--r--dist/Cwd/t/Functions.t9
-rw-r--r--dist/Cwd/t/Spec.t45
-rw-r--r--dist/Cwd/t/tmpdir.t22
3 files changed, 33 insertions, 43 deletions
diff --git a/dist/Cwd/t/Functions.t b/dist/Cwd/t/Functions.t
index 457f53cb6f..6ab225fe7d 100644
--- a/dist/Cwd/t/Functions.t
+++ b/dist/Cwd/t/Functions.t
@@ -1,10 +1,9 @@
#!/usr/bin/perl -w
-use Test;
-use File::Spec::Functions qw/:ALL/;
-plan tests => 2;
+use Test::More tests => 3;
+BEGIN {use_ok('File::Spec::Functions', ':ALL');}
-ok catfile('a','b','c'), File::Spec->catfile('a','b','c');
+is(catfile('a','b','c'), File::Spec->catfile('a','b','c'));
# seems to return 0 or 1, so see if we can call it - 2003-07-07 tels
-ok case_tolerant(), '/^0|1$/';
+like(case_tolerant(), qr/\A(?:0|1)\z/);
diff --git a/dist/Cwd/t/Spec.t b/dist/Cwd/t/Spec.t
index 0c658e2fd4..950fa7aa4f 100644
--- a/dist/Cwd/t/Spec.t
+++ b/dist/Cwd/t/Spec.t
@@ -1,12 +1,10 @@
#!/usr/bin/perl -w
-use Test;
+use strict;
+use Test::More;
-# Grab all of the plain routines from File::Spec
-use File::Spec @File::Spec::EXPORT_OK ;
+require_ok('File::Spec');
-require File::Spec::Unix ;
-require File::Spec::Win32 ;
require Cwd;
eval {
@@ -43,18 +41,16 @@ if ( $@ ) {
- ;
$INC{"VMS/Filespec.pm"} = 1 ;
}
-require File::Spec::VMS ;
-require File::Spec::OS2 ;
-require File::Spec::Mac ;
-require File::Spec::Epoc ;
-require File::Spec::Cygwin ;
+foreach (qw(Unix Win32 VMS OS2 Mac Epoc Cygwin)) {
+ require_ok("File::Spec::$_");
+}
# Each element in this array is a single test. Storing them this way makes
# maintenance easy, and should be OK since perl should be pretty functional
# before these tests are run.
-@tests = (
+my @tests = (
# [ Function , Expected , Platform ]
[ "Unix->case_tolerant()", '0' ],
@@ -253,8 +249,6 @@ require File::Spec::Cygwin ;
[ "Win32->canonpath('/..\\')", '\\' ],
[ "Win32->canonpath('d1/../foo')", 'foo' ],
-[ "Win32->can('_cwd')", '/CODE/' ],
-
# FakeWin32 subclass (see below) just sets CWD to C:\one\two and getdcwd('D') to D:\alpha\beta
[ "FakeWin32->abs2rel('/t1/t2/t3','/t1/t2/t3')", '.' ],
@@ -743,9 +737,7 @@ require File::Spec::Cygwin ;
) ;
-my $test_count = scalar @tests;
-
-plan tests => scalar @tests;
+can_ok('File::Spec::Win32', '_cwd');
{
package File::Spec::FakeWin32;
@@ -773,7 +765,6 @@ plan tests => scalar @tests;
}
}
-
# Tries a named function with the given args and compares the result against
# an expected result. Works with functions that return scalars or arrays.
for ( @tests ) {
@@ -783,15 +774,15 @@ for ( @tests ) {
$function =~ s/^([^\$].*->)/File::Spec::$1/;
my $got = join ',', eval $function;
- if ( $@ ) {
- if ( $@ =~ /^\Q$skip_exception/ ) {
- skip "skip $function: $skip_exception", 1;
- }
- else {
- ok $@, '', $function;
- }
- next;
+ SKIP: {
+ if ($@) {
+ skip "skip $function: $skip_exception", 1
+ if $@ =~ /^\Q$skip_exception/;
+ is($@, '', $function);
+ } else {
+ is($got, $expected, $function);
+ }
}
-
- ok $got, $expected, $function;
}
+
+done_testing();
diff --git a/dist/Cwd/t/tmpdir.t b/dist/Cwd/t/tmpdir.t
index 6adad18cb9..6f7f318180 100644
--- a/dist/Cwd/t/tmpdir.t
+++ b/dist/Cwd/t/tmpdir.t
@@ -1,13 +1,12 @@
use strict;
-use Test;
+use Test::More tests => 5;
# Grab all of the plain routines from File::Spec
use File::Spec;
use File::Spec::Win32;
-plan tests => 4;
+require_ok($_) foreach qw(File::Spec File::Spec::Win32);
-ok 1, 1, "Loaded";
if ($^O eq 'VMS') {
# hack:
@@ -17,15 +16,16 @@ if ($^O eq 'VMS') {
}
my $num_keys = keys %ENV;
File::Spec->tmpdir;
-ok scalar keys %ENV, $num_keys, "tmpdir() shouldn't change the contents of %ENV";
+is scalar keys %ENV, $num_keys, "tmpdir() shouldn't change the contents of %ENV";
-if ($^O eq 'VMS') {
- skip("Can't make list assignment to %ENV on this system", 1);
-} else {
- local %ENV;
- File::Spec::Win32->tmpdir;
- ok scalar keys %ENV, 0, "Win32->tmpdir() shouldn't change the contents of %ENV";
+SKIP: {
+ skip("Can't make list assignment to %ENV on this system", 1)
+ if $^O eq 'VMS';
+
+ local %ENV;
+ File::Spec::Win32->tmpdir;
+ is(scalar keys %ENV, 0, "Win32->tmpdir() shouldn't change the contents of %ENV");
}
File::Spec::Win32->tmpdir;
-ok scalar keys %ENV, $num_keys, "Win32->tmpdir() shouldn't change the contents of %ENV";
+is(scalar keys %ENV, $num_keys, "Win32->tmpdir() shouldn't change the contents of %ENV");