1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

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

above changes.


git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@42565 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
usa 2013-08-15 12:38:02 +00:00
parent d6af2a2b21
commit ce3ca270a5
2 changed files with 29 additions and 0 deletions

View file

@ -7,6 +7,9 @@ Thu Aug 15 20:51:29 2013 NAKAMURA Usaku <usa@ruby-lang.org>
* 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@ruby-lang.org>
* win32/win32.c (clock_gettime): improve precision when freq is less

View file

@ -1,5 +1,6 @@
require 'test/unit'
require 'tempfile'
require "thread"
require_relative 'envutil'
require_relative 'ut_eof'
@ -118,6 +119,31 @@ class TestFile < Test::Unit::TestCase
}
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|