summaryrefslogtreecommitdiff
path: root/lib/assertions.pm
diff options
context:
space:
mode:
authorSalvador FandiƱo <sfandino@yahoo.com>2003-02-21 17:26:16 +0000
committerRafael Garcia-Suarez <rgarciasuarez@gmail.com>2003-03-04 20:49:59 +0000
commit8fa7688f7865696bdfa78bc12d4ffb78bd1d6103 (patch)
tree9737caf004c7fafa8466b02223aa35b52064734f /lib/assertions.pm
parent9bf4a77902309e820b008865d9ebf6110e4a6cac (diff)
downloadperl-8fa7688f7865696bdfa78bc12d4ffb78bd1d6103.tar.gz
[PATCH] assertions
Message-ID: <3E566138.4090709@yahoo.com> and the complement : (with added comments) Subject: [PATCH] bug in ext/B/t/deparse.t Message-ID: <3E563E16.7060303@yahoo.com> plus perldiag.pod patch for the new warning (previous change was, once again, empty) p4raw-id: //depot/perl@18828
Diffstat (limited to 'lib/assertions.pm')
-rw-r--r--lib/assertions.pm21
1 files changed, 17 insertions, 4 deletions
diff --git a/lib/assertions.pm b/lib/assertions.pm
index 918808d00d..7af0fb0994 100644
--- a/lib/assertions.pm
+++ b/lib/assertions.pm
@@ -6,6 +6,7 @@ our $VERSION = '0.01';
# use warnings;
my $hint=0x01000000;
+my $seen_hint=0x02000000;
sub syntax_error ($$) {
my ($expr, $why)=@_;
@@ -13,6 +14,15 @@ sub syntax_error ($$) {
Carp::croak("syntax error on assertion filter '$expr' ($why)");
}
+sub my_warn ($) {
+ my $error=shift;
+ require warnings;
+ if (warnings::enabled('assertions')) {
+ require Carp;
+ Carp::carp($error);
+ }
+}
+
sub calc_expr {
my $expr=shift;
my @tokens=split / \s*
@@ -30,6 +40,8 @@ sub calc_expr {
my @op='start';
for my $t (@tokens) {
+ next if (!defined $t or $t eq '');
+
if ($t eq '(') {
unshift @now, 1;
unshift @op, 'start';
@@ -45,9 +57,6 @@ sub calc_expr {
and syntax_error $expr, 'consecutive operators';
$op[0]='&&';
}
- elsif (!defined $t or $t eq '') {
- # warn "empty token";
- }
else {
if ($t eq ')') {
@now==1 and
@@ -59,6 +68,9 @@ sub calc_expr {
shift @op;
}
elsif ($t eq '_') {
+ unless ($^H & $seen_hint) {
+ my_warn "assertion status '_' referenced but not previously defined";
+ }
$t=($^H & $hint) ? 1 : 0;
}
elsif ($t ne '0' and $t ne '1') {
@@ -98,11 +110,12 @@ sub import {
unless (calc_expr $expr) {
# print STDERR "assertions deactived";
$^H &= ~$hint;
+ $^H |= $seen_hint;
return;
}
}
# print STDERR "assertions actived";
- $^H |= $hint;
+ $^H |= $hint|$seen_hint;
}