Skip to content

Commit e89de6e

Browse files
authored
Merge pull request #67252 from mikeash/remove-foundation-tests
[Test] Remove stdlib/NSStringAPI.swift and some supporting code.
2 parents 9e39793 + ea6a2e2 commit e89de6e

File tree

3 files changed

+0
-1990
lines changed

3 files changed

+0
-1990
lines changed

stdlib/private/StdlibUnittestFoundationExtras/StdlibUnittestFoundationExtras.swift

-49
Original file line numberDiff line numberDiff line change
@@ -14,55 +14,6 @@ import ObjectiveC
1414
import Foundation
1515
import StdlibUnittest
1616

17-
internal var _temporaryLocaleCurrentLocale: NSLocale?
18-
19-
extension NSLocale {
20-
@objc
21-
public class func __swiftUnittest_currentLocale() -> NSLocale {
22-
return _temporaryLocaleCurrentLocale!
23-
}
24-
}
25-
26-
public func withOverriddenLocaleCurrentLocale<Result>(
27-
_ temporaryLocale: NSLocale,
28-
_ body: () -> Result
29-
) -> Result {
30-
guard let oldMethod = class_getClassMethod(
31-
NSLocale.self, #selector(getter: NSLocale.current)) as Optional
32-
else {
33-
preconditionFailure("Could not find +[Locale currentLocale]")
34-
}
35-
36-
guard let newMethod = class_getClassMethod(
37-
NSLocale.self, #selector(NSLocale.__swiftUnittest_currentLocale)) as Optional
38-
else {
39-
preconditionFailure("Could not find +[Locale __swiftUnittest_currentLocale]")
40-
}
41-
42-
precondition(_temporaryLocaleCurrentLocale == nil,
43-
"Nested calls to withOverriddenLocaleCurrentLocale are not supported")
44-
45-
_temporaryLocaleCurrentLocale = temporaryLocale
46-
method_exchangeImplementations(oldMethod, newMethod)
47-
let result = body()
48-
method_exchangeImplementations(newMethod, oldMethod)
49-
_temporaryLocaleCurrentLocale = nil
50-
51-
return result
52-
}
53-
54-
public func withOverriddenLocaleCurrentLocale<Result>(
55-
_ temporaryLocaleIdentifier: String,
56-
_ body: () -> Result
57-
) -> Result {
58-
precondition(
59-
NSLocale.availableLocaleIdentifiers.contains(temporaryLocaleIdentifier),
60-
"Requested locale \(temporaryLocaleIdentifier) is not available")
61-
62-
return withOverriddenLocaleCurrentLocale(
63-
NSLocale(localeIdentifier: temporaryLocaleIdentifier), body)
64-
}
65-
6617
/// Executes the `body` in an autorelease pool if the platform does not
6718
/// implement the return-autoreleased optimization.
6819
///

0 commit comments

Comments
 (0)