$t=($^H{assertions} & $hint) ? 1 : 0;
}
elsif ($t ne '0' and $t ne '1') {
- $t = ( grep { ref $_ eq 'Regexp'
+ $t = ( grep { re::is_regexp($_)
? $t=~$_
- : $_->check($t)
+ : $_->($t)
} @{^ASSERTING} ) ? 1 : 0;
}
sub import {
shift;
@_ = '.*' unless @_;
- push @{^ASSERTING}, map { ref $_ eq 'Regexp' ? $_ : qr/^(?:$_)\z/ } @_;
+ push @{^ASSERTING}, map { ref $_ ? $_ : qr/^(?:$_)\z/ } @_;
}
1;
The import parameters are a list of strings or of regular expressions. The
assertion tags that match those regexps are enabled. If no parameter is
-given, all assertions are activated.
+given, all assertions are activated. References are activated as-is.
=head1 SEE ALSO
my $supported = assertions::compat::supported();
-my $n=@expr/2 + ($supported ? 10 : 0);
+my $n=@expr/2 + ($supported ? 12 : 0);
my $i=1;
print "1..$n\n";
}
}
print "ok ", $i++, "\n";
+
+ # 11
+ {
+ use assertions::activate sub { return 1 if $_[0] eq 'via_sub' };
+ use assertions 'via_sub';
+ callme(my $b=47);
+ unless ($b == 47) {
+ print STDERR "this shouldn't fail ever (b=$b)\n";
+ print "not ";
+ }
+ }
+ print "ok ", $i++, "\n";
+
+ # 12
+ {
+ use assertions 'not_asserted';
+ callme(my $b=48);
+ if ($b == 48) {
+ print STDERR "this shouldn't fail ever (b=$b)\n";
+ print "not ";
+ }
+ }
+ print "ok ", $i++, "\n";
}