This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
0ad5dac4dc9f1188972a972343975c4815e391f6
[perl5.git] / t / op / mkdir.t
1 #!./perl -w
2
3 BEGIN {
4     chdir 't' if -d 't';
5     @INC = '../lib';
6     require './test.pl';
7 }
8
9 plan tests => 22;
10
11 use File::Path;
12 rmtree('blurfl');
13
14 # tests 3 and 7 rather naughtily expect English error messages
15 $ENV{'LC_ALL'} = 'C';
16 $ENV{LANGUAGE} = 'C'; # GNU locale extension
17
18 ok(mkdir('blurfl',0777));
19 ok(!mkdir('blurfl',0777));
20 ok($!{EEXIST} || $! =~ /cannot move|exist|denied|unknown/i);
21 ok(-d 'blurfl');
22 ok(rmdir('blurfl'));
23 ok(!rmdir('blurfl'));
24 ok($!{ENOENT} || $! =~ /cannot find|such|exist|not found|not a directory|unknown/i);
25 ok(mkdir('blurfl'));
26 ok(rmdir('blurfl'));
27
28 # trailing slashes will be removed before the system call to mkdir
29 ok(mkdir('blurfl///'));
30 ok(-d 'blurfl');
31 ok(rmdir('blurfl///'));
32 ok(!-d 'blurfl');
33
34 # test default argument
35
36 $_ = 'blurfl';
37 ok(mkdir);
38 ok(-d);
39 ok(rmdir);
40 ok(!-d);
41 $_ = 'lfrulb';
42
43 {
44     my $_ = 'blurfl';
45     ok(mkdir);
46     ok(-d);
47     ok(-d 'blurfl');
48     ok(!-d 'lfrulb');
49     ok(rmdir);
50 }