@@ -14,55 +14,6 @@ import ObjectiveC
1414import Foundation
1515import 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