1use strict;
2use warnings;
3use Test2::Tools::Tiny;
4use Test2::Event::Exception;
5
6my $exception = Test2::Event::Exception->new(
7    trace => {frame => []},
8    error => "evil at lake_of_fire.t line 6\n",
9);
10
11ok($exception->causes_fail, "Exception events always cause failure");
12
13is($exception->summary, "Exception: evil at lake_of_fire.t line 6", "Got summary");
14
15ok($exception->diagnostics, "Exception events are counted as diagnostics");
16
17my $facet_data = $exception->facet_data;
18ok($facet_data->{about}, "Got common facet data");
19
20is_deeply(
21    $facet_data->{errors},
22    [{
23        tag => 'ERROR',
24        fail => 1,
25        details => "evil at lake_of_fire.t line 6\n",
26    }],
27    "Got error facet",
28);
29
30my $hash = {an => 'error'};
31my $str = "$hash";
32
33$exception = Test2::Event::Exception->new(
34    trace => {frame => []},
35    error => $hash,
36);
37
38ok($exception->causes_fail, "Exception events always cause failure");
39
40is($exception->error, $str, "Got stringified exception");
41
42$facet_data = $exception->facet_data;
43ok($facet_data->{about}, "Got common facet data");
44
45is_deeply(
46    $facet_data->{errors},
47    [{
48        tag => 'ERROR',
49        fail => 1,
50        details => $str,
51    }],
52    "Got error facet",
53);
54
55done_testing;
56