File: 07-no_plan.t

package info (click to toggle)
libtest-warnings-perl 0.016-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 352 kB
  • ctags: 8
  • sloc: perl: 339; makefile: 2
file content (34 lines) | stat: -rw-r--r-- 807 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
use strict;
use warnings FATAL => 'all';

# we intended to insert a test at END time whenever:
# - done_testing has not been run,
# - AND ':no_end_test' is not imported,
# - AND EITHER at least one test has been run, OR there was a plan.

# before v0.003, these last two conditions were also ANDed, so we
# never got a test added when we were running tests without a plan
# and terminated without done_testing (such as terminating a forked
# process).

use Test::More 'no_plan';

# define our END block first, so it is run last (after TW's END)
END {
    final_tests();
}

use Test::Warnings;

pass('this is a passing test');

# now we "END"...

sub final_tests
{
    is(
        Test::Builder->new->current_test, 2,
        'two tests have been run (the pass, and our no-warnings-via-END test)',
    );
}