Skip to content

Commit c99db1a

Browse files
author
“saiHemak”
committed
Done the changes as per the comments
1 parent bbaf4f2 commit c99db1a

File tree

2 files changed

+14
-15
lines changed

2 files changed

+14
-15
lines changed

Foundation/NSBundle.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,19 +77,19 @@ public class Bundle: NSObject {
7777
public func unload() -> Bool { NSUnimplemented() }
7878

7979
public func preflight() throws {
80-
var unmangaedError:Unmanaged<CFError>? = nil
81-
try withUnsafeMutablePointer(&unmangaedError) { (unmanagedCFError: UnsafeMutablePointer<Unmanaged<CFError>?>) in
82-
CFBundlePreflightExecutable(_bundle, unmanagedCFError)
80+
var unmanagedError:Unmanaged<CFError>? = nil
81+
try withUnsafeMutablePointer(&unmanagedError) { (unmanagedCFError: UnsafeMutablePointer<Unmanaged<CFError>?>) in
82+
CFBundlePreflightExecutable(_bundle, unmanagedCFError)
8383
if let error = unmanagedCFError.pointee {
8484
throw error.takeRetainedValue()._nsObject
8585
}
8686
}
8787
}
8888

8989
public func loadAndReturnError() throws {
90-
var unmangaedError:Unmanaged<CFError>? = nil
91-
try withUnsafeMutablePointer(&unmangaedError) { (unmanagedCFError: UnsafeMutablePointer<Unmanaged<CFError>?>) in
92-
CFBundleLoadExecutableAndReturnError(_bundle, unmanagedCFError)
90+
var unmanagedError:Unmanaged<CFError>? = nil
91+
try withUnsafeMutablePointer(&unmanagedError) { (unmanagedCFError: UnsafeMutablePointer<Unmanaged<CFError>?>) in
92+
CFBundleLoadExecutableAndReturnError(_bundle, unmanagedCFError)
9393
if let error = unmanagedCFError.pointee {
9494
let retainedValue = error.takeRetainedValue()
9595
throw retainedValue._nsObject

TestFoundation/TestNSBundle.swift

Lines changed: 8 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,9 @@ class TestNSBundle : XCTestCase {
2929
("test_localizations", test_localizations),
3030
("test_URLsForResourcesWithExtension", test_URLsForResourcesWithExtension),
3131
("test_bundleLoad", test_bundleLoad),
32-
("test_bundleLoadWithError",test_bundleLoadWithError),
33-
("test_bundleWithInvalidPath",test_bundleWithInvalidPath),
34-
("test_bundlePreflight",test_bundlePreflight),
35-
32+
("test_bundleLoadWithError", test_bundleLoadWithError),
33+
("test_bundleWithInvalidPath", test_bundleWithInvalidPath),
34+
("test_bundlePreflight", test_bundlePreflight),
3635
]
3736
}
3837

@@ -165,7 +164,7 @@ class TestNSBundle : XCTestCase {
165164
}
166165

167166
func test_bundleLoadWithError(){
168-
let bundleValid = NSBundle.mainBundle()
167+
let bundleValid = Bundle.main()
169168
//test valid load using loadAndReturnError
170169
do{
171170
try bundleValid.loadAndReturnError()
@@ -174,26 +173,26 @@ class TestNSBundle : XCTestCase {
174173
}
175174
// executable cannot be located
176175
guard let playground = _setupPlayground() else { XCTFail("Unable to create playground"); return }
177-
let bundle = NSBundle(path: playground + _bundleName)
176+
let bundle = Bundle(path: playground + _bundleName)
178177
XCTAssertThrowsError(try bundle!.loadAndReturnError())
179178
_cleanupPlayground(playground)
180179
}
181180

182181
func test_bundleWithInvalidPath(){
183-
let bundleInvalid = NSBundle(path: "/tmp/test.playground")
182+
let bundleInvalid = Bundle(path: "/tmp/test.playground")
184183
XCTAssertNil(bundleInvalid)
185184
}
186185

187186
func test_bundlePreflight(){
188-
let bundleValid = NSBundle.mainBundle()
187+
let bundleValid = Bundle.main()
189188
do{
190189
try bundleValid.preflight()
191190
}catch{
192191
XCTFail("should not fail to load")
193192
}
194193
// executable cannot be located ..preflight should report error
195194
guard let playground = _setupPlayground() else { XCTFail("Unable to create playground"); return }
196-
let bundle = NSBundle(path: playground + _bundleName)
195+
let bundle = Bundle(path: playground + _bundleName)
197196
XCTAssertThrowsError(try bundle!.preflight())
198197
_cleanupPlayground(playground)
199198
}

0 commit comments

Comments
 (0)