summaryrefslogtreecommitdiff
path: root/t/test_pl
diff options
context:
space:
mode:
authorBrad Gilbert <b2gills@gmail.com>2012-09-25 13:12:54 -0500
committerFather Chrysostomos <sprout@cpan.org>2012-09-25 14:35:13 -0700
commit856b2dd2bfc175ae9c3e539b0e325390a24a1d6d (patch)
treece0b81707ec59c8b7f25497fa2bce41e01076686 /t/test_pl
parentca3b95856a20c1076fe7a1239379b44400faeed6 (diff)
downloadperl-856b2dd2bfc175ae9c3e539b0e325390a24a1d6d.tar.gz
Make t/test_pl/tempfile.t produce more diagnostics
Diffstat (limited to 't/test_pl')
-rw-r--r--t/test_pl/tempfile.t33
1 files changed, 27 insertions, 6 deletions
diff --git a/t/test_pl/tempfile.t b/t/test_pl/tempfile.t
index f384ba813c..51937c4ad6 100644
--- a/t/test_pl/tempfile.t
+++ b/t/test_pl/tempfile.t
@@ -9,9 +9,30 @@ use strict;
my $prefix = 'tmp'.$$;
sub skip_files{
- my($skip,$to) = @_;
- note("skipping $skip filenames so that the next one will end with $to.");
- tempfile() for 1..$skip;
+ my($skip,$to,$next) = @_;
+ my($last,$check);
+ my $cmp = $prefix . $to;
+
+ for( 1..$skip ){
+ $check = tempfile();
+ $last = $_;
+ if( $check eq $cmp && $_ != $skip ){
+ # let the next test pass
+ last;
+ }
+ }
+
+ my $common_mess = "skip $skip filenames to $to so that the next one will end with $next";
+ if( $last == $skip ){
+ if( $check eq $cmp ){
+ pass( $common_mess );
+ }else{
+ my($alpha) = $check =~ /\Atmp\d+([A-Z][A-Z]?)\Z/;
+ fail( $common_mess, "only skipped to $alpha" )
+ }
+ }else{
+ fail( $common_mess, "only skipped $last files" );
+ }
}
note("skipping the first filename because it is taken for use by _fresh_perl()");
@@ -19,17 +40,17 @@ 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,'Z');
+skip_files(22,'Y','Z');
is( tempfile(), "${prefix}Z", 'Last single letter filename');
is( tempfile(), "${prefix}AA", 'First double letter filename');
-skip_files(24,'AZ');
+skip_files(24,'AY','AZ');
is( tempfile(), "${prefix}AZ");
is( tempfile(), "${prefix}BA");
-skip_files(26 * 24 + 24,'ZZ');
+skip_files(26 * 24 + 24,'ZY','ZZ');
is( tempfile(), "${prefix}ZZ", 'Last available filename');
ok( !eval{tempfile()}, 'Should bail after Last available filename' );