summaryrefslogtreecommitdiff
path: root/t/lib/feature/implicit
blob: 99ab01180e0ae6e76d6205725427d7f9be670833 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
Check implicit loading of features with use VERSION.

__END__
# Standard feature bundle
use feature ":5.10";
say "Hello", "world";
EXPECT
Helloworld
########
# VERSION requirement, dotted notation
use 5.9.5;
say "Hello", "world";
EXPECT
Helloworld
########
# VERSION requirement, v-dotted notation
use v5.9.5;
say "Hello", "world";
EXPECT
Helloworld
########
# VERSION requirement, decimal notation
use 5.009005;
say "Helloworld";
EXPECT
Helloworld
########
# VERSION requirement, doesn't load anything with require
require 5.9.5;
print "<".$INC{"feature.pm"}.">\n";
EXPECT
<>
########
# VERSION requirement in eval {}
eval {
    use 5.9.5;
    say "Hello", "world";
}
EXPECT
Helloworld
########
# VERSION requirement in eval ""
eval q{
    use 5.9.5;
    say "Hello", "world";
}
EXPECT
Helloworld
########
# VERSION requirement in BEGIN
BEGIN {
    use 5.9.5;
    say "Hello", "world";
}
EXPECT
Helloworld
########
# no implicit features with 'no'
eval "no " . ($]+1); print $@;
EXPECT
########
# lower version after higher version
sub evalbytes { print "evalbytes sub\n" }
sub say { print "say sub\n" }
use 5.015;
evalbytes "say 'yes'";
use 5.014;
evalbytes;
use 5;
say "no"
EXPECT
yes
evalbytes sub
say sub
########
# No $[ under 5.15
# SKIP ? not defined DynaLoader::boot_DynaLoader
use v5.14;
no warnings 'deprecated';
$[ = 1;
print qw[a b c][2], "\n";
use v5.15;
print qw[a b c][2], "\n";
EXPECT
b
c
########
# $[ under < 5.10
# SKIP ? not defined DynaLoader::boot_DynaLoader
use feature 'say'; # make sure it is loaded and modifies %^H; we are test-
use v5.8.8;        # ing to make sure it does not disable $[
no warnings 'deprecated';
$[ = 1;
print qw[a b c][2], "\n";
EXPECT
b
########
# $[ under < 5.10 after use v5.15
# SKIP ? not defined DynaLoader::boot_DynaLoader
use v5.15;
use v5.8.8;
no warnings 'deprecated';
$[ = 1;
print qw[a b c][2], "\n";
EXPECT
b
########
# Implicit unicode_string feature
use v5.14;
my $sharp_s = chr utf8::unicode_to_native(0xdf);
print 'ss' =~ /$sharp_s/i ? "ok\n" : "nok\n";
use v5.8.8;
print 'ss' =~ /$sharp_s/i ? "ok\n" : "nok\n";
EXPECT
ok
nok
########
# Implicit unicode_eval feature
use v5.15;
print eval "use utf8; q|\xc5\xbf|" eq "\xc5\xbf" ? "ok\n" : "nok\n";
use v5.8.8;
print eval "use utf8; q|\xc5\xbf|" eq "\x{17f}" ? "ok\n" : "nok\n";
EXPECT
ok
ok