Skip to content

Commit bafd8c2

Browse files
authored
Merge pull request #1320 from swizzlr/swizzlr/resolve-not-even-twice
2 parents b63c178 + 259739a commit bafd8c2

File tree

4 files changed

+53
-0
lines changed

4 files changed

+53
-0
lines changed

Foundation.xcodeproj/project.pbxproj

+4
Original file line numberDiff line numberDiff line change
@@ -337,6 +337,7 @@
337337
BD8042161E09857800487EB8 /* TestLengthFormatter.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD8042151E09857800487EB8 /* TestLengthFormatter.swift */; };
338338
BDBB65901E256BFA001A7286 /* TestEnergyFormatter.swift in Sources */ = {isa = PBXBuildFile; fileRef = BDBB658F1E256BFA001A7286 /* TestEnergyFormatter.swift */; };
339339
BDFDF0A71DFF5B3E00C04CC5 /* TestPersonNameComponents.swift in Sources */ = {isa = PBXBuildFile; fileRef = BDFDF0A61DFF5B3E00C04CC5 /* TestPersonNameComponents.swift */; };
340+
BF85E9D81FBDCC2000A79793 /* TestHost.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF85E9D71FBDCC2000A79793 /* TestHost.swift */; };
340341
BF8E65311DC3B3CB005AB5C3 /* TestNotification.swift in Sources */ = {isa = PBXBuildFile; fileRef = BF8E65301DC3B3CB005AB5C3 /* TestNotification.swift */; };
341342
CC5249C01D341D23007CB54D /* TestUnitConverter.swift in Sources */ = {isa = PBXBuildFile; fileRef = CC5249BF1D341D23007CB54D /* TestUnitConverter.swift */; };
342343
CD1C7F7D1E303B47008E331C /* TestNSError.swift in Sources */ = {isa = PBXBuildFile; fileRef = CD1C7F7C1E303B47008E331C /* TestNSError.swift */; };
@@ -807,6 +808,7 @@
807808
BD8042151E09857800487EB8 /* TestLengthFormatter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestLengthFormatter.swift; sourceTree = "<group>"; };
808809
BDBB658F1E256BFA001A7286 /* TestEnergyFormatter.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestEnergyFormatter.swift; sourceTree = "<group>"; };
809810
BDFDF0A61DFF5B3E00C04CC5 /* TestPersonNameComponents.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestPersonNameComponents.swift; sourceTree = "<group>"; };
811+
BF85E9D71FBDCC2000A79793 /* TestHost.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = TestHost.swift; sourceTree = "<group>"; };
810812
BF8E65301DC3B3CB005AB5C3 /* TestNotification.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestNotification.swift; sourceTree = "<group>"; };
811813
C2A9D75B1C15C08B00993803 /* TestNSUUID.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestNSUUID.swift; sourceTree = "<group>"; };
812814
C93559281C12C49F009FD6A9 /* TestAffineTransform.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = TestAffineTransform.swift; sourceTree = "<group>"; };
@@ -1506,6 +1508,7 @@
15061508
EA54A6FA1DB16D53009E0809 /* TestObjCRuntime.swift */,
15071509
5B6F17941C48631C00935030 /* TestProcess.swift */,
15081510
400E22641C1A4E58007C5933 /* TestProcessInfo.swift */,
1511+
BF85E9D71FBDCC2000A79793 /* TestHost.swift */,
15091512
EA01AAEB1DA839C4008F4E07 /* TestProgress.swift */,
15101513
5E5835F31C20C9B500C81317 /* TestThread.swift */,
15111514
B951B5EB1F4E2A2000D8B332 /* TestNSLock.swift */,
@@ -2431,6 +2434,7 @@
24312434
2EBE67A51C77BF0E006583D5 /* TestDateFormatter.swift in Sources */,
24322435
5B13B3291C582D4C00651CE2 /* TestCalendar.swift in Sources */,
24332436
5B13B34F1C582D4C00651CE2 /* TestXMLParser.swift in Sources */,
2437+
BF85E9D81FBDCC2000A79793 /* TestHost.swift in Sources */,
24342438
D5C40F331CDA1D460005690C /* TestOperationQueue.swift in Sources */,
24352439
BDBB65901E256BFA001A7286 /* TestEnergyFormatter.swift in Sources */,
24362440
5B13B32F1C582D4C00651CE2 /* TestNSGeometry.swift in Sources */,

Foundation/Host.swift

+2
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,7 @@ open class Host: NSObject {
9393
}
9494
ifa = ifaValue.ifa_next
9595
}
96+
_resolved = true
9697
#endif
9798
}
9899

@@ -155,6 +156,7 @@ open class Host: NSObject {
155156
lookupInfo(&_names, NI_NOFQDN|NI_NAMEREQD)
156157
res = info.ai_next
157158
}
159+
_resolved = true
158160
}
159161
#endif
160162
}

TestFoundation/TestHost.swift

+46
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
// This source file is part of the Swift.org open source project
2+
//
3+
// Copyright (c) 2014 - 2016 Apple Inc. and the Swift project authors
4+
// Licensed under Apache License v2.0 with Runtime Library Exception
5+
//
6+
// See http://swift.org/LICENSE.txt for license information
7+
// See http://swift.org/CONTRIBUTORS.txt for the list of Swift project authors
8+
//
9+
10+
11+
#if DEPLOYMENT_RUNTIME_OBJC || os(Linux)
12+
import Foundation
13+
import XCTest
14+
#else
15+
import SwiftFoundation
16+
import SwiftXCTest
17+
#endif
18+
19+
20+
class TestHost: XCTestCase {
21+
22+
static var allTests: [(String, (TestHost) -> () throws -> Void)] {
23+
return [
24+
("test_addressesDoNotGrow", test_addressesDoNotGrow),
25+
]
26+
}
27+
28+
// SR-6391
29+
func test_addressesDoNotGrow() {
30+
let local = Host.current()
31+
let localAddressesFirst = local.addresses
32+
let localAddressesSecond = local.addresses
33+
XCTAssertEqual(localAddressesSecond.count, localAddressesFirst.count)
34+
35+
let dns = Host(address: "8.8.8.8")
36+
let dnsAddressesFirst = dns.addresses
37+
let dnsAddressesSecond = dns.addresses
38+
XCTAssertEqual(dnsAddressesSecond.count, dnsAddressesFirst.count)
39+
40+
let swift = Host(name: "swift.org")
41+
let swiftAddressesFirst = swift.addresses
42+
let swiftAddressesSecond = swift.addresses
43+
XCTAssertEqual(swiftAddressesSecond.count, swiftAddressesFirst.count)
44+
}
45+
}
46+

TestFoundation/main.swift

+1
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ XCTMain([
6767
testCase(TestPipe.allTests),
6868
testCase(TestNSPredicate.allTests),
6969
testCase(TestProcessInfo.allTests),
70+
testCase(TestHost.allTests),
7071
testCase(TestPropertyListSerialization.allTests),
7172
testCase(TestNSRange.allTests),
7273
testCase(TestNSRegularExpression.allTests),

0 commit comments

Comments
 (0)