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; 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; 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; 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; 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 36syntax error at - line 2, near "STDOUT continue" 37Execution of - aborted due to compilation errors. 38######## 39# Use switch; so given is a keyword 40use feature 'switch'; 41given("okay\n") { print } 42EXPECT 43okay 44######## 45# Use switch; so when is a keyword 46use feature 'switch'; 47given(1) { when(1) { print "okay" } } 48EXPECT 49okay 50######## 51# Use switch; so default is a keyword 52use feature 'switch'; 53given(1) { default { print "okay" } } 54EXPECT 55okay 56######## 57# Use switch; so break is a keyword 58use feature 'switch'; 59break; 60EXPECT 61Can't "break" outside a given block at - line 3. 62######## 63# Use switch; so continue is a keyword 64use feature 'switch'; 65continue; 66EXPECT 67Can't "continue" outside a when block at - line 3. 68######## 69# switch out of scope; given should be a bareword. 70use warnings; 71{ use feature 'switch'; 72 given (1) {print "Okay here\n";} 73} 74print STDOUT given; 75EXPECT 76Unquoted string "given" may clash with future reserved word at - line 6. 77Okay here 78given 79######## 80# switch out of scope; when should be a bareword. 81use warnings; 82{ use feature 'switch'; 83 given (1) { when(1) {print "Okay here\n";} } 84} 85print STDOUT when; 86EXPECT 87Unquoted string "when" may clash with future reserved word at - line 6. 88Okay here 89when 90######## 91# switch out of scope; default should be a bareword. 92use warnings; 93{ use feature 'switch'; 94 given (1) { default {print "Okay here\n";} } 95} 96print STDOUT default; 97EXPECT 98Unquoted string "default" may clash with future reserved word at - line 6. 99Okay here 100default 101######## 102# switch out of scope; break should be a bareword. 103use warnings; 104{ use feature 'switch'; 105 given (1) { break } 106} 107print STDOUT break; 108EXPECT 109Unquoted string "break" may clash with future reserved word at - line 6. 110break 111######## 112# switch out of scope; continue should not work 113{ use feature 'switch'; 114 given (1) { default {continue} } 115} 116print STDOUT continue; 117EXPECT 118syntax error at - line 5, near "STDOUT continue" 119Execution of - aborted due to compilation errors. 120######## 121# C<no feature 'switch'> should work 122use warnings; 123use feature 'switch'; 124given (1) { when(1) {print "Okay here\n";} } 125no feature 'switch'; 126print STDOUT when; 127EXPECT 128Unquoted string "when" may clash with future reserved word at - line 6. 129Okay here 130when 131######## 132# C<no feature> should work too 133use warnings; 134use feature 'switch'; 135given (1) { when(1) {print "Okay here\n";} } 136no feature; 137print STDOUT when; 138EXPECT 139Unquoted string "when" may clash with future reserved word at - line 6. 140Okay here 141when 142######## 143# Without the feature, no 'Unambiguous use of' warning: 144use warnings; 145@break = ($break = "break"); 146print ${break}, ${break[0]}; 147EXPECT 148breakbreak 149######## 150# With the feature, we get an 'Unambiguous use of' warning: 151use warnings; 152use feature 'switch'; 153@break = ($break = "break"); 154print ${break}, ${break[0]}; 155EXPECT 156Ambiguous use of ${break} resolved to $break at - line 5. 157Ambiguous use of ${break[...]} resolved to $break[...] at - line 5. 158breakbreak 159