This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
longstanding bug in parsing "require VERSION", could reallocate
[perl5.git] / t / comp / use.t
CommitLineData
8ebc5c01
PP
1#!./perl
2
3BEGIN {
4 chdir 't' if -d 't';
93430cb4 5 unshift @INC, '../lib';
8ebc5c01
PP
6}
7
9f3d182e 8print "1..15\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
25eval sprintf "use %.5f;", $];
26if ($@) {
27 print STDERR $@,"\n";
28 print "not ";
29}
30print "ok ",$i++,"\n";
31
32
33eval sprintf "use %.5f;", $] - 0.000001;
34if ($@) {
35 print STDERR $@,"\n";
36 print "not ";
37}
38print "ok ",$i++,"\n";
39
40eval sprintf("use %.5f;", $] + 1);
41unless ($@) {
42 print "not ";
43}
44print "ok ",$i++,"\n";
45
46eval sprintf "use %.5f;", $] + 0.00001;
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
85print "not " unless $INC[0] eq "fred";
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
95print "not " unless $INC[0] eq "joe";
96print "ok ",$i++,"\n";
97
98eval "use lib 1.01 qw(freda)";
99unless ($@) {
100 print "not ";
101}
102print "ok ",$i++,"\n";
103
104print "not " if $INC[0] eq "freda";
105print "ok ",$i++,"\n";