File: 03-subtest.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 (33 lines) | stat: -rw-r--r-- 742 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
use strict;
use warnings FATAL => 'all';

use Test::More 0.94;
use Test::Warnings ':all';

is(1, 1, 'passing test');

my $had_no_warnings_called;

{
    no strict 'refs';
    my $orig = *{'Test::Warnings::had_no_warnings'}{CODE};
    no warnings 'redefine';
    *{'Test::Warnings::had_no_warnings'} = sub(;$) {
        $had_no_warnings_called++;
        $orig->(@_);
    };
}

subtest 'here is a subtest' => sub {
    pass('another passing test');
    # no test is added via the done_testing here
    done_testing;
};

ok(!$had_no_warnings_called, 'had_no_warnings was not called via the subtest\'s done_testing');

done_testing;

# we are done testing, so we need to signal our status via exit codes.
exit($had_no_warnings_called ? 0 : 1);