Assert-Refute
view release on metacpan or search on metacpan
t/217-refute_invariant.t view on Meta::CPAN
#!perl
use strict;
use warnings;
BEGIN{ delete @ENV{qw(NDEBUG PERL_NDEBUG)} };
use Test::More tests => 3;
use Assert::Refute qw(refute_invariant);
my @warn;
my $alive = eval {
local $SIG{__WARN__} = sub { push @warn, shift };
refute_invariant "Foobared" => sub {
package T;
use Assert::Refute qw(:all);
is 42, 137, 'life is fine';
};
1;
};
is $alive, 1, "code lives"
or diag "Died: $@";
is scalar @warn, 1, "1 warning";
note "<REPORT>";
note $warn[0] || '(none)';
note "</REPORT>";
like $warn[0], qr/not ok 1.*Contract.*\bFoobared\b.*/s, "warning as expected";
( run in 0.693 second using v1.01-cache-2.11-cpan-df04353d9ac )