This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
change "when" keyword to "whereso"
[perl5.git] / t / lib / feature / bundle
CommitLineData
82cfb3a2
S
1Check feature bundles.
2
3__END__
4# Standard feature bundle
5use feature ":5.10";
6say "Hello", "world";
7EXPECT
8Helloworld
9########
1863b879
RGS
10# Standard feature bundle, no 5.11
11use feature ":5.10";
b9887820 12say utf8::native_to_unicode(ord uc chr utf8::unicode_to_native(233));
1863b879
RGS
13EXPECT
14233
15########
16# Standard feature bundle, 5.11
17use feature ":5.11";
b9887820 18say utf8::native_to_unicode(ord uc chr utf8::unicode_to_native(233));
1863b879
RGS
19EXPECT
20201
21########
22# Standard feature bundle, 5.11
23use feature ":5.11";
24use utf8;
b9887820 25say utf8::native_to_unicode(ord "\ué"); # this is utf8
1863b879
RGS
26EXPECT
27201
28########
82cfb3a2
S
29# more specific: 5.10.0 maps to 5.10
30use feature ":5.10.0";
31say "Hello", "world";
32EXPECT
33Helloworld
34########
35# as does 5.10.1
36use feature ":5.10.1";
37say "Hello", "world";
38EXPECT
39Helloworld
40########
41# as does 5.10.99
42use feature ":5.10.99";
43say "Hello", "world";
44EXPECT
45Helloworld
46########
47# 5.9.5 also supported
48use feature ":5.9.5";
49say "Hello", "world";
50EXPECT
51Helloworld
52########
53# 5.9 not supported
54use feature ":5.9";
55EXPECT
56OPTIONS regex
57^Feature bundle "5.9" is not supported by Perl \d+\.\d+\.\d+ at - line \d+
58########
59# 5.9.4 not supported
60use feature ":5.9.4";
61EXPECT
62OPTIONS regex
63^Feature bundle "5.9.4" is not supported by Perl \d+\.\d+\.\d+ at - line \d+
64########
65# 5.8.8 not supported
66use feature ":5.8.8";
67EXPECT
68OPTIONS regex
69^Feature bundle "5.8.8" is not supported by Perl \d+\.\d+\.\d+ at - line \d+
4a4443f2
FC
70########
71# :default
72BEGIN { *say = *state = *given = sub { print "custom sub\n" }; }
73use feature ":default";
74say "yes";
75state my $foo;
76given a => chance;
77EXPECT
78custom sub
79custom sub
80custom sub
7d69d4a6
FC
81########
82# :default and $[
83# SKIP ? not defined DynaLoader::boot_DynaLoader
84no feature;
85use feature ":default";
86$[ = 1;
87print qw[a b c][2], "\n";
39ec54a5 88use feature ":5.16"; # should not disable anything; no feature ':all' does that
7d69d4a6 89print qw[a b c][2], "\n";
39ec54a5 90no feature ':all';
7d69d4a6
FC
91print qw[a b c][2], "\n";
92use feature ":5.16";
93print qw[a b c][2], "\n";
94EXPECT
95Use of assignment to $[ is deprecated at - line 4.
96b
97b
98c
99c
39ec54a5
RS
100########
101# "no feature"
102use feature ':5.16'; # turns array_base off
103no feature; # resets to :default, thus turns array_base on
104$[ = 1;
105print qw[a b c][2], "\n";
106EXPECT
107Use of assignment to $[ is deprecated at - line 4.
108b
109########
110# "no feature 'all"
111$[ = 1;
112print qw[a b c][2], "\n";
113no feature ':all'; # turns array_base (and everything else) off
114$[ = 1;
115print qw[a b c][2], "\n";
116EXPECT
117Use of assignment to $[ is deprecated at - line 2.
118Assigning non-zero to $[ is no longer possible at - line 5.
119b
71622e40
FC
120########
121# NAME $^H accidentally enabling all features
122eval 'BEGIN { $^H |= 0x1c020000 } $_ = evalbytes 12345';
123print $_||$@;
124EXPECT
125Number found where operator expected at (eval 1) line 1, near "evalbytes 12345"
126 (Do you need to predeclare evalbytes?)
127syntax error at (eval 1) line 1, near "evalbytes 12345"