The London Perl and Raku Workshop takes place on 26th Oct 2024. If your company depends on Perl, please consider sponsoring and/or attending.
#!/usr/bin/perl

use strict;
use warnings;

use Test::More;

BEGIN {
	plan skip_all => "Test::Warn required for this test" unless eval { require Test::Warn };
	plan 'no_plan';
}

use Test::Warn;

{
	package Foo;
	use ok 'Devel::PartialDump' => qw(warn show carp dump);

	sub w { warn ["foo"] }
	sub c { carp ["foo"] }
	sub d { dump ["foo"] }
	sub s { show ["foo"] }
}

can_ok( Foo => qw(warn show carp dump) );

warning_like { Foo::w } qr/foo/, 'warn';
warning_like { Foo::c } { carped => qr/foo/ }, 'carp';

warning_is { like( Foo::d, qr/foo/, "dump" ) } [], "dump doesn't warn";
warning_like { is_deeply( Foo::s, ["foo"], "show" ) } qr/foo/, "show warns";