[macruby-changes] [MacRuby/MacRuby] ae5989: StringIO#gets will accept an Object of limit that ...

noreply at github.com noreply at github.com
Thu Apr 7 22:44:52 PDT 2011


Branch: refs/heads/master
Home:   https://github.com/MacRuby/MacRuby

Commit: ae598909c1043014a4cd4409302f49e1a8b14803
    https://github.com/MacRuby/MacRuby/commit/ae598909c1043014a4cd4409302f49e1a8b14803
Author: Watson <watson1978 at gmail.com>
Date:   2011-04-07 (Thu, 07 Apr 2011)

Changed paths:
  M lib/stringio.rb

Log Message:
-----------
StringIO#gets will accept an Object of limit that has a to_int method.

Test Script:
{{{
require 'test/unit/assertions.rb'
include Test::Unit::Assertions
require 'stringio'

f = StringIO.new("foo\nbar\nbaz\n")
obj = Object.new
def obj.to_int
  2
end
assert_equal("fo", f.gets(obj))

obj = Object.new
def obj.to_str
  'a'
end
assert_equal("o\nba", f.gets(obj))

obj = Object.new
def obj.to_int
  2
end
def obj.to_str
  'a'
end
assert_equal("r\nba", f.gets(obj))
assert_raise(TypeError){ f.gets('\n', '2') }

puts :ok
}}}




More information about the macruby-changes mailing list