diff options
author | Todd C. Miller <millert@cvs.openbsd.org> | 1999-04-29 22:42:18 +0000 |
---|---|---|
committer | Todd C. Miller <millert@cvs.openbsd.org> | 1999-04-29 22:42:18 +0000 |
commit | 37583d269f066aa8aa04ea18126b188d12257e6d (patch) | |
tree | bba3141cc21b941e00df1c922f6b91f28d81a28a /gnu/usr.bin/perl/t/comp | |
parent | d8fdfa5c3dd1aecb5a53cab412e78ab3b5c9833c (diff) |
perl5.005_03
Diffstat (limited to 'gnu/usr.bin/perl/t/comp')
-rw-r--r-- | gnu/usr.bin/perl/t/comp/require.t | 52 |
1 files changed, 52 insertions, 0 deletions
diff --git a/gnu/usr.bin/perl/t/comp/require.t b/gnu/usr.bin/perl/t/comp/require.t new file mode 100644 index 00000000000..5c41f5ccece --- /dev/null +++ b/gnu/usr.bin/perl/t/comp/require.t @@ -0,0 +1,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 'parse error' instead of 'syntax error', +# various yaccs may or may not capitalize 'syntax'. +print "# $@\nnot " unless $@ =~ /(syntax|parse) error/mi; +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 |