defined @array and defined %hash need no warnings 'deprecated';
[p5sagit/p5-mst-13.2.git] / t / op / mkdir.t
old mode 100755 (executable)
new mode 100644 (file)
index cf8e55d..bd0d1b4
@@ -1,12 +1,13 @@
-#!./perl
-
-print "1..9\n";
+#!./perl -w
 
 BEGIN {
     chdir 't' if -d 't';
-    unshift @INC, '../lib';
+    @INC = '../lib';
+    require './test.pl';
 }
 
+plan tests => 22;
+
 use File::Path;
 rmtree('blurfl');
 
@@ -14,12 +15,36 @@ rmtree('blurfl');
 $ENV{'LC_ALL'} = 'C';
 $ENV{LANGUAGE} = 'C'; # GNU locale extension
 
-print (mkdir('blurfl',0777) ? "ok 1\n" : "not ok 1\n");
-print (mkdir('blurfl',0777) ? "not ok 2\n" : "ok 2\n");
-print ($! =~ /cannot move|exist|denied/ ? "ok 3\n" : "# $!\nnot ok 3\n");
-print (-d 'blurfl' ? "ok 4\n" : "not ok 4\n");
-print (rmdir('blurfl') ? "ok 5\n" : "not ok 5\n");
-print (rmdir('blurfl') ? "not ok 6\n" : "ok 6\n");
-print ($! =~ /cannot find|such|exist|not found/i ? "ok 7\n" : "# $!\nnot ok 7\n");
-print (mkdir('blurfl') ? "ok 8\n" : "not ok 8\n");
-print (rmdir('blurfl') ? "ok 9\n" : "not ok 9\n");
+ok(mkdir('blurfl',0777));
+ok(!mkdir('blurfl',0777));
+like($!, qr/cannot move|exist|denied|unknown/i);
+ok(-d 'blurfl');
+ok(rmdir('blurfl'));
+ok(!rmdir('blurfl'));
+like($!, qr/cannot find|such|exist|not found|not a directory|unknown/i);
+ok(mkdir('blurfl'));
+ok(rmdir('blurfl'));
+
+# trailing slashes will be removed before the system call to mkdir
+ok(mkdir('blurfl///'));
+ok(-d 'blurfl');
+ok(rmdir('blurfl///'));
+ok(!-d 'blurfl');
+
+# test default argument
+
+$_ = 'blurfl';
+ok(mkdir);
+ok(-d);
+ok(rmdir);
+ok(!-d);
+$_ = 'lfrulb';
+
+{
+    my $_ = 'blurfl';
+    ok(mkdir);
+    ok(-d);
+    ok(-d 'blurfl');
+    ok(!-d 'lfrulb');
+    ok(rmdir);
+}