xref: /openbsd-src/gnu/usr.bin/perl/t/lib/feature/bundle (revision e068048151d29f2562a32185e21a8ba885482260)
143003dfeSmillertCheck feature bundles.
243003dfeSmillert
343003dfeSmillert__END__
443003dfeSmillert# Standard feature bundle
543003dfeSmillertuse feature ":5.10";
643003dfeSmillertsay "Hello", "world";
743003dfeSmillertEXPECT
843003dfeSmillertHelloworld
943003dfeSmillert########
10b39c5158Smillert# Standard feature bundle, no 5.11
11b39c5158Smillertuse feature ":5.10";
12b8851fccSafresh1say utf8::native_to_unicode(ord uc chr utf8::unicode_to_native(233));
13b39c5158SmillertEXPECT
14b39c5158Smillert233
15b39c5158Smillert########
16b39c5158Smillert# Standard feature bundle, 5.11
17b39c5158Smillertuse feature ":5.11";
18b8851fccSafresh1say utf8::native_to_unicode(ord uc chr utf8::unicode_to_native(233));
19b39c5158SmillertEXPECT
20b39c5158Smillert201
21b39c5158Smillert########
22b39c5158Smillert# Standard feature bundle, 5.11
23b39c5158Smillertuse feature ":5.11";
24b39c5158Smillertuse utf8;
25b8851fccSafresh1say utf8::native_to_unicode(ord "\ué"); # this is utf8
26b39c5158SmillertEXPECT
27b39c5158Smillert201
28b39c5158Smillert########
2943003dfeSmillert# more specific: 5.10.0 maps to 5.10
3043003dfeSmillertuse feature ":5.10.0";
3143003dfeSmillertsay "Hello", "world";
3243003dfeSmillertEXPECT
3343003dfeSmillertHelloworld
3443003dfeSmillert########
3543003dfeSmillert# as does 5.10.1
3643003dfeSmillertuse feature ":5.10.1";
3743003dfeSmillertsay "Hello", "world";
3843003dfeSmillertEXPECT
3943003dfeSmillertHelloworld
4043003dfeSmillert########
4143003dfeSmillert# as does 5.10.99
4243003dfeSmillertuse feature ":5.10.99";
4343003dfeSmillertsay "Hello", "world";
4443003dfeSmillertEXPECT
4543003dfeSmillertHelloworld
4643003dfeSmillert########
4743003dfeSmillert# 5.9.5 also supported
4843003dfeSmillertuse feature ":5.9.5";
4943003dfeSmillertsay "Hello", "world";
5043003dfeSmillertEXPECT
5143003dfeSmillertHelloworld
5243003dfeSmillert########
5343003dfeSmillert# 5.9 not supported
5443003dfeSmillertuse feature ":5.9";
5543003dfeSmillertEXPECT
5643003dfeSmillertOPTIONS regex
5743003dfeSmillert^Feature bundle "5.9" is not supported by Perl \d+\.\d+\.\d+ at - line \d+
5843003dfeSmillert########
5943003dfeSmillert# 5.9.4 not supported
6043003dfeSmillertuse feature ":5.9.4";
6143003dfeSmillertEXPECT
6243003dfeSmillertOPTIONS regex
6343003dfeSmillert^Feature bundle "5.9.4" is not supported by Perl \d+\.\d+\.\d+ at - line \d+
6443003dfeSmillert########
6543003dfeSmillert# 5.8.8 not supported
6643003dfeSmillertuse feature ":5.8.8";
6743003dfeSmillertEXPECT
6843003dfeSmillertOPTIONS regex
6943003dfeSmillert^Feature bundle "5.8.8" is not supported by Perl \d+\.\d+\.\d+ at - line \d+
70898184e3Ssthen########
71898184e3Ssthen# :default
72898184e3SsthenBEGIN { *say = *state = *given = sub { print "custom sub\n" }; }
73898184e3Ssthenuse feature ":default";
74898184e3Ssthensay "yes";
75898184e3Ssthenstate my $foo;
76898184e3Ssthengiven a => chance;
77898184e3SsthenEXPECT
78898184e3Ssthencustom sub
79898184e3Ssthencustom sub
80898184e3Ssthencustom sub
81898184e3Ssthen########
82898184e3Ssthen# :default and $[
83898184e3Ssthen# SKIP ? not defined DynaLoader::boot_DynaLoader
84898184e3Ssthenno feature;
85898184e3Ssthenuse feature ":default";
86b46d8ef2Safresh1$[ = 0;
87898184e3Ssthen$[ = 1;
88898184e3SsthenEXPECT
89b46d8ef2Safresh1Assigning non-zero to $[ is no longer possible at - line 5.
90898184e3Ssthen########
91898184e3Ssthen# "no feature"
92898184e3Ssthenuse feature ':5.16'; # turns array_base off
93b46d8ef2Safresh1no feature; # resets to :default, thus would turn array_base on, if it still existed
94b46d8ef2Safresh1$[ = 0;
95898184e3Ssthen$[ = 1;
96898184e3SsthenEXPECT
97b46d8ef2Safresh1Assigning non-zero to $[ is no longer possible at - line 5.
98898184e3Ssthen########
99898184e3Ssthen# "no feature 'all"
100898184e3Ssthenno feature ':all'; # turns array_base (and everything else) off
101898184e3Ssthen$[ = 1;
102898184e3SsthenEXPECT
103b46d8ef2Safresh1Assigning non-zero to $[ is no longer possible at - line 3.
104fb8aa749Safresh1########
105fb8aa749Safresh1# NAME $^H accidentally enabling all features
106*e0680481Safresh1# HINT_FEATURE_MASK | HINT_LOCALIZE_HH
107*e0680481Safresh1eval 'BEGIN { $^H |= 0x3c020000 } $_ = evalbytes 12345';
108fb8aa749Safresh1print $_||$@;
109fb8aa749Safresh1EXPECT
110*e0680481Safresh1Number found where operator expected (Do you need to predeclare "evalbytes"?) at (eval 1) line 1, near "evalbytes 12345"
111fb8aa749Safresh1syntax error at (eval 1) line 1, near "evalbytes 12345"
112*e0680481Safresh1Execution of (eval 1) aborted due to compilation errors.
113