+ is $x, 1, 'die - localize inside eval [ok - x]';
+ is $y, undef, 'die - localize inside eval [ok - y]';
+}
+
+SKIP:
+{
+ skip 'Perl 5.10 required to test given/when' => 30 if "$]" < 5.010;
+
+ eval <<' GIVEN_TEST_1';
+ BEGIN {
+ if ("$]" >= 5.017_011) {
+ require warnings;
+ warnings->unimport('experimental::smartmatch');
+ }
+ }
+ use feature 'switch';
+ local $y;
+ {
+ local $x = 1;
+ given (1) {
+ local $x = 2;
+ when (1) {
+ local $x = 3;
+ localize '$y' => 1 => UP UP;
+ is $x, 3, 'given/when - localize at given [not yet - x]';
+ is $y, undef, 'given/when - localize at given [not yet - y]';
+ }
+ fail 'not reached';
+ }
+ is $x, 1, 'given/when - localize at given [ok - x]';
+ is $y, 1, 'given/when - localize at given [ok - y]';
+ }
+ GIVEN_TEST_1
+ fail $@ if $@;
+
+ eval <<' GIVEN_TEST_2';
+ BEGIN {
+ if ("$]" >= 5.017_011) {
+ require warnings;
+ warnings->unimport('experimental::smartmatch');
+ }
+ }
+ use feature 'switch';
+ local $y;
+ {
+ local $x = 1;
+ given (1) {
+ local $x = 2;
+ when (1) {
+ local $x = 3;
+ localize '$y' => 1 => UP UP;
+ is $x, 3, 'given/when/continue - localize at given [not yet 1 - x]';
+ is $y, undef, 'given/when/continue - localize at given [not yet 1 - y]';
+ continue;
+ }
+ is $x, 2, 'given/when/continue - localize at given [not yet 2 - x]';
+ is $y, undef, 'given/when/continue - localize at given [not yet 2 - y]';
+ }
+ is $x, 1, 'given/when/continue - localize at given [ok - x]';
+ is $y, 1, 'given/when/continue - localize at given [ok - y]';
+ }
+ GIVEN_TEST_2
+ fail $@ if $@;
+
+ eval <<' GIVEN_TEST_3';
+ BEGIN {
+ if ("$]" >= 5.017_011) {
+ require warnings;
+ warnings->unimport('experimental::smartmatch');
+ }
+ }
+ use feature 'switch';
+ local $y;
+ {
+ local $x = 1;
+ given (1) {
+ local $x = 2;
+ default {
+ local $x = 3;
+ localize '$y' => 1 => UP UP;
+ is $x, 3, 'given/default - localize at given [not yet - x]';
+ is $y, undef, 'given/default - localize at given [not yet - y]';
+ }
+ fail 'not reached';
+ }
+ is $x, 1, 'given/default - localize at given [ok - x]';
+ is $y, 1, 'given/default - localize at given [ok - y]';
+ }
+ GIVEN_TEST_3
+ fail $@ if $@;
+
+ eval <<' GIVEN_TEST_4';
+ BEGIN {
+ if ("$]" >= 5.017_011) {
+ require warnings;
+ warnings->unimport('experimental::smartmatch');
+ }
+ }
+ use feature 'switch';
+ local $y;
+ {
+ local $x = 1;
+ given (1) {
+ local $x = 2;
+ default {
+ local $x = 3;
+ localize '$y' => 1 => UP UP;
+ is $x, 3, 'given/default/continue - localize at given [not yet 1 - x]';
+ is $y, undef, 'given/default/continue - localize at given [not yet 1 - y]';
+ continue;
+ }
+ is $x, 2, 'given/default/continue - localize at given [not yet 2 - x]';
+ is $y, undef, 'given/default/continue - localize at given [not yet 2 - y]';
+ }
+ is $x, 1, 'given/default/continue - localize at given [ok - x]';
+ is $y, 1, 'given/default/continue - localize at given [ok - y]';
+ }
+ GIVEN_TEST_4
+ fail $@ if $@;
+
+ eval <<' GIVEN_TEST_5';
+ BEGIN {
+ if ("$]" >= 5.017_011) {
+ require warnings;
+ warnings->unimport('experimental::smartmatch');
+ }
+ }
+ use feature 'switch';
+ local $y;
+ {
+ local $x = 1;
+ given (1) {
+ local $x = 2;
+ default {
+ local $x = 3;
+ given (2) {
+ local $x = 4;
+ when (2) {
+ local $x = 5;
+ localize '$y' => 1 => UP UP UP;
+ is $x, 5, 'given/default/given/when - localize at default [not yet 1 - x]';
+ is $y, undef, 'given/default/given/when - localize at default [not yet 1 - y]';
+ continue;
+ }
+ is $x, 4, 'given/default/given/when - localize at default [not yet 2 - x]';
+ is $y, undef, 'given/default/given/when - localize at default [not yet 2 - y]';
+ }
+ is $x, 3, 'given/default/given/when - localize at default [not yet 3 - x]';
+ is $y, undef, 'given/default/given/when - localize at default [not yet 3 - y]';
+ continue;
+ }
+ is $x, 2, 'given/default/given/when - localize at default [ok 1 - x]';
+ is $y, 1, 'given/default/given/when - localize at default [ok 1 - y]';
+ }
+ is $x, 1, 'given/default/given/when - localize at default [ok 2 - x]';
+ is $y, undef, 'given/default/given/when - localize at default [ok 2 - y]';
+ }
+ GIVEN_TEST_5
+ fail $@ if $@;