1850e2753SmillertCheck the lexical scoping of the switch keywords. 2850e2753Smillert(The actual behaviour is tested in t/op/switch.t) 3850e2753Smillert 4850e2753Smillert__END__ 5850e2753Smillert# No switch; given should be a bareword. 6*f2a19305Safresh1use warnings; no warnings 'deprecated'; 7850e2753Smillertprint STDOUT given; 8850e2753SmillertEXPECT 9850e2753SmillertUnquoted string "given" may clash with future reserved word at - line 3. 10850e2753Smillertgiven 11850e2753Smillert######## 12850e2753Smillert# No switch; when should be a bareword. 13*f2a19305Safresh1use warnings; no warnings 'deprecated'; 14850e2753Smillertprint STDOUT when; 15850e2753SmillertEXPECT 16850e2753SmillertUnquoted string "when" may clash with future reserved word at - line 3. 17850e2753Smillertwhen 18850e2753Smillert######## 19850e2753Smillert# No switch; default should be a bareword. 20*f2a19305Safresh1use warnings; no warnings 'deprecated'; 21850e2753Smillertprint STDOUT default; 22850e2753SmillertEXPECT 23850e2753SmillertUnquoted string "default" may clash with future reserved word at - line 3. 24850e2753Smillertdefault 25850e2753Smillert######## 26850e2753Smillert# No switch; break should be a bareword. 27*f2a19305Safresh1use warnings; no warnings 'deprecated'; 28850e2753Smillertprint STDOUT break; 29850e2753SmillertEXPECT 30850e2753SmillertUnquoted string "break" may clash with future reserved word at - line 3. 31850e2753Smillertbreak 32850e2753Smillert######## 33850e2753Smillert# No switch; but continue is still a keyword 34850e2753Smillertprint STDOUT continue; 35850e2753SmillertEXPECT 36898184e3SsthenCan't "continue" outside a when block at - line 2. 37850e2753Smillert######## 38850e2753Smillert# Use switch; so given is a keyword 39*f2a19305Safresh1use feature 'switch'; no warnings 'deprecated'; 40850e2753Smillertgiven("okay\n") { print } 41850e2753SmillertEXPECT 42850e2753Smillertokay 43850e2753Smillert######## 44850e2753Smillert# Use switch; so when is a keyword 45*f2a19305Safresh1use feature 'switch'; no warnings 'deprecated'; 46850e2753Smillertgiven(1) { when(1) { print "okay" } } 47850e2753SmillertEXPECT 48850e2753Smillertokay 49850e2753Smillert######## 50850e2753Smillert# Use switch; so default is a keyword 51*f2a19305Safresh1use feature 'switch'; no warnings 'deprecated'; 52850e2753Smillertgiven(1) { default { print "okay" } } 53850e2753SmillertEXPECT 54850e2753Smillertokay 55850e2753Smillert######## 56850e2753Smillert# Use switch; so break is a keyword 57850e2753Smillertuse feature 'switch'; 58850e2753Smillertbreak; 59850e2753SmillertEXPECT 60850e2753SmillertCan't "break" outside a given block at - line 3. 61850e2753Smillert######## 62850e2753Smillert# switch out of scope; given should be a bareword. 63*f2a19305Safresh1use warnings; no warnings 'deprecated'; 64850e2753Smillert{ use feature 'switch'; 65850e2753Smillert given (1) {print "Okay here\n";} 66850e2753Smillert} 67850e2753Smillertprint STDOUT given; 68850e2753SmillertEXPECT 69850e2753SmillertUnquoted string "given" may clash with future reserved word at - line 6. 70850e2753SmillertOkay here 71850e2753Smillertgiven 72850e2753Smillert######## 73850e2753Smillert# switch out of scope; when should be a bareword. 74*f2a19305Safresh1use warnings; no warnings 'deprecated'; 75850e2753Smillert{ use feature 'switch'; 76850e2753Smillert given (1) { when(1) {print "Okay here\n";} } 77850e2753Smillert} 78850e2753Smillertprint STDOUT when; 79850e2753SmillertEXPECT 80850e2753SmillertUnquoted string "when" may clash with future reserved word at - line 6. 81850e2753SmillertOkay here 82850e2753Smillertwhen 83850e2753Smillert######## 84850e2753Smillert# switch out of scope; default should be a bareword. 85*f2a19305Safresh1use warnings; no warnings 'deprecated'; 86850e2753Smillert{ use feature 'switch'; 87850e2753Smillert given (1) { default {print "Okay here\n";} } 88850e2753Smillert} 89850e2753Smillertprint STDOUT default; 90850e2753SmillertEXPECT 91850e2753SmillertUnquoted string "default" may clash with future reserved word at - line 6. 92850e2753SmillertOkay here 93850e2753Smillertdefault 94850e2753Smillert######## 95850e2753Smillert# switch out of scope; break should be a bareword. 96*f2a19305Safresh1use warnings; no warnings 'deprecated'; 97850e2753Smillert{ use feature 'switch'; 98850e2753Smillert given (1) { break } 99850e2753Smillert} 100850e2753Smillertprint STDOUT break; 101850e2753SmillertEXPECT 102850e2753SmillertUnquoted string "break" may clash with future reserved word at - line 6. 103850e2753Smillertbreak 104850e2753Smillert######## 105850e2753Smillert# C<no feature 'switch'> should work 106*f2a19305Safresh1use warnings; no warnings 'deprecated'; 107850e2753Smillertuse feature 'switch'; 108850e2753Smillertgiven (1) { when(1) {print "Okay here\n";} } 109850e2753Smillertno feature 'switch'; 110850e2753Smillertprint STDOUT when; 111850e2753SmillertEXPECT 112850e2753SmillertUnquoted string "when" may clash with future reserved word at - line 6. 113850e2753SmillertOkay here 114850e2753Smillertwhen 115850e2753Smillert######## 116850e2753Smillert# C<no feature> should work too 117*f2a19305Safresh1use warnings; no warnings 'deprecated'; 118850e2753Smillertuse feature 'switch'; 119850e2753Smillertgiven (1) { when(1) {print "Okay here\n";} } 120850e2753Smillertno feature; 121850e2753Smillertprint STDOUT when; 122850e2753SmillertEXPECT 123850e2753SmillertUnquoted string "when" may clash with future reserved word at - line 6. 124850e2753SmillertOkay here 125850e2753Smillertwhen 126850e2753Smillert######## 127850e2753Smillert# Without the feature, no 'Unambiguous use of' warning: 128*f2a19305Safresh1use warnings; no warnings 'deprecated'; 129850e2753Smillert@break = ($break = "break"); 130850e2753Smillertprint ${break}, ${break[0]}; 131850e2753SmillertEXPECT 132850e2753Smillertbreakbreak 133850e2753Smillert######## 134850e2753Smillert# With the feature, we get an 'Unambiguous use of' warning: 135*f2a19305Safresh1use warnings; no warnings 'deprecated'; 136850e2753Smillertuse feature 'switch'; 137850e2753Smillert@break = ($break = "break"); 138850e2753Smillertprint ${break}, ${break[0]}; 139850e2753SmillertEXPECT 140850e2753SmillertAmbiguous use of ${break} resolved to $break at - line 5. 141850e2753SmillertAmbiguous use of ${break[...]} resolved to $break[...] at - line 5. 142850e2753Smillertbreakbreak 143