develooper Front page | perl.perl5.porters | Postings from June 2008

[PATCH] add eval and error support to the t/op/smartmatch.t test

Thread Previous | Thread Next
From:
Yuval Kogman
Date:
June 28, 2008 15:41
Subject:
[PATCH] add eval and error support to the t/op/smartmatch.t test
Message ID:
1214692846-62413-3-git-send-email-nothingmuch@woobling.org
---
 t/op/smartmatch.t |   15 ++++++++++++---
 1 files changed, 12 insertions(+), 3 deletions(-)

diff --git a/t/op/smartmatch.t b/t/op/smartmatch.t
index 79b6b9b..e57e2dd 100644
--- a/t/op/smartmatch.t
+++ b/t/op/smartmatch.t
@@ -43,15 +43,24 @@ sub match_test {
     my ($yn, $left, $right) = @_;
 
     die "Bad test spec: ($yn, $left, $right)"
-	unless $yn eq "" || $yn eq "!";
+	unless $yn eq "" || $yn eq "!" || $yn eq '@';
     
     my $tstr = "$left ~~ $right";
     
     my $res;
     $res = eval $tstr // "";	#/ <- fix syntax colouring
 
-    die $@ if $@ ne "";
-    ok( ($yn =~ /!/ xor $res), "$tstr: $res");
+    chomp $@;
+
+    if ( $yn eq '@' ) {
+	ok( $@ ne '', sprintf "%s%s: %s", $tstr, $@ ? ( ', $@', $@ ) : ( '', $res ) );
+    } else {
+	if ( $@ ne '' ) {
+	    fail("$tstr, \$\@: $@");
+	} else {
+	    ok( ($yn eq '!' xor $res), "$tstr: $res");
+	}
+    }
 }
 
 
-- 
1.5.6.1.dirty


Thread Previous | Thread Next


nntp.perl.org: Perl Programming lists via nntp and http.
Comments to Ask Bjørn Hansen at ask@perl.org | Group listing | About