From: Yuval Kogman Date: Sat, 28 Jun 2008 22:40:35 +0000 (+0300) Subject: add eval and error support to the t/op/smartmatch.t test X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=a86f5011b590cb88c7014f49e191e01aa918b09b;p=p5sagit%2Fp5-mst-13.2.git add eval and error support to the t/op/smartmatch.t test --- 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"); + } + } }