diff options
author | Samuel Williams <samuel.williams@oriontransfer.co.nz> | 2023-05-15 11:13:51 +0900 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-05-15 11:13:51 +0900 |
commit | 0b2613f44309bddae45562c9f3a14ed43e56959b (patch) | |
tree | 1634ce5d3d078d2c686b3345dcd8fe40f13fd244 /test | |
parent | 91c004885fc75a93cadf0094fa86ec3bd0ec25f5 (diff) | |
download | ruby-0b2613f44309bddae45562c9f3a14ed43e56959b.tar.gz |
`rb_io_puts` should not write zero length strings. (#7806)
Diffstat (limited to 'test')
-rw-r--r-- | test/fiber/test_io.rb | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/test/fiber/test_io.rb b/test/fiber/test_io.rb index de88745e57..c1ad56a8cf 100644 --- a/test/fiber/test_io.rb +++ b/test/fiber/test_io.rb @@ -170,6 +170,34 @@ class TestFiberIO < Test::Unit::TestCase assert_predicate(o, :closed?) end + def test_puts_empty + omit "UNIXSocket is not defined!" unless defined?(UNIXSocket) + + i, o = UNIXSocket.pair + i.nonblock = false + o.nonblock = false + + thread = Thread.new do + # This scheduler provides non-blocking `io_read`/`io_write`: + scheduler = IOBufferScheduler.new + Fiber.set_scheduler scheduler + + Fiber.schedule do + # This was causing a segfault on older Ruby. + o.puts "" + o.puts nil + o.close + end + end + + thread.join + + message = i.read + i.close + + assert_equal $/*2, message + end + def test_io_select omit "UNIXSocket is not defined!" unless defined?(UNIXSocket) |