mirror of
https://github.com/ruby/ruby.git
synced 2025-08-28 15:36:16 +02:00
string.c: consistent paragraph mode with IO
* string.c (rb_str_enumerate_lines): in paragraph mode, do not include newlines which separate paragraphs, so that it will be consistent with IO#each_line. git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57184 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
110bfb7152
commit
091f99b4b9
2 changed files with 13 additions and 14 deletions
|
@ -661,8 +661,8 @@ CODE
|
|||
|
||||
res=[]
|
||||
S("hello\n\n\nworld").lines(S('')).each {|x| res << x}
|
||||
assert_equal(S("hello\n\n\n"), res[0])
|
||||
assert_equal(S("world"), res[1])
|
||||
assert_equal(S("hello\n\n"), res[0])
|
||||
assert_equal(S("world"), res[1])
|
||||
|
||||
$/ = "!"
|
||||
res=[]
|
||||
|
@ -782,8 +782,8 @@ CODE
|
|||
|
||||
res=[]
|
||||
S("hello\n\n\nworld").each_line(S('')) {|x| res << x}
|
||||
assert_equal(S("hello\n\n\n"), res[0])
|
||||
assert_equal(S("world"), res[1])
|
||||
assert_equal(S("hello\n\n"), res[0])
|
||||
assert_equal(S("world"), res[1])
|
||||
|
||||
$/ = "!"
|
||||
|
||||
|
@ -824,8 +824,8 @@ CODE
|
|||
|
||||
res = []
|
||||
S("hello\n\n\nworld").each_line(S(''), chomp: true) {|x| res << x}
|
||||
assert_equal(S("hello\n\n"), res[0])
|
||||
assert_equal(S("world"), res[1])
|
||||
assert_equal(S("hello\n"), res[0])
|
||||
assert_equal(S("world"), res[1])
|
||||
|
||||
res = []
|
||||
S("hello!world").each_line(S('!'), chomp: true) {|x| res << x}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue