summaryrefslogtreecommitdiffstats
path: root/test/ruby
diff options
context:
space:
mode:
authormame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-03-08 16:12:09 +0000
committermame <mame@b2dd03c8-39d4-4d8f-98ff-823fe69b080e>2009-03-08 16:12:09 +0000
commit2ef289e1ad71e1573e79ec631d2f03253ef47c7c (patch)
treefbf3feeb6d39a022ab23b9147ae5f95d4ec1146c /test/ruby
parent7c6b3c7e90947c19274907def320e05b088010da (diff)
downloadruby-2ef289e1ad71e1573e79ec631d2f03253ef47c7c.tar.gz
ruby-2ef289e1ad71e1573e79ec631d2f03253ef47c7c.tar.xz
ruby-2ef289e1ad71e1573e79ec631d2f03253ef47c7c.zip
* test/ruby/test_file_exhaustive.rb: add tests for File#size and
File.absolute_path. git-svn-id: http://svn.ruby-lang.org/repos/ruby/trunk@22823 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test/ruby')
-rw-r--r--test/ruby/test_file_exhaustive.rb19
1 files changed, 18 insertions, 1 deletions
diff --git a/test/ruby/test_file_exhaustive.rb b/test/ruby/test_file_exhaustive.rb
index 7ed2abb56..67ac1037c 100644
--- a/test/ruby/test_file_exhaustive.rb
+++ b/test/ruby/test_file_exhaustive.rb
@@ -259,7 +259,7 @@ class TestFileExhaustive < Test::Unit::TestCase
assert(!(File.identical?(@nofile, @file)))
end
- def test_size
+ def test_s_size
assert_integer(File.size(@dir))
assert_equal(3, File.size(@file))
assert_equal(0, File.size(@zerofile))
@@ -385,6 +385,9 @@ class TestFileExhaustive < Test::Unit::TestCase
assert_equal(@file, File.expand_path(@file + "."))
assert_equal(@file, File.expand_path(@file + "::$DATA"))
end
+ assert_kind_of(String, File.expand_path("~"))
+ assert_raise(ArgumentError) { File.expand_path("~foo_bar_baz_unknown_user_wahaha") }
+ assert_raise(ArgumentError) { File.expand_path("~foo_bar_baz_unknown_user_wahaha", "/") }
end
def test_basename
@@ -731,4 +734,18 @@ class TestFileExhaustive < Test::Unit::TestCase
end.join
end
end
+
+ def test_size
+ assert_equal(3, File.open(@file) {|f| f.size })
+ File.open(@file, "a") do |f|
+ f.write("bar")
+ assert_equal(6, f.size)
+ end
+ end
+
+ def test_absolute_path
+ assert_equal(File.join(Dir.pwd, "~foo"), File.absolute_path("~foo"))
+ dir = File.expand_path("/bar")
+ assert_equal(File.join(dir, "~foo"), File.absolute_path("~foo", dir))
+ end
end