9 # don't make this lexical
12 my $Is_EBCDIC = (ord('A') == 193) ? 1 : 0;
13 my $Is_UTF8 = (${^OPEN} || "") =~ /:utf8/;
15 if ($Is_EBCDIC || $Is_UTF8) { $total_tests = 20; }
16 print "1..$total_tests\n";
20 write_file('bleah.pm',@_);
21 eval { require "bleah.pm" };
22 my @a; # magic guard for scope violations (must be first lexical in file)
27 open(REQ,">$f") or die "Can't write '$f': $!";
31 close REQ or die "Could not close $f: $!";
35 print "# $@\nnot " if $@;
36 print "ok ",$i++,"\n";
38 eval { require 5.005 };
39 print "# $@\nnot " if $@;
40 print "ok ",$i++,"\n";
42 eval { require 5.005; };
43 print "# $@\nnot " if $@;
44 print "ok ",$i++,"\n";
49 print "# $@\nnot " if $@;
50 print "ok ",$i++,"\n";
52 # new style version numbers
54 eval { require v5.5.630; };
55 print "# $@\nnot " if $@;
56 print "ok ",$i++,"\n";
58 eval { require 10.0.2; };
59 print "# $@\nnot " unless $@ =~ /^Perl v10\.0\.2 required/;
60 print "ok ",$i++,"\n";
62 eval q{ use v5.5.630; };
63 print "# $@\nnot " if $@;
64 print "ok ",$i++,"\n";
66 eval q{ use 10.0.2; };
67 print "# $@\nnot " unless $@ =~ /^Perl v10\.0\.2 required/;
68 print "ok ",$i++,"\n";
71 eval { require $ver; };
72 print "# $@\nnot " if $@;
73 print "ok ",$i++,"\n";
77 eval { require $ver; };
78 print "# $@\nnot " unless $@ =~ /^Perl v10\.200\.0 required/;
79 print "ok ",$i++,"\n";
82 eval { require $ver; };
83 print "# $@\nnot " unless $@ =~ /^Perl v10\.0\.20 required/;
84 print "ok ",$i++,"\n";
86 print "not " unless 5.5.1 gt v5.5;
87 print "ok ",$i++,"\n";
90 print "not " unless v5.5.640 eq "\x{5}\x{5}\x{280}";
91 print "ok ",$i++,"\n";
93 print "not " unless v7.15 eq "\x{7}\x{f}";
94 print "ok ",$i++,"\n";
97 unless v1.20.300.4000.50000.600000 eq "\x{1}\x{14}\x{12c}\x{fa0}\x{c350}\x{927c0}";
98 print "ok ",$i++,"\n";
101 # interaction with pod (see the eof)
102 write_file('bleah.pm', "print 'ok $i\n'; 1;\n");
106 # run-time failure in require
108 print "# $@\nnot " unless $@ =~ /did not return a true/;
109 print "ok ",$i++,"\n";
111 # compile-time failure in require
113 # bison says 'parse error' instead of 'syntax error',
114 # various yaccs may or may not capitalize 'syntax'.
115 print "# $@\nnot " unless $@ =~ /(syntax|parse) error/mi;
116 print "ok ",$i++,"\n";
120 print "# $@\nnot " if $@;
121 print "ok ",$i++,"\n";
123 # do FILE shouldn't see any outside lexicals
125 write_file("bleah.do", <<EOT);
126 \$x = "not ok $i\\n";
130 sub dofile { do "bleah.do"; };
133 # UTF-encoded things - skipped on EBCDIC machines and on UTF-8 input
135 if ($Is_EBCDIC || $Is_UTF8) { exit; }
137 my $utf8 = chr(0xFEFF);
139 $i++; do_require(qq(${utf8}print "ok $i\n"; 1;\n));
142 my $utf16 = pack("$_[0]*", unpack("C*", $_[1]));
143 return @_ == 3 && $_[2] ? pack("$_[0]", 0xFEFF) . $utf16 : $utf16;
146 $i++; do_require(bytes_to_utf16('n', qq(print "ok $i\\n"; 1;\n), 1)); # BE
147 $i++; do_require(bytes_to_utf16('v', qq(print "ok $i\\n"; 1;\n), 1)); # LE
149 END { 1 while unlink 'bleah.pm'; 1 while unlink 'bleah.do'; }
151 # ***interaction with pod (don't put any thing after here)***