summaryrefslogtreecommitdiff
path: root/lib/Test
diff options
context:
space:
mode:
authorSteve Peters <steve@fisharerojo.org>2006-09-13 13:35:32 +0000
committerSteve Peters <steve@fisharerojo.org>2006-09-13 13:35:32 +0000
commitb7f9bbeb27deb5ace5bde1b13a5221532eb90ed0 (patch)
tree24b4957f49056396e0eed78f88da6648424fb0e7 /lib/Test
parentfea7688c419f77f70fbdf9124ff5cef2c8a4be23 (diff)
downloadperl-b7f9bbeb27deb5ace5bde1b13a5221532eb90ed0.tar.gz
Upgrade to Test-Simple-0.64_02
p4raw-id: //depot/perl@28836
Diffstat (limited to 'lib/Test')
-rw-r--r--lib/Test/Builder.pm129
-rw-r--r--lib/Test/Builder/Module.pm2
-rw-r--r--lib/Test/Builder/Tester.pm31
-rw-r--r--lib/Test/More.pm8
-rw-r--r--lib/Test/Simple.pm2
-rw-r--r--lib/Test/Simple/Changes18
-rw-r--r--lib/Test/Simple/t/00test_harness_check.t2
-rw-r--r--lib/Test/Simple/t/diag.t2
-rw-r--r--lib/Test/Simple/t/extra.t4
-rw-r--r--lib/Test/Simple/t/fail-like.t2
-rw-r--r--lib/Test/Simple/t/fail-more.t58
-rw-r--r--lib/Test/Simple/t/fail.t4
-rw-r--r--lib/Test/Simple/t/fail_one.t2
-rw-r--r--lib/Test/Simple/t/harness_active.t8
-rw-r--r--lib/Test/Simple/t/is_deeply_fail.t40
-rw-r--r--lib/Test/Simple/t/is_fh.t14
-rw-r--r--lib/Test/Simple/t/missing.t2
-rw-r--r--lib/Test/Simple/t/no_plan.t73
-rw-r--r--lib/Test/Simple/t/plan.t6
-rw-r--r--lib/Test/Simple/t/plan_bad.t68
-rw-r--r--lib/Test/Simple/t/skip.t2
-rw-r--r--lib/Test/Simple/t/sort_bug.t4
-rw-r--r--lib/Test/Simple/t/threads.t4
23 files changed, 240 insertions, 245 deletions
diff --git a/lib/Test/Builder.pm b/lib/Test/Builder.pm
index d9ebef1125..d0b379aba4 100644
--- a/lib/Test/Builder.pm
+++ b/lib/Test/Builder.pm
@@ -8,14 +8,15 @@ $^C ||= 0;
use strict;
use vars qw($VERSION);
-$VERSION = '0.33';
+$VERSION = '0.33_02';
$VERSION = eval $VERSION; # make the alpha version come out as a number
# Make Test::Builder thread-safe for ithreads.
BEGIN {
use Config;
- # Load threads::shared when threads are turned on
- if( $] >= 5.008 && $Config{useithreads} && $INC{'threads.pm'}) {
+ # Load threads::shared when threads are turned on.
+ # 5.8.0's threads are so busted we no longer support them.
+ if( $] >= 5.008001 && $Config{useithreads} && $INC{'threads.pm'}) {
require threads::shared;
# Hack around YET ANOTHER threads::shared bug. It would
@@ -35,7 +36,7 @@ BEGIN {
$$data = ${$_[0]};
}
else {
- die "Unknown type: ".$type;
+ die("Unknown type: ".$type);
}
$_[0] = &threads::shared::share($_[0]);
@@ -50,14 +51,14 @@ BEGIN {
${$_[0]} = $$data;
}
else {
- die "Unknown type: ".$type;
+ die("Unknown type: ".$type);
}
return $_[0];
};
}
- # 5.8.0's threads::shared is busted when threads are off.
- # We emulate it here.
+ # 5.8.0's threads::shared is busted when threads are off
+ # and earlier Perls just don't have that module at all.
else {
*share = sub { return $_[0] };
*lock = sub { 0 };
@@ -247,8 +248,7 @@ sub plan {
return unless $cmd;
if( $self->{Have_Plan} ) {
- die sprintf "You tried to plan twice! Second plan at %s line %d\n",
- ($self->caller)[1,2];
+ $self->croak("You tried to plan twice");
}
if( $cmd eq 'no_plan' ) {
@@ -259,20 +259,19 @@ sub plan {
}
elsif( $cmd eq 'tests' ) {
if( $arg ) {
+ local $Level = $Level + 1;
return $self->expected_tests($arg);
}
elsif( !defined $arg ) {
- die "Got an undefined number of tests. Looks like you tried to ".
- "say how many tests you plan to run but made a mistake.\n";
+ $self->croak("Got an undefined number of tests");
}
elsif( !$arg ) {
- die "You said to run 0 tests! You've got to run something.\n";
+ $self->croak("You said to run 0 tests");
}
}
else {
- require Carp;
my @args = grep { defined } ($cmd, $arg);
- Carp::croak("plan() doesn't understand @args");
+ $self->croak("plan() doesn't understand @args");
}
return 1;
@@ -293,7 +292,7 @@ sub expected_tests {
my($max) = @_;
if( @_ ) {
- die "Number of tests must be a postive integer. You gave it '$max'.\n"
+ $self->croak("Number of tests must be a positive integer. You gave it '$max'")
unless $max =~ /^\+?\d+$/ and $max > 0;
$self->{Expected_Tests} = $max;
@@ -386,10 +385,7 @@ sub ok {
# store, so we turn it into a boolean.
$test = $test ? 1 : 0;
- unless( $self->{Have_Plan} ) {
- require Carp;
- Carp::croak("You tried to run a test without a plan! Gotta have a plan.");
- }
+ $self->_plan_check;
lock $self->{Curr_Test};
$self->{Curr_Test}++;
@@ -451,10 +447,10 @@ ERR
if( defined $name ) {
$self->diag(qq[ $msg test '$name'\n]);
- $self->diag(qq[ in $file at line $line.\n]);
+ $self->diag(qq[ at $file line $line.\n]);
}
else {
- $self->diag(qq[ $msg test in $file at line $line.\n]);
+ $self->diag(qq[ $msg test at $file line $line.\n]);
}
}
@@ -889,10 +885,7 @@ sub skip {
$why ||= '';
$self->_unoverload_str(\$why);
- unless( $self->{Have_Plan} ) {
- require Carp;
- Carp::croak("You tried to run tests without a plan! Gotta have a plan.");
- }
+ $self->_plan_check;
lock($self->{Curr_Test});
$self->{Curr_Test}++;
@@ -933,10 +926,7 @@ sub todo_skip {
my($self, $why) = @_;
$why ||= '';
- unless( $self->{Have_Plan} ) {
- require Carp;
- Carp::croak("You tried to run tests without a plan! Gotta have a plan.");
- }
+ $self->_plan_check;
lock($self->{Curr_Test});
$self->{Curr_Test}++;
@@ -1182,6 +1172,7 @@ sub _print {
print $fh $msg;
}
+=begin private
=item B<_print_diag>
@@ -1189,6 +1180,8 @@ sub _print {
Like _print, but prints to the current diagnostic filehandle.
+=end private
+
=cut
sub _print_diag {
@@ -1232,7 +1225,7 @@ sub output {
my($self, $fh) = @_;
if( defined $fh ) {
- $self->{Out_FH} = _new_fh($fh);
+ $self->{Out_FH} = $self->_new_fh($fh);
}
return $self->{Out_FH};
}
@@ -1241,7 +1234,7 @@ sub failure_output {
my($self, $fh) = @_;
if( defined $fh ) {
- $self->{Fail_FH} = _new_fh($fh);
+ $self->{Fail_FH} = $self->_new_fh($fh);
}
return $self->{Fail_FH};
}
@@ -1250,23 +1243,24 @@ sub todo_output {
my($self, $fh) = @_;
if( defined $fh ) {
- $self->{Todo_FH} = _new_fh($fh);
+ $self->{Todo_FH} = $self->_new_fh($fh);
}
return $self->{Todo_FH};
}
sub _new_fh {
+ my $self = shift;
my($file_or_fh) = shift;
my $fh;
- if( _is_fh($file_or_fh) ) {
+ if( $self->_is_fh($file_or_fh) ) {
$fh = $file_or_fh;
}
else {
$fh = do { local *FH };
- open $fh, ">$file_or_fh" or
- die "Can't open test output log $file_or_fh: $!";
+ open $fh, ">$file_or_fh" or
+ $self->croak("Can't open test output log $file_or_fh: $!");
_autoflush($fh);
}
@@ -1275,6 +1269,7 @@ sub _new_fh {
sub _is_fh {
+ my $self = shift;
my $maybe_fh = shift;
return 0 unless defined $maybe_fh;
@@ -1325,6 +1320,49 @@ sub _open_testhandles {
}
+=item carp
+
+ $tb->carp(@message);
+
+Warns with C<@message> but the message will appear to come from the
+point where the original test function was called (C<$tb->caller>).
+
+=item croak
+
+ $tb->croak(@message);
+
+Dies with C<@message> but the message will appear to come from the
+point where the original test function was called (C<$tb->caller>).
+
+=cut
+
+sub _message_at_caller {
+ my $self = shift;
+
+ local $Level = $Level + 2;
+ my($pack, $file, $line) = $self->caller;
+ return join("", @_) . " at $file line $line.\n";
+}
+
+sub carp {
+ my $self = shift;
+ warn $self->_message_at_caller(@_);
+}
+
+sub croak {
+ my $self = shift;
+ die $self->_message_at_caller(@_);
+}
+
+sub _plan_check {
+ my $self = shift;
+
+ unless( $self->{Have_Plan} ) {
+ local $Level = $Level + 1;
+ $self->croak("You tried to run a test without a plan");
+ }
+}
+
=back
@@ -1352,8 +1390,7 @@ sub current_test {
lock($self->{Curr_Test});
if( defined $num ) {
unless( $self->{Have_Plan} ) {
- require Carp;
- Carp::croak("Can't change the current test number without a plan!");
+ $self->croak("Can't change the current test number without a plan!");
}
$self->{Curr_Test} = $num;
@@ -1523,16 +1560,16 @@ error message.
sub _sanity_check {
my $self = shift;
- _whoa($self->{Curr_Test} < 0, 'Says here you ran a negative number of tests!');
- _whoa(!$self->{Have_Plan} and $self->{Curr_Test},
+ $self->_whoa($self->{Curr_Test} < 0, 'Says here you ran a negative number of tests!');
+ $self->_whoa(!$self->{Have_Plan} and $self->{Curr_Test},
'Somehow your tests ran without a plan!');
- _whoa($self->{Curr_Test} != @{ $self->{Test_Results} },
+ $self->_whoa($self->{Curr_Test} != @{ $self->{Test_Results} },
'Somehow you got a different number of results than tests ran!');
}
=item B<_whoa>
- _whoa($check, $description);
+ $self->_whoa($check, $description);
A sanity check, similar to assert(). If the $check is true, something
has gone horribly wrong. It will die with the given $description and
@@ -1541,9 +1578,10 @@ a note to contact the author.
=cut
sub _whoa {
- my($check, $desc) = @_;
+ my($self, $check, $desc) = @_;
if( $check ) {
- die <<WHOA;
+ local $Level = $Level + 1;
+ $self->croak(<<"WHOA");
WHOA! $desc
This should never happen! Please contact the author immediately!
WHOA
@@ -1713,10 +1751,13 @@ If you fail more than 254 tests, it will be reported as 254.
=head1 THREADS
-In perl 5.8.0 and later, Test::Builder is thread-safe. The test
+In perl 5.8.1 and later, Test::Builder is thread-safe. The test
number is shared amongst all threads. This means if one thread sets
the test number using current_test() they will all be effected.
+While versions earlier than 5.8.1 had threads they contain too many
+bugs to support.
+
Test::Builder is only thread-aware if threads.pm is loaded I<before>
Test::Builder.
diff --git a/lib/Test/Builder/Module.pm b/lib/Test/Builder/Module.pm
index 855488a491..146e4341f9 100644
--- a/lib/Test/Builder/Module.pm
+++ b/lib/Test/Builder/Module.pm
@@ -5,7 +5,7 @@ use Test::Builder;
require Exporter;
@ISA = qw(Exporter);
-$VERSION = '0.03';
+$VERSION = '0.03_02';
use strict;
diff --git a/lib/Test/Builder/Tester.pm b/lib/Test/Builder/Tester.pm
index 7eab5a5dc4..ab32588ee5 100644
--- a/lib/Test/Builder/Tester.pm
+++ b/lib/Test/Builder/Tester.pm
@@ -2,7 +2,7 @@ package Test::Builder::Tester;
use strict;
use vars qw(@EXPORT $VERSION @ISA);
-$VERSION = "1.04";
+$VERSION = "1.04_02";
use Test::Builder;
use Symbol;
@@ -497,17 +497,17 @@ sub expect
my @checks = @_;
foreach my $check (@checks) {
$check = $self->_translate_Failed_check($check);
- push @{$self->[2]}, ref $check ? $check : "$check\n";
+ push @{$self->{wanted}}, ref $check ? $check : "$check\n";
}
}
-sub _translate_Failed_check
+sub _translate_Failed_check
{
my($self, $check) = @_;
if( $check =~ /\A(.*)# (Failed .*test) \((.*?) at line (\d+)\)\z/ ) {
- $check = qr/\Q$1\E#\s+\Q$2\E.*?\n?.*?\Q$3\E at line \Q$4\E.*\n?/;
+ $check = qr/\Q$1\E#\s+\Q$2\E.*?\n?.*?\Qat $3\E line \Q$4\E.*\n?/;
}
return $check;
@@ -524,8 +524,8 @@ sub check
# turn off warnings as these might be undef
local $^W = 0;
- my @checks = @{$self->[2]};
- my $got = $self->[1];
+ my @checks = @{$self->{wanted}};
+ my $got = $self->{got};
foreach my $check (@checks) {
$check = qr/^\Q$check\E/ unless ref $check;
return 0 unless $got =~ s/^$check//;
@@ -592,26 +592,30 @@ sub complaint
sub reset
{
my $self = shift;
- @$self = ($self->[0], '', []);
+ %$self = (
+ type => $self->{type},
+ got => '',
+ wanted => [],
+ );
}
sub got
{
my $self = shift;
- return $self->[1];
+ return $self->{got};
}
sub wanted
{
my $self = shift;
- return $self->[2];
+ return $self->{wanted};
}
sub type
{
my $self = shift;
- return $self->[0];
+ return $self->{type};
}
###
@@ -620,13 +624,16 @@ sub type
sub PRINT {
my $self = shift;
- $self->[1] .= join '', @_;
+ $self->{got} .= join '', @_;
}
sub TIEHANDLE {
my($class, $type) = @_;
- my $self = bless [$type], $class;
+ my $self = bless {
+ type => $type
+ }, $class;
+
$self->reset;
return $self;
diff --git a/lib/Test/More.pm b/lib/Test/More.pm
index 465ccd3e5d..4759e686e3 100644
--- a/lib/Test/More.pm
+++ b/lib/Test/More.pm
@@ -16,7 +16,7 @@ sub _carp {
use vars qw($VERSION @ISA @EXPORT %EXPORT_TAGS $TODO);
-$VERSION = '0.64';
+$VERSION = '0.64_02';
$VERSION = eval $VERSION; # make the alpha version come out as a number
use Test::Builder::Module;
@@ -41,7 +41,7 @@ Test::More - yet another framework for writing test scripts
=head1 SYNOPSIS
- use Test::More tests => $Num_Tests;
+ use Test::More tests => 23;
# or
use Test::More qw(no_plan);
# or
@@ -113,7 +113,7 @@ failure.
The preferred way to do this is to declare a plan when you C<use Test::More>.
- use Test::More tests => $Num_Tests;
+ use Test::More tests => 23;
There are rare cases when you will not know beforehand how many tests
your script is going to run. In this case, you can declare that you
@@ -1465,6 +1465,8 @@ This may cause problems:
use Test::More
use threads;
+5.8.1 and above are supported. Anything below that has too many bugs.
+
=item Test::Harness upgrade
diff --git a/lib/Test/Simple.pm b/lib/Test/Simple.pm
index ae912d29ba..2edea47d23 100644
--- a/lib/Test/Simple.pm
+++ b/lib/Test/Simple.pm
@@ -4,7 +4,7 @@ use 5.004;
use strict 'vars';
use vars qw($VERSION @ISA @EXPORT);
-$VERSION = '0.64';
+$VERSION = '0.64_02';
$VERSION = eval $VERSION; # make the alpha version come out as a number
use Test::Builder::Module;
diff --git a/lib/Test/Simple/Changes b/lib/Test/Simple/Changes
index 94491eb3f1..433720d1c6 100644
--- a/lib/Test/Simple/Changes
+++ b/lib/Test/Simple/Changes
@@ -1,3 +1,21 @@
+0.64_02 Sat Sep 9 12:16:56 EDT 2006
+ - Last release broke Perls earlier than 5.8.
+
+0.64_01 Mon Sep 4 04:40:42 EDT 2006
+ - Small improvement to the docs to avoid user confusion over
+ "use Test::More tests => $num_tests" (Thanks Eric Wilhelm)
+ - Minor fix for a test failure in is_deeply_fail for some Windows
+ users. Not a real bug. [rt.cpan.org 21310]
+ - _print_diag() accidentally leaked into the public documentation.
+ It is a private method.
+ * Made most of the error messages report in the caller's context.
+ [rt.cpan.org #20639]
+ * Made the failure diagnostic message file and line reporting portion
+ match Perl's for easier integration with Perl aware editors.
+ (so its "at $file line $line_num." now)
+ [rt.cpan.org #20639]
+ * 5.8.0 threads are no longer supported. There's too many bugs.
+
0.64 Sun Jul 16 02:47:29 PDT 2006
* 0.63's change to test_fail() broke backwards compatibility. They
have been removed for the time being. test_pass() went with it.
diff --git a/lib/Test/Simple/t/00test_harness_check.t b/lib/Test/Simple/t/00test_harness_check.t
index d50c8b5ffd..262d53b523 100644
--- a/lib/Test/Simple/t/00test_harness_check.t
+++ b/lib/Test/Simple/t/00test_harness_check.t
@@ -8,7 +8,7 @@ plan tests => 1;
my $TH_Version = 2.03;
require Test::Harness;
-unless( cmp_ok( $Test::Harness::VERSION, '>', $TH_Version, "T::H version" ) ) {
+unless( cmp_ok( $Test::Harness::VERSION, '>=', $TH_Version, "T::H version" ) ) {
diag <<INSTRUCTIONS;
Test::Simple/More/Builder has features which depend on a version of
diff --git a/lib/Test/Simple/t/diag.t b/lib/Test/Simple/t/diag.t
index 0b2a51fc6a..b5e5876a4f 100644
--- a/lib/Test/Simple/t/diag.t
+++ b/lib/Test/Simple/t/diag.t
@@ -15,7 +15,7 @@ BEGIN {
# lots of threading bugs.
use Config;
BEGIN {
- if( $] >= 5.008 && $Config{useithreads} ) {
+ if( $] >= 5.008001 && $Config{useithreads} ) {
require threads;
'threads'->import;
}
diff --git a/lib/Test/Simple/t/extra.t b/lib/Test/Simple/t/extra.t
index a0058661c4..6a0082ff3f 100644
--- a/lib/Test/Simple/t/extra.t
+++ b/lib/Test/Simple/t/extra.t
@@ -48,9 +48,9 @@ OUT
$TB->is_eq($$err, <<ERR);
# Failed test 'Bar'
-# in $0 at line 31.
+# at $0 line 31.
# Failed test 'Sar'
-# in $0 at line 34.
+# at $0 line 34.
# Looks like you planned 3 tests but ran 2 extra.
# Looks like you failed 2 tests of 5 run.
ERR
diff --git a/lib/Test/Simple/t/fail-like.t b/lib/Test/Simple/t/fail-like.t
index 5631b589d6..dea03e8e7f 100644
--- a/lib/Test/Simple/t/fail-like.t
+++ b/lib/Test/Simple/t/fail-like.t
@@ -54,7 +54,7 @@ OUT
my $err_re = <<ERR;
# Failed test 'is foo like that'
-# in .* at line 1\.
+# at .* line 1\.
# 'foo'
# doesn't match '\\(\\?-xism:that\\)'
# Looks like you failed 1 test of 1\\.
diff --git a/lib/Test/Simple/t/fail-more.t b/lib/Test/Simple/t/fail-more.t
index 07d5d37c85..20e3261611 100644
--- a/lib/Test/Simple/t/fail-more.t
+++ b/lib/Test/Simple/t/fail-more.t
@@ -58,7 +58,7 @@ my $Filename = quotemeta $0;
ok( 0, 'failing' );
err_ok( <<ERR );
# Failed test 'failing'
-# in $0 at line 38.
+# at $0 line 38.
ERR
#line 40
@@ -68,19 +68,19 @@ is( undef, 0, 'undef is 0?');
is( '', 0, 'empty string is 0?' );
err_ok( <<ERR );
# Failed test 'foo is bar?'
-# in $0 at line 40.
+# at $0 line 40.
# got: 'foo'
# expected: 'bar'
# Failed test 'undef is empty string?'
-# in $0 at line 41.
+# at $0 line 41.
# got: undef
# expected: ''
# Failed test 'undef is 0?'
-# in $0 at line 42.
+# at $0 line 42.
# got: undef
# expected: '0'
# Failed test 'empty string is 0?'
-# in $0 at line 43.
+# at $0 line 43.
# got: ''
# expected: '0'
ERR
@@ -91,17 +91,17 @@ isn't("foo", "foo",'foo isn\'t foo?' );
isnt(undef, undef, 'undef isnt undef?');
err_ok( <<ERR );
# Failed test 'foo isnt foo?'
-# in $0 at line 45.
+# at $0 line 45.
# 'foo'
# ne
# 'foo'
# Failed test 'foo isn\'t foo?'
-# in $0 at line 46.
+# at $0 line 46.
# 'foo'
# ne
# 'foo'
# Failed test 'undef isnt undef?'
-# in $0 at line 47.
+# at $0 line 47.
# undef
# ne
# undef
@@ -112,11 +112,11 @@ like( "foo", '/that/', 'is foo like that' );
unlike( "foo", '/foo/', 'is foo unlike foo' );
err_ok( <<ERR );
# Failed test 'is foo like that'
-# in $0 at line 48.
+# at $0 line 48.
# 'foo'
# doesn't match '/that/'
# Failed test 'is foo unlike foo'
-# in $0 at line 49.
+# at $0 line 49.
# 'foo'
# matches '/foo/'
ERR
@@ -126,7 +126,7 @@ ERR
like( "bug", '/(%)/', 'regex with % in it' );
err_ok( <<ERR );
# Failed test 'regex with % in it'
-# in $0 at line 60.
+# at $0 line 60.
# 'bug'
# doesn't match '/(%)/'
ERR
@@ -135,7 +135,7 @@ ERR
fail('fail()');
err_ok( <<ERR );
# Failed test 'fail()'
-# in $0 at line 67.
+# at $0 line 67.
ERR
#line 52
@@ -144,14 +144,14 @@ can_ok('Mooble::Hooble::Yooble', ());
can_ok(undef, undef);
err_ok( <<ERR );
# Failed test 'Mooble::Hooble::Yooble->can(...)'
-# in $0 at line 52.
+# at $0 line 52.
# Mooble::Hooble::Yooble->can('this') failed
# Mooble::Hooble::Yooble->can('that') failed
# Failed test 'Mooble::Hooble::Yooble->can(...)'
-# in $0 at line 53.
+# at $0 line 53.
# can_ok() called with no methods
# Failed test '->can(...)'
-# in $0 at line 54.
+# at $0 line 54.
# can_ok() called with empty class or reference
ERR
@@ -162,16 +162,16 @@ isa_ok(undef, "Wibble", "Another Wibble");
isa_ok([], "HASH");
err_ok( <<ERR );
# Failed test 'The object isa Wibble'
-# in $0 at line 55.
+# at $0 line 55.
# The object isn't a 'Wibble' it's a 'Foo'
# Failed test 'My Wibble isa Wibble'
-# in $0 at line 56.
+# at $0 line 56.
# My Wibble isn't a reference
# Failed test 'Another Wibble isa Wibble'
-# in $0 at line 57.
+# at $0 line 57.
# Another Wibble isn't defined
# Failed test 'The object isa HASH'
-# in $0 at line 58.
+# at $0 line 58.
# The object isn't a 'HASH' it's a 'ARRAY'
ERR
@@ -182,20 +182,20 @@ cmp_ok( 42, '!=', 42 , ' !=' );
cmp_ok( 1, '&&', 0 , ' &&' );
err_ok( <<ERR );
# Failed test 'cmp_ok eq'
-# in $0 at line 68.
+# at $0 line 68.
# got: 'foo'
# expected: 'bar'
# Failed test ' =='
-# in $0 at line 69.
+# at $0 line 69.
# got: 42.1
# expected: 23
# Failed test ' !='
-# in $0 at line 70.
+# at $0 line 70.
# '42'
# !=
# '42'
# Failed test ' &&'
-# in $0 at line 71.
+# at $0 line 71.
# '1'
# &&
# '0'
@@ -206,7 +206,7 @@ ERR
cmp_ok( 42, 'eq', "foo", ' eq with numbers' );
err_ok( <<ERR );
# Failed test ' eq with numbers'
-# in $0 at line 196.
+# at $0 line 196.
# got: '42'
# expected: 'foo'
ERR
@@ -220,7 +220,7 @@ ERR
cmp_ok( 42, '==', "foo", ' == with strings' );
err_ok( <<ERR );
# Failed test ' == with strings'
-# in $0 at line 211.
+# at $0 line 211.
# got: 42
# expected: foo
ERR
@@ -239,11 +239,11 @@ cmp_ok( $!, 'eq', '', ' eq with stringified errno' );
cmp_ok( $!, '==', -1, ' eq with numerified errno' );
err_ok( <<ERR );
# Failed test ' eq with stringified errno'
-# in $0 at line 80.
+# at $0 line 80.
# got: '$Errno_String'
# expected: ''
# Failed test ' eq with numerified errno'
-# in $0 at line 81.
+# at $0 line 81.
# got: $Errno_Number
# expected: -1
ERR
@@ -253,7 +253,7 @@ use_ok('Hooble::mooble::yooble');
my $more_err_re = <<ERR;
# Failed test 'use Hooble::mooble::yooble;'
-# in $Filename at line 84\\.
+# at $Filename line 84\\.
# Tried to use 'Hooble::mooble::yooble'.
# Error: Can't locate Hooble.* in \\\@INC .*
# BEGIN failed--compilation aborted at $Filename line 84.
@@ -266,7 +266,7 @@ My::Test::like($err->read, "/^$more_err_re/");
require_ok('ALL::YOUR::BASE::ARE::BELONG::TO::US::wibble');
$more_err_re = <<ERR;
# Failed test 'require ALL::YOUR::BASE::ARE::BELONG::TO::US::wibble;'
-# in $Filename at line 85\\.
+# at $Filename line 85\\.
# Tried to require 'ALL::YOUR::BASE::ARE::BELONG::TO::US::wibble'.
# Error: Can't locate ALL.* in \\\@INC .*
ERR
diff --git a/lib/Test/Simple/t/fail.t b/lib/Test/Simple/t/fail.t
index 822fcb8c70..6be111893d 100644
--- a/lib/Test/Simple/t/fail.t
+++ b/lib/Test/Simple/t/fail.t
@@ -61,9 +61,9 @@ OUT
My::Test::ok($$err eq <<ERR);
# Failed test 'oh no!'
-# in $0 at line 38.
+# at $0 line 38.
# Failed test 'damnit'
-# in $0 at line 39.
+# at $0 line 39.
# Looks like you failed 2 tests of 5.
ERR
diff --git a/lib/Test/Simple/t/fail_one.t b/lib/Test/Simple/t/fail_one.t
index fe22624741..46b181d6a1 100644
--- a/lib/Test/Simple/t/fail_one.t
+++ b/lib/Test/Simple/t/fail_one.t
@@ -53,7 +53,7 @@ not ok 1
OUT
My::Test::ok($$err eq <<ERR) || print $$err;
-# Failed test in $0 at line 45.
+# Failed test at $0 line 45.
# Looks like you failed 1 test of 1.
ERR
diff --git a/lib/Test/Simple/t/harness_active.t b/lib/Test/Simple/t/harness_active.t
index d3ae56a828..7b027a7b40 100644
--- a/lib/Test/Simple/t/harness_active.t
+++ b/lib/Test/Simple/t/harness_active.t
@@ -52,13 +52,13 @@ Test::More->builder->no_ending(1);
fail( "this fails" );
err_ok( <<ERR );
# Failed test 'this fails'
-# in $0 at line 62.
+# at $0 line 62.
ERR
#line 72
is( 1, 0 );
err_ok( <<ERR );
-# Failed test in $0 at line 72.
+# Failed test at $0 line 72.
# got: '1'
# expected: '0'
ERR
@@ -72,7 +72,7 @@ ERR
err_ok( <<ERR );
# Failed test 'this fails'
-# in $0 at line 71.
+# at $0 line 71.
ERR
@@ -80,7 +80,7 @@ ERR
is( 1, 0 );
err_ok( <<ERR );
-# Failed test in $0 at line 84.
+# Failed test at $0 line 84.
# got: '1'
# expected: '0'
ERR
diff --git a/lib/Test/Simple/t/is_deeply_fail.t b/lib/Test/Simple/t/is_deeply_fail.t
index 94ece33edb..a28b24ccdf 100644
--- a/lib/Test/Simple/t/is_deeply_fail.t
+++ b/lib/Test/Simple/t/is_deeply_fail.t
@@ -64,7 +64,7 @@ ok !is_deeply('foo', 'bar', 'plain strings');
is( $out, "not ok 1 - plain strings\n", 'plain strings' );
is( $err, <<ERR, ' right diagnostic' );
# Failed test 'plain strings'
-# in $0 at line 68.
+# at $0 line 68.
# got: 'foo'
# expected: 'bar'
ERR
@@ -75,7 +75,7 @@ ok !is_deeply({}, [], 'different types');
is( $out, "not ok 2 - different types\n", 'different types' );
like( $err, <<ERR, ' right diagnostic' );
# Failed test 'different types'
-# in $Filename at line 78.
+# at $Filename line 78.
# Structures begin differing at:
# \\\$got = HASH\\(0x[0-9a-f]+\\)
# \\\$expected = ARRAY\\(0x[0-9a-f]+\\)
@@ -87,7 +87,7 @@ is( $out, "not ok 3 - hashes with different values\n",
'hashes with different values' );
is( $err, <<ERR, ' right diagnostic' );
# Failed test 'hashes with different values'
-# in $0 at line 88.
+# at $0 line 88.
# Structures begin differing at:
# \$got->{this} = '42'
# \$expected->{this} = '43'
@@ -99,7 +99,7 @@ is( $out, "not ok 4 - hashes with different keys\n",
'hashes with different keys' );
is( $err, <<ERR, ' right diagnostic' );
# Failed test 'hashes with different keys'
-# in $0 at line 99.
+# at $0 line 99.
# Structures begin differing at:
# \$got->{this} = Does not exist
# \$expected->{this} = '42'
@@ -111,7 +111,7 @@ is( $out, "not ok 5 - arrays of different length\n",
'arrays of different length' );
is( $err, <<ERR, ' right diagnostic' );
# Failed test 'arrays of different length'
-# in $0 at line 110.
+# at $0 line 110.
# Structures begin differing at:
# \$got->[9] = Does not exist
# \$expected->[9] = '10'
@@ -122,7 +122,7 @@ ok !is_deeply([undef, undef], [undef], 'arrays of undefs' );
is( $out, "not ok 6 - arrays of undefs\n", 'arrays of undefs' );
is( $err, <<ERR, ' right diagnostic' );
# Failed test 'arrays of undefs'
-# in $0 at line 121.
+# at $0 line 121.
# Structures begin differing at:
# \$got->[1] = undef
# \$expected->[1] = Does not exist
@@ -133,7 +133,7 @@ ok !is_deeply({ foo => undef }, {}, 'hashes of undefs' );
is( $out, "not ok 7 - hashes of undefs\n", 'hashes of undefs' );
is( $err, <<ERR, ' right diagnostic' );
# Failed test 'hashes of undefs'
-# in $0 at line 131.
+# at $0 line 131.
# Structures begin differing at:
# \$got->{foo} = undef
# \$expected->{foo} = Does not exist
@@ -144,7 +144,7 @@ ok !is_deeply(\42, \23, 'scalar refs');
is( $out, "not ok 8 - scalar refs\n", 'scalar refs' );
is( $err, <<ERR, ' right diagnostic' );
# Failed test 'scalar refs'
-# in $0 at line 141.
+# at $0 line 141.
# Structures begin differing at:
# \${ \$got} = '42'
# \${\$expected} = '23'
@@ -156,7 +156,7 @@ is( $out, "not ok 9 - mixed scalar and array refs\n",
'mixed scalar and array refs' );
like( $err, <<ERR, ' right diagnostic' );
# Failed test 'mixed scalar and array refs'
-# in $Filename at line 151.
+# at $Filename line 151.
# Structures begin differing at:
# \\\$got = ARRAY\\(0x[0-9a-f]+\\)
# \\\$expected = SCALAR\\(0x[0-9a-f]+\\)
@@ -176,7 +176,7 @@ ok !is_deeply($a1, $b1, 'deep scalar refs');
is( $out, "not ok 10 - deep scalar refs\n", 'deep scalar refs' );
is( $err, <<ERR, ' right diagnostic' );
# Failed test 'deep scalar refs'
-# in $0 at line 173.
+# at $0 line 173.
# Structures begin differing at:
# \${\${ \$got}} = '42'
# \${\${\$expected}} = '23'
@@ -203,7 +203,7 @@ ok( @Test::More::Data_Stack == 0, '@Data_Stack not holding onto things' );
is( $out, "not ok 11 - deep structures\n", 'deep structures' );
is( $err, <<ERR, ' right diagnostic' );
# Failed test 'deep structures'
-# in $0 at line 198.
+# at $0 line 198.
# Structures begin differing at:
# \$got->{that}{foo} = Does not exist
# \$expected->{that}{foo} = '42'
@@ -252,7 +252,7 @@ $$err = $$out = '';
ok !is_deeply( [\'a', 'b'], [\'a', 'c'] );
is( $out, "not ok 20\n", 'scalar refs in an array' );
is( $err, <<ERR, ' right diagnostic' );
-# Failed test in $0 at line 274.
+# Failed test at $0 line 274.
# Structures begin differing at:
# \$got->[1] = 'b'
# \$expected->[1] = 'c'
@@ -264,7 +264,7 @@ my $ref = \23;
ok !is_deeply( 23, $ref );
is( $out, "not ok 21\n", 'scalar vs ref' );
is( $err, <<ERR, ' right diagnostic');
-# Failed test in $0 at line 286.
+# Failed test at $0 line 286.
# Structures begin differing at:
# \$got = '23'
# \$expected = $ref
@@ -274,7 +274,7 @@ ERR
ok !is_deeply( $ref, 23 );
is( $out, "not ok 22\n", 'ref vs scalar' );
is( $err, <<ERR, ' right diagnostic');
-# Failed test in $0 at line 296.
+# Failed test at $0 line 296.
# Structures begin differing at:
# \$got = $ref
# \$expected = '23'
@@ -284,7 +284,7 @@ ERR
ok !is_deeply( undef, [] );
is( $out, "not ok 23\n", 'is_deeply and undef [RT 9441]' );
like( $err, <<ERR, ' right diagnostic' );
-# Failed test in $Filename at line 306\\.
+# Failed test at $Filename line 306\\.
# Structures begin differing at:
# \\\$got = undef
# \\\$expected = ARRAY\\(0x[0-9a-f]+\\)
@@ -300,7 +300,7 @@ ERR
ok !is_deeply( $array, $hash );
is( $out, "not ok 24\n", 'is_deeply and different reference types' );
is( $err, <<ERR, ' right diagnostic' );
-# Failed test in $0 at line 321.
+# Failed test at $0 line 321.
# Structures begin differing at:
# \$got = $array
# \$expected = $hash
@@ -310,7 +310,7 @@ ERR
ok !is_deeply( [$array], [$hash] );
is( $out, "not ok 25\n", 'nested different ref types' );
is( $err, <<ERR, ' right diagnostic' );
-# Failed test in $0 at line 332.
+# Failed test at $0 line 332.
# Structures begin differing at:
# \$got->[0] = $array
# \$expected->[0] = $hash
@@ -330,7 +330,7 @@ ERR
ok !is_deeply( [$foo], [$bar] );
is( $out, "not ok 26\n", 'string overloaded refs respected in diag' );
is( $err, <<ERR, ' right diagnostic' );
-# Failed test in $0 at line 353.
+# Failed test at $0 line 353.
# Structures begin differing at:
# \$got->[0] = $foo
# \$expected->[0] = 'wibble'
@@ -349,7 +349,7 @@ ERR
ok !is_deeply( sub {"foo"}, sub {"bar"} ), 'function refs';
is( $out, "not ok 27\n" );
like( $err, <<ERR, ' right diagnostic' );
-# Failed test in $Filename at line 349.
+# Failed test at $Filename line 349.
# Structures begin differing at:
# \\\$got = CODE\\(0x[0-9a-f]+\\)
# \\\$expected = CODE\\(0x[0-9a-f]+\\)
@@ -364,7 +364,7 @@ ERR
ok !is_deeply( $glob1, $glob2 ), 'typeglobs';
is( $out, "not ok 28\n" );
like( $err, <<ERR, ' right diagnostic' );
-# Failed test in $Filename at line 357.
+# Failed test at $Filename line 357.
# Structures begin differing at:
# \\\$got = GLOB\\(0x[0-9a-f]+\\)
# \\\$expected = GLOB\\(0x[0-9a-f]+\\)
diff --git a/lib/Test/Simple/t/is_fh.t b/lib/Test/Simple/t/is_fh.t
index a1c201c2cc..2661f6869f 100644
--- a/lib/Test/Simple/t/is_fh.t
+++ b/lib/Test/Simple/t/is_fh.t
@@ -14,16 +14,16 @@ use strict;
use Test::More tests => 8;
use TieOut;
-ok( !Test::Builder::_is_fh("foo"), 'string is not a filehandle' );
-ok( !Test::Builder::_is_fh(''), 'empty string' );
-ok( !Test::Builder::_is_fh(undef), 'undef' );
+ok( !Test::Builder->_is_fh("foo"), 'string is not a filehandle' );
+ok( !Test::Builder->_is_fh(''), 'empty string' );
+ok( !Test::Builder->_is_fh(undef), 'undef' );
ok( open(FILE, '>foo') );
END { close FILE; unlink 'foo' }
-ok( Test::Builder::_is_fh(*FILE) );
-ok( Test::Builder::_is_fh(\*FILE) );
-ok( Test::Builder::_is_fh(*FILE{IO}) );
+ok( Test::Builder->_is_fh(*FILE) );
+ok( Test::Builder->_is_fh(\*FILE) );
+ok( Test::Builder->_is_fh(*FILE{IO}) );
tie *OUT, 'TieOut';
-ok( Test::Builder::_is_fh(*OUT) );
+ok( Test::Builder->_is_fh(*OUT) );
diff --git a/lib/Test/Simple/t/missing.t b/lib/Test/Simple/t/missing.t
index e57cace508..7912137a06 100644
--- a/lib/Test/Simple/t/missing.t
+++ b/lib/Test/Simple/t/missing.t
@@ -43,7 +43,7 @@ OUT
My::Test::is($$err, <<ERR);
# Failed test 'Bar'
-# in $0 at line 31.
+# at $0 line 31.
# Looks like you planned 5 tests but only ran 2.
# Looks like you failed 1 test of 2 run.
ERR
diff --git a/lib/Test/Simple/t/no_plan.t b/lib/Test/Simple/t/no_plan.t
index c0af2d4647..6eecd43ec4 100644
--- a/lib/Test/Simple/t/no_plan.t
+++ b/lib/Test/Simple/t/no_plan.t
@@ -1,3 +1,5 @@
+#!/usr/bin/perl -w
+
BEGIN {
if( $ENV{PERL_CORE} ) {
chdir 't';
@@ -8,66 +10,19 @@ BEGIN {
}
}
-# Can't use Test.pm, that's a 5.005 thing.
-package My::Test;
-
-print "1..12\n";
-
-my $test_num = 1;
-# Utility testing functions.
-sub ok ($;$) {
- my($test, $name) = @_;
- my $ok = '';
- $ok .= "not " unless $test;
- $ok .= "ok $test_num";
- $ok .= " - $name" if defined $name;
- $ok .= "\n";
- print $ok;
- $test_num++;
-}
-
-
-package main;
-
-require Test::Simple;
-
-require Test::Simple::Catch;
-my($out, $err) = Test::Simple::Catch::caught();
+use Test::More tests => 6;
-eval {
- Test::Simple->import;
-};
+my $tb = Test::Builder->create;
+$tb->level(0);
-My::Test::ok($$out eq '');
-My::Test::ok($$err eq '');
-My::Test::ok($@ eq '');
+#line 19
+ok !eval { $tb->plan(tests => undef) };
+is($@, "Got an undefined number of tests at $0 line 19.\n");
-eval {
- Test::Simple->import(tests => undef);
-};
+#line 23
+ok !eval { $tb->plan(tests => 0) };
+is($@, "You said to run 0 tests at $0 line 23.\n");
-My::Test::ok($$out eq '');
-My::Test::ok($$err eq '');
-My::Test::ok($@ =~ /Got an undefined number of tests/);
-
-eval {
- Test::Simple->import(tests => 0);
-};
-
-My::Test::ok($$out eq '');
-My::Test::ok($$err eq '');
-My::Test::ok($@ =~ /You said to run 0 tests!/);
-
-eval {
- Test::Simple::ok(1);
-};
-My::Test::ok( $@ =~ /You tried to run a test without a plan!/);
-
-
-END {
- My::Test::ok($$out eq '');
- My::Test::ok($$err eq "");
-
- # Prevent Test::Simple from exiting with non zero.
- exit 0;
-}
+#line 27
+ok !eval { $tb->ok(1) };
+is( $@, "You tried to run a test without a plan at $0 line 27.\n");
diff --git a/lib/Test/Simple/t/plan.t b/lib/Test/Simple/t/plan.t
index fa46744b06..0d3ce89edb 100644
--- a/lib/Test/Simple/t/plan.t
+++ b/lib/Test/Simple/t/plan.t
@@ -11,9 +11,11 @@ use Test::More;
plan tests => 4;
eval { plan tests => 4 };
-like( $@, '/^You tried to plan twice!/', 'disallow double plan' );
+is( $@, sprintf("You tried to plan twice at %s line %d.\n", $0, __LINE__ - 1),
+ 'disallow double plan' );
eval { plan 'no_plan' };
-like( $@, '/^You tried to plan twice!/', 'disallow chaning plan' );
+is( $@, sprintf("You tried to plan twice at %s line %d.\n", $0, __LINE__ -1),
+ 'disallow changing plan' );
pass('Just testing plan()');
pass('Testing it some more');
diff --git a/lib/Test/Simple/t/plan_bad.t b/lib/Test/Simple/t/plan_bad.t
index cc1295a8f9..d20797ecb7 100644
--- a/lib/Test/Simple/t/plan_bad.t
+++ b/lib/Test/Simple/t/plan_bad.t
@@ -8,57 +8,27 @@ BEGIN {
}
-# Can't use Test.pm, that's a 5.005 thing.
-package My::Test;
+use Test::More tests => 10;
+use Test::Builder;
+my $tb = Test::Builder->create;
+$tb->level(0);
-print "1..7\n";
-
-my $test_num = 1;
-# Utility testing functions.
-sub ok ($;$) {
- my($test, $name) = @_;
- my $ok = '';
- $ok .= "not " unless $test;
- $ok .= "ok $test_num";
- $ok .= " - $name" if defined $name;
- $ok .= "\n";
- print $ok;
- $test_num++;
-
- return $test;
-}
-
-
-sub is ($$;$) {
- my($this, $that, $name) = @_;
- my $test = $this eq $that;
- my $ok = '';
- $ok .= "not " unless $test;
- $ok .= "ok $test_num";
- $ok .= " - $name" if defined $name;
- $ok .= "\n";
- print $ok;
-
- unless( $test ) {
- print "# got \n$this";
- print "# expected \n$that";
- }
- $test_num++;
-
- return $test;
-}
-
-
-use Test::More import => ['plan'];
-
-ok !eval { plan tests => 'no_plan'; };
-is $@, "Number of tests must be a postive integer. You gave it 'no_plan'.\n";
+ok !eval { $tb->plan( tests => 'no_plan' ); };
+is $@, sprintf "Number of tests must be a positive integer. You gave it 'no_plan' at %s line %d.\n", $0, __LINE__ - 1;
my $foo = [];
my @foo = ($foo, 2, 3);
-ok !eval { plan tests => @foo };
-is $@, "Number of tests must be a postive integer. You gave it '$foo'.\n";
+ok !eval { $tb->plan( tests => @foo ) };
+is $@, sprintf "Number of tests must be a positive integer. You gave it '$foo' at %s line %d.\n", $0, __LINE__ - 1;
+
+#line 25
+ok !eval { $tb->plan( tests => -1 ) };
+is $@, "Number of tests must be a positive integer. You gave it '-1' at $0 line 25.\n";
+
+#line 29
+ok !eval { $tb->plan( tests => '' ) };
+is $@, "You said to run 0 tests at $0 line 29.\n";
-ok !eval { plan tests => 0 };
-ok !eval { plan tests => -1 };
-ok !eval { plan tests => '' };
+#line 33
+ok !eval { $tb->plan( 'wibble' ) };
+is $@, "plan() doesn't understand wibble at $0 line 33.\n";
diff --git a/lib/Test/Simple/t/skip.t b/lib/Test/Simple/t/skip.t
index f2ea9fbf20..b7ec32adbe 100644
--- a/lib/Test/Simple/t/skip.t
+++ b/lib/Test/Simple/t/skip.t
@@ -94,5 +94,5 @@ SKIP: {
pass "This does not run";
}
- like $warning, qr/^skip\(\) was passed a non-numeric number of tests/;
+ like $warning, '/^skip\(\) was passed a non-numeric number of tests/';
}
diff --git a/lib/Test/Simple/t/sort_bug.t b/lib/Test/Simple/t/sort_bug.t
index aad806c279..03e3df2ac9 100644
--- a/lib/Test/Simple/t/sort_bug.t
+++ b/lib/Test/Simple/t/sort_bug.t
@@ -17,10 +17,10 @@ use strict;
use Config;
BEGIN {
- unless ( $] >= 5.008 && $Config{'useithreads'} &&
+ unless ( $] >= 5.008001 && $Config{'useithreads'} &&
eval { require threads; 'threads'->import; 1; })
{
- print "1..0 # Skip: no threads\n";
+ print "1..0 # Skip: no working threads\n";
exit 0;
}
}
diff --git a/lib/Test/Simple/t/threads.t b/lib/Test/Simple/t/threads.t
index 35696e2705..42ba8c269c 100644
--- a/lib/Test/Simple/t/threads.t
+++ b/lib/Test/Simple/t/threads.t
@@ -9,10 +9,10 @@ BEGIN {
use Config;
BEGIN {
- unless ( $] >= 5.008 && $Config{'useithreads'} &&
+ unless ( $] >= 5.008001 && $Config{'useithreads'} &&
eval { require threads; 'threads'->import; 1; })
{
- print "1..0 # Skip: no threads\n";
+ print "1..0 # Skip: no working threads\n";
exit 0;
}
}