[macruby-changes] [MacRuby/MacRuby] 2ef505: StringIO#read(length) returns binary string when p...
GitHub
noreply at github.com
Tue Feb 21 05:12:36 PST 2012
Branch: refs/heads/master
Home: https://github.com/MacRuby/MacRuby
Commit: 2ef505b1a30abd35717e8f08291af616bd269762
https://github.com/MacRuby/MacRuby/commit/2ef505b1a30abd35717e8f08291af616bd269762
Author: Watson <watson1978 at gmail.com>
Date: 2012-02-21 (Tue, 21 Feb 2012)
Changed paths:
M lib/stringio.rb
Log Message:
-----------
StringIO#read(length) returns binary string when passed length
Test Script
----
require 'stringio'
require 'test/unit/assertions.rb'
include Test::Unit::Assertions
str = "abcdefg" * 100
str.force_encoding('UTF-8')
io = StringIO.new(str)
s = io.read(0)
assert_equal("", s)
assert_equal(Encoding::ASCII_8BIT, s.encoding)
s = io.read(10)
assert_equal("abcdefgabc", s)
assert_equal(Encoding::ASCII_8BIT, s.encoding)
s = io.read()
assert_equal(Encoding::UTF_8, s.encoding)
length = Object.new
def length.to_int
0
end
io = StringIO.new("")
s = io.read(length)
assert_equal("", s)
assert_equal(Encoding::ASCII_8BIT, s.encoding)
More information about the macruby-changes
mailing list