In perl.git, the branch blead has been updated

<http://perl5.git.perl.org/perl.git/commitdiff/92361f5e167f608ba46fdd5ce2e1672a004bd90c?hp=62e21d5f1f96cde772457aab40aa0981d9a53097>

- Log -----------------------------------------------------------------
commit 92361f5e167f608ba46fdd5ce2e1672a004bd90c
Author: Nicholas Clark <[email protected]>
Date:   Wed Dec 15 11:47:19 2010 +0000

    Convert all File::Glob tests to Test::More.
    
    (Apart from basic.t, which was already using Test::More)
-----------------------------------------------------------------------

Summary of changes:
 ext/File-Glob/t/case.t   |   40 ++++++++++++++------------------------
 ext/File-Glob/t/global.t |   47 +++++++++++++++------------------------------
 ext/File-Glob/t/taint.t  |   17 +++++----------
 3 files changed, 37 insertions(+), 67 deletions(-)

diff --git a/ext/File-Glob/t/case.t b/ext/File-Glob/t/case.t
index 04c307c..6362ef0 100644
--- a/ext/File-Glob/t/case.t
+++ b/ext/File-Glob/t/case.t
@@ -8,48 +8,38 @@ BEGIN {
         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);
 }
diff --git a/ext/File-Glob/t/global.t b/ext/File-Glob/t/global.t
index 9eb2de6..cc1f8d0 100644
--- a/ext/File-Glob/t/global.t
+++ b/ext/File-Glob/t/global.t
@@ -8,12 +8,10 @@ BEGIN {
         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," };
 }
@@ -27,62 +25,49 @@ EOMessage
     }
 }
 
-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 = ();
@@ -90,8 +75,7 @@ while (glob('*/*.t')) {
     #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 = ();
@@ -105,5 +89,6 @@ while (<*/*.t>) {
   }
   #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');
diff --git a/ext/File-Glob/t/taint.t b/ext/File-Glob/t/taint.t
index fe2fa23..3f49836 100644
--- a/ext/File-Glob/t/taint.t
+++ b/ext/File-Glob/t/taint.t
@@ -8,19 +8,14 @@ BEGIN {
         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');

--
Perl5 Master Repository

Reply via email to