1Test no feature indirect.
2
3__END__
4# NAME feature indirect
5use feature 'say';
6package Foo {
7  sub new { bless {}, shift }
8}
9# various indirect object look-alikes
10my $foox = "foox";
11print STDERR "Hello\n";
12printf STDERR "Test%s\n", "x";
13say STDERR "Hello";
14exec $foox "foo", "bar";
15system $foox "foo", "bar";
16my $x = new Foo;
17no feature "indirect";
18print STDERR "Hello\n";
19printf STDERR "Test%s\n", "x";
20say STDERR "Hello";
21exec $foox "foo", "bar";
22system $foox "foo", "bar";
23my $y = new Foo;
24EXPECT
25OPTIONS fatal
26Bareword found where operator expected at - line 19, near "new Foo"
27	(Do you need to predeclare new?)
28syntax error at - line 19, near "new Foo"
29Execution of - aborted due to compilation errors.
30########
31# NAME METHOD BLOCK
32use feature 'say';
33package Foo {
34  sub new { bless {}, shift }
35}
36# make sure this works (either way)
37my $st = STDOUT;
38print { $st } "Foo\n";
39say { $st } "Foo";
40
41# make sure this continues to work by default
42my $class = "Foo";
43my $x = new { $class };
44
45use feature "indirect";
46
47# and with it explicitly enabled
48
49print { $st } "Foo\n";
50say { $st } "Foo";
51
52my $y = new { $class };
53
54
55no feature "indirect";
56
57# and only the indirect now fails
58print { $st } "Foo\n";
59say { $st } "Foo";
60my $z = new { $class };
61
62EXPECT
63OPTIONS fatal
64syntax error at - line 29, near "new { "
65Execution of - aborted due to compilation errors.
66########
67# NAME METHOD SCALAR
68use feature 'say';
69package Foo {
70  sub new { bless {}, shift }
71}
72# make sure this works (either way)
73my $st = STDOUT;
74print $st "Foo\n";
75say $st "Foo";
76
77# make sure this continues to work by default
78my $class = "Foo";
79my $x = new $class;
80
81use feature "indirect";
82
83# and with it explicitly enabled
84
85print $st "Foo\n";
86say $st "Foo";
87
88my $y = new $class;
89
90
91no feature "indirect";
92
93# and only the indirect now fails
94print $st "Foo\n";
95say $st "Foo";
96my $z = new $class;
97
98EXPECT
99OPTIONS fatal
100Scalar found where operator expected at - line 29, near "new $class"
101	(Do you need to predeclare new?)
102syntax error at - line 29, near "new $class"
103Execution of - aborted due to compilation errors.
104########
105# NAME FUNCMETH SCALAR
106use feature 'say';
107package Foo {
108  sub new { bless {}, shift }
109}
110# make sure this works (either way)
111my $st = STDOUT;
112print $st ("Foo\n");
113say $st ("Foo");
114
115# make sure this continues to work by default
116my $class = "Foo";
117my $x = new $class ();
118
119use feature "indirect";
120
121# and with it explicitly enabled
122
123print $st ("Foo\n");
124say $st ("Foo");
125
126my $y = new $class ();
127
128
129no feature "indirect";
130
131# and only the indirect now fails
132print $st ("Foo\n");
133say $st ("Foo");
134my $z = new $class ();
135
136EXPECT
137OPTIONS fatal
138Scalar found where operator expected at - line 29, near "new $class"
139	(Do you need to predeclare new?)
140syntax error at - line 29, near "new $class "
141Execution of - aborted due to compilation errors.
142