Having to count tests is annoying for maintainers.
Also, manually updating count tests is problematic when multiple people
are working on the same code; it causes merge conflicts and recounts.
done_testing() is available since Test::More 0.88 which was released in
2009.
This commit changes all tests under lib/ that use Test::More and were
planning the number of tests.
Michiel Beijen is now a Perl author
Michael van Elst <mlelstv@serpens.de>
Michael Witten <mfwitten@gmail.com>
Michele Sardo
+Michiel Beijen <mb@x14.nl>
Mik Firestone <fireston@lexmark.com>
Mike Doherty <mike@mikedoherty.ca>
Mike Fletcher <fletch@phydeaux.org>
use strict;
use Test::More;
-plan tests => 3904;
use feature (sprintf(":%vd", $^V)); # to avoid relying on the feature
# logic to add CORE::
ok($pass, "sanity checks");
}
+done_testing();
+
__DATA__
#
# format:
# publicise an API for subclassing B::Deparse they can prevent us from
# gratuitously breaking conventions that CPAN modules already use.
-use Test::More tests => 2;
+use Test::More;
use B::Deparse;
like $nm->coderef2text(sub { my $c; /(??{ $c })/; }),
qr/\Q(??{\E \$c_groovy/,
'overriding padname works for renaming lexicals in regexp blocks';
+
+done_testing();
use warnings;
use strict;
our ($foo, $bar, $baz, $ballast);
-use Test::More tests => 213;
+use Test::More;
use Benchmark qw(:all);
}
}
+done_testing();
package TieOut;
}
}
use strict;
-use Test::More 'no_plan';
+use Test::More;
BEGIN {use_ok 'Config::Extensions', '%Extensions'};
my $type = $val . '_ext';
like($Config{$type}, $re, "$key is $type");
}
+
+done_testing();
my $dualfalse = dualvar(0, 'false');
my $dualtrue = dualvar(1, 'true');
-use Test::More tests => 106;
+use Test::More;
# must happen at compile time for DB:: package variable localizations to work
BEGIN {
ok( defined &{ "DB::$method" }, "DB::$method() should be defined" );
}
+done_testing();
+
# DB::skippkg() uses lexical
# DB::ready() uses lexical
return $@;
}
-use Test::More tests => 21;
+use Test::More;
BEGIN { use_ok('DBM_Filter') };
my $db_file;
is $@, '', "untie without inner references" ;
}
+done_testing();
END { unlink keys %files if keys %files }
-use Test::More tests => 189;
+use Test::More;
BEGIN { use_ok('DBM_Filter') };
my $db_file;
}
+done_testing();
}
require "dbm_filter_util.pl";
-use Test::More tests => 23;
+use Test::More;
BEGIN { use_ok('DBM_Filter') };
my $db_file;
is $@, '', "untie without inner references" ;
}
+done_testing();
require "dbm_filter_util.pl";
-use Test::More tests => 26;
+use Test::More;
BEGIN { use_ok('DBM_Filter') };
my $db_file;
}
}
+
+done_testing();
require "dbm_filter_util.pl";
-use Test::More tests => 22;
+use Test::More;
BEGIN { use_ok('DBM_Filter') };
my $db_file;
is $@, '', "untie without inner references" ;
}
+done_testing();
require "dbm_filter_util.pl";
-use Test::More tests => 26;
+use Test::More;
BEGIN { use_ok('DBM_Filter') };
my $db_file;
is $@, '', "untie without inner references" ;
}
+done_testing();
require "dbm_filter_util.pl";
-use Test::More tests => 20;
+use Test::More;
BEGIN { use_ok('DBM_Filter') };
my $db_file;
is $@, '', "untie without inner references" ;
}
+done_testing();
}
use DirHandle;
-use Test::More tests => 31;
+use Test::More;
# Fetching the list of files in two different ways and expecting them
# to be the same is a race condition when tests are running in parallel.
if ($chdir) {
chdir "..";
}
+
+done_testing();
@INC = '../lib';
}
-use Test::More tests => 58;
+use Test::More;
use English qw( -no_match_vars ) ;
use Config;
::is $LIST_SEPARATOR, 'frooble';
}
+# because of the 'package' statements above, we have to prefix Test::More::
+Test::More::done_testing();
+
__END__
This is a line.
This is a paragraph.
@INC = '../lib';
}
-use Test::More tests => 65;
+use Test::More;
BEGIN { use_ok 'File::Basename' }
ok tainted(dirname($TAINT.'/perl/lib//'));
ok all_tainted(fileparse($TAINT.'/dir/draft.book7','\.book\d+'));
}
+
+done_testing();
}
}
-use Test::More ( tests => 16 );
+use Test::More;
use File::Compare qw(compare compare_text);
# Upon success, compare() and compare_text() return a Unix-ish 0
"compare() fails: second argument undefined");
}
+done_testing();
+
sub get_valid_whitespace {
return ' ' unless $^O eq 'VMS';
return (exists $ENV{'DECC$EFS_CHARSET'} && $ENV{'DECC$EFS_CHARSET'} =~ /^[ET1]/i)
my $TB = Test::More->builder;
-plan tests => 466;
-
# We are going to override rename() later on but Perl has to see an override
# at compile time to honor it.
BEGIN { *CORE::GLOBAL::rename = sub { CORE::rename($_[0], $_[1]) }; }
"copy with buffer above normal size";
}
+done_testing();
END {
1 while unlink "copy-$$";
use strict;
use FileHandle;
autoflush STDOUT 1;
-use Test::More (tests => 12);
+use Test::More;
my $TB = Test::More->builder;
my $mystdout = new_from_fd FileHandle 1,"w";
}
ok(!FileHandle->new('', 'r'), "Can't open empty filename");
+
+done_testing();
use strict;
use warnings;
-use Test::More tests => 22;
+use Test::More;
use Getopt::Std;
our ($warning, $opt_f, $opt_i, $opt_o, $opt_x, $opt_y, %opt);
"getopt: single switch; switch expected argument, none provided; value undef");
undef %opt;
}
+
+done_testing();
}
}
-use Test::More tests => 82;
+use Test::More;
my $ro_err = qr/^Modification of a read-only value attempted/;
eval { &Internals::SvREFCNT($foo, 0..3);};
like($@, qr/\Q$usage\E/);
}
+
+done_testing();
}
}
-use Test::More tests => 10;
+use Test::More;
BEGIN { use_ok 'Net::hostent' }
}
}
}
+
+done_testing();
use File::Basename;
use File::Spec;
use Test::More;
-plan tests => 8;
use_ok( 'Pod::Usage' );
is( $pod2usage, $pod2text, 'Verbose level >= 2 eq pod2text' );
+done_testing();
package CatchOut;
sub TIEHANDLE { bless \( my $self ), shift }
@INC = '../lib';
}
-use Test::More tests => 31;
+use Test::More;
BEGIN { $_ = 'foo'; } # because Symbol used to clobber $_
ok( defined $Bar::{variable}, 'third transient variable in stash' );
ok( ! defined(Symbol::delete_package('Bar::Bar::')),
'delete_package() returns undef due to undefined leaf');
+
+done_testing();
use Thread qw(:DEFAULT async yield);
-use Test::More tests => 13;
+use Test::More;
my $lock;
{
is($thr->join(), 3, "->join returned thread's tid");
}
-# EOF
+done_testing();
use strict;
use warnings;
-use Test::More tests => 11;
+use Test::More;
use_ok('Tie::Hash');
tie my %tied, 'Tie::ExtraHash';
# SCALAR
is(scalar(%tied), scalar(%hash), "SCALAR");
+done_testing();
@INC = '../lib';
}
-use Test::More tests => 29;
+use Test::More;
use_ok('Tie::StdHandle');
ok(close($f), "close");
unlink("afile");
+
+done_testing();
@INC = '../lib';
}
-use Test::More tests => 1;
+use Test::More;
use Tie::Handle;
# For backwards compatibility with 5.8.x
ok( Foo->can("TIEHANDLE"), "loading Tie::Handle loads TieStdHandle" );
+
+done_testing();
# These tests are not complete. Patches welcome.
-use Test::More tests => 3;
+use Test::More;
BEGIN {use_ok( 'Tie::Hash' )};
eval { Tie::Hash->$method() };
like( $@, qr/doesn't define an? $method/, "croaks on inherited $method()" );
}
+
+done_testing();
package main;
our $flag;
-use Test::More tests => 16;
+use Test::More;
use_ok( 'Tie::Scalar' );
ok $r1 && $called1, "inheriting new() does not croak";
ok $r2 && $called2, "inheriting TIESCALAR() does not croak";
+
+done_testing();
@times = (-2**55, -2**50, -2**33, -2**31-1, -1, 0, 1, 2**31-1, 2**33, 2**50, 2**55, time);
@methods = qw(sec min hour mday mon year wday yday isdst);
- plan tests => (@times * (@methods + 1)) + 1;
-
use_ok Time::gmtime;
}
is $gmtime->$method, shift @gmtime, "gmtime($time)->$method";
}
}
+
+done_testing();
@times = (-2**55, -2**50, -2**33, -2**31-1, -1, 0, 1, 2**31-1, 2**33, 2**50, 2**55, time);
@methods = qw(sec min hour mday mon year wday yday isdst);
- plan tests => (@times * (@methods + 1)) + 1;
-
use_ok Time::localtime;
}
is $localtime->$method, shift @localtime, "localtime($time)->$method";
}
}
+
+done_testing();
}
BEGIN {
- plan tests => 5;
use_ok('User::grent');
}
# Testing pretty much anything else is unportable.
+done_testing();
_cleanup( @blib_dirs );
}
-use Test::More tests => 7;
+use Test::More;
eval 'use blib;';
ok( $@ =~ /Cannot find blib/, 'Fails if blib directory not found' );
ok( grep(m|\Q$blib_lib\E$|, @INC[0,1]) == 1, " $blib_lib in \@INC");
ok( grep(m|\Q$blib_arch\E$|, @INC[0,1]) == 1, " $blib_arch in \@INC");
+done_testing();
+
END { _cleanup( @blib_dirs ); }
use Test::More;
-plan tests => scalar @prgs;
-
require "dumpvar.pl";
sub unctrl { print dumpvar::unctrl($_[0]), "\n" }
}
}
+done_testing();
+
package TieOut;
sub TIEHANDLE {
}
use Config;
-use Test::More tests => 15;
+use Test::More;
# these two should be kept in sync with the pragma itself
# if hint bits are changed there, other things *will* break
unlink $tstfile;
warn "Can't remove $tstfile: $!" if -e $tstfile;
}
+
+done_testing();
EOXSFILES
);
-my $total_tests = 3; # opening, closing and deleting the header file.
-for (my $i = $#tests; $i > 0; $i-=3) {
- # 1 test for running it, 1 test for the expected result, and 1 for each file
- # plus 1 to open and 1 to check for the use in lib/$name.pm and Makefile.PL
- # And 1 more for our check for "bonus" files, 2 more for ExtUtil::Manifest.
- # And 1 more to examine const-c.inc contents in tests that use $header.
- # use the () to force list context and hence count the number of matches.
- $total_tests += 9 + (() = $tests[$i] =~ /(Writing)/sg);
- $total_tests++ if $tests[$i-2] =~ / \Q$header\E$/;
-}
-
-plan tests => $total_tests;
-
ok (open (HEADER, '>', $header), "open '$header'");
print HEADER <<HEADER or die $!;
#define Camel 2
}
cmp_ok (unlink ($header), "==", 1, "unlink '$header'") or die "\$! is $!";
+
+done_testing();
use integer;
-use Test::More tests => 15;
+use Test::More;
use Config;
my $x = 4.5;
is($@, '', 'IV_MIN % -1 succeeds');
is($biff, 0, 'IV_MIN % -1 == 0');
}
+
+done_testing();
push @INC, '../lib';
}
-use Test::More tests => 12;
+use Test::More;
BEGIN {
use_ok( 'less' );
is_deeply([sort less->of],[sort qw(random acts)],'less random acts');
is(scalar less->of('random'),1,'less random');
+
+done_testing();
}
$| = 1;
-use Test::More 'tests' => 140;
+use Test::More;
my $ii = 36028797018963971; # 2^55 + 3
}
}
-# EOF
+done_testing();
#./perl
-use Test::More tests => 50;
+use Test::More;
use Scalar::Util qw(refaddr);
BEGIN { ok(!exists($^H{overloading}), "overloading hint removed") }
}
+
+done_testing();
use strict;
use warnings;
-use Test::More tests => @TestSizes * 2 # sort() tests
- * 3 # number of pragmas to test
- + 10; # tests for sort::current
+use Test::More;
# Generate array of specified size for testing sort.
#
}
is($sort_current, 'stable', 'sort::current for stable');
}
+
+done_testing();
my $Invoke_Perl = qq(MCR $perl "-I[-.lib]");
-use Test::More tests => 29;
+use Test::More;
SKIP: {
skip("tests for non-VMS only", 1) if $^O eq 'VMS';
}
}
+done_testing();
+
#====== need this to make sure error messages come out, even if
# they were turned off in invoking procedure
sub do_a_perl {