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