Skip to content

Commit ac0014d

Browse files
committed
ObjCBool: Add boolValue property
- Update uses of Bool to ObjCBool where appropiate
1 parent 0e784e9 commit ac0014d

File tree

4 files changed

+11
-8
lines changed

4 files changed

+11
-8
lines changed

Foundation/NSSwiftRuntime.swift

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ import CoreFoundation
2525
#endif
2626

2727
public typealias ObjCBool = Bool
28+
extension ObjCBool {
29+
public var boolValue: Bool { return self == true }
30+
}
2831

2932
internal class __NSCFType : NSObject {
3033
private var _cfinfo : Int32

TestFoundation/TestFileManager.swift

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,10 @@ class TestFileManager : XCTestCase {
5353
// Ensure attempting to create the directory again fails gracefully.
5454
XCTAssertNil(try? fm.createDirectory(atPath: path, withIntermediateDirectories:false, attributes:nil))
5555

56-
var isDir = false
56+
var isDir: ObjCBool = false
5757
let exists = fm.fileExists(atPath: path, isDirectory: &isDir)
5858
XCTAssertTrue(exists)
59-
XCTAssertTrue(isDir)
59+
XCTAssertTrue(isDir.boolValue)
6060

6161
do {
6262
try fm.removeItem(atPath: path)
@@ -74,10 +74,10 @@ class TestFileManager : XCTestCase {
7474

7575
XCTAssertTrue(fm.createFile(atPath: path, contents: Data(), attributes: nil))
7676

77-
var isDir = false
77+
var isDir: ObjCBool = false
7878
let exists = fm.fileExists(atPath: path, isDirectory: &isDir)
7979
XCTAssertTrue(exists)
80-
XCTAssertFalse(isDir)
80+
XCTAssertFalse(isDir.boolValue)
8181

8282
do {
8383
try fm.removeItem(atPath: path)
@@ -467,9 +467,9 @@ class TestFileManager : XCTestCase {
467467
}
468468

469469
func directoryExists(atPath path: String) -> Bool {
470-
var isDir = false
470+
var isDir: ObjCBool = false
471471
let exists = fm.fileExists(atPath: path, isDirectory: &isDir)
472-
return exists && isDir
472+
return exists && isDir.boolValue
473473
}
474474

475475
func createDirectory(atPath path: String) {

TestFoundation/TestHTTPCookieStorage.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -238,7 +238,7 @@ class TestHTTPCookieStorage: XCTestCase {
238238
destPath = NSHomeDirectory() + "/.local/share" + bundleName + "/.cookies.shared"
239239
}
240240
let fm = FileManager.default
241-
var isDir = false
241+
var isDir: ObjCBool = false
242242
let exists = fm.fileExists(atPath: destPath, isDirectory: &isDir)
243243
XCTAssertTrue(exists)
244244
//Test by setting the environmental variable

TestFoundation/TestUtils.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,7 @@ func ensureFiles(_ fileNames: [String]) -> Bool {
4141
print(err)
4242
return false
4343
}
44-
} else if !isDir {
44+
} else if !isDir.boolValue {
4545
return false
4646
}
4747

0 commit comments

Comments
 (0)