File: 012reporter-callback.t

package info (click to toggle)
libmail-message-perl 3.017-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 1,632 kB
  • sloc: perl: 11,156; makefile: 4
file content (39 lines) | stat: -rw-r--r-- 1,032 bytes parent folder | download | duplicates (4)
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
35
36
37
38
39
#!/usr/bin/env perl
#
# Test installing a log callback
#

use strict;
use warnings;

use Mail::Message::Test;
use Mail::Reporter;

use Test::More tests => 13;

my ($thing, $level, @text);
sub callback($$@) { ($thing, $level, @text) = @_ }

my ($l, $t) = Mail::Reporter->defaultTrace(PROGRESS => \&callback);
ok(defined $l);
ok(defined $t);

is($l, 'NONE',                      'string log level');
cmp_ok($l, '==',  6,                'numeric log level');

is($t, 'PROGRESS',                  'string trace level');
cmp_ok($t, '==',  3,                'string trace level');

Mail::Reporter->log(ERROR => 'one', 'two');

is($thing, 'Mail::Reporter',        'class call');
is($level, 'ERROR',                 'string trace level');
cmp_ok(@text, '==', 1,              'text');
is($text[0], "onetwo");

($thing, $level, @text) = ();
Mail::Reporter->log(NOTICE => 'three');
ok(!defined $thing,                 'too low level, nothing');
ok(!defined $level,                 'no level');
cmp_ok(@text, '==', 0,              'no text');