From: Uri Guttman <uri@quad.(none)>
Date: Thu, 22 Apr 2010 05:41:30 +0000 (-0400)
Subject: added perms.t test to test write_file's perms option
X-Git-Url: http://git.shadowcat.co.uk/gitweb/gitweb.cgi?a=commitdiff_plain;h=2b56fd3b8faea62fa5e2d41792a898de39032b13;p=urisagit%2FPerl-Docs.git

added perms.t test to test write_file's perms option
---

diff --git a/t/perms.t b/t/perms.t
new file mode 100644
index 0000000..4b779df
--- /dev/null
+++ b/t/perms.t
@@ -0,0 +1,30 @@
+#!/usr/local/bin/perl -w
+
+use strict ;
+use Test::More ;
+use File::Slurp ;
+
+plan tests => 2 ;
+
+my $file = "perms.$$" ;
+
+my $text = <<END ;
+This is a bit of contents
+to store in a file.
+END
+
+umask 027 ;
+
+write_file( $file, $text ) ;
+is( getmode( $file ), 0640, 'default perms works' ) ;
+unlink $file ;
+
+write_file( $file, { perms => 0777 }, $text ) ;
+is( getmode( $file ), 0750, 'set perms works' ) ;
+unlink $file ;
+
+exit ;
+
+sub getmode {
+	return 07777 & (stat $_[0])[2] ;
+}