diff options
author | Gerard Goossen <gerard@ggoossen.net> | 2009-11-21 12:16:07 +0100 |
---|---|---|
committer | Rafael Garcia-Suarez <rgs@consttype.org> | 2009-11-21 19:49:48 +0100 |
commit | b500e03bf95eb884a53407409b4e755d303171a4 (patch) | |
tree | 2ea466912e5adede52f4d5b2907358ab8f9602cc /t/op/goto.t | |
parent | 021f53de09926928546378b3552f9240c9241dde (diff) | |
download | perl-b500e03bf95eb884a53407409b4e755d303171a4.tar.gz |
deprecate "goto" to jump into a construct
Diffstat (limited to 't/op/goto.t')
-rw-r--r-- | t/op/goto.t | 21 |
1 files changed, 18 insertions, 3 deletions
diff --git a/t/op/goto.t b/t/op/goto.t index c79b424b90..5aaf630bb9 100644 --- a/t/op/goto.t +++ b/t/op/goto.t @@ -10,28 +10,37 @@ BEGIN { use warnings; use strict; -plan tests => 58; +plan tests => 66; our $TODO; +my $deprecated = 0; +local $SIG{__WARN__} = sub { if ($_[0] =~ m/jump into a construct/) { $deprecated++; } else { warn $_[0] } }; + our $foo; while ($?) { $foo = 1; label1: + is($deprecated, 1); + $deprecated = 0; $foo = 2; goto label2; } continue { $foo = 0; goto label4; label3: + is($deprecated, 1); + $deprecated = 0; $foo = 4; goto label4; } +is($deprecated, 0); goto label1; $foo = 3; label2: is($foo, 2, 'escape while loop'); +is($deprecated, 0); goto label3; label4: @@ -60,7 +69,7 @@ sub bar { exit; FINALE: -is(curr_test(), 16, 'FINALE'); +is(curr_test(), 20, 'FINALE'); # does goto LABEL handle block contexts correctly? # note that this scope-hopping differs from last & next, @@ -174,13 +183,18 @@ ok($ok, 'works correctly in a nested eval string'); A: { if ($false) { redo A; B: $ok = 1; redo A; } } goto B unless $count++; } + is($deprecated, 0); a(); ok($ok, '#19061 loop label wiped away by goto'); + is($deprecated, 1); + $deprecated = 0; $ok = 0; my $p; for ($p=1;$p && goto A;$p=0) { A: $ok = 1 } ok($ok, 'weird case of goto and for(;;) loop'); + is($deprecated, 1); + $deprecated = 0; } # bug #9990 - don't prematurely free the CV we're &going to. @@ -250,7 +264,7 @@ exit; bypass: -is(curr_test(), 5, 'eval "goto $x"'); +is(curr_test(), 9, 'eval "goto $x"'); # Test autoloading mechanism. @@ -459,3 +473,4 @@ TODO: { } } +is($deprecated, 0); |