Assert-Refute
view release on metacpan or search on metacpan
t/201-current_contract.t view on Meta::CPAN
# Load BEFORE T::M to avoid detecting it
use Assert::Refute qw(:core);
use Test::More;
use Scalar::Util qw(refaddr);
my @trace;
my $report = refute_and_report {
push @trace, current_contract;
push @trace, "alive";
};
is refaddr $trace[0], refaddr $report, "current_contract is same as report";
is $trace[1], "alive", "current_contract lives";
my $permitted = eval {
current_contract;
"Should not be";
};
like $@, qr/[Nn]ot currently testing anything/, "Thou shall not pass";
is $permitted, undef, "Unreachable";
done_testing;
t/216-carp-title.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(assert_refute);
my @warn;
my $alive = eval {
local $SIG{__WARN__} = sub { push @warn, shift };
assert_refute {
package T;
use Assert::Refute qw(:all);
plan tests => 1, title => 'Foobared';
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";
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 1.285 second using v1.01-cache-2.11-cpan-df04353d9ac )