[macruby-changes] [4781] MacRuby/trunk/lib/stringio.rb
source_changes at macosforge.org
source_changes at macosforge.org
Sun Oct 10 04:00:21 PDT 2010
Revision: 4781
http://trac.macosforge.org/projects/ruby/changeset/4781
Author: watson1978 at gmail.com
Date: 2010-10-10 04:00:18 -0700 (Sun, 10 Oct 2010)
Log Message:
-----------
Fixed a bug of StringIO#read(length). Should return empty string when specified 0 to length.
Test Script:
{{{
require 'stringio'
def assert_equal(x, y)
if x == y
puts "ok"
else
puts "ng : x = #{x.inspect} : y = #{y.inspect}"
end
end
str = StringIO.new("")
assert_equal("", str.read(0))
assert_equal(nil, str.read(1))
puts "-----"
str = StringIO.new("abc")
s = 'xxx'
assert_equal("", t = str.read(0, s))
assert_equal("", s)
assert_equal(t.object_id, s.object_id)
assert_equal("", str.read(0))
assert_equal("abc", str.read)
assert_equal("", str.read(0))
assert_equal(nil, str.read(1))
}}}
Modified Paths:
--------------
MacRuby/trunk/lib/stringio.rb
Modified: MacRuby/trunk/lib/stringio.rb
===================================================================
--- MacRuby/trunk/lib/stringio.rb 2010-10-09 19:36:15 UTC (rev 4780)
+++ MacRuby/trunk/lib/stringio.rb 2010-10-10 11:00:18 UTC (rev 4781)
@@ -132,7 +132,9 @@
raise TypeError unless buffer.respond_to?(:to_str)
buffer = buffer.to_str
- if length == nil
+ if length == 0
+ buffer.replace("")
+ elsif length == nil
return "" if self.eof?
buffer.replace(@string[@pos..-1])
@pos = string.size
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.macosforge.org/pipermail/macruby-changes/attachments/20101010/b00de581/attachment.html>
More information about the macruby-changes
mailing list