9 # don't make this lexical
15 write_file('bleah.pm',@_);
16 eval { require "bleah.pm" };
17 my @a; # magic guard for scope violations (must be first lexical in file)
22 open(REQ,">$f") or die "Can't write '$f': $!";
29 print "# $@\nnot " if $@;
30 print "ok ",$i++,"\n";
32 eval { require 5.005 };
33 print "# $@\nnot " if $@;
34 print "ok ",$i++,"\n";
36 eval { require 5.005; };
37 print "# $@\nnot " if $@;
38 print "ok ",$i++,"\n";
43 print "# $@\nnot " if $@;
44 print "ok ",$i++,"\n";
46 # new style version numbers
48 eval { require v5.5.630; };
49 print "# $@\nnot " if $@;
50 print "ok ",$i++,"\n";
52 eval { require 10.0.2; };
53 print "# $@\nnot " unless $@ =~ /^Perl v10\.0\.2 required/;
54 print "ok ",$i++,"\n";
56 eval q{ use v5.5.630; };
57 print "# $@\nnot " if $@;
58 print "ok ",$i++,"\n";
60 eval q{ use 10.0.2; };
61 print "# $@\nnot " unless $@ =~ /^Perl v10\.0\.2 required/;
62 print "ok ",$i++,"\n";
65 eval { require $ver; };
66 print "# $@\nnot " if $@;
67 print "ok ",$i++,"\n";
71 eval { require $ver; };
72 print "# $@\nnot " unless $@ =~ /^Perl v10\.200\.0 required/;
73 print "ok ",$i++,"\n";
76 eval { require $ver; };
77 print "# $@\nnot " unless $@ =~ /^Perl v10\.0\.20 required/;
78 print "ok ",$i++,"\n";
80 print "not " unless 5.5.1 gt v5.5;
81 print "ok ",$i++,"\n";
85 print "not " unless v5.5.640 eq "\x{5}\x{5}\x{280}";
86 print "ok ",$i++,"\n";
88 print "not " unless v7.15 eq "\x{7}\x{f}";
89 print "ok ",$i++,"\n";
92 unless v1.20.300.4000.50000.600000 eq "\x{1}\x{14}\x{12c}\x{fa0}\x{c350}\x{927c0}";
93 print "ok ",$i++,"\n";
96 # interaction with pod (see the eof)
97 write_file('bleah.pm', "print 'ok $i\n'; 1;\n");
101 # run-time failure in require
103 print "# $@\nnot " unless $@ =~ /did not return a true/;
104 print "ok ",$i++,"\n";
106 # compile-time failure in require
108 # bison says 'parse error' instead of 'syntax error',
109 # various yaccs may or may not capitalize 'syntax'.
110 print "# $@\nnot " unless $@ =~ /(syntax|parse) error/mi;
111 print "ok ",$i++,"\n";
115 print "# $@\nnot " if $@;
116 print "ok ",$i++,"\n";
118 # do FILE shouldn't see any outside lexicals
120 write_file("bleah.do", <<EOT);
121 \$x = "not ok $i\\n";
125 sub dofile { do "bleah.do"; };
129 my $utf8 = chr(0xFEFF);
131 $i++; do_require(qq(${utf8}print "ok $i\n"; 1;\n));
134 my $utf16 = pack("$_[0]*", unpack("C*", $_[1]));
135 return @_ == 3 && $_[2] ? pack("$_[0]", 0xFEFF) . $utf16 : $utf16;
138 $i++; do_require(bytes_to_utf16('n', qq(print "ok $i\\n"; 1;\n), 1)); # BE
139 $i++; do_require(bytes_to_utf16('v', qq(print "ok $i\\n"; 1;\n), 1)); # LE
141 END { 1 while unlink 'bleah.pm'; 1 while unlink 'bleah.do'; }
143 # ***interaction with pod (don't put any thing after here)***