This is a live mirror of the Perl 5 development currently hosted at https://github.com/perl/perl5
Convert utf8decode.t to test.pl
[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 unless (eval {
12     require File::Path;
13     File::Path::rmtree('blurfl');
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 }    
20
21 # tests 3 and 7 rather naughtily expect English error messages
22 $ENV{'LC_ALL'} = 'C';
23 $ENV{LANGUAGE} = 'C'; # GNU locale extension
24
25 ok(mkdir('blurfl',0777));
26 ok(!mkdir('blurfl',0777));
27 ok($!{EEXIST} || $! =~ /cannot move|exist|denied|unknown/i);
28 ok(-d 'blurfl');
29 ok(rmdir('blurfl'));
30 ok(!rmdir('blurfl'));
31 ok($!{ENOENT} || $! =~ /cannot find|such|exist|not found|not a directory|unknown/i);
32 ok(mkdir('blurfl'));
33 ok(rmdir('blurfl'));
34
35 # trailing slashes will be removed before the system call to mkdir
36 ok(mkdir('blurfl///'));
37 ok(-d 'blurfl');
38 ok(rmdir('blurfl///'));
39 ok(!-d 'blurfl');
40
41 # test default argument
42
43 $_ = 'blurfl';
44 ok(mkdir);
45 ok(-d);
46 ok(rmdir);
47 ok(!-d);
48 $_ = 'lfrulb';
49
50 {
51     my $_ = 'blurfl';
52     ok(mkdir);
53     ok(-d);
54     ok(-d 'blurfl');
55     ok(!-d 'lfrulb');
56     ok(rmdir);
57 }