1use strict; 2use warnings; 3use Test2::Tools::Tiny; 4use Test2::Event::Diag; 5use Test2::EventFacet::Trace; 6 7my $diag = Test2::Event::Diag->new( 8 trace => Test2::EventFacet::Trace->new(frame => [__PACKAGE__, __FILE__, __LINE__]), 9 message => 'foo', 10); 11 12is($diag->summary, 'foo', "summary is just message"); 13 14$diag = Test2::Event::Diag->new( 15 trace => Test2::EventFacet::Trace->new(frame => [__PACKAGE__, __FILE__, __LINE__]), 16 message => undef, 17); 18 19is($diag->message, 'undef', "set undef message to undef"); 20is($diag->summary, 'undef', "summary is just message even when undef"); 21 22$diag = Test2::Event::Diag->new( 23 trace => Test2::EventFacet::Trace->new(frame => [__PACKAGE__, __FILE__, __LINE__]), 24 message => {}, 25); 26 27like($diag->message, qr/^HASH\(.*\)$/, "stringified the input value"); 28 29ok($diag->diagnostics, "Diag events are counted as diagnostics"); 30 31$diag = Test2::Event::Diag->new( 32 trace => Test2::EventFacet::Trace->new(frame => [__PACKAGE__, __FILE__, __LINE__]), 33 message => "Hi there", 34); 35 36my $facet_data = $diag->facet_data; 37ok($facet_data->{about}, "Got 'about' from common"); 38ok($facet_data->{trace}, "Got 'trace' from common"); 39 40is_deeply( 41 $facet_data->{info}, 42 [{ 43 tag => 'DIAG', 44 debug => 1, 45 details => 'Hi there', 46 }], 47 "Got info facet" 48); 49 50done_testing; 51