Repository: apple/swift-nio
File: Tests/NIOPosixTests/SelectorTest.swift (Swift)

Code before:
        var readyCount = 0
        try selector.whenReady(strategy: .block) {
        } _: { ev in
            readyCount += 1
            if socket1 === ev.registration.socket {
                try selector.deregister(selectable: socket2)
                if closeAfterDeregister {
                    try socket2.close()
                }
            } else if socket2 === ev.registration.socket {
                try selector.deregister(selectable: socket1)
                if closeAfterDeregister {
                    try socket1.close()
                }
            } else {
                XCTFail("ev.registration.socket was neither \(socket1) or \(socket2) but \(ev.registration.socket)")
            }
        }

        XCTAssertEqual(1, readyCount)
    }

    private static let testWeDoNotDeliverEventsForPreviouslyClosedChannels_numberOfChannelsToUse = 10
    func testWeDoNotDeliverEventsForPreviouslyClosedChannels() {
        /// We use this class to box mutable values, generally in this test anything boxed should only be read/written
        /// on the event loop `el`..
        final class Box<T>: @unchecked Sendable {
            init(_ value: T) {
                self._value = value
            }
            private var _value: T
            var value: T {
                get {
                    XCTAssertNotNil(MultiThreadedEventLoopGroup.currentEventLoop)
                    return self._value
                }
                set {
                    XCTAssertNotNil(MultiThreadedEventLoopGroup.currentEventLoop)
                    self._value = newValue
                }
            }
        }
        enum DidNotReadError: Error {
            case didNotReadGotInactive
            case didNotReadGotReadComplete
        }

        /// This handler is inserted in the `ChannelPipeline` that are re-connected. So we're closing a bunch of
        /// channels and (in the same event loop tick) we then connect the same number for which I'm using the
        /// terminology 're-connect' here.
        /// These re-connected channels will re-use the fd numbers of the just closed channels. The interesting thing

Review comment (suggestion):
```suggestion
        /// on the event loop `el`.
```

Code after:
        var readyCount = 0
        try selector.whenReady(strategy: .block) {
        } _: { ev in
            readyCount += 1
            if socket1 === ev.registration.socket {
                try selector.deregister(selectable: socket2)
                if closeAfterDeregister {
                    try socket2.close()
                }
            } else if socket2 === ev.registration.socket {
                try selector.deregister(selectable: socket1)
                if closeAfterDeregister {
                    try socket1.close()
                }
            } else {
                XCTFail("ev.registration.socket was neither \(socket1) or \(socket2) but \(ev.registration.socket)")
            }
        }

        XCTAssertEqual(1, readyCount)
    }

    private static let testWeDoNotDeliverEventsForPreviouslyClosedChannels_numberOfChannelsToUse = 10
    func testWeDoNotDeliverEventsForPreviouslyClosedChannels() {
        /// We use this class to box mutable values, generally in this test anything boxed should only be read/written
        /// on the event loop `el`.
        final class Box<T>: @unchecked Sendable {
            init(_ value: T) {
                self._value = value
            }
            private var _value: T
            var value: T {
                get {
                    XCTAssertNotNil(MultiThreadedEventLoopGroup.currentEventLoop)
                    return self._value
                }
                set {
                    XCTAssertNotNil(MultiThreadedEventLoopGroup.currentEventLoop)
                    self._value = newValue
                }
            }
        }
        enum DidNotReadError: Error {
            case didNotReadGotInactive
            case didNotReadGotReadComplete
        }

        /// This handler is inserted in the `ChannelPipeline` that are re-connected. So we're closing a bunch of
        /// channels and (in the same event loop tick) we then connect the same number for which I'm using the
        /// terminology 're-connect' here.
        /// These re-connected channels will re-use the fd numbers of the just closed channels. The interesting thing