diff options
author | Salvador Fandiño <sfandino@yahoo.com> | 2002-11-30 17:24:09 +0000 |
---|---|---|
committer | hv <hv@crypt.org> | 2003-02-16 13:55:10 +0000 |
commit | 06492da604676b8820ba5623ac813ceec4f48731 (patch) | |
tree | 51a6bda59973daccf9c0377e9639e90650598088 /lib/assertions.pm | |
parent | ed25273444c5542e4865fbe422e026b78ba33b80 (diff) | |
download | perl-06492da604676b8820ba5623ac813ceec4f48731.tar.gz |
add support for assertions. Updated form of:
Subject: Re: Did the assertion patch/feature submission get overlooked?
Message-ID: <3DE8F439.50402@yahoo.com>
p4raw-id: //depot/perl@18727
Diffstat (limited to 'lib/assertions.pm')
-rw-r--r-- | lib/assertions.pm | 94 |
1 files changed, 94 insertions, 0 deletions
diff --git a/lib/assertions.pm b/lib/assertions.pm new file mode 100644 index 0000000000..50e06a76df --- /dev/null +++ b/lib/assertions.pm @@ -0,0 +1,94 @@ +package assertions; + +our $VERSION = '0.01'; + +# use strict; +# use warnings; + +my $hint=0x01000000; + +sub import { + shift; + @_=(scalar(caller)) unless @_; + + if ($_[0] eq '&') { + return unless $^H & $hint; + shift; + } + + for my $tag (@_) { + unless (grep { $tag=~$_ } @{^ASSERTING}) { + $^H &= ~$hint; + return; + } + } + $^H |= $hint; +} + +sub unimport { + $^H &= ~$hint; +} + +1; +__END__ + + +=head1 NAME + +assertions - selects assertions + +=head1 SYNOPSIS + + sub assert (&) : assertion { &{$_[0]}() } + + use assertions 'foo'; + assert { print "asserting 'foo'\n" }; + + { + use assertions qw( foo bar ); + assert { print "asserting 'foo' & 'bar'\n" }; + } + + { + use assertions qw( bar ); + assert { print "asserting 'bar'\n" }; + } + + { + use assertions qw( & bar ); + assert { print "asserting 'foo' & 'bar'\n" }; + } + + assert { print "asserting 'foo' again\n" }; + + +=head1 ABSTRACT + +C<assertions> pragma selects the tags used to control assertion +execution. + +=head1 DESCRIPTION + + + + +=head2 EXPORT + +None by default. + +=head1 SEE ALSO + + + +=head1 AUTHOR + +Salvador Fandiño, E<lt>sfandino@yahoo.comE<gt> + +=head1 COPYRIGHT AND LICENSE + +Copyright 2002 by Salvador Fandiño + +This library is free software; you can redistribute it and/or modify +it under the same terms as Perl itself. + +=cut |