diff options
author | NARUSE, Yui <naruse@airemix.jp> | 2021-02-02 17:50:36 +0900 |
---|---|---|
committer | NARUSE, Yui <naruse@airemix.jp> | 2021-02-02 17:50:36 +0900 |
commit | 3cebc709539c9d0ac5bf0b7b280ec74c8029815f (patch) | |
tree | 7f17fa2ac908a706c6d3660e78d5f1051e88c465 /test/pathname | |
parent | 2dc39e2fd45aacd5fcd33ed80f602bd6f2ddb504 (diff) |
merge revision(s) 9241211538189a58b477bd55b539357617fd42ed: [Backport #17589]
Forward keyword arguments for Pathname#each_line [Bug #17589]
---
ext/pathname/pathname.c | 4 ++--
test/pathname/test_pathname.rb | 26 ++++++++++++++++++++++++++
2 files changed, 28 insertions(+), 2 deletions(-)
Diffstat (limited to 'test/pathname')
-rw-r--r-- | test/pathname/test_pathname.rb | 26 |
1 files changed, 26 insertions, 0 deletions
diff --git a/test/pathname/test_pathname.rb b/test/pathname/test_pathname.rb index 43cef4849f..113bb818ce 100644 --- a/test/pathname/test_pathname.rb +++ b/test/pathname/test_pathname.rb @@ -707,6 +707,32 @@ class TestPathname < Test::Unit::TestCase } end + def test_each_line_opts + with_tmpchdir('rubytest-pathname') {|dir| + open("a", "w") {|f| f.puts 1, 2 } + a = [] + Pathname("a").each_line(chomp: true) {|line| a << line } + assert_equal(["1", "2"], a) + + a = [] + Pathname("a").each_line("2", chomp: true) {|line| a << line } + assert_equal(["1\n", "\n"], a) + + a = [] + Pathname("a").each_line(1, chomp: true) {|line| a << line } + assert_equal(["1", "", "2", ""], a) + + a = [] + Pathname("a").each_line("2", 1, chomp: true) {|line| a << line } + assert_equal(["1", "\n", "", "\n"], a) + + a = [] + enum = Pathname("a").each_line(chomp: true) + enum.each {|line| a << line } + assert_equal(["1", "2"], a) + } + end + def test_readlines with_tmpchdir('rubytest-pathname') {|dir| open("a", "w") {|f| f.puts 1, 2 } |