This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Move Term::Cap from ext/ to cpan/
[perl5.git] / ext / Test-Simple / t / Builder / done_testing_plan_mismatch.t
1 #!/usr/bin/perl -w
2
3 # What if there's a plan and done_testing but they don't match?
4
5 use strict;
6 BEGIN {
7     if( $ENV{PERL_CORE} ) {
8         chdir 't';
9         @INC = ('../lib', 'lib');
10     }
11     else {
12         unshift @INC, 't/lib';
13     }
14 }
15
16 use Test::Builder;
17 use Test::Builder::NoOutput;
18
19 my $tb = Test::Builder::NoOutput->create;
20
21 {
22     # Normalize test output
23     local $ENV{HARNESS_ACTIVE};
24
25     $tb->plan( tests => 3 );
26     $tb->ok(1);
27     $tb->ok(1);
28     $tb->ok(1);
29
30 #line 24
31     $tb->done_testing(2);
32 }
33
34 my $Test = Test::Builder->new;
35 $Test->plan( tests => 1 );
36 $Test->level(0);
37 $Test->is_eq($tb->read, <<"END");
38 1..3
39 ok 1
40 ok 2
41 ok 3
42 not ok 4 - planned to run 3 but done_testing() expects 2
43 #   Failed test 'planned to run 3 but done_testing() expects 2'
44 #   at $0 line 24.
45 END