<commit_before>require_relative '../spec_helper'
require_relative '../fixtures/classes'

describe 'Socket#sysaccept' do
  SocketSpecs.each_ip_protocol do |family, ip_address|
    before do
      @server   = Socket.new(family, :STREAM)
      @sockaddr = Socket.sockaddr_in(0, ip_address)
    end

    after do
      @server.close
    end

    platform_is_not :aix, :freebsd, :windows, :solaris, :darwin do # hangs
      describe 'using an unbound socket'  do
        it 'raises Errno::EINVAL' do
          lambda { @server.sysaccept }.should raise_error(Errno::EINVAL)
        end
      end

      describe "using a bound socket that's not listening" do
        before do
          @server.bind(@sockaddr)
        end

        it 'raises Errno::EINVAL' do
          lambda { @server.sysaccept }.should raise_error(Errno::EINVAL)
        end
      end
    end

    describe "using a bound socket that's listening" do
      before do
        @server.bind(@sockaddr)
        @server.listen(1)
<commit_msg>Simplify guards, the behavior seems Linux-specific<commit_after>require_relative '../spec_helper'
require_relative '../fixtures/classes'

describe 'Socket#sysaccept' do
  SocketSpecs.each_ip_protocol do |family, ip_address|
    before do
      @server   = Socket.new(family, :STREAM)
      @sockaddr = Socket.sockaddr_in(0, ip_address)
    end

    after do
      @server.close
    end

    platform_is :linux do # hangs on other platforms
      describe 'using an unbound socket'  do
        it 'raises Errno::EINVAL' do
          lambda { @server.sysaccept }.should raise_error(Errno::EINVAL)
        end
      end

      describe "using a bound socket that's not listening" do
        before do
          @server.bind(@sockaddr)
        end

        it 'raises Errno::EINVAL' do
          lambda { @server.sysaccept }.should raise_error(Errno::EINVAL)
        end
      end
    end

    describe "using a bound socket that's listening" do
      before do
        @server.bind(@sockaddr)
        @server.listen(1)

{'fraction_non_alphanumeric': 0.090233019335647, 'fraction_numerical': 0.0019831432821021317, 'mean_word_length': 2.4673539518900345, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1773660', 'n_tokens_mistral': 618, 'n_tokens_neox': 590, 'n_words': 172}