summaryrefslogtreecommitdiff
path: root/test/ruby/test_argf.rb
diff options
context:
space:
mode:
authorNobuyoshi Nakada <nobu@ruby-lang.org>2021-02-08 11:04:23 +0900
committerNobuyoshi Nakada <nobu@ruby-lang.org>2021-02-08 11:31:34 +0900
commit1d686bdeb9d144f4ae2298c7ab5f46edefbd18dc (patch)
tree4ba75cd42b29c2195394cb378cd67fac33f92597 /test/ruby/test_argf.rb
parent1ba2b5cdee62426326b93b77877c141609f0b939 (diff)
Added test for keyword arguments to ARGF
Diffstat (limited to 'test/ruby/test_argf.rb')
-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 6262514241d..874f0841d63 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)