You are an expert in writing code in many different languages. Your goal is to perform code completion for the following code, keeping in mind the rest of the code and the file meta data.
    Metadata details:
    filename: test_addrinfo.rb
    path of file: ./repos/truffleruby/test/mri/tests/socket
    
    the code of the file until where you have to start completion: # frozen_string_literal: true

begin
  require "socket"
rescue LoadError
end

require "test/unit"

class TestSocketAddrinfo < Test::Unit::TestCase
  HAS_UNIXSOCKET = defined?(UNIXSocket) && /cygwin/ !~ RUBY_PLATFORM

    
  def test_socket_connect_nonblock
    s1 = Socket.new(:INET, :STREAM, 0)
    s1.bind(Socket.sockaddr_in(0, "127.0.0.1"))
    s1.listen(5)
    ai = Addrinfo.new(s1.getsockname)
    s2 = Socket.new(:INET, :STREAM, 0)
    begin
      s2.connect_nonblock(ai)
    rescue IO::WaitWritable
      IO.select(nil, [s2])
      r = s2.getsockopt(Socket::SOL_SOCKET, Socket::SO_ERROR)
      assert_equal(0, r.int, "NOERROR is expected but #{r.inspect}")
      begin
        s2.connect_nonblock(ai)
      rescue Errno::EISCONN
      end