This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[win32] fix extra LEAVE when require fails
[perl5.git] / t / comp / require.t
CommitLineData
f46d017c
GS
1#!./perl
2
3BEGIN {
4 chdir 't' if -d 't';
5 @INC = ('.');
6}
7
8# don't make this lexical
9$i = 1;
10print "1..3\n";
11
12sub do_require {
13 %INC = ();
14 open(REQ,">bleah.pm") or die "Can't write 'bleah.pm': $!";
15 print REQ @_;
16 close REQ;
17 eval { require "bleah.pm" };
18 my @a; # magic guard for scope violations (must be first lexical in file)
19}
20
21# run-time failure in require
22do_require "0;\n";
23print "# $@\nnot " unless $@ =~ /did not return a true/;
24print "ok ",$i++,"\n";
25
26# compile-time failure in require
27do_require "1)\n";
28print "# $@\nnot " unless $@ =~ /syntax error/;
29print "ok ",$i++,"\n";
30
31# successful require
32do_require "1";
33print "# $@\nnot " if $@;
34print "ok ",$i++,"\n";
35
36unlink 'bleah.pm';