summaryrefslogtreecommitdiff
path: root/cpan/Test-Simple/t/Legacy/subtest
diff options
context:
space:
mode:
authorChad Granum <chad.granum@dreamhost.com>2014-10-23 12:03:23 -0700
committerJames E Keenan <jkeenan@cpan.org>2014-10-26 11:59:40 -0400
commit07308ed1589cc2f7837b5d3a1303d200a49b9338 (patch)
treed3fd48fe8ab2e8f8432c5b7a429a41d715301bff /cpan/Test-Simple/t/Legacy/subtest
parentb17645516d4569fdfc26a2ed61c6e8704ced92cf (diff)
downloadperl-07308ed1589cc2f7837b5d3a1303d200a49b9338.tar.gz
Import Test-More 1.301001 alpha 63
Diffstat (limited to 'cpan/Test-Simple/t/Legacy/subtest')
-rw-r--r--cpan/Test-Simple/t/Legacy/subtest/args.t34
-rw-r--r--cpan/Test-Simple/t/Legacy/subtest/bail_out.t64
-rw-r--r--cpan/Test-Simple/t/Legacy/subtest/basic.t215
-rw-r--r--cpan/Test-Simple/t/Legacy/subtest/die.t30
-rw-r--r--cpan/Test-Simple/t/Legacy/subtest/do.t17
-rw-r--r--cpan/Test-Simple/t/Legacy/subtest/exceptions.t67
-rw-r--r--cpan/Test-Simple/t/Legacy/subtest/for_do_t.test9
-rw-r--r--cpan/Test-Simple/t/Legacy/subtest/fork.t51
-rw-r--r--cpan/Test-Simple/t/Legacy/subtest/implicit_done.t31
-rw-r--r--cpan/Test-Simple/t/Legacy/subtest/line_numbers.t131
-rw-r--r--cpan/Test-Simple/t/Legacy/subtest/plan.t49
-rw-r--r--cpan/Test-Simple/t/Legacy/subtest/predicate.t166
-rw-r--r--cpan/Test-Simple/t/Legacy/subtest/singleton.t38
-rw-r--r--cpan/Test-Simple/t/Legacy/subtest/threads.t25
-rw-r--r--cpan/Test-Simple/t/Legacy/subtest/todo.t204
-rw-r--r--cpan/Test-Simple/t/Legacy/subtest/wstat.t24
16 files changed, 1155 insertions, 0 deletions
diff --git a/cpan/Test-Simple/t/Legacy/subtest/args.t b/cpan/Test-Simple/t/Legacy/subtest/args.t
new file mode 100644
index 0000000000..d43ac5288e
--- /dev/null
+++ b/cpan/Test-Simple/t/Legacy/subtest/args.t
@@ -0,0 +1,34 @@
+#!/usr/bin/perl -w
+
+use strict;
+use Test::Builder;
+
+BEGIN {
+ if( $ENV{PERL_CORE} ) {
+ chdir 't';
+ @INC = ( '../lib', 'lib' );
+ }
+ else {
+ unshift @INC, 't/lib';
+ }
+}
+use Test::Builder::NoOutput;
+
+my $tb = Test::Builder->new;
+
+$tb->ok( !eval { $tb->subtest() } );
+$tb->like( $@, qr/^\Qsubtest()'s second argument must be a code ref/ );
+
+$tb->ok( !eval { $tb->subtest("foo") } );
+$tb->like( $@, qr/^\Qsubtest()'s second argument must be a code ref/ );
+
+use Carp qw/confess/;
+$tb->subtest('Arg passing', sub {
+ my $foo = shift;
+ my $child = Test::Builder->new;
+ $child->is_eq($foo, 'foo');
+ $child->done_testing;
+ $child->finalize;
+}, 'foo');
+
+$tb->done_testing();
diff --git a/cpan/Test-Simple/t/Legacy/subtest/bail_out.t b/cpan/Test-Simple/t/Legacy/subtest/bail_out.t
new file mode 100644
index 0000000000..d6b074c2cf
--- /dev/null
+++ b/cpan/Test-Simple/t/Legacy/subtest/bail_out.t
@@ -0,0 +1,64 @@
+#!/usr/bin/perl -w
+
+BEGIN {
+ if( $ENV{PERL_CORE} ) {
+ chdir 't';
+ @INC = ('../lib', 'lib');
+ }
+ else {
+ unshift @INC, 't/lib';
+ }
+}
+
+my $Exit_Code;
+BEGIN {
+ *CORE::GLOBAL::exit = sub { $Exit_Code = shift; die };
+}
+
+use Test::Builder;
+use Test::More;
+
+my $output;
+my $TB = Test::More->builder;
+$TB->output(\$output);
+
+my $Test = Test::Builder->create;
+$Test->level(0);
+
+$Test->plan(tests => 2);
+
+plan tests => 4;
+
+ok 'foo';
+my $ok = eval {
+ subtest 'bar' => sub {
+ plan tests => 3;
+ ok 'sub_foo';
+ subtest 'sub_bar' => sub {
+ plan tests => 3;
+ ok 'sub_sub_foo';
+ ok 'sub_sub_bar';
+ BAIL_OUT("ROCKS FALL! EVERYONE DIES!");
+ ok 'sub_sub_baz';
+ };
+ ok 'sub_baz';
+ };
+ 1;
+};
+
+$Test->is_eq( $output, <<'OUT' );
+1..4
+ok 1
+# Subtest: bar
+ 1..3
+ ok 1
+ # Subtest: sub_bar
+ 1..3
+ ok 1
+ ok 2
+ Bail out! ROCKS FALL! EVERYONE DIES!
+ Bail out! ROCKS FALL! EVERYONE DIES!
+Bail out! ROCKS FALL! EVERYONE DIES!
+OUT
+
+$Test->is_eq( $Exit_Code, 255 );
diff --git a/cpan/Test-Simple/t/Legacy/subtest/basic.t b/cpan/Test-Simple/t/Legacy/subtest/basic.t
new file mode 100644
index 0000000000..964b60d6bf
--- /dev/null
+++ b/cpan/Test-Simple/t/Legacy/subtest/basic.t
@@ -0,0 +1,215 @@
+#!/usr/bin/perl -w
+
+BEGIN {
+ if( $ENV{PERL_CORE} ) {
+ chdir 't';
+ @INC = ( '../lib', 'lib' );
+ }
+ else {
+ unshift @INC, 't/lib';
+ }
+}
+
+use strict;
+use warnings;
+
+use Test::Builder::NoOutput;
+
+use Test::More tests => 18;
+
+# Formatting may change if we're running under Test::Harness.
+$ENV{HARNESS_ACTIVE} = 0;
+
+{
+ my $tb = Test::Builder::NoOutput->create;
+
+ $tb->plan( tests => 7 );
+ for( 1 .. 3 ) {
+ $tb->ok( $_, "We're on $_" );
+ $tb->diag("We ran $_");
+ }
+ {
+ my $indented = $tb->child;
+ $indented->plan('no_plan');
+ $indented->ok( 1, "We're on 1" );
+ $indented->ok( 1, "We're on 2" );
+ $indented->ok( 1, "We're on 3" );
+ $indented->finalize;
+ }
+ for( 7, 8, 9 ) {
+ $tb->ok( $_, "We're on $_" );
+ }
+
+ is $tb->read, <<"END", 'Output should nest properly';
+1..7
+ok 1 - We're on 1
+# We ran 1
+ok 2 - We're on 2
+# We ran 2
+ok 3 - We're on 3
+# We ran 3
+ ok 1 - We're on 1
+ ok 2 - We're on 2
+ ok 3 - We're on 3
+ 1..3
+ok 4 - Child of $0
+ok 5 - We're on 7
+ok 6 - We're on 8
+ok 7 - We're on 9
+END
+}
+{
+ my $tb = Test::Builder::NoOutput->create;
+
+ $tb->plan('no_plan');
+ for( 1 .. 1 ) {
+ $tb->ok( $_, "We're on $_" );
+ $tb->diag("We ran $_");
+ }
+ {
+ my $indented = $tb->child;
+ $indented->plan('no_plan');
+ $indented->ok( 1, "We're on 1" );
+ {
+ my $indented2 = $indented->child('with name');
+ $indented2->plan( tests => 2 );
+ $indented2->ok( 1, "We're on 2.1" );
+ $indented2->ok( 1, "We're on 2.1" );
+ $indented2->finalize;
+ }
+ $indented->ok( 1, 'after child' );
+ $indented->finalize;
+ }
+ for(7) {
+ $tb->ok( $_, "We're on $_" );
+ }
+
+ $tb->_ending;
+ is $tb->read, <<"END", 'We should allow arbitrary nesting';
+ok 1 - We're on 1
+# We ran 1
+ ok 1 - We're on 1
+ 1..2
+ ok 1 - We're on 2.1
+ ok 2 - We're on 2.1
+ ok 2 - with name
+ ok 3 - after child
+ 1..3
+ok 2 - Child of $0
+ok 3 - We're on 7
+1..3
+END
+}
+
+{
+#line 108
+ my $tb = Test::Builder::NoOutput->create;
+
+ {
+ my $child = $tb->child('expected to fail');
+ $child->plan( tests => 3 );
+ $child->ok(1);
+ $child->ok(0);
+ $child->ok(3);
+ $child->finalize;
+ }
+
+ {
+ my $child = $tb->child('expected to pass');
+ $child->plan( tests => 3 );
+ $child->ok(1);
+ $child->ok(2);
+ $child->ok(3);
+ $child->finalize;
+ }
+ is $tb->read, <<"END", 'Previous child failures should not force subsequent failures';
+ 1..3
+ ok 1
+ not ok 2
+ # Failed test at $0 line 114.
+ ok 3
+ # Looks like you failed 1 test of 3.
+not ok 1 - expected to fail
+# Failed test 'expected to fail'
+# at $0 line 116.
+ 1..3
+ ok 1
+ ok 2
+ ok 3
+ok 2 - expected to pass
+END
+}
+{
+ my $tb = Test::Builder::NoOutput->create;
+ my $child = $tb->child('one');
+ is $child->{$_}, $tb->{$_}, "The child should copy the ($_) filehandle"
+ foreach qw{Out_FH Todo_FH Fail_FH};
+ $child->finalize;
+}
+{
+ my $tb = Test::Builder::NoOutput->create;
+ my $child = $tb->child('one');
+ can_ok $child, 'parent';
+ is $child->parent, $tb, '... and it should return the parent of the child';
+ ok !defined $tb->parent, '... but top level builders should not have parents';
+
+ can_ok $tb, 'name';
+ is $tb->name, $0, 'The top level name should be $0';
+ is $child->name, 'one', '... but child names should be whatever we set them to';
+ $child->finalize;
+ $child = $tb->child;
+ is $child->name, 'Child of '.$tb->name, '... or at least have a sensible default';
+ $child->finalize;
+}
+# Skip all subtests
+{
+ my $tb = Test::Builder::NoOutput->create;
+
+ {
+ my $child = $tb->child('skippy says he loves you');
+ eval { $child->plan( skip_all => 'cuz I said so' ) };
+ ok my $error = $@, 'A child which does a "skip_all" should throw an exception';
+ isa_ok $error, 'Test::Stream::Event', '... and the exception it throws';
+ }
+ subtest 'skip all', sub {
+ plan skip_all => 'subtest with skip_all';
+ ok 0, 'This should never be run';
+ };
+}
+
+# to do tests
+{
+#line 204
+ my $tb = Test::Builder::NoOutput->create;
+ $tb->plan( tests => 1 );
+ my $child = $tb->child;
+ $child->plan( tests => 1 );
+ $child->todo_start( 'message' );
+ $child->ok( 0 );
+ $child->todo_end;
+ $child->finalize;
+ $tb->_ending;
+ is $tb->read, <<"END", 'TODO tests should not make the parent test fail';
+1..1
+ 1..1
+ not ok 1 # TODO message
+ # Failed (TODO) test at $0 line 209.
+ok 1 - Child of $0
+END
+}
+{
+ my $tb = Test::Builder::NoOutput->create;
+ $tb->plan( tests => 1 );
+ my $child = $tb->child;
+ $child->finalize;
+ $tb->_ending;
+ my $expected = <<"END";
+1..1
+not ok 1 - Child of $0
+# Failed test 'Child of $0'
+# at $0 line 225.
+# No tests run for subtest.
+END
+ like $tb->read, qr/\Q$expected/,
+ 'Not running subtests should make the parent test fail';
+}
diff --git a/cpan/Test-Simple/t/Legacy/subtest/die.t b/cpan/Test-Simple/t/Legacy/subtest/die.t
new file mode 100644
index 0000000000..7965e9088b
--- /dev/null
+++ b/cpan/Test-Simple/t/Legacy/subtest/die.t
@@ -0,0 +1,30 @@
+#!/usr/bin/perl -w
+
+# What happens when a subtest dies?
+
+use lib 't/lib';
+
+use strict;
+use Test::Builder;
+use Test::Builder::NoOutput;
+
+my $Test = Test::Builder->new;
+
+{
+ my $tb = Test::Builder::NoOutput->create;
+
+ $tb->ok(1);
+
+ $Test->ok( !eval {
+ $tb->subtest("death" => sub {
+ die "Death in the subtest";
+ });
+ 1;
+ });
+ $Test->like( $@, qr/^Death in the subtest at $0 line /);
+
+ $Test->ok( !$tb->parent, "the parent object is restored after a die" );
+}
+
+
+$Test->done_testing();
diff --git a/cpan/Test-Simple/t/Legacy/subtest/do.t b/cpan/Test-Simple/t/Legacy/subtest/do.t
new file mode 100644
index 0000000000..b034893f63
--- /dev/null
+++ b/cpan/Test-Simple/t/Legacy/subtest/do.t
@@ -0,0 +1,17 @@
+#!/usr/bin/perl -w
+
+# Test the idiom of running another test file as a subtest.
+
+use strict;
+use Test::More;
+
+pass("First");
+
+my $file = "t/Legacy/subtest/for_do_t.test";
+ok -e $file, "subtest test file exists";
+
+subtest $file => sub { do $file };
+
+pass("Last");
+
+done_testing(4);
diff --git a/cpan/Test-Simple/t/Legacy/subtest/exceptions.t b/cpan/Test-Simple/t/Legacy/subtest/exceptions.t
new file mode 100644
index 0000000000..c4e57a982f
--- /dev/null
+++ b/cpan/Test-Simple/t/Legacy/subtest/exceptions.t
@@ -0,0 +1,67 @@
+#!/usr/bin/perl -w
+
+BEGIN {
+ if( $ENV{PERL_CORE} ) {
+ chdir 't';
+ @INC = ( '../lib', 'lib' );
+ }
+ else {
+ unshift @INC, 't/lib';
+ }
+}
+
+use strict;
+use warnings;
+use Test::Builder::NoOutput;
+use Test::More tests => 7;
+
+{
+ my $tb = Test::Builder::NoOutput->create;
+ my $child = $tb->child('one');
+ eval { $tb->child('two') };
+ my $error = $@;
+ like $error, qr/\QYou already have a child named (one) running/,
+ 'Trying to create a child with another one active should fail';
+ $child->finalize;
+}
+{
+ my $tb = Test::Builder::NoOutput->create;
+ my $child = $tb->child('one');
+ ok my $child2 = $child->child('two'), 'Trying to create nested children should succeed';
+ eval { $child->finalize };
+ my $error = $@;
+ like $error, qr/\QCan't call finalize() with child (two) active/,
+ '... but trying to finalize() a child with open children should fail';
+ $child2->finalize;
+ $child->finalize;
+}
+{
+ my $tb = Test::Builder::NoOutput->create;
+ my $child = $tb->child('one');
+ eval { $child->DESTROY };
+ like $@, qr/\QChild (one) exited without calling finalize()/,
+ 'Failing to call finalize should issue an appropriate diagnostic';
+ ok !$tb->is_passing, '... and should cause the test suite to fail';
+ $child->finalize;
+}
+{
+ my $tb = Test::Builder::NoOutput->create;
+
+ $tb->plan( tests => 7 );
+ for( 1 .. 3 ) {
+ $tb->ok( $_, "We're on $_" );
+ $tb->diag("We ran $_");
+ }
+ {
+ my $indented = $tb->child;
+ $indented->plan('no_plan');
+ $indented->ok( 1, "We're on 1" );
+ eval { $tb->ok( 1, 'This should throw an exception' ) };
+ $indented->finalize;
+ }
+
+ my $error = $@;
+ like $error, qr/\QCannot run test (This should throw an exception) with active children/,
+ 'Running a test with active children should fail';
+ ok !$tb->is_passing, '... and should cause the test suite to fail';
+}
diff --git a/cpan/Test-Simple/t/Legacy/subtest/for_do_t.test b/cpan/Test-Simple/t/Legacy/subtest/for_do_t.test
new file mode 100644
index 0000000000..413923bceb
--- /dev/null
+++ b/cpan/Test-Simple/t/Legacy/subtest/for_do_t.test
@@ -0,0 +1,9 @@
+# Test used by t/subtest/do.t
+
+use Test::More;
+
+pass("First");
+pass("Second");
+pass("Third");
+
+done_testing(3);
diff --git a/cpan/Test-Simple/t/Legacy/subtest/fork.t b/cpan/Test-Simple/t/Legacy/subtest/fork.t
new file mode 100644
index 0000000000..0191e7894b
--- /dev/null
+++ b/cpan/Test-Simple/t/Legacy/subtest/fork.t
@@ -0,0 +1,51 @@
+#!/usr/bin/perl -w
+use strict;
+use warnings;
+use Config;
+use IO::Pipe;
+use Test::Builder;
+use Test::More;
+
+my $Can_Fork = $Config{d_fork} ||
+ (($^O eq 'MSWin32' || $^O eq 'NetWare') and
+ $Config{useithreads} and
+ $Config{ccflags} =~ /-DPERL_IMPLICIT_SYS/
+ );
+
+if( !$Can_Fork ) {
+ plan 'skip_all' => "This system cannot fork";
+}
+else {
+ plan 'tests' => 1;
+}
+
+subtest 'fork within subtest' => sub {
+ plan tests => 2;
+
+ my $pipe = IO::Pipe->new;
+ my $pid = fork;
+ defined $pid or plan skip_all => "Fork not working";
+
+ if ($pid) {
+ $pipe->reader;
+ my $child_output = do { local $/ ; <$pipe> };
+ waitpid $pid, 0;
+
+ is $?, 0, 'child exit status';
+ like $child_output, qr/^[\s#]+Child Done\s*\z/, 'child output';
+ }
+ else {
+ $pipe->writer;
+
+ # Force all T::B output into the pipe, for the parent
+ # builder as well as the current subtest builder.
+ my $builder = Test::Builder->new;
+ $builder->output($pipe);
+ $builder->failure_output($pipe);
+ $builder->todo_output($pipe);
+
+ diag 'Child Done';
+ exit 0;
+ }
+};
+
diff --git a/cpan/Test-Simple/t/Legacy/subtest/implicit_done.t b/cpan/Test-Simple/t/Legacy/subtest/implicit_done.t
new file mode 100644
index 0000000000..0963e72c59
--- /dev/null
+++ b/cpan/Test-Simple/t/Legacy/subtest/implicit_done.t
@@ -0,0 +1,31 @@
+#!/usr/bin/perl -w
+
+# A subtest without a plan implicitly calls "done_testing"
+
+use strict;
+use Test::More;
+
+pass "Before";
+
+subtest 'basic' => sub {
+ pass "Inside sub test";
+};
+
+subtest 'with done' => sub {
+ pass 'This has done_testing';
+ done_testing;
+};
+
+subtest 'with plan' => sub {
+ plan tests => 1;
+ pass 'I have a plan, Batman!';
+};
+
+subtest 'skipping' => sub {
+ plan skip_all => 'Skipping';
+ fail 'Shouldnt see me!';
+};
+
+pass "After";
+
+done_testing;
diff --git a/cpan/Test-Simple/t/Legacy/subtest/line_numbers.t b/cpan/Test-Simple/t/Legacy/subtest/line_numbers.t
new file mode 100644
index 0000000000..cc9c10db4f
--- /dev/null
+++ b/cpan/Test-Simple/t/Legacy/subtest/line_numbers.t
@@ -0,0 +1,131 @@
+#!/usr/bin/perl -w
+
+# Test Test::More::subtest(), focusing on correct line numbers in
+# failed test diagnostics.
+
+BEGIN {
+ if( $ENV{PERL_CORE} ) {
+ chdir 't';
+ @INC = ( '../lib', 'lib' );
+ }
+ else {
+ unshift @INC, 't/lib';
+ }
+}
+
+use strict;
+use warnings;
+
+use Test::More tests => 5;
+use Test::Builder;
+use Test::Builder::Tester;
+
+# Formatting may change if we're running under Test::Harness.
+$ENV{HARNESS_ACTIVE} = 0;
+
+our %line;
+
+{
+ test_out("# Subtest: namehere");
+ test_out(" 1..3");
+ test_out(" ok 1");
+ test_out(" not ok 2");
+ test_err(" # Failed test at $0 line $line{innerfail1}.");
+ test_out(" ok 3");
+ test_err(" # Looks like you failed 1 test of 3.");
+ test_out("not ok 1 - namehere");
+ test_err("# Failed test 'namehere'");
+ test_err("# at $0 line $line{outerfail1}.");
+
+ subtest namehere => sub {
+ plan tests => 3;
+ ok 1;
+ ok 0; BEGIN{ $line{innerfail1} = __LINE__ }
+ ok 1;
+ }; BEGIN{ $line{outerfail1} = __LINE__ }
+
+ test_test("un-named inner tests");
+}
+{
+ test_out("# Subtest: namehere");
+ test_out(" 1..3");
+ test_out(" ok 1 - first is good");
+ test_out(" not ok 2 - second is bad");
+ test_err(" # Failed test 'second is bad'");
+ test_err(" # at $0 line $line{innerfail2}.");
+ test_out(" ok 3 - third is good");
+ test_err(" # Looks like you failed 1 test of 3.");
+ test_out("not ok 1 - namehere");
+ test_err("# Failed test 'namehere'");
+ test_err("# at $0 line $line{outerfail2}.");
+
+ subtest namehere => sub {
+ plan tests => 3;
+ ok 1, "first is good";
+ ok 0, "second is bad"; BEGIN{ $line{innerfail2} = __LINE__ }
+ ok 1, "third is good";
+ }; BEGIN{ $line{outerfail2} = __LINE__ }
+
+ test_test("named inner tests");
+}
+
+sub run_the_subtest {
+ subtest namehere => sub {
+ plan tests => 3;
+ ok 1, "first is good";
+ ok 0, "second is bad"; BEGIN{ $line{innerfail3} = __LINE__ }
+ ok 1, "third is good";
+ }; BEGIN{ $line{outerfail3} = __LINE__ }
+}
+{
+ test_out("# Subtest: namehere");
+ test_out(" 1..3");
+ test_out(" ok 1 - first is good");
+ test_out(" not ok 2 - second is bad");
+ test_err(" # Failed test 'second is bad'");
+ test_err(" # at $0 line $line{innerfail3}.");
+ test_out(" ok 3 - third is good");
+ test_err(" # Looks like you failed 1 test of 3.");
+ test_out("not ok 1 - namehere");
+ test_err("# Failed test 'namehere'");
+ test_err("# at $0 line $line{outerfail3}.");
+
+ run_the_subtest();
+
+ test_test("subtest() called from a sub");
+}
+{
+ test_out( "# Subtest: namehere");
+ test_out( " 1..0");
+ test_err( " # No tests run!");
+ test_out( 'not ok 1 - namehere');
+ test_err(q{# Failed test 'namehere'});
+ test_err( "# at $0 line $line{outerfail4}.");
+ test_err( "# No tests run for subtest.");
+
+ subtest namehere => sub {
+ done_testing;
+ }; BEGIN{ $line{outerfail4} = __LINE__ }
+
+ test_test("lineno in 'No tests run' diagnostic");
+}
+{
+ test_out("# Subtest: namehere");
+ test_out(" 1..1");
+ test_out(" not ok 1 - foo is bar");
+ test_err(" # Failed test 'foo is bar'");
+ test_err(" # at $0 line $line{is_fail}.");
+ test_err(" # got: 'foo'");
+ test_err(" # expected: 'bar'");
+ test_err(" # Looks like you failed 1 test of 1.");
+ test_out('not ok 1 - namehere');
+ test_err("# Failed test 'namehere'");
+ test_err("# at $0 line $line{is_outer_fail}.");
+
+ subtest namehere => sub {
+ plan tests => 1;
+ is 'foo', 'bar', 'foo is bar'; BEGIN{ $line{is_fail} = __LINE__ }
+ }; BEGIN{ $line{is_outer_fail} = __LINE__ }
+
+ test_test("diag indent for is() in subtest");
+}
diff --git a/cpan/Test-Simple/t/Legacy/subtest/plan.t b/cpan/Test-Simple/t/Legacy/subtest/plan.t
new file mode 100644
index 0000000000..7e944ab283
--- /dev/null
+++ b/cpan/Test-Simple/t/Legacy/subtest/plan.t
@@ -0,0 +1,49 @@
+#!/usr/bin/perl -w
+
+BEGIN {
+ if( $ENV{PERL_CORE} ) {
+ chdir 't';
+ @INC = ( '../lib', 'lib' );
+ }
+ else {
+ unshift @INC, 't/lib';
+ }
+}
+
+use strict;
+use warnings;
+
+use Test::Builder::NoOutput;
+
+use Test::More tests => 6;
+
+# Formatting may change if we're running under Test::Harness.
+$ENV{HARNESS_ACTIVE} = 0;
+
+{
+ ok defined &subtest, 'subtest() should be exported to our namespace';
+ is prototype('subtest'), undef, '... has no prototype';
+
+ subtest 'subtest with plan', sub {
+ plan tests => 2;
+ ok 1, 'planned subtests should work';
+ ok 1, '... and support more than one test';
+ };
+ subtest 'subtest without plan', sub {
+ plan 'no_plan';
+ ok 1, 'no_plan subtests should work';
+ ok 1, '... and support more than one test';
+ ok 1, '... no matter how many tests are run';
+ };
+ subtest 'subtest with implicit done_testing()', sub {
+ ok 1, 'subtests with an implicit done testing should work';
+ ok 1, '... and support more than one test';
+ ok 1, '... no matter how many tests are run';
+ };
+ subtest 'subtest with explicit done_testing()', sub {
+ ok 1, 'subtests with an explicit done testing should work';
+ ok 1, '... and support more than one test';
+ ok 1, '... no matter how many tests are run';
+ done_testing();
+ };
+}
diff --git a/cpan/Test-Simple/t/Legacy/subtest/predicate.t b/cpan/Test-Simple/t/Legacy/subtest/predicate.t
new file mode 100644
index 0000000000..73b9c81056
--- /dev/null
+++ b/cpan/Test-Simple/t/Legacy/subtest/predicate.t
@@ -0,0 +1,166 @@
+#!/usr/bin/perl -w
+
+# Test the use of subtest() to define new test predicates that combine
+# multiple existing predicates.
+
+BEGIN {
+ if( $ENV{PERL_CORE} ) {
+ chdir 't';
+ @INC = ( '../lib', 'lib' );
+ }
+ else {
+ unshift @INC, 't/lib';
+ }
+}
+
+use strict;
+use warnings;
+
+use Test::More tests => 5;
+use Test::Builder;
+use Test::Builder::Tester;
+
+# Formatting may change if we're running under Test::Harness.
+$ENV{HARNESS_ACTIVE} = 0;
+
+our %line;
+
+# Define a new test predicate with Test::More::subtest(), using
+# Test::More predicates as building blocks...
+
+sub foobar_ok ($;$) {
+ my ($value, $name) = @_;
+ $name ||= "foobar_ok";
+
+ local $Test::Builder::Level = $Test::Builder::Level + 1;
+ subtest $name => sub {
+ plan tests => 2;
+ ok $value =~ /foo/, "foo";
+ ok $value =~ /bar/, "bar"; BEGIN{ $line{foobar_ok_bar} = __LINE__ }
+ };
+}
+{
+ test_out("# Subtest: namehere");
+ test_out(" 1..2");
+ test_out(" ok 1 - foo");
+ test_out(" not ok 2 - bar");
+ test_err(" # Failed test 'bar'");
+ test_err(" # at $0 line $line{foobar_ok_bar}.");
+ test_err(" # Looks like you failed 1 test of 2.");
+ test_out("not ok 1 - namehere");
+ test_err("# Failed test 'namehere'");
+ test_err("# at $0 line ".(__LINE__+2).".");
+
+ foobar_ok "foot", "namehere";
+
+ test_test("foobar_ok failing line numbers");
+}
+
+# Wrap foobar_ok() to make another new predicate...
+
+sub foobar_ok_2 ($;$) {
+ my ($value, $name) = @_;
+
+ local $Test::Builder::Level = $Test::Builder::Level + 1;
+ foobar_ok($value, $name);
+}
+{
+ test_out("# Subtest: namehere");
+ test_out(" 1..2");
+ test_out(" ok 1 - foo");
+ test_out(" not ok 2 - bar");
+ test_err(" # Failed test 'bar'");
+ test_err(" # at $0 line $line{foobar_ok_bar}.");
+ test_err(" # Looks like you failed 1 test of 2.");
+ test_out("not ok 1 - namehere");
+ test_err("# Failed test 'namehere'");
+ test_err("# at $0 line ".(__LINE__+2).".");
+
+ foobar_ok_2 "foot", "namehere";
+
+ test_test("foobar_ok_2 failing line numbers");
+}
+
+# Define another new test predicate, this time using
+# Test::Builder::subtest() rather than Test::More::subtest()...
+
+sub barfoo_ok ($;$) {
+ my ($value, $name) = @_;
+ $name ||= "barfoo_ok";
+
+ Test::Builder->new->subtest($name => sub {
+ plan tests => 2;
+ ok $value =~ /foo/, "foo";
+ ok $value =~ /bar/, "bar"; BEGIN{ $line{barfoo_ok_bar} = __LINE__ }
+ });
+}
+{
+ test_out("# Subtest: namehere");
+ test_out(" 1..2");
+ test_out(" ok 1 - foo");
+ test_out(" not ok 2 - bar");
+ test_err(" # Failed test 'bar'");
+ test_err(" # at $0 line $line{barfoo_ok_bar}.");
+ test_err(" # Looks like you failed 1 test of 2.");
+ test_out("not ok 1 - namehere");
+ test_err("# Failed test 'namehere'");
+ test_err("# at $0 line ".(__LINE__+2).".");
+
+ barfoo_ok "foot", "namehere";
+
+ test_test("barfoo_ok failing line numbers");
+}
+
+# Wrap barfoo_ok() to make another new predicate...
+
+sub barfoo_ok_2 ($;$) {
+ my ($value, $name) = @_;
+
+ local $Test::Builder::Level = $Test::Builder::Level + 1;
+ barfoo_ok($value, $name);
+}
+{
+ test_out("# Subtest: namehere");
+ test_out(" 1..2");
+ test_out(" ok 1 - foo");
+ test_out(" not ok 2 - bar");
+ test_err(" # Failed test 'bar'");
+ test_err(" # at $0 line $line{barfoo_ok_bar}.");
+ test_err(" # Looks like you failed 1 test of 2.");
+ test_out("not ok 1 - namehere");
+ test_err("# Failed test 'namehere'");
+ test_err("# at $0 line ".(__LINE__+2).".");
+
+ barfoo_ok_2 "foot", "namehere";
+
+ test_test("barfoo_ok_2 failing line numbers");
+}
+
+# A subtest-based predicate called from within a subtest
+{
+ test_out("# Subtest: outergroup");
+ test_out(" 1..2");
+ test_out(" ok 1 - this passes");
+ test_out(" # Subtest: namehere");
+ test_out(" 1..2");
+ test_out(" ok 1 - foo");
+ test_out(" not ok 2 - bar");
+ test_err(" # Failed test 'bar'");
+ test_err(" # at $0 line $line{barfoo_ok_bar}.");
+ test_err(" # Looks like you failed 1 test of 2.");
+ test_out(" not ok 2 - namehere");
+ test_err(" # Failed test 'namehere'");
+ test_err(" # at $0 line $line{ipredcall}.");
+ test_err(" # Looks like you failed 1 test of 2.");
+ test_out("not ok 1 - outergroup");
+ test_err("# Failed test 'outergroup'");
+ test_err("# at $0 line $line{outercall}.");
+
+ subtest outergroup => sub {
+ plan tests => 2;
+ ok 1, "this passes";
+ barfoo_ok_2 "foot", "namehere"; BEGIN{ $line{ipredcall} = __LINE__ }
+ }; BEGIN{ $line{outercall} = __LINE__ }
+
+ test_test("outergroup with internal barfoo_ok_2 failing line numbers");
+}
diff --git a/cpan/Test-Simple/t/Legacy/subtest/singleton.t b/cpan/Test-Simple/t/Legacy/subtest/singleton.t
new file mode 100644
index 0000000000..0c25261f5b
--- /dev/null
+++ b/cpan/Test-Simple/t/Legacy/subtest/singleton.t
@@ -0,0 +1,38 @@
+#!/usr/bin/perl -w
+
+BEGIN {
+ if( $ENV{PERL_CORE} ) {
+ chdir 't';
+ @INC = ( '../lib', 'lib' );
+ }
+ else {
+ unshift @INC, 't/lib';
+ }
+}
+
+use strict;
+use warnings;
+use Test::More tests => 3;
+
+{
+
+ package Test::Singleton;
+
+ use Test::Builder;
+ my $TB = Test::Builder->new;
+
+ sub singleton_ok ($;$) {
+ my( $val, $name ) = @_;
+ $TB->ok( $val, $name );
+ }
+}
+
+ok 1, 'TB top level';
+subtest 'doing a subtest' => sub {
+ plan tests => 4;
+ ok 1, 'first test in subtest';
+ Test::Singleton::singleton_ok(1, 'this should not fail');
+ ok 1, 'second test in subtest';
+ Test::Singleton::singleton_ok(1, 'this should not fail');
+};
+ok 1, 'left subtest';
diff --git a/cpan/Test-Simple/t/Legacy/subtest/threads.t b/cpan/Test-Simple/t/Legacy/subtest/threads.t
new file mode 100644
index 0000000000..5d053ca2db
--- /dev/null
+++ b/cpan/Test-Simple/t/Legacy/subtest/threads.t
@@ -0,0 +1,25 @@
+#!/usr/bin/perl -w
+
+use strict;
+use warnings;
+
+use Config;
+BEGIN {
+ unless ( $] >= 5.008001 && $Config{'useithreads'} &&
+ eval { require threads; 'threads'->import; 1; })
+ {
+ print "1..0 # Skip: no working threads\n";
+ exit 0;
+ }
+}
+
+use Test::More;
+
+subtest 'simple test with threads on' => sub {
+ is( 1+1, 2, "simple test" );
+ is( "a", "a", "another simple test" );
+};
+
+pass("Parent retains sharedness");
+
+done_testing(2);
diff --git a/cpan/Test-Simple/t/Legacy/subtest/todo.t b/cpan/Test-Simple/t/Legacy/subtest/todo.t
new file mode 100644
index 0000000000..82de40e3da
--- /dev/null
+++ b/cpan/Test-Simple/t/Legacy/subtest/todo.t
@@ -0,0 +1,204 @@
+#!/usr/bin/perl -w
+
+# Test todo subtests.
+#
+# A subtest in a todo context should have all of its diagnostic output
+# redirected to the todo output destination, but individual tests
+# within the subtest should not become todo tests themselves.
+
+BEGIN {
+ if( $ENV{PERL_CORE} ) {
+ chdir 't';
+ @INC = ( '../lib', 'lib' );
+ }
+ else {
+ unshift @INC, 't/lib';
+ }
+}
+
+use strict;
+use warnings;
+
+use Test::More;
+use Test::Builder;
+use Test::Builder::Tester;
+
+# Formatting may change if we're running under Test::Harness.
+$ENV{HARNESS_ACTIVE} = 0;
+
+our %line;
+
+# Repeat each test for various combinations of the todo reason,
+# the mechanism by which it is set and $Level.
+our @test_combos;
+foreach my $level (1, 2, 3) {
+ push @test_combos, ['$TODO', 'Reason', $level],
+ ['todo_start', 'Reason', $level],
+ ['todo_start', '', $level],
+ ['todo_start', 0, $level];
+}
+
+plan tests => 8 * @test_combos;
+
+sub test_subtest_in_todo {
+ my ($name, $code, $want_out, $no_tests_run) = @_;
+
+ #my $xxx = $no_tests_run ? 'No tests run for subtest "xxx"' : 'xxx';
+ my @no_test_err = $no_tests_run ? ('# No tests run for subtest.') : ();
+
+ chomp $want_out;
+ my @outlines = split /\n/, $want_out;
+
+ foreach my $combo (@test_combos) {
+ my ($set_via, $todo_reason, $level) = @$combo;
+
+ test_out(
+ "# Subtest: xxx",
+ @outlines,
+ map { my $x = $_; $x =~ s/\s+$//; $x } (
+ "not ok 1 - xxx # TODO $todo_reason",
+ "# Failed (TODO) test 'xxx'",
+ "# at $0 line $line{xxx}.",
+ @no_test_err,
+ "not ok 2 - regular todo test # TODO $todo_reason",
+ "# Failed (TODO) test 'regular todo test'",
+ "# at $0 line $line{reg}.",
+ )
+ );
+
+ {
+ local $TODO = $set_via eq '$TODO' ? $todo_reason : undef;
+ if ($set_via eq 'todo_start') {
+ Test::Builder->new->todo_start($todo_reason);
+ }
+
+ subtest_at_level(
+ 'xxx', $code, $level); BEGIN{ $line{xxx} = __LINE__ }
+ ok 0, 'regular todo test'; BEGIN{ $line{reg} = __LINE__ }
+
+ if ($set_via eq 'todo_start') {
+ Test::Builder->new->todo_end;
+ }
+ }
+
+ last unless test_test("$name ($level), todo [$todo_reason] set via $set_via");
+ }
+}
+
+package Foo; # If several stack frames are in package 'main' then $Level
+ # could be wrong and $main::TODO might still be found. Using
+ # another package makes the tests more sensitive.
+
+sub main::subtest_at_level {
+ my ($name, $code, $level) = @_;
+
+ if ($level > 1) {
+ local $Test::Builder::Level = $Test::Builder::Level + 1;
+ main::subtest_at_level($name, $code, $level-1);
+ }
+ else {
+ Test::Builder->new->subtest($name => $code);
+ }
+}
+
+package main;
+
+test_subtest_in_todo("plan, no tests run", sub {
+ plan tests => 2;
+}, <<END, 1);
+ 1..2
+ # No tests run!
+END
+
+test_subtest_in_todo("noplan, no tests run", sub {
+ plan 'no_plan';
+}, <<END, 1);
+ # No tests run!
+END
+
+test_subtest_in_todo("missingplan, no tests run", sub {
+ 1;
+}, <<END, 1);
+ 1..0
+ # No tests run!
+END
+
+test_subtest_in_todo("donetesting, no tests run", sub {
+ done_testing;
+}, <<END, 1);
+ 1..0
+ # No tests run!
+END
+
+test_subtest_in_todo("1 failed test", sub {
+ ok 0, 'failme'; BEGIN { $line{fail1} = __LINE__ }
+}, <<END);
+ not ok 1 - failme
+ # Failed test 'failme'
+ # at $0 line $line{fail1}.
+ 1..1
+ # Looks like you failed 1 test of 1.
+END
+
+test_subtest_in_todo("1fail, wrongplan", sub {
+ plan tests => 17;
+ ok 0, 'failme'; BEGIN { $line{fail2} = __LINE__ }
+}, <<END);
+ 1..17
+ not ok 1 - failme
+ # Failed test 'failme'
+ # at $0 line $line{fail2}.
+ # Looks like you planned 17 tests but ran 1.
+ # Looks like you failed 1 test of 1 run.
+END
+
+test_subtest_in_todo("1fail, 1pass", sub {
+ ok 0, 'failme'; BEGIN { $line{fail3} = __LINE__ }
+ ok 1, 'passme';
+}, <<END);
+ not ok 1 - failme
+ # Failed test 'failme'
+ # at $0 line $line{fail3}.
+ ok 2 - passme
+ 1..2
+ # Looks like you failed 1 test of 2.
+END
+
+test_subtest_in_todo("todo tests in the subtest", sub {
+ ok 0, 'inner test 1'; BEGIN{ $line{in1} = __LINE__ }
+
+ TODO: {
+ local $TODO = 'Inner1';
+ ok 0, 'failing TODO a'; BEGIN{ $line{fta} = __LINE__ }
+ ok 1, 'unexpected pass a';
+ }
+
+ ok 0, 'inner test 2'; BEGIN{ $line{in2} = __LINE__ }
+
+ Test::Builder->new->todo_start('Inner2');
+ ok 0, 'failing TODO b'; BEGIN{ $line{ftb} = __LINE__ }
+ ok 1, 'unexpected pass b';
+ Test::Builder->new->todo_end;
+
+ ok 0, 'inner test 3'; BEGIN{ $line{in3} = __LINE__ }
+}, <<END);
+ not ok 1 - inner test 1
+ # Failed test 'inner test 1'
+ # at $0 line $line{in1}.
+ not ok 2 - failing TODO a # TODO Inner1
+ # Failed (TODO) test 'failing TODO a'
+ # at $0 line $line{fta}.
+ ok 3 - unexpected pass a # TODO Inner1
+ not ok 4 - inner test 2
+ # Failed test 'inner test 2'
+ # at $0 line $line{in2}.
+ not ok 5 - failing TODO b # TODO Inner2
+ # Failed (TODO) test 'failing TODO b'
+ # at $0 line $line{ftb}.
+ ok 6 - unexpected pass b # TODO Inner2
+ not ok 7 - inner test 3
+ # Failed test 'inner test 3'
+ # at $0 line $line{in3}.
+ 1..7
+ # Looks like you failed 3 tests of 7.
+END
diff --git a/cpan/Test-Simple/t/Legacy/subtest/wstat.t b/cpan/Test-Simple/t/Legacy/subtest/wstat.t
new file mode 100644
index 0000000000..ee2f19866d
--- /dev/null
+++ b/cpan/Test-Simple/t/Legacy/subtest/wstat.t
@@ -0,0 +1,24 @@
+#!/usr/bin/perl -w
+
+# Test that setting $? doesn't affect subtest success
+
+use strict;
+use Test::More;
+
+subtest foo => sub {
+ plan tests => 1;
+ $? = 1;
+ pass('bar');
+};
+
+is $?, 1, "exit code keeps on from a subtest";
+
+subtest foo2 => sub {
+ plan tests => 1;
+ pass('bar2');
+ $? = 1;
+};
+
+is $?, 1, "exit code keeps on from a subtest";
+
+done_testing(4);