diff options
Diffstat (limited to 't/lib/ftmp-tempfile.t')
-rwxr-xr-x | t/lib/ftmp-tempfile.t | 39 |
1 files changed, 22 insertions, 17 deletions
diff --git a/t/lib/ftmp-tempfile.t b/t/lib/ftmp-tempfile.t index 9c0de8b955..3cb73c20e0 100755 --- a/t/lib/ftmp-tempfile.t +++ b/t/lib/ftmp-tempfile.t @@ -1,30 +1,35 @@ -#!./perl +#!/usr/bin/perl -w +# Test for File::Temp - tempfile function BEGIN { - chdir 't' if -d 't'; - unshift @INC, '../lib'; + chdir 't' if -d 't'; + unshift @INC, '../lib'; + require Test; import Test; + plan(tests => 11); } -# Test for File::Temp - tempfile function - use strict; -use Test; -BEGIN { plan tests => 10} use File::Spec; -use File::Temp qw/ tempfile tempdir/; # Will need to check that all files were unlinked correctly -# Set up an END block here to do it (since the END blocks -# set up by File::Temp will be evaluated in reverse order we -# set ours up first.... +# Set up an END block here to do it + +my (@files, @dirs); # Array containing list of dirs/files to test # Loop over an array hoping that the files dont exist -my @files; -eval q{ END { foreach (@files) { ok( !(-e $_) )} } 1; } || die; +END { foreach (@files) { ok( !(-e $_) )} } # And a test for directories -my @dirs; -eval q{ END { foreach (@dirs) { ok( !(-d $_) )} } 1; } || die; +END { foreach (@dirs) { ok( !(-d $_) )} } + +# Need to make sure that the END blocks are setup before +# the ones that File::Temp configures since END blocks are evaluated +# in revers order and we need to check the files *after* File::Temp +# removes them +use File::Temp qw/ tempfile tempdir/; + +# Now we start the tests properly +ok(1); # Tempfile @@ -88,5 +93,5 @@ print "# TEMPFILE: Created $tempfile\n"; ok( (-f $tempfile) ); push(@files, $tempfile); -# no tests yet to make sure that the END{} blocks correctly remove -# the files +# Now END block will execute to test the removal of directories + |