summaryrefslogtreecommitdiff
path: root/test/pathname
diff options
context:
space:
mode:
authorakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-08-09 13:15:49 +0000
committerakr <akr@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2010-08-09 13:15:49 +0000
commitec5bb26fa031288fd8f935443805f68e5637ee75 (patch)
tree044e5291fb5eb8ed50ad75979ebf409be64de5d9 /test/pathname
parent55584cb206746bd632ef13356cf88036cc59c353 (diff)
* ext/pathname/pathname.c (path_open): Pathname#open
translated from pathname.rb. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@28941 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/pathname')
-rw-r--r--test/pathname/test_pathname.rb20
1 files changed, 19 insertions, 1 deletions
diff --git a/test/pathname/test_pathname.rb b/test/pathname/test_pathname.rb
index 815713b..25e0423 100644
--- a/test/pathname/test_pathname.rb
+++ b/test/pathname/test_pathname.rb
@@ -818,9 +818,27 @@ class TestPathname < Test::Unit::TestCase
def test_open
with_tmpchdir('rubytest-pathname') {|dir|
open("a", "w") {|f| f.write "abc" }
- Pathname("a").open {|f|
+ path = Pathname("a")
+
+ path.open {|f|
+ assert_equal("abc", f.read)
+ }
+
+ path.open("r") {|f|
assert_equal("abc", f.read)
}
+
+ Pathname("b").open("w", 0444) {|f| f.write "def" }
+ assert_equal(0444, File.stat("b").mode & 0777)
+ assert_equal("def", File.read("b"))
+
+ Pathname("c").open("w", 0444, {}) {|f| f.write "ghi" }
+ assert_equal(0444, File.stat("c").mode & 0777)
+ assert_equal("ghi", File.read("c"))
+
+ g = path.open
+ assert_equal("abc", g.read)
+ g.close
}
end