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