summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--test/ruby/test_argf.rb42
1 files changed, 42 insertions, 0 deletions
diff --git a/test/ruby/test_argf.rb b/test/ruby/test_argf.rb
index 6262514241..874f0841d6 100644
--- a/test/ruby/test_argf.rb
+++ b/test/ruby/test_argf.rb
@@ -745,6 +745,18 @@ class TestArgf < Test::Unit::TestCase
["\"a\\n\"", "\"b\\n\""], [])
assert_in_out_err(['-e', 'ARGF.each_line(chomp: true) {|para| p para}'], "a\nb\n",
["\"a\"", "\"b\""], [])
+
+ t = make_tempfile
+ argf = ARGF.class.new(t.path)
+ lines = []
+ begin
+ argf.each_line(chomp: true) do |line|
+ lines << line
+ end
+ ensure
+ argf.close
+ end
+ assert_equal(%w[foo bar baz], lines)
end
def test_each_byte
@@ -993,6 +1005,36 @@ class TestArgf < Test::Unit::TestCase
assert_nil(argf.gets, bug4274)
end
+ def test_readlines_chomp
+ t = make_tempfile
+ argf = ARGF.class.new(t.path)
+ begin
+ assert_equal(%w[foo bar baz], argf.readlines(chomp: true))
+ ensure
+ argf.close
+ end
+ end
+
+ def test_readline_chomp
+ t = make_tempfile
+ argf = ARGF.class.new(t.path)
+ begin
+ assert_equal("foo", argf.readline(chomp: true))
+ ensure
+ argf.close
+ end
+ end
+
+ def test_gets_chomp
+ t = make_tempfile
+ argf = ARGF.class.new(t.path)
+ begin
+ assert_equal("foo", argf.gets(chomp: true))
+ ensure
+ argf.close
+ end
+ end
+
def test_readlines_twice
bug5952 = '[ruby-dev:45160]'
assert_ruby_status(["-e", "2.times {STDIN.tty?; readlines}"], "", bug5952)