mirror of
				https://github.com/ruby/ruby.git
				synced 2022-11-09 12:17:21 -05:00 
			
		
		
		
	Improve consistency of tests.
This commit is contained in:
		
							parent
							
								
									a3ac1bf450
								
							
						
					
					
						commit
						e6e9cef06e
					
				
				
				Notes:
				
					git
				
				2020-07-20 10:21:25 +09:00 
				
			
			
			
		
		
					 3 changed files with 13 additions and 5 deletions
				
			
		| 
						 | 
				
			
			@ -1,6 +1,7 @@
 | 
			
		|||
# frozen_string_literal: true
 | 
			
		||||
 | 
			
		||||
require 'fiber'
 | 
			
		||||
require 'socket'
 | 
			
		||||
 | 
			
		||||
begin
 | 
			
		||||
  require 'io/nonblock'
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -1,19 +1,19 @@
 | 
			
		|||
# frozen_string_literal: true
 | 
			
		||||
require 'test/unit'
 | 
			
		||||
require 'socket'
 | 
			
		||||
require_relative 'scheduler'
 | 
			
		||||
 | 
			
		||||
class TestFiberEnumerator < Test::Unit::TestCase
 | 
			
		||||
  MESSAGE = "Hello World"
 | 
			
		||||
 | 
			
		||||
  def test_read_characters
 | 
			
		||||
    skip unless defined?(UNIXSocket)
 | 
			
		||||
    skip "UNIXSocket is not defined!" unless defined?(UNIXSocket)
 | 
			
		||||
 | 
			
		||||
    i, o = UNIXSocket.pair
 | 
			
		||||
 | 
			
		||||
    unless i.nonblock? && o.nonblock?
 | 
			
		||||
      i.close
 | 
			
		||||
      o.close
 | 
			
		||||
      skip
 | 
			
		||||
      skip "I/O is not non-blocking!"
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    message = String.new
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
| 
						 | 
				
			
			@ -6,10 +6,15 @@ class TestFiberIO < Test::Unit::TestCase
 | 
			
		|||
  MESSAGE = "Hello World"
 | 
			
		||||
 | 
			
		||||
  def test_read
 | 
			
		||||
    skip unless defined?(UNIXSocket)
 | 
			
		||||
    skip "UNIXSocket is not defined!" unless defined?(UNIXSocket)
 | 
			
		||||
 | 
			
		||||
    i, o = UNIXSocket.pair
 | 
			
		||||
    skip unless i.nonblock? && o.nonblock?
 | 
			
		||||
 | 
			
		||||
    unless i.nonblock? && o.nonblock?
 | 
			
		||||
      i.close
 | 
			
		||||
      o.close
 | 
			
		||||
      skip "I/O is not non-blocking!"
 | 
			
		||||
    end
 | 
			
		||||
 | 
			
		||||
    message = nil
 | 
			
		||||
 | 
			
		||||
| 
						 | 
				
			
			@ -31,5 +36,7 @@ class TestFiberIO < Test::Unit::TestCase
 | 
			
		|||
    thread.join
 | 
			
		||||
 | 
			
		||||
    assert_equal MESSAGE, message
 | 
			
		||||
    assert_predicate(i, :closed?)
 | 
			
		||||
    assert_predicate(o, :closed?)
 | 
			
		||||
  end
 | 
			
		||||
end
 | 
			
		||||
| 
						 | 
				
			
			
 | 
			
		|||
		Loading…
	
	Add table
		Add a link
		
	
		Reference in a new issue