File: 60mojo.t

package info (click to toggle)
liblog-report-perl 1.40-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid, trixie
  • size: 568 kB
  • sloc: perl: 2,905; makefile: 8
file content (40 lines) | stat: -rw-r--r-- 873 bytes parent folder | download | duplicates (5)
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
#!/usr/bin/env perl
# Test MojoX::Log::Report

use warnings;
use strict;
use lib 'lib', '../lib';

use Test::More;
use Log::Report undef;

use Data::Dumper;

BEGIN
{   eval "require Mojolicious";
    plan skip_all => 'Mojolicious is not installed'
        if $@;

    plan skip_all => 'installed Mojolicious too old (requires 2.16)'
        if $Mojolicious::VERSION < 2.16;
    plan tests => 7;
}

use_ok('MojoX::Log::Report');

my $log = MojoX::Log::Report->new;
isa_ok($log, 'MojoX::Log::Report');
isa_ok($log, 'Mojo::Log');

my $tmp;
dispatcher close => 'default';
try { $log->error("going to die"); $tmp = 42 } mode => 3;
my $err = $@;
#warn Dumper $err;

cmp_ok($tmp, '==', 42, 'errors not cast directly');
ok($err->success, 'block continued succesfully');

my @exc = $err->exceptions;
cmp_ok(scalar @exc, '==', 1, "caught 1");
is("$exc[0]", "error: going to die\n");