xref: /openbsd-src/gnu/usr.bin/perl/cpan/Test-Simple/t/Legacy/Builder/done_testing_plan_mismatch.t (revision 5759b3d249badf144a6240f7eec4dcf9df003e6b)
1#!/usr/bin/perl -w
2
3# What if there's a plan and done_testing but they don't match?
4
5use strict;
6BEGIN {
7    if( $ENV{PERL_CORE} ) {
8        chdir 't';
9        @INC = ('../lib', 'lib');
10    }
11    else {
12        unshift @INC, 't/lib';
13    }
14}
15
16use Test::Builder;
17use Test::Builder::NoOutput;
18
19my $tb = Test::Builder::NoOutput->create;
20
21# TB methods expect to be wrapped
22sub ok { $tb->ok(@_) }
23sub plan { $tb->plan(@_) }
24sub done_testing { $tb->done_testing(@_) }
25
26{
27    # Normalize test output
28    local $ENV{HARNESS_ACTIVE};
29
30    plan( tests => 3 );
31    ok(1);
32    ok(1);
33    ok(1);
34
35#line 24
36    done_testing(2);
37}
38
39my $Test = Test::Builder->new;
40$Test->plan( tests => 1 );
41$Test->level(0);
42$Test->is_eq($tb->read, <<"END");
431..3
44ok 1
45ok 2
46ok 3
47not ok 4 - planned to run 3 but done_testing() expects 2
48#   Failed test 'planned to run 3 but done_testing() expects 2'
49#   at $0 line 24.
50END
51