From: Vincent Pit Date: Sun, 11 Jan 2009 11:59:30 +0000 (+0100) Subject: Add t/55-unwind-multi.t (with a failing test) X-Git-Tag: v0.04~12 X-Git-Url: http://git.vpit.fr/?a=commitdiff_plain;h=c3c8cfc85dacca6cceb4872df2c33502e2dcf4fa;p=perl%2Fmodules%2FScope-Upper.git Add t/55-unwind-multi.t (with a failing test) --- diff --git a/MANIFEST b/MANIFEST index da4fe1a..3a77814 100644 --- a/MANIFEST +++ b/MANIFEST @@ -25,6 +25,7 @@ t/40-localize_delete-target.t t/41-localize_delete-level.t t/44-localize_delete-magic.t t/50-unwind-context.t +t/55-unwind-multi.t t/81-stress-level.t t/90-boilerplate.t t/91-pod.t diff --git a/t/55-unwind-multi.t b/t/55-unwind-multi.t new file mode 100644 index 0000000..aa37026 --- /dev/null +++ b/t/55-unwind-multi.t @@ -0,0 +1,65 @@ +#!perl -T + +use strict; +use warnings; + +use Test::More tests => 13; + +use Scope::Upper qw/unwind/; + +my ($l1, $l2); + +our $x; + +sub c { + $x = 3; + sub { + unwind("eval", eval { + do { + for (3, 4, 5) { + 1, unwind('from', 'the', 'sub', 'c' => $l1); + } + } + } => $l2); + }->(2, 3, 4); + return 'in c' +} + +sub b { + local $x = 2; + my @c = (1 .. 12, c()); + is $x, 3, '$x in b after c()'; + return @c, 'in b'; +} + +sub a { + local $x = 1; + my @b = b(); + is $x, 1, '$x in a after b()'; + return @b, 'in a'; +} + +$l1 = 0; +$l2 = 0; +is_deeply [ a() ], [ 1 .. 12, 'in c', 'in b', 'in a' ], + 'l1=0, l2=0'; + +$l1 = 0; +$l2 = 1; +is_deeply [ a() ], [ 1 .. 12, qw/eval from the sub c/, 'in b', 'in a' ], + 'l1=0, l2=1'; + +$l1 = 0; +$l2 = 2; +is_deeply [ a() ], [ qw/eval from the sub c/, 'in a' ], + 'l1=0, l2=2'; + +$l1 = 4; +$l2 = 999; +is_deeply [ a() ], [ 1 .. 12, qw/from the sub c/, 'in b', 'in a' ], + 'l1=4, l2=?'; + +$l1 = 5; +$l2 = 999; +is_deeply [ a() ], [ qw/from the sub c/, 'in a' ], + 'l1=5, l2=?';