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 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
|
#!/usr/bin/env perl
#
# Test producing warnings, errors and family.
#
use strict;
use warnings;
use Mail::Reporter;
use Mail::Message::Test;
use Test::More tests => 41;
#
# Dualvar logPriority
#
my $a = Mail::Reporter->logPriority('WARNING');
ok(defined $a);
ok($a == 4);
is($a, 'WARNING');
my $b = Mail::Reporter->logPriority('WARNINGS');
ok(defined $b);
ok($b == 4);
is($b, 'WARNING');
my $c = Mail::Reporter->logPriority(4);
ok(defined $c);
ok($c == 4);
is($c, 'WARNING');
my $d = Mail::Reporter->logPriority('AAP');
ok(!defined $d);
my $e = Mail::Reporter->logPriority(8);
ok(!defined $e);
#
# Initial default trace
#
my ($l, $t) = Mail::Reporter->defaultTrace;
ok(defined $l);
ok(defined $t);
is($l, 'WARNING', 'string log level');
cmp_ok($l, '==', 4, 'numeric log level');
is($t, 'WARNING', 'string trace level');
cmp_ok($t, '==', 4, 'string trace level');
#
# Set default trace
#
($l, $t) = Mail::Reporter->defaultTrace('DEBUG', 'ERRORS');
ok(defined $l);
ok(defined $t);
is($l, 'DEBUG', 'string log level');
cmp_ok($l, '==', 1, 'numeric log level');
is($t, 'ERROR', 'string trace level');
cmp_ok($t, '==', 5, 'string trace level');
($l, $t) = Mail::Reporter->defaultTrace('PROGRESS');
is($l, 'PROGRESS', 'string log level');
cmp_ok($l, '==', 3, 'numeric log level');
is($t, 'PROGRESS', 'string trace level');
cmp_ok($t, '==', 3, 'string trace level');
($l, $t) = Mail::Reporter->defaultTrace('WARNING', 'WARNINGS');
is($l, 'WARNING', 'string log level');
cmp_ok($l, '==', 4, 'numeric log level');
is($t, 'WARNING', 'string trace level');
cmp_ok($t, '==', 4, 'string trace level');
#
# Reporting levels based on objects
#
my $rep = Mail::Reporter->new;
ok(defined $rep);
is($rep->log, 'WARNING', 'Default log-level');
cmp_ok($rep->log, '==', 4);
$l = $rep->log;
is($l, 'WARNING', 'Default log-level');
cmp_ok($l, '==', 4);
is($rep->trace, 'WARNING', 'Default trace-level');
cmp_ok($rep->trace, '==', 4);
$t = $rep->trace;
is($t, 'WARNING', 'Default trace-level');
cmp_ok($t, '==', 4);
cmp_ok($rep->trace('ERROR'), '==', 5, 'Check error level numbers');
|