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