mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
* test/ruby/test_file_exhaustive.rb: add tests for File#size and
File.absolute_path. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@22823 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
6ad0626daa
commit
6ff04457c0
2 changed files with 23 additions and 1 deletions
|
@ -1,3 +1,8 @@
|
||||||
|
Mon Mar 9 01:11:17 2009 Yusuke Endoh <mame@tsg.ne.jp>
|
||||||
|
|
||||||
|
* test/ruby/test_file_exhaustive.rb: add tests for File#size and
|
||||||
|
File.absolute_path.
|
||||||
|
|
||||||
Sun Mar 8 23:02:50 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
Sun Mar 8 23:02:50 2009 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||||
|
|
||||||
* win32/Makefile.sub (LDFLAGS): always prepends -link.
|
* win32/Makefile.sub (LDFLAGS): always prepends -link.
|
||||||
|
|
|
@ -259,7 +259,7 @@ class TestFileExhaustive < Test::Unit::TestCase
|
||||||
assert(!(File.identical?(@nofile, @file)))
|
assert(!(File.identical?(@nofile, @file)))
|
||||||
end
|
end
|
||||||
|
|
||||||
def test_size
|
def test_s_size
|
||||||
assert_integer(File.size(@dir))
|
assert_integer(File.size(@dir))
|
||||||
assert_equal(3, File.size(@file))
|
assert_equal(3, File.size(@file))
|
||||||
assert_equal(0, File.size(@zerofile))
|
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 + "."))
|
||||||
assert_equal(@file, File.expand_path(@file + "::$DATA"))
|
assert_equal(@file, File.expand_path(@file + "::$DATA"))
|
||||||
end
|
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
|
end
|
||||||
|
|
||||||
def test_basename
|
def test_basename
|
||||||
|
@ -731,4 +734,18 @@ class TestFileExhaustive < Test::Unit::TestCase
|
||||||
end.join
|
end.join
|
||||||
end
|
end
|
||||||
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
|
end
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue