Commit | Line | Data |
f46d017c |
1 | #!./perl |
2 | |
3 | BEGIN { |
4 | chdir 't' if -d 't'; |
342930fb |
5 | @INC = ('.', '../lib'); |
f46d017c |
6 | } |
7 | |
8 | # don't make this lexical |
9 | $i = 1; |
4a9ae47a |
10 | print "1..4\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 | |
26 | # interaction with pod (see the eof) |
27 | write_file('bleah.pm', "print 'ok $i\n'; 1;\n"); |
28 | require "bleah.pm"; |
29 | $i++; |
30 | |
f46d017c |
31 | # run-time failure in require |
32 | do_require "0;\n"; |
33 | print "# $@\nnot " unless $@ =~ /did not return a true/; |
34 | print "ok ",$i++,"\n"; |
35 | |
36 | # compile-time failure in require |
37 | do_require "1)\n"; |
9d116dd7 |
38 | print "# $@\nnot " unless $@ =~ /syntax error/i; |
f46d017c |
39 | print "ok ",$i++,"\n"; |
40 | |
41 | # successful require |
42 | do_require "1"; |
43 | print "# $@\nnot " if $@; |
44 | print "ok ",$i++,"\n"; |
45 | |
4a9ae47a |
46 | END { unlink 'bleah.pm'; } |
47 | |
48 | # ***interaction with pod (don't put any thing after here)*** |
49 | |
50 | =pod |