summaryrefslogtreecommitdiff
path: root/cpan/Test-Simple/t
diff options
context:
space:
mode:
authorChad Granum <exodist7@gmail.com>2015-01-31 12:19:22 -0800
committerFather Chrysostomos <sprout@cpan.org>2015-01-31 13:57:08 -0800
commit18864292b4751beee108b3b4983f9ddf2228f8ef (patch)
tree89c294cebeb7bcf29136a9be7c1fd29cb72616bb /cpan/Test-Simple/t
parentad51375676d14fd63b202ee0090e1351632109ff (diff)
downloadperl-18864292b4751beee108b3b4983f9ddf2228f8ef.tar.gz
Test-Simple Version Bump, 1.301001_098 (RC18)
Diffstat (limited to 'cpan/Test-Simple/t')
-rw-r--r--cpan/Test-Simple/t/Behavior/MonkeyPatching_diag.t21
-rw-r--r--cpan/Test-Simple/t/Behavior/MonkeyPatching_plan.t31
-rw-r--r--cpan/Test-Simple/t/Behavior/cmp_ok_undef.t19
-rw-r--r--cpan/Test-Simple/t/Behavior/event_clone_args.t22
-rw-r--r--cpan/Test-Simple/t/Behavior/skip_all_in_subtest.t11
-rw-r--r--cpan/Test-Simple/t/Legacy/ribasushi_diag.t59
-rw-r--r--cpan/Test-Simple/t/Legacy/subtest/basic.t14
-rw-r--r--cpan/Test-Simple/t/Test-Stream-Event-Diag.t4
-rw-r--r--cpan/Test-Simple/t/Test-Stream-ForceExit.t4
9 files changed, 114 insertions, 71 deletions
diff --git a/cpan/Test-Simple/t/Behavior/MonkeyPatching_diag.t b/cpan/Test-Simple/t/Behavior/MonkeyPatching_diag.t
index 2a62f68022..e89f02cc97 100644
--- a/cpan/Test-Simple/t/Behavior/MonkeyPatching_diag.t
+++ b/cpan/Test-Simple/t/Behavior/MonkeyPatching_diag.t
@@ -13,6 +13,7 @@ my $orig = Test::Builder->can('diag');
use Test::More;
use Test::Stream;
use Test::MostlyLike;
+ use Test::Stream::Tester qw/intercept/;
no warnings 'redefine';
local *Test::Builder::diag = sub {
@@ -29,8 +30,10 @@ my $orig = Test::Builder->can('diag');
my @warnings;
{
local $SIG{__WARN__} = sub { push @warnings => @_ };
- diag('first');
- diag('seconds');
+ intercept {
+ diag('first');
+ diag('seconds');
+ };
}
mostly_like(
\@warnings,
@@ -47,6 +50,7 @@ my $orig = Test::Builder->can('diag');
use Test::More;
use Test::Stream;
use Test::MostlyLike;
+ use Test::Stream::Tester qw/intercept/;
no warnings 'redefine';
local *Test::Builder::diag = sub {
@@ -63,8 +67,10 @@ my $orig = Test::Builder->can('diag');
my @warnings;
{
local $SIG{__WARN__} = sub { push @warnings => @_ };
- diag('first');
- diag('seconds');
+ intercept {
+ diag('first');
+ diag('seconds');
+ };
}
mostly_like(
\@warnings,
@@ -79,6 +85,7 @@ my $orig = Test::Builder->can('diag');
{
package MyLegacyTester;
use Test::More;
+ use Test::Stream::Tester qw/intercept/;
no warnings 'redefine';
local *Test::Builder::diag = sub {
@@ -90,8 +97,10 @@ my $orig = Test::Builder->can('diag');
my @warnings;
{
local $SIG{__WARN__} = sub { push @warnings => @_ };
- diag('first');
- diag('seconds');
+ intercept {
+ diag('first');
+ diag('seconds');
+ };
}
is(@warnings, 0, "no warnings for a legacy tester");
}
diff --git a/cpan/Test-Simple/t/Behavior/MonkeyPatching_plan.t b/cpan/Test-Simple/t/Behavior/MonkeyPatching_plan.t
index bec61caa6e..236a083cbf 100644
--- a/cpan/Test-Simple/t/Behavior/MonkeyPatching_plan.t
+++ b/cpan/Test-Simple/t/Behavior/MonkeyPatching_plan.t
@@ -4,7 +4,7 @@ use B;
use Test::Stream;
use Test::MostlyLike;
-use Test::More tests => 6;
+use Test::More tests => 8;
use Test::Builder; # Not loaded by default in modern mode
my $orig = Test::Builder->can('plan');
@@ -84,3 +84,32 @@ mostly_like(
"Got the warning once"
);
+
+
+no warnings 'redefine';
+*Test::Builder::plan = sub { };
+use warnings;
+my $ok;
+events_are(
+ intercept {
+ $ok = eval {
+ plan(tests => 1);
+ plan(tests => 2);
+ ok(1);
+ ok(1);
+ ok(1);
+ done_testing;
+ 1;
+ };
+ },
+ check {
+ event ok => { bool => 1 };
+ event ok => { bool => 1 };
+ event ok => { bool => 1 };
+ event plan => { max => 3 };
+ directive 'end';
+ },
+ "Make sure plan monkeypatching does not effect done_testing"
+);
+
+ok($ok, "Did not die");
diff --git a/cpan/Test-Simple/t/Behavior/cmp_ok_undef.t b/cpan/Test-Simple/t/Behavior/cmp_ok_undef.t
new file mode 100644
index 0000000000..1e317c55d1
--- /dev/null
+++ b/cpan/Test-Simple/t/Behavior/cmp_ok_undef.t
@@ -0,0 +1,19 @@
+use Test::More;
+use strict;
+use warnings;
+
+use Test::Stream::Tester;
+
+my @warnings;
+local $SIG{__WARN__} = sub { push @warnings => @_ };
+my @events = intercept { cmp_ok( undef, '==', 6 ) };
+
+is(@warnings, 1, "1 warning");
+
+like(
+ $warnings[0],
+ qr/Use of uninitialized value .* at \(eval in cmp_ok\)/,
+ "Got the expected warning"
+);
+
+done_testing;
diff --git a/cpan/Test-Simple/t/Behavior/event_clone_args.t b/cpan/Test-Simple/t/Behavior/event_clone_args.t
new file mode 100644
index 0000000000..7d4824d550
--- /dev/null
+++ b/cpan/Test-Simple/t/Behavior/event_clone_args.t
@@ -0,0 +1,22 @@
+use Test::More;
+use strict;
+use warnings;
+
+use B;
+use Test::Stream::Tester qw/intercept/;
+
+my @events;
+
+my $x1 = \(my $y1);
+push @events => intercept { note $x1 };
+is(B::svref_2object($x1)->REFCNT, 2, "Note does not store a ref");
+
+my $x2 = \(my $y2);
+push @events => intercept { diag $x2 };
+is(B::svref_2object($x2)->REFCNT, 2, "diag does not store a ref");
+
+my $x3 = \(my $y3);
+push @events => intercept { ok($x3, "Generating") };
+is(B::svref_2object($x3)->REFCNT, 2, "ok does not store a ref");
+
+done_testing;
diff --git a/cpan/Test-Simple/t/Behavior/skip_all_in_subtest.t b/cpan/Test-Simple/t/Behavior/skip_all_in_subtest.t
index d4b12ce7db..5f8abea6a6 100644
--- a/cpan/Test-Simple/t/Behavior/skip_all_in_subtest.t
+++ b/cpan/Test-Simple/t/Behavior/skip_all_in_subtest.t
@@ -5,12 +5,23 @@ use warnings;
use Test::More;
+my @warnings;
+local $SIG{__WARN__} = sub { push @warnings, $_[0] };
+
subtest my_subtest1 => sub {
my $file = __FILE__;
$file =~ s/\.t$/1.load/;
do $file;
};
+is(scalar(@warnings), 1, "one warning");
+like(
+ $warnings[0],
+ qr/^SKIP_ALL in subtest via 'BEGIN' or 'use'/,
+ "the warning"
+);
+
+
subtest my_subtest2 => sub {
my $file = __FILE__;
$file =~ s/\.t$/2.load/;
diff --git a/cpan/Test-Simple/t/Legacy/ribasushi_diag.t b/cpan/Test-Simple/t/Legacy/ribasushi_diag.t
deleted file mode 100644
index 570ee5159b..0000000000
--- a/cpan/Test-Simple/t/Legacy/ribasushi_diag.t
+++ /dev/null
@@ -1,59 +0,0 @@
-use strict;
-use warnings;
-
-use Test::More;
-
-BEGIN {
- my $has_module = eval { require SQL::Abstract::Test; 1 };
- my $required = $ENV{AUTHOR_TESTING};
-
- if ($required && !$has_module) {
- die "This test requires 'SQL::Abstract::Test' to be installed when AUTHOR_TESTING.\n";
- }
-
- unless($required) {
- plan skip_all => "Only run when AUTHOR_TESTING is set";
- }
-}
-
-{
- package Worker;
-
- sub do_work {
- local $Test::Builder::Level = $Test::Builder::Level + 2;
- shift->();
- }
-}
-
-use SQL::Abstract::Test;
-use Test::Stream::Tester;
-
-my $events = intercept {
- local $TODO = "Not today";
-
- Worker::do_work(
- sub {
- SQL::Abstract::Test::is_same_sql_bind(
- 'buh', [],
- 'bah', [1],
- );
- }
- );
-};
-
-ok( !(grep { $_->context->in_todo ? 0 : 1 } @{$events->[0]->diag}), "All diag is todo" );
-
-events_are(
- $events,
- check {
- event ok => {
- in_todo => 1,
- };
- event note => { in_todo => 1 };
- event note => { in_todo => 1 };
- dir 'end';
- },
- "All events are TODO"
-);
-
-done_testing;
diff --git a/cpan/Test-Simple/t/Legacy/subtest/basic.t b/cpan/Test-Simple/t/Legacy/subtest/basic.t
index 5a0166d5db..92af4dc8f1 100644
--- a/cpan/Test-Simple/t/Legacy/subtest/basic.t
+++ b/cpan/Test-Simple/t/Legacy/subtest/basic.t
@@ -15,7 +15,7 @@ use warnings;
use Test::Builder::NoOutput;
-use Test::More tests => 16;
+use Test::More tests => 18;
# Formatting may change if we're running under Test::Harness.
$ENV{HARNESS_ACTIVE} = 0;
@@ -166,8 +166,18 @@ END
my $tb = Test::Builder::NoOutput->create;
{
+ my @warnings;
+ local $SIG{__WARN__} = sub { push @warnings, $_[0] };
+
my $child = $tb->child('skippy says he loves you');
- eval { $child->plan( skip_all => 'cuz I said so' ) };
+ eval { $child->plan(skip_all => 'cuz I said so') };
+
+ is(scalar(@warnings), 1, "one warning");
+ like(
+ $warnings[0],
+ qr/^SKIP_ALL in subtest could not find flow-control label,/,
+ "the warning"
+ );
}
subtest 'skip all', sub {
plan skip_all => 'subtest with skip_all';
diff --git a/cpan/Test-Simple/t/Test-Stream-Event-Diag.t b/cpan/Test-Simple/t/Test-Stream-Event-Diag.t
index 95ba48ea6e..d5297d2d15 100644
--- a/cpan/Test-Simple/t/Test-Stream-Event-Diag.t
+++ b/cpan/Test-Simple/t/Test-Stream-Event-Diag.t
@@ -3,6 +3,7 @@ use warnings;
use Test::Stream;
use Test::More;
+use Test::Stream::Tester qw/intercept/;
use ok 'Test::Stream::Event::Diag';
@@ -10,7 +11,8 @@ my $ctx = context(-1); my $line = __LINE__;
$ctx = $ctx->snapshot;
is($ctx->line, $line, "usable context");
-my $diag = $ctx->diag('hello');
+my $diag;
+intercept { $diag = context()->diag('hello') };
ok($diag, "build diag");
isa_ok($diag, 'Test::Stream::Event::Diag');
is($diag->message, 'hello', "message");
diff --git a/cpan/Test-Simple/t/Test-Stream-ForceExit.t b/cpan/Test-Simple/t/Test-Stream-ForceExit.t
index 6bae48c788..8596494fed 100644
--- a/cpan/Test-Simple/t/Test-Stream-ForceExit.t
+++ b/cpan/Test-Simple/t/Test-Stream-ForceExit.t
@@ -19,7 +19,7 @@ unless ($pid) {
{
my $force_exit = Test::Stream::ForceExit->new;
- diag "In Child";
+ note "In Child";
}
print $write "Did not exit!";
@@ -48,7 +48,7 @@ unless ($pid) {
{
my $force_exit = Test::Stream::ForceExit->new;
- diag "In Child $$";
+ note "In Child $$";
$force_exit->done(1);
}