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
|
Check feature bundles.
__END__
# Standard feature bundle
use feature ":5.10";
say "Hello", "world";
EXPECT
Helloworld
########
# Standard feature bundle, no 5.11
use feature ":5.10";
say ord uc chr 233;
EXPECT
233
########
# Standard feature bundle, 5.11
use feature ":5.11";
say ord uc chr 233;
EXPECT
201
########
# Standard feature bundle, 5.11
use feature ":5.11";
use utf8;
say ord "\ué"; # this is utf8
EXPECT
201
########
# more specific: 5.10.0 maps to 5.10
use feature ":5.10.0";
say "Hello", "world";
EXPECT
Helloworld
########
# as does 5.10.1
use feature ":5.10.1";
say "Hello", "world";
EXPECT
Helloworld
########
# as does 5.10.99
use feature ":5.10.99";
say "Hello", "world";
EXPECT
Helloworld
########
# 5.9.5 also supported
use feature ":5.9.5";
say "Hello", "world";
EXPECT
Helloworld
########
# 5.9 not supported
use feature ":5.9";
EXPECT
OPTIONS regex
^Feature bundle "5.9" is not supported by Perl \d+\.\d+\.\d+ at - line \d+
########
# 5.9.4 not supported
use feature ":5.9.4";
EXPECT
OPTIONS regex
^Feature bundle "5.9.4" is not supported by Perl \d+\.\d+\.\d+ at - line \d+
########
# 5.8.8 not supported
use feature ":5.8.8";
EXPECT
OPTIONS regex
^Feature bundle "5.8.8" is not supported by Perl \d+\.\d+\.\d+ at - line \d+
########
# :default
BEGIN { *say = *state = *given = sub { print "custom sub\n" }; }
use feature ":default";
say "yes";
state my $foo;
given a => chance;
EXPECT
custom sub
custom sub
custom sub
########
# :default and $[
# SKIP ? not defined DynaLoader::boot_DynaLoader
no feature;
use feature ":default";
$[ = 1;
print qw[a b c][2], "\n";
use feature ":5.16"; # should not disable anything; no feature ':all' does that
print qw[a b c][2], "\n";
no feature ':all';
print qw[a b c][2], "\n";
use feature ":5.16";
print qw[a b c][2], "\n";
EXPECT
Use of assignment to $[ is deprecated at - line 4.
b
b
c
c
########
# "no feature"
use feature ':5.16'; # turns array_base off
no feature; # resets to :default, thus turns array_base on
$[ = 1;
print qw[a b c][2], "\n";
EXPECT
Use of assignment to $[ is deprecated at - line 4.
b
########
# "no feature 'all"
$[ = 1;
print qw[a b c][2], "\n";
no feature ':all'; # turns array_base (and everything else) off
$[ = 1;
print qw[a b c][2], "\n";
EXPECT
Use of assignment to $[ is deprecated at - line 2.
Assigning non-zero to $[ is no longer possible at - line 5.
b
########
# NAME $^H accidentally enabling all features
eval 'BEGIN { $^H |= 0x1c020000 } $_ = evalbytes 12345';
print $_||$@;
EXPECT
Number found where operator expected at (eval 1) line 1, near "evalbytes 12345"
(Do you need to predeclare evalbytes?)
syntax error at (eval 1) line 1, near "evalbytes 12345"
|