From 7c3b91c9f12b27ba22681c090153e77219e6cecd Mon Sep 17 00:00:00 2001 From: Brad Gilbert Date: Tue, 4 Feb 2014 10:31:46 -0600 Subject: [PATCH] Test that tempfile() in t/test.pl skips files that already exist --- t/test_pl/tempfile.t | 13 ++++++++++++- 1 file changed, 12 insertions(+), 1 deletion(-) diff --git a/t/test_pl/tempfile.t b/t/test_pl/tempfile.t index dba363e..5c0e76e 100644 --- a/t/test_pl/tempfile.t +++ b/t/test_pl/tempfile.t @@ -44,7 +44,18 @@ note("skipping the first filename because it is taken for use by _fresh_perl()") is( tempfile(), "${prefix}B"); is( tempfile(), "${prefix}C"); -skip_files(22,'Y','Z'); +{ + ok( open( my $fh, '>', "${prefix}D" ), 'created file with the next filename' ); + is( tempfile(), "${prefix}E", 'properly skips files that already exist'); + + if( close($fh) ){ + unlink_all("${prefix}D"); + }else{ + tempfile(); # allow the rest of the tests to work correctly + } +} + +skip_files(20,'Y','Z'); is( tempfile(), "${prefix}Z", 'Last single letter filename'); is( tempfile(), "${prefix}AA", 'First double letter filename'); -- 2.7.4