From e423ae28c9b1ec76f76a6f13b729cf05ad216917 Mon Sep 17 00:00:00 2001 From: BurdetteLamar Date: Fri, 19 Jan 2024 17:03:20 +0000 Subject: [PATCH] More tests --- test/ruby/test_argf.rb | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/test/ruby/test_argf.rb b/test/ruby/test_argf.rb index 12f7d6485a1193..fed1bf88b46997 100644 --- a/test/ruby/test_argf.rb +++ b/test/ruby/test_argf.rb @@ -1140,4 +1140,40 @@ def test_sized_read argf.close end end + + def test_putc + t = make_tempfile0("argf-#{__method__}") + t.puts 'bar' + t.close + ruby('-pi-', '-e', "print ARGF.putc('x')", t.path) do |f| + end + assert_equal("xxbar\n", File.read(t.path)) + end + + def test_puts + t = make_tempfile0("argf-#{__method__}") + t.puts 'bar' + t.close + ruby('-pi-', '-e', "print ARGF.puts('foo')", t.path) do |f| + end + assert_equal("foo\nbar\n", File.read(t.path)) + end + + def test_print + t = make_tempfile0("argf-#{__method__}") + t.puts 'bar' + t.close + ruby('-pi-', '-e', "print ARGF.print('foo')", t.path) do |f| + end + assert_equal("foobar\n", File.read(t.path)) + end + + def test_printf + t = make_tempfile0("argf-#{__method__}") + t.puts 'bar' + t.close + ruby('-pi-', '-e', "print ARGF.printf('%s', 'foo')", t.path) do |f| + end + assert_equal("foobar\n", File.read(t.path)) + end end