Sha256: b375fdf3d0635e777f4e22fef9b5258186a7c30a2054422d5deee4bd959c265e
Contents?: true
Size: 888 Bytes
Versions: 8
Compression:
Stored size: 888 Bytes
Contents
# -*- encoding: binary -*- require 'test/unit' require 'tempfile' $-w = true require 'io/splice' Thread.abort_on_exception = true class Test_IO_Splice_In_Full < Test::Unit::TestCase def test_splice_in_full rd, wr = IO.pipe tmp = Tempfile.new 'splice-read' Thread.new do 111.times do sleep 0.002 wr.write "HIHIHI" end end nr = IO.splice rd, nil, tmp, nil, 666, IO::Splice::WAITALL assert_equal 666, nr tmp.rewind assert_equal "HIHIHI" * 111, tmp.read end def test_tee_in_full rd, wr = IO.pipe a, b = IO.pipe thr = Thread.new { a.read(666) } Thread.new do 111.times do sleep 0.001 wr.syswrite "HIHIHI" end end nr = IO.tee rd, b, 666, IO::Splice::WAITALL assert_equal 666, nr thr.join assert_equal "HIHIHI" * 111, thr.value end end if defined?(RUBY_ENGINE)
Version data entries
8 entries across 8 versions & 1 rubygems