xref: /onnv-gate/usr/src/cmd/perl/5.8.4/distrib/t/comp/use.t (revision 0:68f95e015346)
1*0Sstevel@tonic-gate#!./perl
2*0Sstevel@tonic-gate
3*0Sstevel@tonic-gateBEGIN {
4*0Sstevel@tonic-gate    chdir 't' if -d 't';
5*0Sstevel@tonic-gate    @INC = '../lib';
6*0Sstevel@tonic-gate}
7*0Sstevel@tonic-gate
8*0Sstevel@tonic-gateprint "1..28\n";
9*0Sstevel@tonic-gate
10*0Sstevel@tonic-gatemy $i = 1;
11*0Sstevel@tonic-gateeval "use 5.000";	# implicit semicolon
12*0Sstevel@tonic-gateif ($@) {
13*0Sstevel@tonic-gate    print STDERR $@,"\n";
14*0Sstevel@tonic-gate    print "not ";
15*0Sstevel@tonic-gate}
16*0Sstevel@tonic-gateprint "ok ",$i++,"\n";
17*0Sstevel@tonic-gate
18*0Sstevel@tonic-gateeval "use 5.000;";
19*0Sstevel@tonic-gateif ($@) {
20*0Sstevel@tonic-gate    print STDERR $@,"\n";
21*0Sstevel@tonic-gate    print "not ";
22*0Sstevel@tonic-gate}
23*0Sstevel@tonic-gateprint "ok ",$i++,"\n";
24*0Sstevel@tonic-gate
25*0Sstevel@tonic-gateeval sprintf "use %.5f;", $];
26*0Sstevel@tonic-gateif ($@) {
27*0Sstevel@tonic-gate    print STDERR $@,"\n";
28*0Sstevel@tonic-gate    print "not ";
29*0Sstevel@tonic-gate}
30*0Sstevel@tonic-gateprint "ok ",$i++,"\n";
31*0Sstevel@tonic-gate
32*0Sstevel@tonic-gate
33*0Sstevel@tonic-gateeval sprintf "use %.5f;", $] - 0.000001;
34*0Sstevel@tonic-gateif ($@) {
35*0Sstevel@tonic-gate    print STDERR $@,"\n";
36*0Sstevel@tonic-gate    print "not ";
37*0Sstevel@tonic-gate}
38*0Sstevel@tonic-gateprint "ok ",$i++,"\n";
39*0Sstevel@tonic-gate
40*0Sstevel@tonic-gateeval sprintf("use %.5f;", $] + 1);
41*0Sstevel@tonic-gateunless ($@) {
42*0Sstevel@tonic-gate    print "not ";
43*0Sstevel@tonic-gate}
44*0Sstevel@tonic-gateprint "ok ",$i++,"\n";
45*0Sstevel@tonic-gate
46*0Sstevel@tonic-gateeval sprintf "use %.5f;", $] + 0.00001;
47*0Sstevel@tonic-gateunless ($@) {
48*0Sstevel@tonic-gate    print "not ";
49*0Sstevel@tonic-gate}
50*0Sstevel@tonic-gateprint "ok ",$i++,"\n";
51*0Sstevel@tonic-gate
52*0Sstevel@tonic-gate
53*0Sstevel@tonic-gate{ use lib }	# check that subparse saves pending tokens
54*0Sstevel@tonic-gate
55*0Sstevel@tonic-gatelocal $lib::VERSION = 1.0;
56*0Sstevel@tonic-gate
57*0Sstevel@tonic-gateeval "use lib 0.9";
58*0Sstevel@tonic-gateif ($@) {
59*0Sstevel@tonic-gate    print STDERR $@,"\n";
60*0Sstevel@tonic-gate    print "not ";
61*0Sstevel@tonic-gate}
62*0Sstevel@tonic-gateprint "ok ",$i++,"\n";
63*0Sstevel@tonic-gate
64*0Sstevel@tonic-gateeval "use lib 1.0";
65*0Sstevel@tonic-gateif ($@) {
66*0Sstevel@tonic-gate    print STDERR $@,"\n";
67*0Sstevel@tonic-gate    print "not ";
68*0Sstevel@tonic-gate}
69*0Sstevel@tonic-gateprint "ok ",$i++,"\n";
70*0Sstevel@tonic-gate
71*0Sstevel@tonic-gateeval "use lib 1.01";
72*0Sstevel@tonic-gateunless ($@) {
73*0Sstevel@tonic-gate    print "not ";
74*0Sstevel@tonic-gate}
75*0Sstevel@tonic-gateprint "ok ",$i++,"\n";
76*0Sstevel@tonic-gate
77*0Sstevel@tonic-gate
78*0Sstevel@tonic-gateeval "use lib 0.9 qw(fred)";
79*0Sstevel@tonic-gateif ($@) {
80*0Sstevel@tonic-gate    print STDERR $@,"\n";
81*0Sstevel@tonic-gate    print "not ";
82*0Sstevel@tonic-gate}
83*0Sstevel@tonic-gateprint "ok ",$i++,"\n";
84*0Sstevel@tonic-gate
85*0Sstevel@tonic-gateprint "not " unless ($INC[0] eq "fred" || ($^O eq 'MacOS' && $INC[0] eq ":fred:"));
86*0Sstevel@tonic-gateprint "ok ",$i++,"\n";
87*0Sstevel@tonic-gate
88*0Sstevel@tonic-gateeval "use lib 1.0 qw(joe)";
89*0Sstevel@tonic-gateif ($@) {
90*0Sstevel@tonic-gate    print STDERR $@,"\n";
91*0Sstevel@tonic-gate    print "not ";
92*0Sstevel@tonic-gate}
93*0Sstevel@tonic-gateprint "ok ",$i++,"\n";
94*0Sstevel@tonic-gate
95*0Sstevel@tonic-gateprint "not " unless ($INC[0] eq "joe" || ($^O eq 'MacOS' && $INC[0] eq ":joe:"));
96*0Sstevel@tonic-gateprint "ok ",$i++,"\n";
97*0Sstevel@tonic-gate
98*0Sstevel@tonic-gateeval "use lib 1.01 qw(freda)";
99*0Sstevel@tonic-gateunless ($@) {
100*0Sstevel@tonic-gate    print "not ";
101*0Sstevel@tonic-gate}
102*0Sstevel@tonic-gateprint "ok ",$i++,"\n";
103*0Sstevel@tonic-gate
104*0Sstevel@tonic-gateprint "not " if ($INC[0] eq "freda" || ($^O eq 'MacOS' && $INC[0] eq ":freda:"));
105*0Sstevel@tonic-gateprint "ok ",$i++,"\n";
106*0Sstevel@tonic-gate
107*0Sstevel@tonic-gate{
108*0Sstevel@tonic-gate    local $lib::VERSION = 35.36;
109*0Sstevel@tonic-gate    eval "use lib v33.55";
110*0Sstevel@tonic-gate    print "not " if $@;
111*0Sstevel@tonic-gate    print "ok ",$i++,"\n";
112*0Sstevel@tonic-gate
113*0Sstevel@tonic-gate    eval "use lib v100.105";
114*0Sstevel@tonic-gate    unless ($@ =~ /lib version 100\.105 required--this is only version 35\.3/) {
115*0Sstevel@tonic-gate	print "not ";
116*0Sstevel@tonic-gate    }
117*0Sstevel@tonic-gate    print "ok ",$i++,"\n";
118*0Sstevel@tonic-gate
119*0Sstevel@tonic-gate    eval "use lib 33.55";
120*0Sstevel@tonic-gate    print "not " if $@;
121*0Sstevel@tonic-gate    print "ok ",$i++,"\n";
122*0Sstevel@tonic-gate
123*0Sstevel@tonic-gate    eval "use lib 100.105";
124*0Sstevel@tonic-gate    unless ($@ =~ /lib version 100\.105 required--this is only version 35\.3/) {
125*0Sstevel@tonic-gate	print "not ";
126*0Sstevel@tonic-gate    }
127*0Sstevel@tonic-gate    print "ok ",$i++,"\n";
128*0Sstevel@tonic-gate
129*0Sstevel@tonic-gate    local $lib::VERSION = '35.36';
130*0Sstevel@tonic-gate    eval "use lib v33.55";
131*0Sstevel@tonic-gate    print "not " if $@;
132*0Sstevel@tonic-gate    print "ok ",$i++,"\n";
133*0Sstevel@tonic-gate
134*0Sstevel@tonic-gate    eval "use lib v100.105";
135*0Sstevel@tonic-gate    unless ($@ =~ /lib version 100\.105 required--this is only version 35\.36/) {
136*0Sstevel@tonic-gate	print "not ";
137*0Sstevel@tonic-gate    }
138*0Sstevel@tonic-gate    print "ok ",$i++,"\n";
139*0Sstevel@tonic-gate
140*0Sstevel@tonic-gate    eval "use lib 33.55";
141*0Sstevel@tonic-gate    print "not " if $@;
142*0Sstevel@tonic-gate    print "ok ",$i++,"\n";
143*0Sstevel@tonic-gate
144*0Sstevel@tonic-gate    eval "use lib 100.105";
145*0Sstevel@tonic-gate    unless ($@ =~ /lib version 100\.105 required--this is only version 35\.36/) {
146*0Sstevel@tonic-gate	print "not ";
147*0Sstevel@tonic-gate    }
148*0Sstevel@tonic-gate    print "ok ",$i++,"\n";
149*0Sstevel@tonic-gate
150*0Sstevel@tonic-gate    local $lib::VERSION = v35.36;
151*0Sstevel@tonic-gate    eval "use lib v33.55";
152*0Sstevel@tonic-gate    print "not " if $@;
153*0Sstevel@tonic-gate    print "ok ",$i++,"\n";
154*0Sstevel@tonic-gate
155*0Sstevel@tonic-gate    eval "use lib v100.105";
156*0Sstevel@tonic-gate    unless ($@ =~ /lib v100\.105 required--this is only v35\.36/) {
157*0Sstevel@tonic-gate	print "not ";
158*0Sstevel@tonic-gate    }
159*0Sstevel@tonic-gate    print "ok ",$i++,"\n";
160*0Sstevel@tonic-gate
161*0Sstevel@tonic-gate    eval "use lib 33.55";
162*0Sstevel@tonic-gate    print "not " if $@;
163*0Sstevel@tonic-gate    print "ok ",$i++,"\n";
164*0Sstevel@tonic-gate
165*0Sstevel@tonic-gate    eval "use lib 100.105";
166*0Sstevel@tonic-gate    unless ($@ =~ /lib version 100\.105 required--this is only version 35\.036/) {
167*0Sstevel@tonic-gate	print "not ";
168*0Sstevel@tonic-gate    }
169*0Sstevel@tonic-gate    print "ok ",$i++,"\n";
170*0Sstevel@tonic-gate}
171*0Sstevel@tonic-gate
172*0Sstevel@tonic-gate
173*0Sstevel@tonic-gate{
174*0Sstevel@tonic-gate    # Regression test for patch 14937:
175*0Sstevel@tonic-gate    #   Check that a .pm file with no package or VERSION doesn't core.
176*0Sstevel@tonic-gate    open F, ">xxx.pm" or die "Cannot open xxx.pm: $!\n";
177*0Sstevel@tonic-gate    print F "1;\n";
178*0Sstevel@tonic-gate    close F;
179*0Sstevel@tonic-gate    eval "use lib '.'; use xxx 3;";
180*0Sstevel@tonic-gate    unless ($@ =~ /^xxx defines neither package nor VERSION--version check failed at/) {
181*0Sstevel@tonic-gate	print "not ";
182*0Sstevel@tonic-gate    }
183*0Sstevel@tonic-gate    print "ok ",$i++,"\n";
184*0Sstevel@tonic-gate    unlink 'xxx.pm';
185*0Sstevel@tonic-gate}
186