Change 31316 by [EMAIL PROTECTED] on 2007/05/31 12:11:40

        Subject: [PATCH] minor assertions improvements
        From: Ricardo SIGNES <[EMAIL PROTECTED]>
        Date: Wed, 30 May 2007 21:47:15 -0400
        Message-ID: <[EMAIL PROTECTED]>

Affected files ...

... //depot/perl/lib/assertions.pm#10 edit
... //depot/perl/lib/assertions/activate.pm#9 edit
... //depot/perl/t/comp/assertions.t#5 edit

Differences ...

==== //depot/perl/lib/assertions.pm#10 (text) ====
Index: perl/lib/assertions.pm
--- perl/lib/assertions.pm#9~28808~     2006-09-08 01:36:32.000000000 -0700
+++ perl/lib/assertions.pm      2007-05-31 05:11:40.000000000 -0700
@@ -73,9 +73,9 @@
                    $t=($^H{assertions} & $hint) ? 1 : 0;
                }
                elsif ($t ne '0' and $t ne '1') {
-                   $t = ( grep { ref $_ eq 'Regexp'
+                   $t = ( grep { re::is_regexp($_)
                                      ? $t=~$_
-                                     : $_->check($t)
+                                     : $_->($t)
                                } @{^ASSERTING} ) ? 1 : 0;
                }
 

==== //depot/perl/lib/assertions/activate.pm#9 (text) ====
Index: perl/lib/assertions/activate.pm
--- perl/lib/assertions/activate.pm#8~27356~    2006-03-01 08:29:37.000000000 
-0800
+++ perl/lib/assertions/activate.pm     2007-05-31 05:11:40.000000000 -0700
@@ -5,7 +5,7 @@
 sub import {
     shift;
     @_ = '.*' unless @_;
-    push @{^ASSERTING}, map { ref $_ eq 'Regexp' ? $_ : qr/^(?:$_)\z/ } @_;
+    push @{^ASSERTING}, map { ref $_ ? $_ : qr/^(?:$_)\z/ } @_;
 }
 
 1;
@@ -33,7 +33,7 @@
 
 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.
+given, all assertions are activated.  References are activated as-is.
 
 =head1 SEE ALSO
 

==== //depot/perl/t/comp/assertions.t#5 (text) ====
Index: perl/t/comp/assertions.t
--- perl/t/comp/assertions.t#4~27356~   2006-03-01 08:29:37.000000000 -0800
+++ perl/t/comp/assertions.t    2007-05-31 05:11:40.000000000 -0700
@@ -41,7 +41,7 @@
 
 my $supported = assertions::compat::supported();
 
-my [EMAIL PROTECTED]/2 + ($supported ? 10 : 0);
+my [EMAIL PROTECTED]/2 + ($supported ? 12 : 0);
 my $i=1;
 print "1..$n\n";
 
@@ -168,4 +168,27 @@
        }
     }
     print "ok ", $i++, "\n";
+
+    # 11
+    {
+        use assertions::activate sub { return 1 if $_[0] eq 'via_sub' };
+       use assertions 'via_sub';
+       callme(my $b=47);
+       unless ($b == 47) {
+           print STDERR "this shouldn't fail ever (b=$b)\n";
+           print "not ";
+       }
+    }
+    print "ok ", $i++, "\n";
+
+    # 12
+    {
+       use assertions 'not_asserted';
+       callme(my $b=48);
+       if ($b == 48) {
+           print STDERR "this shouldn't fail ever (b=$b)\n";
+           print "not ";
+       }
+    }
+    print "ok ", $i++, "\n";
 }
End of Patch.

Reply via email to