10 sub syntax_error ($$) {
13 Carp::croak("syntax error on assertion filter '$expr' ($why)");
18 my @tokens=split / \s*
27 # print STDERR "tokens: -", join('-',@tokens), "-\n";
40 and syntax_error $expr, 'consecutive operators';
45 and syntax_error $expr, 'consecutive operators';
48 elsif (!defined $t or $t eq '') {
54 syntax_error $expr, 'unbalanced parens';
56 syntax_error $expr, "key missing after operator '$op[0]'";
62 $t=($^H & $hint) ? 1 : 0;
64 elsif ($t ne '0' and $t ne '1') {
65 # print STDERR "'$t' resolved as ";
66 $t=grep ({ $t=~$_ } @{^ASSERTING}) ? 1 : 0;
67 # print STDERR "$t\n";
71 syntax_error $expr, 'operator expected';
73 if ($op[0] eq 'start') {
76 elsif ($op[0] eq '||') {
86 @now==1 or syntax_error $expr, 'unbalanced parens';
87 defined $op[0] and syntax_error $expr, "expression ends on operator '$op[0]'";
94 # print STDERR "\@_=", join("|", @_), "\n";
96 @_=(scalar(caller)) unless @_;
97 foreach my $expr (@_) {
98 unless (calc_expr $expr) {
99 # print STDERR "assertions deactived";
104 # print STDERR "assertions actived";
121 assertions - selects assertions
125 sub assert (&) : assertion { &{$_[0]}() }
127 use assertions 'foo';
128 assert { print "asserting 'foo'\n" };
131 use assertions qw( foo bar );
132 assert { print "asserting 'foo' & 'bar'\n" };
136 use assertions qw( bar );
137 assert { print "asserting 'bar'\n" };
141 use assertions ' _ && bar ';
142 assert { print "asserting 'foo' && 'bar'\n" };
145 assert { print "asserting 'foo' again\n" };
150 C<assertions> pragma selects the tags used to control assertion
168 Salvador FandiE<ntilde>o, E<lt>sfandino@yahoo.comE<gt>
170 =head1 COPYRIGHT AND LICENSE
172 Copyright 2002 by Salvador FandiE<ntilde>o
174 This library is free software; you can redistribute it and/or modify
175 it under the same terms as Perl itself.