@@ -193,6 +193,7 @@ final class MachPortTests: XCTestCase {
193193 _ = copy
194194 }
195195 catch Mach . PortRightError . deadName {
196+ // success
196197 }
197198 }
198199
@@ -203,10 +204,11 @@ final class MachPortTests: XCTestCase {
203204 _ = copy
204205 }
205206 catch Mach . PortRightError . deadName {
207+ // success
206208 }
207209 }
208210
209- func testMakeReceivedRightFromExistingName ( ) throws {
211+ func testMakeReceiveRightFromExistingName ( ) throws {
210212 var name = mach_port_name_t ( MACH_PORT_NULL)
211213 var kr = mach_port_allocate ( mach_task_self_, MACH_PORT_RIGHT_RECEIVE, & name)
212214 XCTAssertEqual ( kr, KERN_SUCCESS)
@@ -222,17 +224,14 @@ final class MachPortTests: XCTestCase {
222224 }
223225 }
224226
225- func testDeinitDeadSendRight( ) throws {
226- let send = Mach . Port< Mach . SendRight> ( name: 0xffffffff )
227- send. withBorrowedName {
228- XCTAssertEqual ( $0, . max)
229- }
230- _ = consume send
227+ func testDeinitDeadSendRights( ) throws {
228+ let recv = Mach . Port < Mach . ReceiveRight > ( )
229+ let send = recv. makeSendRight ( )
230+ let send1 = recv. makeSendOnceRight ( )
231231
232- let send1 = Mach . Port< Mach . SendOnceRight> ( name: 0xffffffff )
233- send1. withBorrowedName {
234- XCTAssertEqual ( $0, . max)
235- }
232+ _ = consume recv
233+ // `send` and `send1` have become dead names
234+ _ = consume send
236235 _ = consume send1
237236 }
238237}
0 commit comments