summaryrefslogtreecommitdiff
path: root/test/pathname/test_pathname.rb
diff options
context:
space:
mode:
Diffstat (limited to 'test/pathname/test_pathname.rb')
-rw-r--r--test/pathname/test_pathname.rb26
1 files changed, 26 insertions, 0 deletions
diff --git a/test/pathname/test_pathname.rb b/test/pathname/test_pathname.rb
index 2ce32a6c12..e5168d5e2e 100644
--- a/test/pathname/test_pathname.rb
+++ b/test/pathname/test_pathname.rb
@@ -690,6 +690,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 }