print "1..0\n";
exit 0;
}
- print "1..7\n";
}
-END {
- print "not ok 1\n" unless $loaded;
+
+use Test::More tests => 7;
+
+BEGIN {
+ use_ok('File::Glob', qw(:glob csh_glob));
}
-use File::Glob qw(:glob csh_glob);
-$loaded = 1;
-print "ok 1\n";
my $pat = "op/G*.t";
-# Test the actual use of the case sensitivity tags, via csh_glob()
import File::Glob ':nocase';
@a = csh_glob($pat);
-print "not " unless @a >= 8;
-print "ok 2\n";
+cmp_ok(scalar @a, '>=', 8, 'use of the case sensitivity tags, via csh_glob()');
# This may fail on systems which are not case-PRESERVING
import File::Glob ':case';
-@a = csh_glob($pat); # None should be uppercase
-print "not " unless @a == 0;
-print "ok 3\n";
+@a = csh_glob($pat);
+is(scalar @a, 0, 'None should be uppercase');
-# Test the explicit use of the GLOB_NOCASE flag
@a = bsd_glob($pat, GLOB_NOCASE);
-print "not " unless @a >= 3;
-print "ok 4\n";
+cmp_ok(scalar @a, '>=', 3, 'explicit use of the GLOB_NOCASE flag');
# Test Win32 backslash nastiness...
-if ($^O ne 'MSWin32' && $^O ne 'NetWare') {
- print "ok 5\nok 6\nok 7\n";
-}
-else {
+SKIP: {
+ skip 'Not Win32 or NetWare', 3 unless $^O eq 'MSWin32' || $^O eq 'NetWare';
+
@a = File::Glob::glob("op\\g*.t");
- print "not " unless @a >= 8;
- print "ok 5\n";
+ cmp_ok(scalar @a, '>=', 8);
mkdir "[]", 0;
@a = File::Glob::glob("\\[\\]", GLOB_QUOTE);
rmdir "[]";
- print "# returned @a\nnot " unless @a == 1;
- print "ok 6\n";
+ is(scalar @a, 1);
@a = bsd_glob("op\\*", GLOB_QUOTE);
- print "not " if @a == 0;
- print "ok 7\n";
+ isnt(scalar @a, 0);
}
print "1..0\n";
exit 0;
}
- print "1..10\n";
-}
-END {
- print "not ok 1\n" unless $loaded;
}
+use Test::More tests => 11;
+
BEGIN {
*CORE::GLOBAL::glob = sub { "Just another Perl hacker," };
}
}
}
-use File::Glob ':globally';
-$loaded = 1;
-print "ok 1\n";
+BEGIN {
+ use_ok('File::Glob', ':globally');
+}
$_ = "op/*.t";
my @r = glob;
-print "not " if $_ ne ("op/*.t");
-print "ok 2\n";
+is($_, "op/*.t");
-print "# |@r|\nnot " if @r < 3;
-print "ok 3\n";
+cmp_ok(scalar @r, '>=', 3);
-# check if <*/*> works
@r = <*/*.t>;
# at least t/global.t t/basic.t, t/taint.t
-print "not " if @r < 3;
-print "ok 4\n";
+cmp_ok(scalar @r, '>=', 3, 'check if <*/*> works');
my $r = scalar @r;
-# check if scalar context works
@r = ();
while (defined($_ = <*/*.t>)) {
#print "# $_\n";
push @r, $_;
}
-print "not " if @r != $r;
-print "ok 5\n";
+is(scalar @r, $r, 'check if scalar context works');
-# check if list context works
@r = ();
for (<*/*.t>) {
#print "# $_\n";
push @r, $_;
}
-print "not " if @r != $r;
-print "ok 6\n";
+is(scalar @r, $r, 'check if list context works');
-# test if implicit assign to $_ in while() works
@r = ();
while (<*/*.t>) {
#print "# $_\n";
push @r, $_;
}
-print "not " if @r != $r;
-print "ok 7\n";
+is(scalar @r, $r, 'implicit assign to $_ in while()');
-# test if explicit glob() gets assign magic too
my @s = ();
while (glob('*/*.t')) {
#print "# $_\n";
push @s, $_;
}
-print "not " if "@r" ne "@s";
-print "ok 8\n";
+is("@r", "@s", 'explicit glob() gets assign magic too');
-# how about in a different package, like?
package Foo;
use File::Glob ':globally';
@s = ();
#print "# $_\n";
push @s, $_;
}
-print "not " if "@r" ne "@s";
-print "ok 9\n";
+main::is("@r", "@s", 'in a different package');
# test if different glob ops maintain independent contexts
@s = ();
}
#print " >\n";
}
-print "not " if "@r" ne "@s" or not $i;
-print "ok 10\n";
+
+main::is("@r", "@s", 'different glob ops maintain independent contexts');
+main::isnt($i, 0, 'different glob ops maintain independent contexts');
print "1..0\n";
exit 0;
}
- print "1..2\n";
}
-END {
- print "not ok 1\n" unless $loaded;
+
+use Test::More tests => 2;
+
+BEGIN {
+ use_ok('File::Glob');
}
-use File::Glob;
-$loaded = 1;
-print "ok 1\n";
-# all filenames should be tainted
@a = File::Glob::bsd_glob("*");
eval { $a = join("",@a), kill 0; 1 };
-unless ($@ =~ /Insecure dependency/) {
- print "not ";
-}
-print "ok 2\n";
+like($@, qr/Insecure dependency/, 'all filenames should be tainted');