-#!./perl
-
-BEGIN {
- chdir 't' if -d 't';
- unshift @INC, '../lib';
-}
-
+#!/usr/local/bin/perl -w
# Test for File::Temp - tempfile function
use strict;
use Test;
-BEGIN { plan tests => 10}
+BEGIN { plan tests => 11}
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
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
+