xref: /openbsd/gnu/usr.bin/perl/t/lib/feature/implicit (revision 3d61058a)
1Check implicit loading of features with use VERSION.
2
3__END__
4# Standard feature bundle
5use feature ":5.10";
6say "Hello", "world";
7EXPECT
8Helloworld
9########
10# VERSION requirement, dotted notation
11use 5.9.5;
12say "Hello", "world";
13EXPECT
14Helloworld
15########
16# VERSION requirement, v-dotted notation
17use v5.9.5;
18say "Hello", "world";
19EXPECT
20Helloworld
21########
22# VERSION requirement, decimal notation
23use 5.009005;
24say "Helloworld";
25EXPECT
26Helloworld
27########
28# VERSION requirement, doesn't load anything with require
29require 5.9.5;
30print "<".$INC{"feature.pm"}.">\n";
31EXPECT
32<>
33########
34# VERSION requirement in eval {}
35eval {
36    use 5.9.5;
37    say "Hello", "world";
38}
39EXPECT
40Helloworld
41########
42# VERSION requirement in eval ""
43eval q{
44    use 5.9.5;
45    say "Hello", "world";
46}
47EXPECT
48Helloworld
49########
50# VERSION requirement in BEGIN
51BEGIN {
52    use 5.9.5;
53    say "Hello", "world";
54}
55EXPECT
56Helloworld
57########
58# no implicit features with 'no'
59eval "no " . ($]+1); print $@;
60EXPECT
61########
62# lower version after higher version
63sub evalbytes { print "evalbytes sub\n" }
64sub say { print "say sub\n" }
65use 5;
66say "no";
67use 5.015;
68evalbytes "say 'yes'";
69use 5.014;
70evalbytes;
71EXPECT
72Changing use VERSION while another use VERSION is in scope is deprecated, and will become fatal in Perl 5.44 at - line 8.
73say sub
74yes
75evalbytes sub
76########
77# Implicit unicode_string feature
78use v5.10;
79my $sharp_s = chr utf8::unicode_to_native(0xdf);
80print 'ss' =~ /$sharp_s/i ? "ok\n" : "nok\n";
81use v5.14;
82print 'ss' =~ /$sharp_s/i ? "ok\n" : "nok\n";
83EXPECT
84Changing use VERSION while another use VERSION is in scope is deprecated, and will become fatal in Perl 5.44 at - line 5.
85nok
86ok
87########
88# Implicit unicode_eval feature
89require '../../t/charset_tools.pl';
90my $long_s = byte_utf8a_to_utf8n("\xc5\xbf");
91use v5.10;
92print eval "use utf8; q|$long_s|" eq "\x{17f}" ? "ok\n" : "nok\n";
93use v5.15;
94print eval "use utf8; q|$long_s|" eq $long_s ? "ok\n" : "nok\n";
95EXPECT
96Changing use VERSION while another use VERSION is in scope is deprecated, and will become fatal in Perl 5.44 at - line 6.
97ok
98ok
99