diff options
Diffstat (limited to 'cpan/Test-Simple/t/Builder')
-rw-r--r-- | cpan/Test-Simple/t/Builder/carp.t | 11 | ||||
-rw-r--r-- | cpan/Test-Simple/t/Builder/done_testing_with_plan.t | 2 | ||||
-rw-r--r-- | cpan/Test-Simple/t/Builder/fork_with_new_stdout.t | 44 | ||||
-rw-r--r-- | cpan/Test-Simple/t/Builder/is_fh.t | 2 | ||||
-rw-r--r-- | cpan/Test-Simple/t/Builder/maybe_regex.t | 2 | ||||
-rw-r--r-- | cpan/Test-Simple/t/Builder/reset.t | 4 | ||||
-rw-r--r-- | cpan/Test-Simple/t/Builder/reset_outputs.t | 35 |
7 files changed, 70 insertions, 30 deletions
diff --git a/cpan/Test-Simple/t/Builder/carp.t b/cpan/Test-Simple/t/Builder/carp.t index e89eeebfb9..fb37c2f7f8 100644 --- a/cpan/Test-Simple/t/Builder/carp.t +++ b/cpan/Test-Simple/t/Builder/carp.t @@ -1,4 +1,6 @@ #!/usr/bin/perl +use strict; +use warnings; BEGIN { if( $ENV{PERL_CORE} ) { @@ -10,15 +12,16 @@ BEGIN { use Test::More tests => 3; use Test::Builder; +use Test::Builder::Provider; -my $tb = Test::Builder->create; -sub foo { $tb->croak("foo") } -sub bar { $tb->carp("bar") } +provides qw/foo bar/; +sub foo { builder()->croak("foo") } +sub bar { builder()->carp("bar") } eval { foo() }; is $@, sprintf "foo at %s line %s.\n", $0, __LINE__ - 1; -eval { $tb->croak("this") }; +eval { builder()->croak("this") }; is $@, sprintf "this at %s line %s.\n", $0, __LINE__ - 1; { diff --git a/cpan/Test-Simple/t/Builder/done_testing_with_plan.t b/cpan/Test-Simple/t/Builder/done_testing_with_plan.t index c0a3d0f014..2d10322eea 100644 --- a/cpan/Test-Simple/t/Builder/done_testing_with_plan.t +++ b/cpan/Test-Simple/t/Builder/done_testing_with_plan.t @@ -5,7 +5,7 @@ use strict; use Test::Builder; my $tb = Test::Builder->new; -$tb->plan( tests => 2 ); +$tb->plan(tests => 2); $tb->ok(1); $tb->ok(1); $tb->done_testing(2); diff --git a/cpan/Test-Simple/t/Builder/fork_with_new_stdout.t b/cpan/Test-Simple/t/Builder/fork_with_new_stdout.t index e38c1d08cb..1e0e97724e 100644 --- a/cpan/Test-Simple/t/Builder/fork_with_new_stdout.t +++ b/cpan/Test-Simple/t/Builder/fork_with_new_stdout.t @@ -8,13 +8,12 @@ use Config; my $b = Test::Builder->new; $b->reset; -my $Can_Fork = $Config{d_fork} || - (($^O eq 'MSWin32' || $^O eq 'NetWare') and - $Config{useithreads} and - $Config{ccflags} =~ /-DPERL_IMPLICIT_SYS/ - ); +my $Can_Fork = $Config{d_fork} + || (($^O eq 'MSWin32' || $^O eq 'NetWare') + and $Config{useithreads} + and $Config{ccflags} =~ /-DPERL_IMPLICIT_SYS/); -if( !$Can_Fork ) { +if (!$Can_Fork) { $b->plan('skip_all' => "This system cannot fork"); } else { @@ -22,23 +21,26 @@ else { } my $pipe = IO::Pipe->new; -if ( my $pid = fork ) { - $pipe->reader; - $b->ok((<$pipe> =~ /FROM CHILD: ok 1/), "ok 1 from child"); - $b->ok((<$pipe> =~ /FROM CHILD: 1\.\.1/), "1..1 from child"); - waitpid($pid, 0); +if (my $pid = fork) { + $pipe->reader; + my @output = <$pipe>; + $b->like($output[0], qr/ok 1/, "ok 1 from child"); + $b->like($output[1], qr/1\.\.1/, "1..1 from child"); + waitpid($pid, 0); } else { - $pipe->writer; - my $pipe_fd = $pipe->fileno; - close STDOUT; - open(STDOUT, ">&$pipe_fd"); - my $b = Test::Builder->new; - $b->reset; - $b->no_plan; - $b->ok(1); -} - + Test::Builder::Formatter::TAP->full_reset; + Test::Builder::Stream->clear; + $pipe->writer; + my $pipe_fd = $pipe->fileno; + close STDOUT; + open(STDOUT, ">&$pipe_fd"); + my $b = Test::Builder->create(shared_stream => 1); + $b->reset; + $b->no_plan; + $b->ok(1); + exit 0; +} =pod #actual diff --git a/cpan/Test-Simple/t/Builder/is_fh.t b/cpan/Test-Simple/t/Builder/is_fh.t index 0eb3ec0b15..f7a5f1a80d 100644 --- a/cpan/Test-Simple/t/Builder/is_fh.t +++ b/cpan/Test-Simple/t/Builder/is_fh.t @@ -41,7 +41,7 @@ package Lying::isa; sub isa { my $self = shift; my $parent = shift; - + return 1 if $parent eq 'IO::Handle'; } diff --git a/cpan/Test-Simple/t/Builder/maybe_regex.t b/cpan/Test-Simple/t/Builder/maybe_regex.t index d1927a56e5..fd8b8d06ed 100644 --- a/cpan/Test-Simple/t/Builder/maybe_regex.t +++ b/cpan/Test-Simple/t/Builder/maybe_regex.t @@ -23,7 +23,7 @@ ok(('bar' !~ /$r/), 'qr// bad match'); SKIP: { skip "blessed regex checker added in 5.10", 3 if $] < 5.010; - + my $obj = bless qr/foo/, 'Wibble'; my $re = $Test->maybe_regex($obj); ok( defined $re, "blessed regex detected" ); diff --git a/cpan/Test-Simple/t/Builder/reset.t b/cpan/Test-Simple/t/Builder/reset.t index 3bc44457fc..5d5be3b976 100644 --- a/cpan/Test-Simple/t/Builder/reset.t +++ b/cpan/Test-Simple/t/Builder/reset.t @@ -13,10 +13,11 @@ BEGIN { } chdir 't'; - use Test::Builder; +use Test::Builder::Formatter::LegacyResults; my $Test = Test::Builder->new; my $tb = Test::Builder->create; +$tb->stream->use_lresults; # We'll need this later to know the outputs were reset my %Original_Output; @@ -70,7 +71,6 @@ $Test->is_eq( fileno $tb->todo_output, # The reset Test::Builder will take over from here. $Test->no_ending(1); - $tb->current_test($Test->current_test); $tb->level(0); $tb->ok(1, 'final test to make sure output was reset'); diff --git a/cpan/Test-Simple/t/Builder/reset_outputs.t b/cpan/Test-Simple/t/Builder/reset_outputs.t new file mode 100644 index 0000000000..b199128ad3 --- /dev/null +++ b/cpan/Test-Simple/t/Builder/reset_outputs.t @@ -0,0 +1,35 @@ +#!perl -w + +BEGIN { + if( $ENV{PERL_CORE} ) { + chdir 't'; + @INC = ('../lib', 'lib'); + } + else { + unshift @INC, 't/lib'; + } +} + +use Test::Builder; +use Test::More 'no_plan'; + +{ + my $tb = Test::Builder->create(); + + # Store the original output filehandles and change them all. + my %original_outputs; + + open my $fh, ">", "dummy_file.tmp"; + END { 1 while unlink "dummy_file.tmp"; } + for my $method (qw(output failure_output todo_output)) { + $original_outputs{$method} = $tb->$method(); + $tb->$method($fh); + is $tb->$method(), $fh; + } + + $tb->reset_outputs; + + for my $method (qw(output failure_output todo_output)) { + is $tb->$method(), $original_outputs{$method}, "reset_outputs() resets $method"; + } +} |