diff options
author | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2021-01-29 13:09:38 +0900 |
---|---|---|
committer | Nobuyoshi Nakada <nobu@ruby-lang.org> | 2021-01-29 14:27:53 +0900 |
commit | 9241211538189a58b477bd55b539357617fd42ed (patch) | |
tree | e3e97a2b46554f9100623a5289b94b17ec065177 /test | |
parent | acb6b395b63ff992ea89ef4dbdff32e5b54e0b20 (diff) | |
download | ruby-9241211538189a58b477bd55b539357617fd42ed.tar.gz |
Forward keyword arguments for Pathname#each_line [Bug #17589]
Diffstat (limited to 'test')
-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 2c07f77511..b04c7ebdae 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 } |