[前][次][番号順一覧][スレッド一覧]

ruby-changes:11215

From: mame <ko1@a...>
Date: Mon, 9 Mar 2009 01:12:23 +0900 (JST)
Subject: [ruby-changes:11215] Ruby:r22823 (trunk): * test/ruby/test_file_exhaustive.rb: add tests for File#size and

mame	2009-03-09 01:12:09 +0900 (Mon, 09 Mar 2009)

  New Revision: 22823

  http://svn.ruby-lang.org/cgi-bin/viewvc.cgi?view=rev&revision=22823

  Log:
    * test/ruby/test_file_exhaustive.rb: add tests for File#size and
      File.absolute_path.

  Modified files:
    trunk/ChangeLog
    trunk/test/ruby/test_file_exhaustive.rb

Index: ChangeLog
===================================================================
--- ChangeLog	(revision 22822)
+++ ChangeLog	(revision 22823)
@@ -1,3 +1,8 @@
+Mon Mar  9 01:11:17 2009  Yusuke Endoh  <mame@t...>
+
+	* 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@r...>
 
 	* win32/Makefile.sub (LDFLAGS): always prepends -link.
Index: test/ruby/test_file_exhaustive.rb
===================================================================
--- test/ruby/test_file_exhaustive.rb	(revision 22822)
+++ test/ruby/test_file_exhaustive.rb	(revision 22823)
@@ -259,7 +259,7 @@
     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 @@
       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 @@
       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

--
ML: ruby-changes@q...
Info: http://www.atdot.net/~ko1/quickml/

[前][次][番号順一覧][スレッド一覧]