[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]
[PATCH] add eval and error support to the t/op/smartmatch.t test
---
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
- Follow-Ups from:
-
Yuval Kogman <nothingmuch@woobling.org>
- References to:
-
"Rafael Garcia-Suarez" <rgarciasuarez@gmail.com>
Yuval Kogman <nothingmuch@woobling.org>
[Date Prev][Date Next] [Thread Prev][Thread Next] [Date Index][Thread Index][Top&Search][Original]