1Check the lexical scoping of the switch keywords. 2(The actual behaviour is tested in t/op/switch.t) 3 4__END__ 5# No switch; given should be a bareword. 6use warnings; no warnings 'experimental::smartmatch'; 7print STDOUT given; 8EXPECT 9Unquoted string "given" may clash with future reserved word at - line 3. 10given 11######## 12# No switch; when should be a bareword. 13use warnings; no warnings 'experimental::smartmatch'; 14print STDOUT when; 15EXPECT 16Unquoted string "when" may clash with future reserved word at - line 3. 17when 18######## 19# No switch; default should be a bareword. 20use warnings; no warnings 'experimental::smartmatch'; 21print STDOUT default; 22EXPECT 23Unquoted string "default" may clash with future reserved word at - line 3. 24default 25######## 26# No switch; break should be a bareword. 27use warnings; no warnings 'experimental::smartmatch'; 28print STDOUT break; 29EXPECT 30Unquoted string "break" may clash with future reserved word at - line 3. 31break 32######## 33# No switch; but continue is still a keyword 34print STDOUT continue; 35EXPECT 36Can't "continue" outside a when block at - line 2. 37######## 38# Use switch; so given is a keyword 39use feature 'switch'; no warnings 'experimental::smartmatch'; 40given("okay\n") { print } 41EXPECT 42okay 43######## 44# Use switch; so when is a keyword 45use feature 'switch'; no warnings 'experimental::smartmatch'; 46given(1) { when(1) { print "okay" } } 47EXPECT 48okay 49######## 50# Use switch; so default is a keyword 51use feature 'switch'; no warnings 'experimental::smartmatch'; 52given(1) { default { print "okay" } } 53EXPECT 54okay 55######## 56# Use switch; so break is a keyword 57use feature 'switch'; 58break; 59EXPECT 60Can't "break" outside a given block at - line 3. 61######## 62# switch out of scope; given should be a bareword. 63use warnings; no warnings 'experimental::smartmatch'; 64{ use feature 'switch'; 65 given (1) {print "Okay here\n";} 66} 67print STDOUT given; 68EXPECT 69Unquoted string "given" may clash with future reserved word at - line 6. 70Okay here 71given 72######## 73# switch out of scope; when should be a bareword. 74use warnings; no warnings 'experimental::smartmatch'; 75{ use feature 'switch'; 76 given (1) { when(1) {print "Okay here\n";} } 77} 78print STDOUT when; 79EXPECT 80Unquoted string "when" may clash with future reserved word at - line 6. 81Okay here 82when 83######## 84# switch out of scope; default should be a bareword. 85use warnings; no warnings 'experimental::smartmatch'; 86{ use feature 'switch'; 87 given (1) { default {print "Okay here\n";} } 88} 89print STDOUT default; 90EXPECT 91Unquoted string "default" may clash with future reserved word at - line 6. 92Okay here 93default 94######## 95# switch out of scope; break should be a bareword. 96use warnings; no warnings 'experimental::smartmatch'; 97{ use feature 'switch'; 98 given (1) { break } 99} 100print STDOUT break; 101EXPECT 102Unquoted string "break" may clash with future reserved word at - line 6. 103break 104######## 105# C<no feature 'switch'> should work 106use warnings; no warnings 'experimental::smartmatch'; 107use feature 'switch'; 108given (1) { when(1) {print "Okay here\n";} } 109no feature 'switch'; 110print STDOUT when; 111EXPECT 112Unquoted string "when" may clash with future reserved word at - line 6. 113Okay here 114when 115######## 116# C<no feature> should work too 117use warnings; no warnings 'experimental::smartmatch'; 118use feature 'switch'; 119given (1) { when(1) {print "Okay here\n";} } 120no feature; 121print STDOUT when; 122EXPECT 123Unquoted string "when" may clash with future reserved word at - line 6. 124Okay here 125when 126######## 127# Without the feature, no 'Unambiguous use of' warning: 128use warnings; no warnings 'experimental::smartmatch'; 129@break = ($break = "break"); 130print ${break}, ${break[0]}; 131EXPECT 132breakbreak 133######## 134# With the feature, we get an 'Unambiguous use of' warning: 135use warnings; no warnings 'experimental::smartmatch'; 136use feature 'switch'; 137@break = ($break = "break"); 138print ${break}, ${break[0]}; 139EXPECT 140Ambiguous use of ${break} resolved to $break at - line 5. 141Ambiguous use of ${break[...]} resolved to $break[...] at - line 5. 142breakbreak 143