xref: /openbsd-src/gnu/usr.bin/perl/cpan/Test-Simple/t/Test2/modules/Util/Trace.t (revision 5759b3d249badf144a6240f7eec4dcf9df003e6b)
1use strict;
2use warnings;
3use Test2::Tools::Tiny;
4use Test2::EventFacet::Trace;
5
6like(
7    exception { 'Test2::EventFacet::Trace'->new() },
8    qr/The 'frame' attribute is required/,
9    "got error"
10);
11
12my $one = 'Test2::EventFacet::Trace'->new(frame => ['Foo::Bar', 'foo.t', 5, 'Foo::Bar::foo']);
13is_deeply($one->frame,  ['Foo::Bar', 'foo.t', 5, 'Foo::Bar::foo'], "Got frame");
14is_deeply([$one->call], ['Foo::Bar', 'foo.t', 5, 'Foo::Bar::foo'], "Got call");
15is($one->package, 'Foo::Bar',      "Got package");
16is($one->file,    'foo.t',         "Got file");
17is($one->line,    5,               "Got line");
18is($one->subname, 'Foo::Bar::foo', "got subname");
19
20is($one->debug, "at foo.t line 5", "got trace");
21$one->set_detail("yo momma");
22is($one->debug, "yo momma", "got detail for trace");
23$one->set_detail(undef);
24
25is(
26    exception { $one->throw('I died') },
27    "I died at foo.t line 5.\n",
28    "got exception"
29);
30
31is_deeply(
32    warnings { $one->alert('I cried') },
33    [ "I cried at foo.t line 5.\n" ],
34    "alter() warns"
35);
36
37my $snap = $one->snapshot;
38is_deeply($snap, $one, "identical");
39ok($snap != $one, "Not the same instance");
40
41done_testing;
42