[MacRuby/MacRuby] 100573: StringIO#gets('', limit) will not cut off newline ...
Branch: refs/heads/master Home: https://github.com/MacRuby/MacRuby Commit: 100573a1a7e4b6baa8759970c7574859ad0d04ff https://github.com/MacRuby/MacRuby/commit/100573a1a7e4b6baa8759970c7574859ad... Author: Watson <watson1978@gmail.com> Date: 2011-04-07 (Thu, 07 Apr 2011) Changed paths: M lib/stringio.rb Log Message: ----------- StringIO#gets('', limit) will not cut off newline of string's "\n\n". Test Script: {{{ require 'test/unit/assertions.rb' include Test::Unit::Assertions require 'stringio' f = StringIO.new("foo\n\n\nbar\n\n") assert_equal("foo\n\n", f.gets('', 4)) assert_equal(5, f.tell) assert_equal("bar\n\n", f.gets('')) assert_equal(11, f.tell) f = StringIO.new("\nfoo\n\n\nbar\n\n") assert_equal("foo\n\n", f.gets('', 5)) assert_equal(6, f.tell) assert_equal("bar\n\n", f.gets('')) assert_equal(12, f.tell) f = StringIO.new("\nfoo\nbar\n\n") assert_equal("foo\n", f.gets('', 5)) assert_equal(5, f.tell) assert_equal("bar\n\n", f.gets('')) assert_equal(10, f.tell) f = StringIO.new("\nfoo\n\n\nbar") assert_equal("foo", f.gets('', 4)) assert_equal(4, f.tell) assert_equal("bar", f.gets('')) assert_equal(10, f.tell) puts :ok }}}
participants (1)
-
noreply@github.com