xref: /openbsd/gnu/usr.bin/perl/t/lib/feature/bundle (revision 73471bf0)
1Check feature bundles.
2
3__END__
4# Standard feature bundle
5use feature ":5.10";
6say "Hello", "world";
7EXPECT
8Helloworld
9########
10# Standard feature bundle, no 5.11
11use feature ":5.10";
12say utf8::native_to_unicode(ord uc chr utf8::unicode_to_native(233));
13EXPECT
14233
15########
16# Standard feature bundle, 5.11
17use feature ":5.11";
18say utf8::native_to_unicode(ord uc chr utf8::unicode_to_native(233));
19EXPECT
20201
21########
22# Standard feature bundle, 5.11
23use feature ":5.11";
24use utf8;
25say utf8::native_to_unicode(ord "\ué"); # this is utf8
26EXPECT
27201
28########
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+
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
81########
82# :default and $[
83# SKIP ? not defined DynaLoader::boot_DynaLoader
84no feature;
85use feature ":default";
86$[ = 0;
87$[ = 1;
88EXPECT
89Assigning non-zero to $[ is no longer possible at - line 5.
90########
91# "no feature"
92use feature ':5.16'; # turns array_base off
93no feature; # resets to :default, thus would turn array_base on, if it still existed
94$[ = 0;
95$[ = 1;
96EXPECT
97Assigning non-zero to $[ is no longer possible at - line 5.
98########
99# "no feature 'all"
100no feature ':all'; # turns array_base (and everything else) off
101$[ = 1;
102EXPECT
103Assigning non-zero to $[ is no longer possible at - line 3.
104########
105# NAME $^H accidentally enabling all features
106eval 'BEGIN { $^H |= 0x1c020000 } $_ = evalbytes 12345';
107print $_||$@;
108EXPECT
109Number found where operator expected at (eval 1) line 1, near "evalbytes 12345"
110	(Do you need to predeclare evalbytes?)
111syntax error at (eval 1) line 1, near "evalbytes 12345"
112