[MacRuby/MacRuby] ae5989: StringIO#gets will accept an Object of limit that ...
Branch: refs/heads/master Home: https://github.com/MacRuby/MacRuby Commit: ae598909c1043014a4cd4409302f49e1a8b14803 https://github.com/MacRuby/MacRuby/commit/ae598909c1043014a4cd4409302f49e1a8... Author: Watson <watson1978@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 }}}
participants (1)
-
noreply@github.com