blob: 1959326281a061ae8158163e8d9a45e06a8954b5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
|
#!./perl
BEGIN {
chdir 't' if -d 't';
@INC = ('.', '../lib');
}
# don't make this lexical
$i = 1;
print "1..4\n";
sub do_require {
%INC = ();
write_file('bleah.pm',@_);
eval { require "bleah.pm" };
my @a; # magic guard for scope violations (must be first lexical in file)
}
sub write_file {
my $f = shift;
open(REQ,">$f") or die "Can't write '$f': $!";
print REQ @_;
close REQ;
}
# interaction with pod (see the eof)
write_file('bleah.pm', "print 'ok $i\n'; 1;\n");
require "bleah.pm";
$i++;
# run-time failure in require
do_require "0;\n";
print "# $@\nnot " unless $@ =~ /did not return a true/;
print "ok ",$i++,"\n";
# compile-time failure in require
do_require "1)\n";
# bison says 'parser error' instead of 'syntax error',
# various yaccs may or may not capitalize 'syntax'.
print "# $@\nnot " unless $@ =~ /(syntax|parser) error/i;
print "ok ",$i++,"\n";
# successful require
do_require "1";
print "# $@\nnot " if $@;
print "ok ",$i++,"\n";
END { unlink 'bleah.pm'; }
# ***interaction with pod (don't put any thing after here)***
=pod
|