diff options
author | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-12-16 01:12:09 +0000 |
---|---|---|
committer | nobu <nobu@b2dd03c8-39d4-4d8f-98ff-823fe69b080e> | 2016-12-16 01:12:09 +0000 |
commit | 75755ef159caafd4d2623b81928b4f7c0791f209 (patch) | |
tree | 6774e5a99e7a96436f5e1025a28392f22d829ab8 /test | |
parent | 17c2828581a4dcd9babb5c754f240aa86523c673 (diff) | |
download | ruby-75755ef159caafd4d2623b81928b4f7c0791f209.tar.gz |
fix chomping newline only line
* string.c (chomp_newline): fix chomping newline only line.
rb_enc_prev_char return NULL if no previous character and must
not call rb_enc_ascget on it. a patch by Ary Borenszweig
<asterite AT gmail.com> at [ruby-core:78666]. [Bug #13037]
git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@57088 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
Diffstat (limited to 'test')
-rw-r--r-- | test/ruby/test_string.rb | 12 |
1 files changed, 12 insertions, 0 deletions
diff --git a/test/ruby/test_string.rb b/test/ruby/test_string.rb index 39477be220..d2fbd00a1d 100644 --- a/test/ruby/test_string.rb +++ b/test/ruby/test_string.rb @@ -843,6 +843,18 @@ CODE assert_equal "hello", S("hello\nworld").each_line(chomp: true).next assert_equal "hello\nworld", S("hello\nworld").each_line(nil, chomp: true).next + + res = [] + S("").each_line(chomp: true) {|x| res << x} + assert_equal([], res) + + res = [] + S("\n").each_line(chomp: true) {|x| res << x} + assert_equal([S("")], res) + + res = [] + S("\r\n").each_line(chomp: true) {|x| res << x} + assert_equal([S("")], res) end def test_lines |