xref: /openbsd-src/gnu/usr.bin/perl/t/lib/feature/say (revision f2a19305cfc49ea4d1a5feb55cd6c283c6f1e031)
1Check the lexical scoping of the say keyword.
2(The actual behaviour is tested in t/op/say.t)
3
4__END__
5# No say; should be a syntax error.
6use warnings;
7say "Hello", "world";
8EXPECT
9Unquoted string "say" may clash with future reserved word at - line 3.
10String found where operator expected (Do you need to predeclare "say"?) at - line 3, near "say "Hello""
11syntax error at - line 3, near "say "Hello""
12Execution of - aborted due to compilation errors.
13########
14# With say, should work
15use warnings;
16use feature "say";
17say "Hello", "world";
18EXPECT
19Helloworld
20########
21# With say, should work in eval too
22use warnings;
23use feature "say";
24eval q(say "Hello", "world");
25EXPECT
26Helloworld
27########
28# feature out of scope; should be a syntax error.
29use warnings;
30{ use feature 'say'; }
31say "Hello", "world";
32EXPECT
33Unquoted string "say" may clash with future reserved word at - line 4.
34String found where operator expected (Do you need to predeclare "say"?) at - line 4, near "say "Hello""
35syntax error at - line 4, near "say "Hello""
36Execution of - aborted due to compilation errors.
37########
38# 'no feature' should work
39use warnings;
40use feature 'say';
41say "Hello", "world";
42no feature;
43say "Hello", "world";
44EXPECT
45Unquoted string "say" may clash with future reserved word at - line 6.
46String found where operator expected (Do you need to predeclare "say"?) at - line 6, near "say "Hello""
47syntax error at - line 6, near "say "Hello""
48Execution of - aborted due to compilation errors.
49########
50# 'no feature "say"' should work too
51use warnings;
52use feature 'say';
53say "Hello", "world";
54no feature 'say';
55say "Hello", "world";
56EXPECT
57Unquoted string "say" may clash with future reserved word at - line 6.
58String found where operator expected (Do you need to predeclare "say"?) at - line 6, near "say "Hello""
59syntax error at - line 6, near "say "Hello""
60Execution of - aborted due to compilation errors.
61