summaryrefslogtreecommitdiff
path: root/t/test_pl
diff options
context:
space:
mode:
authorBrad Gilbert <b2gills@gmail.com>2012-09-16 15:28:01 -0500
committerFather Chrysostomos <sprout@cpan.org>2012-09-25 14:35:13 -0700
commitca3b95856a20c1076fe7a1239379b44400faeed6 (patch)
treef279908fc5bc5421756bf48308498fe859307e7b /t/test_pl
parent7b29226f59fa6ba0679496494a3cc111aa82a513 (diff)
downloadperl-ca3b95856a20c1076fe7a1239379b44400faeed6.tar.gz
Added t/test_pl/tempfile.t
Diffstat (limited to 't/test_pl')
-rw-r--r--t/test_pl/tempfile.t39
1 files changed, 39 insertions, 0 deletions
diff --git a/t/test_pl/tempfile.t b/t/test_pl/tempfile.t
new file mode 100644
index 0000000000..f384ba813c
--- /dev/null
+++ b/t/test_pl/tempfile.t
@@ -0,0 +1,39 @@
+#!./perl
+
+BEGIN {
+ chdir 't' if -d 't';
+ require './test.pl';
+}
+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;
+}
+
+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');
+
+is( tempfile(), "${prefix}Z", 'Last single letter filename');
+is( tempfile(), "${prefix}AA", 'First double letter filename');
+
+skip_files(24,'AZ');
+
+is( tempfile(), "${prefix}AZ");
+is( tempfile(), "${prefix}BA");
+
+skip_files(26 * 24 + 24,'ZZ');
+
+is( tempfile(), "${prefix}ZZ", 'Last available filename');
+ok( !eval{tempfile()}, 'Should bail after Last available filename' );
+my $err = "$@";
+like( $err, qr{^Can't find temporary file name starting}, 'check error string' );
+
+done_testing();