Commit | Line | Data |
f46d017c |
1 | #!./perl |
2 | |
3 | BEGIN { |
4 | chdir 't' if -d 't'; |
93430cb4 |
5 | unshift @INC, ('.', '../lib'); |
f46d017c |
6 | } |
7 | |
8 | # don't make this lexical |
9 | $i = 1; |
a7cb1f99 |
10 | print "1..16\n"; |
f46d017c |
11 | |
12 | sub do_require { |
13 | %INC = (); |
4a9ae47a |
14 | write_file('bleah.pm',@_); |
f46d017c |
15 | eval { require "bleah.pm" }; |
16 | my @a; # magic guard for scope violations (must be first lexical in file) |
17 | } |
18 | |
4a9ae47a |
19 | sub write_file { |
20 | my $f = shift; |
21 | open(REQ,">$f") or die "Can't write '$f': $!"; |
22 | print REQ @_; |
23 | close REQ; |
24 | } |
25 | |
a7cb1f99 |
26 | # new style version numbers |
27 | |
28 | eval { require v5.5.630; }; |
29 | print "# $@\nnot " if $@; |
30 | print "ok ",$i++,"\n"; |
31 | |
32 | eval { require v10.0.2; }; |
33 | print "# $@\nnot " unless $@ =~ /^Perl v10\.0\.2 required/; |
34 | print "ok ",$i++,"\n"; |
35 | |
36 | eval q{ use v5.5.630; }; |
37 | print "# $@\nnot " if $@; |
38 | print "ok ",$i++,"\n"; |
39 | |
40 | eval q{ use v10.0.2; }; |
41 | print "# $@\nnot " unless $@ =~ /^Perl v10\.0\.2 required/; |
42 | print "ok ",$i++,"\n"; |
43 | |
44 | my $ver = v5.5.630; |
45 | eval { require $ver; }; |
46 | print "# $@\nnot " if $@; |
47 | print "ok ",$i++,"\n"; |
48 | |
49 | $ver = v10.0.2; |
50 | eval { require $ver; }; |
51 | print "# $@\nnot " unless $@ =~ /^Perl v10\.0\.2 required/; |
52 | print "ok ",$i++,"\n"; |
53 | |
54 | print "not " unless v5.5.1 gt v5.5; |
55 | print "ok ",$i++,"\n"; |
56 | |
57 | print "not " unless 5.005_01 > v5.5; |
58 | print "ok ",$i++,"\n"; |
59 | |
60 | print "not " unless 5.005_64 - v5.5.640 < 0.0000001; |
61 | print "ok ",$i++,"\n"; |
62 | |
63 | { |
64 | use utf8; |
65 | print "not " unless v5.5.640 eq "\x{5}\x{5}\x{280}"; |
66 | print "ok ",$i++,"\n"; |
67 | |
68 | print "not " unless v7.15 eq "\x{7}\x{f}"; |
69 | print "ok ",$i++,"\n"; |
70 | |
71 | print "not " |
72 | unless v1.20.300.4000.50000.600000 eq "\x{1}\x{14}\x{12c}\x{fa0}\x{c350}\x{927c0}"; |
73 | print "ok ",$i++,"\n"; |
74 | } |
75 | |
4a9ae47a |
76 | # interaction with pod (see the eof) |
77 | write_file('bleah.pm', "print 'ok $i\n'; 1;\n"); |
78 | require "bleah.pm"; |
79 | $i++; |
80 | |
f46d017c |
81 | # run-time failure in require |
82 | do_require "0;\n"; |
83 | print "# $@\nnot " unless $@ =~ /did not return a true/; |
84 | print "ok ",$i++,"\n"; |
85 | |
86 | # compile-time failure in require |
87 | do_require "1)\n"; |
f0ec1f9a |
88 | # bison says 'parse error' instead of 'syntax error', |
d91e2bdb |
89 | # various yaccs may or may not capitalize 'syntax'. |
f0ec1f9a |
90 | print "# $@\nnot " unless $@ =~ /(syntax|parse) error/mi; |
f46d017c |
91 | print "ok ",$i++,"\n"; |
92 | |
93 | # successful require |
94 | do_require "1"; |
95 | print "# $@\nnot " if $@; |
96 | print "ok ",$i++,"\n"; |
97 | |
562a7b0c |
98 | END { 1 while unlink 'bleah.pm'; } |
4a9ae47a |
99 | |
100 | # ***interaction with pod (don't put any thing after here)*** |
101 | |
102 | =pod |