12 my($skip,$to,$next) = @_;
14 my $cmp = $prefix . $to;
19 if( $check eq $cmp && $_ != $skip ){
20 # let the next test pass
25 local $main::Level = $main::Level + 1;
27 my $common_mess = "skip $skip filenames to $to so that the next one will end with $next";
32 my($alpha) = $check =~ /\Atmp\d+([A-Z][A-Z]?)\Z/;
34 diag( "only skipped to $alpha" );
38 diag( "only skipped $last out of $skip files" );
42 note("skipping the first filename because it is taken for use by _fresh_perl()");
44 is( tempfile(), "${prefix}B");
45 is( tempfile(), "${prefix}C");
48 ok( open( my $fh, '>', "${prefix}D" ), 'created file with the next filename' );
49 is( tempfile(), "${prefix}E", 'properly skips files that already exist');
52 unlink_all("${prefix}D");
54 tempfile(); # allow the rest of the tests to work correctly
58 ok( register_tempfile("${prefix}F"), 'registered the next file with register_tempfile' );
59 is( tempfile(), "${prefix}G", 'tempfile() properly skips files added with register_tempfile()' );
61 skip_files(18,'Y','Z');
63 is( tempfile(), "${prefix}Z", 'Last single letter filename');
64 is( tempfile(), "${prefix}AA", 'First double letter filename');
66 skip_files(24,'AY','AZ');
68 is( tempfile(), "${prefix}AZ");
69 is( tempfile(), "${prefix}BA");
71 skip_files(26 * 24 + 24,'ZY','ZZ');
73 is( tempfile(), "${prefix}ZZ", 'Last available filename');
74 ok( !eval{tempfile()}, 'Should bail after Last available filename' );
76 like( $err, qr{^Can't find temporary file name starting}, 'check error string' );
79 my $returned = runperl( progs => [
80 'require q[./test.pl];',
81 'my $t = tempfile();',
83 'print open(FH,q[>],$t) ? qq[ok|] : qq[not ok|] ;',
84 'print -e $t ? qq[ok|] : qq[not ok|];',
86 my($filename,$opened,$existed) = split /\|/, $returned;
88 is( $opened, 'ok', "$filename created" );
89 is( $existed, 'ok', "$filename did exist" );
90 ok( !-e $filename, "$filename doesn't exist now" );