This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Fix bug 36267 - assigning to a tied hash shouldn't change the
[perl5.git] / t / comp / use.t
CommitLineData
8ebc5c01 1#!./perl
2
3BEGIN {
4 chdir 't' if -d 't';
20822f61 5 @INC = '../lib';
8ebc5c01 6}
7
468aa647 8print "1..31\n";
8ebc5c01 9
10my $i = 1;
9f3d182e
GS
11eval "use 5.000"; # implicit semicolon
12if ($@) {
13 print STDERR $@,"\n";
14 print "not ";
15}
16print "ok ",$i++,"\n";
8ebc5c01 17
18eval "use 5.000;";
19if ($@) {
20 print STDERR $@,"\n";
21 print "not ";
22}
23print "ok ",$i++,"\n";
24
468aa647
RGS
25eval "use 6.000;";
26unless ($@ =~ /Perl v6\.0\.0 required--this is only \Q$^V\E, stopped/) {
27 print "not ";
28}
29print "ok ",$i++,"\n";
30
31eval "no 6.000;";
32if ($@) {
33 print STDERR $@,"\n";
34 print "not ";
35}
36print "ok ",$i++,"\n";
37
38eval "no 5.000;";
39unless ($@ =~ /Perls since v5\.0\.0 too modern--this is \Q$^V\E, stopped/) {
40 print "not ";
41}
42print "ok ",$i++,"\n";
43
6d2c9499 44eval sprintf "use %.6f;", $];
8ebc5c01 45if ($@) {
46 print STDERR $@,"\n";
47 print "not ";
48}
49print "ok ",$i++,"\n";
50
51
6d2c9499 52eval sprintf "use %.6f;", $] - 0.000001;
8ebc5c01 53if ($@) {
54 print STDERR $@,"\n";
55 print "not ";
56}
57print "ok ",$i++,"\n";
58
6d2c9499 59eval sprintf("use %.6f;", $] + 1);
8ebc5c01 60unless ($@) {
61 print "not ";
62}
63print "ok ",$i++,"\n";
64
6d2c9499 65eval sprintf "use %.6f;", $] + 0.00001;
8ebc5c01 66unless ($@) {
67 print "not ";
68}
69print "ok ",$i++,"\n";
70
71
18b09519 72{ use lib } # check that subparse saves pending tokens
8ebc5c01 73
74local $lib::VERSION = 1.0;
75
76eval "use lib 0.9";
77if ($@) {
78 print STDERR $@,"\n";
79 print "not ";
80}
81print "ok ",$i++,"\n";
82
83eval "use lib 1.0";
84if ($@) {
85 print STDERR $@,"\n";
86 print "not ";
87}
88print "ok ",$i++,"\n";
89
90eval "use lib 1.01";
91unless ($@) {
92 print "not ";
93}
94print "ok ",$i++,"\n";
95
96
97eval "use lib 0.9 qw(fred)";
98if ($@) {
99 print STDERR $@,"\n";
100 print "not ";
101}
102print "ok ",$i++,"\n";
103
d5201bd2 104print "not " unless ($INC[0] eq "fred" || ($^O eq 'MacOS' && $INC[0] eq ":fred:"));
8ebc5c01 105print "ok ",$i++,"\n";
106
107eval "use lib 1.0 qw(joe)";
108if ($@) {
109 print STDERR $@,"\n";
110 print "not ";
111}
112print "ok ",$i++,"\n";
113
d5201bd2 114print "not " unless ($INC[0] eq "joe" || ($^O eq 'MacOS' && $INC[0] eq ":joe:"));
8ebc5c01 115print "ok ",$i++,"\n";
116
117eval "use lib 1.01 qw(freda)";
118unless ($@) {
119 print "not ";
120}
121print "ok ",$i++,"\n";
122
d5201bd2 123print "not " if ($INC[0] eq "freda" || ($^O eq 'MacOS' && $INC[0] eq ":freda:"));
8ebc5c01 124print "ok ",$i++,"\n";
1571675a
GS
125
126{
127 local $lib::VERSION = 35.36;
128 eval "use lib v33.55";
129 print "not " if $@;
130 print "ok ",$i++,"\n";
131
132 eval "use lib v100.105";
9137345a 133 unless ($@ =~ /lib version 100.105 \(v100\.105\.0\) required--this is only version 35.360 \(v35\.360\.0\)/) {
1571675a
GS
134 print "not ";
135 }
136 print "ok ",$i++,"\n";
137
138 eval "use lib 33.55";
139 print "not " if $@;
140 print "ok ",$i++,"\n";
141
142 eval "use lib 100.105";
9137345a 143 unless ($@ =~ /lib version 100.105 \(v100\.105\.0\) required--this is only version 35.360 \(v35\.360\.0\)/) {
1571675a
GS
144 print "not ";
145 }
146 print "ok ",$i++,"\n";
147
148 local $lib::VERSION = '35.36';
149 eval "use lib v33.55";
150 print "not " if $@;
151 print "ok ",$i++,"\n";
152
153 eval "use lib v100.105";
9137345a 154 unless ($@ =~ /lib version 100.105 \(v100\.105\.0\) required--this is only version 35.360 \(v35\.360\.0\)/) {
1571675a
GS
155 print "not ";
156 }
157 print "ok ",$i++,"\n";
158
159 eval "use lib 33.55";
160 print "not " if $@;
161 print "ok ",$i++,"\n";
162
163 eval "use lib 100.105";
9137345a 164 unless ($@ =~ /lib version 100.105 \(v100\.105\.0\) required--this is only version 35.360 \(v35\.360\.0\)/) {
1571675a
GS
165 print "not ";
166 }
167 print "ok ",$i++,"\n";
168
169 local $lib::VERSION = v35.36;
170 eval "use lib v33.55";
171 print "not " if $@;
172 print "ok ",$i++,"\n";
173
174 eval "use lib v100.105";
e0218a61 175 unless ($@ =~ /lib version 100.105 \(v100\.105\.0\) required--this is only version 35.036000 \(v35\.36\.0\)/) {
1571675a
GS
176 print "not ";
177 }
178 print "ok ",$i++,"\n";
179
180 eval "use lib 33.55";
181 print "not " if $@;
182 print "ok ",$i++,"\n";
183
184 eval "use lib 100.105";
e0218a61 185 unless ($@ =~ /lib version 100.105 \(v100\.105\.0\) required--this is only version 35.036000 \(v35\.36\.0\)/) {
1571675a
GS
186 print "not ";
187 }
188 print "ok ",$i++,"\n";
189}
8312d5ee
PM
190
191
192{
193 # Regression test for patch 14937:
194 # Check that a .pm file with no package or VERSION doesn't core.
195 open F, ">xxx.pm" or die "Cannot open xxx.pm: $!\n";
196 print F "1;\n";
197 close F;
198 eval "use lib '.'; use xxx 3;";
199 unless ($@ =~ /^xxx defines neither package nor VERSION--version check failed at/) {
200 print "not ";
201 }
202 print "ok ",$i++,"\n";
203 unlink 'xxx.pm';
204}