diff options
-rw-r--r-- | MANIFEST | 1 | ||||
-rw-r--r-- | t/op/unlink.t | 38 |
2 files changed, 39 insertions, 0 deletions
@@ -5059,6 +5059,7 @@ t/op/tr.t See if tr works t/op/turkish.t See if we can implement Turkish casing t/op/undef.t See if undef works t/op/universal.t See if UNIVERSAL class works +t/op/unlink.t See if unlink works t/op/unshift.t See if unshift works t/op/upgrade.t See if upgrading and assigning scalars works t/op/utf8cache.t Tests malfunctions of utf8 cache diff --git a/t/op/unlink.t b/t/op/unlink.t new file mode 100644 index 0000000000..7602149909 --- /dev/null +++ b/t/op/unlink.t @@ -0,0 +1,38 @@ +#!./perl + +BEGIN { + chdir 't'; + @INC = '../lib'; + require './test.pl'; +} + +plan 6; + +# Need to run this in a quiet private directory as it assumes that it can +# reliably delete fixed file names. +my $tempdir = tempfile; + +mkdir $tempdir, 0700 or die "Can't mkdir '$tempdir': $!"; +chdir $tempdir or die die "Can't chdir '$tempdir': $!"; + +sub make_file { + my $file = shift; + open my $fh, ">", $file or die "Can't open $file: $!"; + close $fh or die "Can't close $file: $!"; +} + +make_file('aaa'); +is unlink('aaa'), 1, 'retval of unlink with one file name'; +ok (!-e 'aaa', 'unlink unlinked it'); +make_file($_) for 'aaa', 'bbb'; +is unlink('aaa','bbb','ccc'), 2, + 'retval of unlink with list that includes nonexistent file'; +ok (!-e 'aaa' && !-e 'bbb', 'unlink unlank the files it claims it unlank'); +$_ = 'zzz'; +make_file 'zzz'; +is unlink, 1, 'retval of unlink with no args'; +ok !-e 'zzz', 'unlink with no arg unlinked $_'; + + +chdir '..' or die "Couldn't chdir .. for cleanup: $!"; +rmdir $tempdir or die "Couldn't unlink tempdir '$tempdir': $!"; |