This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
use VERSION needs to enable uni8bit hint
[perl5.git] / t / lib / feature / implicit
CommitLineData
7dfde25d
RGS
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;
033d875e 24say "Helloworld";
7dfde25d
RGS
25EXPECT
26Helloworld
27########
7dfde25d
RGS
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
e57ed4ec
FC
57########
58# no implicit features with 'no'
59eval "no " . ($]+1); print $@;
60EXPECT
b50b2058
FC
61########
62# lower version after higher version
63sub evalbytes { print "evalbytes sub\n" }
64sub say { print "say sub\n" }
65use 5.015;
66evalbytes "say 'yes'";
67use 5.014;
68evalbytes;
69use 5;
70say "no"
71EXPECT
72yes
73evalbytes sub
74say sub
7d69d4a6
FC
75########
76# No $[ under 5.15
77# SKIP ? not defined DynaLoader::boot_DynaLoader
78use v5.14;
79no warnings 'deprecated';
80$[ = 1;
81print qw[a b c][2], "\n";
82use v5.15;
83print qw[a b c][2], "\n";
84EXPECT
85b
86c
87########
88# $[ under < 5.10
89# SKIP ? not defined DynaLoader::boot_DynaLoader
90use feature 'say'; # make sure it is loaded and modifies %^H; we are test-
91use v5.8.8; # ing to make sure it does not disable $[
92no warnings 'deprecated';
93$[ = 1;
94print qw[a b c][2], "\n";
95EXPECT
96b
97########
98# $[ under < 5.10 after use v5.15
99# SKIP ? not defined DynaLoader::boot_DynaLoader
100use v5.15;
101use v5.8.8;
102no warnings 'deprecated';
103$[ = 1;
104print qw[a b c][2], "\n";
105EXPECT
106b
6389c777
FC
107########
108# Implicit unicode_string feature
109use v5.14;
110print 'ss' =~ /\xdf/i ? "ok\n" : "nok\n";
111use v5.8.8;
112print 'ss' =~ /\xdf/i ? "ok\n" : "nok\n";
113EXPECT
114ok
115nok