File: 000.2-warn.t

package info (click to toggle)
libdata-printer-perl 1.002001-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 748 kB
  • sloc: perl: 4,364; makefile: 7; sh: 1
file content (18 lines) | stat: -rw-r--r-- 394 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
use strict;
use warnings;
use Test::More tests => 1;
use Data::Printer::Common;

sub warnings(&) {
    my $code = shift;
    my $got;
    local $SIG{__WARN__} = sub {
        $got = shift;
    };
    $code->();
    return $got
}

my $got = warnings { Data::Printer::Common::_warn(undef, "HA!") };

is( $got, "[Data::Printer] HA! at t/000.2-warn.t line 16.\n", 'warn with proper caller/line' );