This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
[perl #128260] Fix \substr %h
[perl5.git] / t / op / mkdir.t
CommitLineData
491873e5 1#!./perl -w
a687059c 2
5a211162
GS
3BEGIN {
4 chdir 't' if -d 't';
20822f61 5 @INC = '../lib';
1d4be626 6 require './test.pl';
1f47e8e2 7}
a687059c 8
7fba2966 9plan tests => 17;
1d4be626 10
94af9289
NC
11unless (eval {
12 require File::Path;
6df8187e 13 File::Path::rmtree('blurfl') if -d 'blurfl';
94af9289
NC
14 1
15}) {
16 diag("$0 may fail if its temporary directory remains from a previous run");
17 diag("Attempted to load File::Path to delete directory t/blurfl - error was\n$@");
18 diag("\nIf you have problems, please manually delete t/blurfl");
19}
5a211162 20
3458556d
J
21# tests 3 and 7 rather naughtily expect English error messages
22$ENV{'LC_ALL'} = 'C';
b598356e 23$ENV{LANGUAGE} = 'C'; # GNU locale extension
3458556d 24
ca7cc9e2
FC
25sub errno_or_skip {
26 SKIP: {
dc279b5a 27 if (is_miniperl && !eval { local $!; require Errno }) {
ca7cc9e2
FC
28 skip "Errno not built yet", 1;
29 }
30 eval "ok($_[0])";
31 }
32}
33
1d4be626
RGS
34ok(mkdir('blurfl',0777));
35ok(!mkdir('blurfl',0777));
ca7cc9e2 36errno_or_skip('$!{EEXIST} || $! =~ /cannot move|exist|denied|unknown/i');
1d4be626
RGS
37ok(-d 'blurfl');
38ok(rmdir('blurfl'));
39ok(!rmdir('blurfl'));
ca7cc9e2
FC
40errno_or_skip('
41 $!{ENOENT}
42 || $! =~ /cannot find|such|exist|not found|not a directory|unknown/i
43');
1d4be626
RGS
44ok(mkdir('blurfl'));
45ok(rmdir('blurfl'));
46
7b903762
RGS
47# trailing slashes will be removed before the system call to mkdir
48ok(mkdir('blurfl///'));
49ok(-d 'blurfl');
50ok(rmdir('blurfl///'));
51ok(!-d 'blurfl');
491873e5
RGS
52
53# test default argument
54
55$_ = 'blurfl';
56ok(mkdir);
57ok(-d);
58ok(rmdir);
59ok(!-d);
60$_ = 'lfrulb';