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