Make adding notes to patchlevel.h easier
[p5sagit/p5-mst-13.2.git] / lib / assertions.pm
CommitLineData
06492da6 1package assertions;
2
3our $VERSION = '0.01';
4
5# use strict;
6# use warnings;
7
8my $hint=0x01000000;
9
10sub import {
11 shift;
12 @_=(scalar(caller)) unless @_;
13
14 if ($_[0] eq '&') {
15 return unless $^H & $hint;
16 shift;
17 }
18
19 for my $tag (@_) {
20 unless (grep { $tag=~$_ } @{^ASSERTING}) {
21 $^H &= ~$hint;
22 return;
23 }
24 }
25 $^H |= $hint;
26}
27
28sub unimport {
29 $^H &= ~$hint;
30}
31
321;
33__END__
34
35
36=head1 NAME
37
38assertions - selects assertions
39
40=head1 SYNOPSIS
41
42 sub assert (&) : assertion { &{$_[0]}() }
43
44 use assertions 'foo';
45 assert { print "asserting 'foo'\n" };
46
47 {
48 use assertions qw( foo bar );
49 assert { print "asserting 'foo' & 'bar'\n" };
50 }
51
52 {
53 use assertions qw( bar );
54 assert { print "asserting 'bar'\n" };
55 }
56
57 {
58 use assertions qw( & bar );
59 assert { print "asserting 'foo' & 'bar'\n" };
60 }
61
62 assert { print "asserting 'foo' again\n" };
63
64
65=head1 ABSTRACT
66
67C<assertions> pragma selects the tags used to control assertion
68execution.
69
70=head1 DESCRIPTION
71
72
73
74
75=head2 EXPORT
76
77None by default.
78
79=head1 SEE ALSO
80
81
82
83=head1 AUTHOR
84
c54bef43 85Salvador FandiE<ntilde>o, E<lt>sfandino@yahoo.comE<gt>
06492da6 86
87=head1 COPYRIGHT AND LICENSE
88
c54bef43 89Copyright 2002 by Salvador FandiE<ntilde>o
06492da6 90
91This library is free software; you can redistribute it and/or modify
92it under the same terms as Perl itself.
93
94=cut