xref: /openbsd/gnu/usr.bin/perl/t/lib/feature/say (revision f2a19305)
1850e2753SmillertCheck the lexical scoping of the say keyword.
2850e2753Smillert(The actual behaviour is tested in t/op/say.t)
3850e2753Smillert
4850e2753Smillert__END__
5850e2753Smillert# No say; should be a syntax error.
6850e2753Smillertuse warnings;
7850e2753Smillertsay "Hello", "world";
8850e2753SmillertEXPECT
9850e2753SmillertUnquoted string "say" may clash with future reserved word at - line 3.
10*f2a19305Safresh1String found where operator expected (Do you need to predeclare "say"?) at - line 3, near "say "Hello""
11850e2753Smillertsyntax error at - line 3, near "say "Hello""
12850e2753SmillertExecution of - aborted due to compilation errors.
13850e2753Smillert########
14850e2753Smillert# With say, should work
15850e2753Smillertuse warnings;
16850e2753Smillertuse feature "say";
17850e2753Smillertsay "Hello", "world";
18850e2753SmillertEXPECT
19850e2753SmillertHelloworld
20850e2753Smillert########
21850e2753Smillert# With say, should work in eval too
22850e2753Smillertuse warnings;
23850e2753Smillertuse feature "say";
24850e2753Smillerteval q(say "Hello", "world");
25850e2753SmillertEXPECT
26850e2753SmillertHelloworld
27850e2753Smillert########
28850e2753Smillert# feature out of scope; should be a syntax error.
29850e2753Smillertuse warnings;
30850e2753Smillert{ use feature 'say'; }
31850e2753Smillertsay "Hello", "world";
32850e2753SmillertEXPECT
33850e2753SmillertUnquoted string "say" may clash with future reserved word at - line 4.
34*f2a19305Safresh1String found where operator expected (Do you need to predeclare "say"?) at - line 4, near "say "Hello""
35850e2753Smillertsyntax error at - line 4, near "say "Hello""
36850e2753SmillertExecution of - aborted due to compilation errors.
37850e2753Smillert########
38850e2753Smillert# 'no feature' should work
39850e2753Smillertuse warnings;
40850e2753Smillertuse feature 'say';
41850e2753Smillertsay "Hello", "world";
42850e2753Smillertno feature;
43850e2753Smillertsay "Hello", "world";
44850e2753SmillertEXPECT
45850e2753SmillertUnquoted string "say" may clash with future reserved word at - line 6.
46*f2a19305Safresh1String found where operator expected (Do you need to predeclare "say"?) at - line 6, near "say "Hello""
47850e2753Smillertsyntax error at - line 6, near "say "Hello""
48850e2753SmillertExecution of - aborted due to compilation errors.
49850e2753Smillert########
50850e2753Smillert# 'no feature "say"' should work too
51850e2753Smillertuse warnings;
52850e2753Smillertuse feature 'say';
53850e2753Smillertsay "Hello", "world";
54850e2753Smillertno feature 'say';
55850e2753Smillertsay "Hello", "world";
56850e2753SmillertEXPECT
57850e2753SmillertUnquoted string "say" may clash with future reserved word at - line 6.
58*f2a19305Safresh1String found where operator expected (Do you need to predeclare "say"?) at - line 6, near "say "Hello""
59850e2753Smillertsyntax error at - line 6, near "say "Hello""
60850e2753SmillertExecution of - aborted due to compilation errors.
61