This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
remove useless "default" mechanism
[perl5.git] / t / lib / feature / implicit
1 Check implicit loading of features with use VERSION.
2
3 __END__
4 # Standard feature bundle
5 use feature ":5.10";
6 say "Hello", "world";
7 EXPECT
8 Helloworld
9 ########
10 # VERSION requirement, dotted notation
11 use 5.9.5;
12 say "Hello", "world";
13 EXPECT
14 Helloworld
15 ########
16 # VERSION requirement, v-dotted notation
17 use v5.9.5;
18 say "Hello", "world";
19 EXPECT
20 Helloworld
21 ########
22 # VERSION requirement, decimal notation
23 use 5.009005;
24 say "Helloworld";
25 EXPECT
26 Helloworld
27 ########
28 # VERSION requirement, doesn't load anything with require
29 require 5.9.5;
30 print "<".$INC{"feature.pm"}.">\n";
31 EXPECT
32 <>
33 ########
34 # VERSION requirement in eval {}
35 eval {
36     use 5.9.5;
37     say "Hello", "world";
38 }
39 EXPECT
40 Helloworld
41 ########
42 # VERSION requirement in eval ""
43 eval q{
44     use 5.9.5;
45     say "Hello", "world";
46 }
47 EXPECT
48 Helloworld
49 ########
50 # VERSION requirement in BEGIN
51 BEGIN {
52     use 5.9.5;
53     say "Hello", "world";
54 }
55 EXPECT
56 Helloworld
57 ########
58 # no implicit features with 'no'
59 eval "no " . ($]+1); print $@;
60 EXPECT
61 ########
62 # lower version after higher version
63 sub evalbytes { print "evalbytes sub\n" }
64 sub say { print "say sub\n" }
65 use 5.015;
66 evalbytes "say 'yes'";
67 use 5.014;
68 evalbytes;
69 use 5;
70 say "no"
71 EXPECT
72 yes
73 evalbytes sub
74 say sub
75 ########
76 # No $[ under 5.15
77 # SKIP ? not defined DynaLoader::boot_DynaLoader
78 use v5.14;
79 no warnings 'deprecated';
80 $[ = 1;
81 print qw[a b c][2], "\n";
82 use v5.15;
83 print qw[a b c][2], "\n";
84 EXPECT
85 b
86 c
87 ########
88 # $[ under < 5.10
89 # SKIP ? not defined DynaLoader::boot_DynaLoader
90 use feature 'say'; # make sure it is loaded and modifies %^H; we are test-
91 use v5.8.8;        # ing to make sure it does not disable $[
92 no warnings 'deprecated';
93 $[ = 1;
94 print qw[a b c][2], "\n";
95 EXPECT
96 b
97 ########
98 # $[ under < 5.10 after use v5.15
99 # SKIP ? not defined DynaLoader::boot_DynaLoader
100 use v5.15;
101 use v5.8.8;
102 no warnings 'deprecated';
103 $[ = 1;
104 print qw[a b c][2], "\n";
105 EXPECT
106 b
107 ########
108 # Implicit unicode_string feature
109 use v5.14;
110 my $sharp_s = chr utf8::unicode_to_native(0xdf);
111 print 'ss' =~ /$sharp_s/i ? "ok\n" : "nok\n";
112 use v5.8.8;
113 print 'ss' =~ /$sharp_s/i ? "ok\n" : "nok\n";
114 EXPECT
115 ok
116 nok
117 ########
118 # Implicit unicode_eval feature
119 use v5.15;
120 require '../../t/charset_tools.pl';
121 my $long_s = byte_utf8a_to_utf8n("\xc5\xbf");
122 print eval "use utf8; q|$long_s|" eq $long_s ? "ok\n" : "nok\n";
123 use v5.8.8;
124 print eval "use utf8; q|$long_s|" eq "\x{17f}" ? "ok\n" : "nok\n";
125 EXPECT
126 ok
127 ok