From: Vincent Pit Date: Thu, 21 Aug 2008 10:49:25 +0000 (+0200) Subject: More eval() tests X-Git-Url: http://git.vpit.fr/?a=commitdiff_plain;h=0d977814f2cfa71e2d4742d7db999976198180f8;p=perl%2Fmodules%2FSub-Nary.git More eval() tests --- diff --git a/t/20-return.t b/t/20-return.t index fe5d21b..32f2bc1 100644 --- a/t/20-return.t +++ b/t/20-return.t @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::More tests => 68; +use Test::More tests => 69; use Sub::Nary; @@ -84,6 +84,7 @@ my @tests = ( [ sub { eval { return } }, 0 ], [ sub { eval { return 1, 2 } }, 2 ], + [ sub { eval { return 1, 2; 3, 4, 5 } }, 2 ], [ sub { eval { }; return $x, 2 }, 2 ], [ sub { return eval { 1, $x }; }, 2 ], [ sub { return 1, eval { $x, eval { $h{foo} } } }, 3 ], diff --git a/t/27-die.t b/t/27-die.t index 3880282..23c71ce 100644 --- a/t/27-die.t +++ b/t/27-die.t @@ -3,7 +3,7 @@ use strict; use warnings; -use Test::More tests => 12; +use Test::More tests => 14; use Sub::Nary; @@ -33,9 +33,12 @@ my @tests = ( [ sub { dies(), 1, do { $x ? @_ : 1 } }, { die => 0.25, 4 => 0.125, 5 => 0.25, list => (0.25 + 0.5) * 0.5 } ], - [ sub { eval "1, do { die }, 3" }, 'list' ], - [ sub { eval { die } }, { 0 => 1 } ], - [ sub { eval { $x ? die : (4, 5) } }, { 0 => 0.5, 2 => 0.5 } ], + [ sub { eval "1, do { die }, 3" }, 'list' ], + [ sub { eval { die } }, { 0 => 1 } ], + [ sub { eval { $x ? die : (4, 5) } }, { 0 => 0.5, 2 => 0.5 } ], + [ sub { eval { $x ? die : (4, 5) }; die if $@; 7 }, { die => 0.5, 1 => 0.5 } ], + [ sub { eval { $x ? die : return (4, 5) }; die if $@; 7 }, + { 2 => 0.5, die => 0.25, 1 => 0.25 } ], ); my $i = 1;