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': $!";
30 print "# $@\nnot " if $@;
31 print "ok ",$i++,"\n";
33 eval { require 5.005 };
34 print "# $@\nnot " if $@;
35 print "ok ",$i++,"\n";
37 eval { require 5.005; };
38 print "# $@\nnot " if $@;
39 print "ok ",$i++,"\n";
44 print "# $@\nnot " if $@;
45 print "ok ",$i++,"\n";
47 # new style version numbers
49 eval { require v5.5.630; };
50 print "# $@\nnot " if $@;
51 print "ok ",$i++,"\n";
53 eval { require 10.0.2; };
54 print "# $@\nnot " unless $@ =~ /^Perl v10\.0\.2 required/;
55 print "ok ",$i++,"\n";
57 eval q{ use v5.5.630; };
58 print "# $@\nnot " if $@;
59 print "ok ",$i++,"\n";
61 eval q{ use 10.0.2; };
62 print "# $@\nnot " unless $@ =~ /^Perl v10\.0\.2 required/;
63 print "ok ",$i++,"\n";
66 eval { require $ver; };
67 print "# $@\nnot " if $@;
68 print "ok ",$i++,"\n";
72 eval { require $ver; };
73 print "# $@\nnot " unless $@ =~ /^Perl v10\.200\.0 required/;
74 print "ok ",$i++,"\n";
77 eval { require $ver; };
78 print "# $@\nnot " unless $@ =~ /^Perl v10\.0\.20 required/;
79 print "ok ",$i++,"\n";
81 print "not " unless 5.5.1 gt v5.5;
82 print "ok ",$i++,"\n";
86 print "not " unless v5.5.640 eq "\x{5}\x{5}\x{280}";
87 print "ok ",$i++,"\n";
89 print "not " unless v7.15 eq "\x{7}\x{f}";
90 print "ok ",$i++,"\n";
93 unless v1.20.300.4000.50000.600000 eq "\x{1}\x{14}\x{12c}\x{fa0}\x{c350}\x{927c0}";
94 print "ok ",$i++,"\n";
97 # interaction with pod (see the eof)
98 write_file('bleah.pm', "print 'ok $i\n'; 1;\n");
102 # run-time failure in require
104 print "# $@\nnot " unless $@ =~ /did not return a true/;
105 print "ok ",$i++,"\n";
107 # compile-time failure in require
109 # bison says 'parse error' instead of 'syntax error',
110 # various yaccs may or may not capitalize 'syntax'.
111 print "# $@\nnot " unless $@ =~ /(syntax|parse) error/mi;
112 print "ok ",$i++,"\n";
116 print "# $@\nnot " if $@;
117 print "ok ",$i++,"\n";
119 # do FILE shouldn't see any outside lexicals
121 write_file("bleah.do", <<EOT);
122 \$x = "not ok $i\\n";
126 sub dofile { do "bleah.do"; };
130 my $utf8 = chr(0xFEFF);
132 $i++; do_require(qq(${utf8}print "ok $i\n"; 1;\n));
135 my $utf16 = pack("$_[0]*", unpack("C*", $_[1]));
136 return @_ == 3 && $_[2] ? pack("$_[0]", 0xFEFF) . $utf16 : $utf16;
139 $i++; do_require(bytes_to_utf16('n', qq(print "ok $i\\n"; 1;\n), 1)); # BE
140 $i++; do_require(bytes_to_utf16('v', qq(print "ok $i\\n"; 1;\n), 1)); # LE
142 END { 1 while unlink 'bleah.pm'; 1 while unlink 'bleah.do'; }
144 # ***interaction with pod (don't put any thing after here)***