$^H |= $hint|$seen_hint;
}
-
-
-
sub unimport {
$^H &= ~$hint;
}
=head1 NAME
-assertions - selects assertions
+assertions - select assertions in blocks of code
=head1 SYNOPSIS
{
use assertions qw( foo bar );
- assert { print "asserting 'foo' & 'bar'\n" };
+ assert { print "asserting 'foo' and 'bar'\n" };
}
{
use assertions qw( bar );
- assert { print "asserting 'bar'\n" };
+ assert { print "asserting only 'bar'\n" };
}
{
assert { print "asserting 'foo' again\n" };
-
-=head1 ABSTRACT
-
-C<assertions> pragma selects the tags used to control assertion
-execution.
-
=head1 DESCRIPTION
+The C<assertions> pragma specifies the tags used to enable and disable
+the execution of assertion subroutines.
+An assertion subroutine is declared with the C<:assertion> attribute.
+This subroutine is not normally executed : it's optimized away by perl
+at compile-time.
-
-=head2 EXPORT
-
-None by default.
+The C<assertion> pragma associates to its lexical scope one or several
+assertion tags. Then, to activate the execution of the assertions
+subroutines in this scope, these tags must be given to perl via the
+B<-A> command-line option.
=head1 SEE ALSO
-
+L<perlrun>.
=head1 AUTHOR
it under the same terms as Perl itself.
=cut
+
+TODO : Some more docs are to be added about assertion expressions.
our $VERSION = '0.01';
-# use strict;
-# use warnings;
-
sub import {
shift;
- @_='.*' unless @_;
- push @{^ASSERTING}, ( map { qr/^(?:$_)$/ } @_) ;
+ @_ = '.*' unless @_;
+ push @{^ASSERTING}, map { qr/^(?:$_)\z/ } @_;
}
1;
=head1 NAME
-assertions::activate - assertions activation
+assertions::activate - activate assertions
=head1 SYNOPSIS
- use assertions::activate 'Foo', 'bar', 'Foo::boz::.*' ;
-
-=head1 ABSTRACT
+ use assertions::activate 'Foo', 'bar', 'Foo::boz::.*';
-C<assertions::activate> module is used to configure assertion
-execution.
+ # activate all assertions
+ use assertions::activate;
=head1 DESCRIPTION
+This module is used internally by perl (and its C<-A> command-line switch) to
+enable and disable assertions. It can also be used directly.
-
-=head2 EXPORT
-
-None by default.
+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.
=head1 SEE ALSO
-L<assertions>
+L<assertions>, L<perlrun>.
=head1 AUTHOR
all -+
|
+ +- assertions
+ |
+- closure
|
+- deprecated
S<[ B<-x>[I<dir>] ]>
S<[ B<-i>[I<extension>] ]>
S<[ B<-e> I<'command'> ] [ B<--> ] [ I<programfile> ] [ I<argument> ]...>
- S<[ B<-C [I<number/list>] >]> ]>
+ S<[ B<-A [I<assertions>] >]>
+ S<[ B<-C [I<number/list>] >]>
=head1 DESCRIPTION
(This means that you cannot use the C<-x> with a directory name that
consists of hexadecimal digits.)
+=item B<-A [I<assertions>]>
+
+Activates the assertions given after the switch as a comma-separated
+list of assertion names. If no assertion name is given, activates all
+assertions. See L<assertions>.
+
=item B<-a>
turns on autosplit mode when used with a B<-n> or B<-p>. An implicit
BEGIN {
chdir 't' if -d 't';
unshift @INC, '../lib';
- require './test.pl'; # for which_perl() etc
+ require './test.pl';
}
BEGIN {
#1
fresh_perl_is('sub cm : assertion { "ok" }; use assertions Hello; print cm()',
'ok',
- { switches => ['-AHello'] }, '-A');
+ { switches => ['-AHello'] }, '-AHello');
#2
fresh_perl_is('sub cm : assertion { "ok" }; use assertions SDFJKS; print cm()',