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

ruby-changes:30486

From: usa <ko1@a...>
Date: Thu, 15 Aug 2013 21:38:15 +0900 (JST)
Subject: [ruby-changes:30486] usa:r42565 (trunk): * test/ruby/test_file.rb (TestFile#test_truncate_size): test for

usa	2013-08-15 21:38:02 +0900 (Thu, 15 Aug 2013)

  New Revision: 42565

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

  Log:
    * test/ruby/test_file.rb (TestFile#test_truncate_size): test for
      above changes.

  Modified files:
    trunk/ChangeLog
    trunk/test/ruby/test_file.rb
Index: ChangeLog
===================================================================
--- ChangeLog	(revision 42564)
+++ ChangeLog	(revision 42565)
@@ -7,6 +7,9 @@ Thu Aug 15 20:51:29 2013  NAKAMURA Usaku https://github.com/ruby/ruby/blob/trunk/ChangeLog#L7
 
 	* file.c (rb_file_truncate): use above function.
 
+	* test/ruby/test_file.rb (TestFile#test_truncate_size): test for
+	  above changes.
+
 Thu Aug 15 18:39:31 2013  NAKAMURA Usaku  <usa@r...>
 
 	* win32/win32.c (clock_gettime): improve precision when freq is less
Index: test/ruby/test_file.rb
===================================================================
--- test/ruby/test_file.rb	(revision 42564)
+++ test/ruby/test_file.rb	(revision 42565)
@@ -1,5 +1,6 @@ https://github.com/ruby/ruby/blob/trunk/test/ruby/test_file.rb#L1
 require 'test/unit'
 require 'tempfile'
+require "thread"
 require_relative 'envutil'
 require_relative 'ut_eof'
 
@@ -118,6 +119,31 @@ class TestFile < Test::Unit::TestCase https://github.com/ruby/ruby/blob/trunk/test/ruby/test_file.rb#L119
     }
   end
 
+  def test_truncate_size
+    Tempfile.create("test-truncate") do |f|
+      q1 = Queue.new
+      q2 = Queue.new
+
+      Thread.new do
+        data = ''
+        64.times do |i|
+          data << i.to_s
+          f.rewind
+          f.print data
+          f.truncate(data.bytesize)
+          q1.push data.bytesize
+          q2.pop
+        end
+        q1.push nil
+      end
+
+      while size = q1.pop
+        assert_equal size, File.size(f.path)
+        q2.push true
+      end
+    end
+  end
+
   def test_read_all_extended_file
     [nil, {:textmode=>true}, {:binmode=>true}].each do |mode|
       Tempfile.create("test-extended-file", mode) {|f|

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

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