Migrate callsites from 'expectNotEmpty()' to 'expectNotNil()'

This commit is contained in:
Dmitri Gribenko
2016-09-10 19:16:26 -07:00
parent 243a35cd65
commit c9041beea3
30 changed files with 134 additions and 134 deletions

View File

@@ -278,7 +278,7 @@ FoundationTestSuite.test("NSKeyedUnarchiver/decodeObjectOfClass(_:forKey:)") {
expectType((NSPredicate?).self, &missing)
var decoded = KU.decodeObject(of: NSPredicate.self, forKey: KEY)
expectNotEmpty(decoded)
expectNotNil(decoded)
expectType((NSPredicate?).self, &decoded)
var wrongType = KU.decodeObject(of: DateFormatter.self, forKey: KEY)

View File

@@ -70,7 +70,7 @@ CFTestSuite.test("protocols/downcast")
components: [1.0, 0.5, 0.25, 1.0])
let opaquePink: AnyObject = pink
let downcasted = opaquePink as? SwiftProto
expectNotEmpty(downcasted)
expectNotNil(downcasted)
expectTrue(pink === downcasted!.doTheThing())
}

View File

@@ -15,7 +15,7 @@ LiteralsTestSuite.test("file") {
// This is what requires the proper bundle folder structure.
let resource = #fileLiteral(resourceName: "testData.plist")
let contents = NSDictionary(contentsOf: resource) as! [String: NSObject]?
_ = expectNotEmpty(contents)
_ = expectNotNil(contents)
expectEqual(["test": true as NSObject], contents!)
}

View File

@@ -158,15 +158,15 @@ ClassProperties.test("optionalProp") {
expectNil(noProp.optionalClassProp)
let hasProp: ProtoWithClassProperty.Type = Subclass.self
expectNotEmpty(hasProp.optionalClassProp)
expectNotNil(hasProp.optionalClassProp)
expectEqual(true, hasProp.optionalClassProp!)
let hasOwnProp: ProtoWithClassProperty.Type = SwiftClass.self
expectNotEmpty(hasOwnProp.optionalClassProp)
expectNotNil(hasOwnProp.optionalClassProp)
expectEqual(true, hasOwnProp.optionalClassProp!)
let hasPropObjC: ProtoWithClassProperty.Type = ObjCSubclassWithClassProperty.self
expectNotEmpty(hasPropObjC.optionalClassProp)
expectNotNil(hasPropObjC.optionalClassProp)
expectEqual(true, hasPropObjC.optionalClassProp!)
}
@@ -183,8 +183,8 @@ ClassProperties.test("namingConflict") {
let sub = NamingConflictSubclass()
expectNil(sub.prop)
expectNotEmpty(type(of: sub).prop)
expectNotEmpty(NamingConflictSubclass.prop)
expectNotNil(type(of: sub).prop)
expectNotNil(NamingConflictSubclass.prop)
}
extension NamingConflictSubclass : PropertyNamingConflictProto {

View File

@@ -74,10 +74,10 @@ ClassProperties.test("runtime")
.code {
let theClass: AnyObject = SwiftClass.self
let prop = class_getProperty(object_getClass(theClass), "value")
expectNotEmpty(prop)
expectNotNil(prop)
let nameAsCString = property_getName(prop)!
expectNotEmpty(nameAsCString)
expectNotNil(nameAsCString)
expectEqual("value", String(cString: nameAsCString))
}

View File

@@ -47,7 +47,7 @@ ObjCRuntimeVisibleTestSuite.test("downcast") {
let obj = HiddenClass.create()
let opaque: AnyObject = obj
let downcasted = opaque as? HiddenClass
expectNotEmpty(downcasted)
expectNotNil(downcasted)
expectTrue(obj === downcasted)
}
@@ -67,7 +67,7 @@ ObjCRuntimeVisibleTestSuite.test("protocols/downcast")
let obj = HiddenClass.create()
let opaque: AnyObject = obj
let downcasted = opaque as? SwiftProto
expectNotEmpty(downcasted)
expectNotNil(downcasted)
expectTrue(obj === downcasted!.doTheThing())
}

View File

@@ -259,28 +259,28 @@ tests.test("Another/${Any}") {
let subclass2 = subclassInBaseBuffer
// Explicit downcast-ability is based on element type, not buffer type
expectNotEmpty(subclassInBaseBuffer as? [Subclass])
expectNotNil(subclassInBaseBuffer as? [Subclass])
// We can up-cast to array of Any
let subclassAsAnyArray: [${Any}] = subclassInBaseBuffer
expectEqual(subclass2, subclassAsAnyArray.map { $0 as! Base })
let downcastBackToBase = subclassAsAnyArray as? [Base]
expectNotEmpty(downcastBackToBase)
expectNotNil(downcastBackToBase)
if let downcastBackToSubclass = expectNotEmpty(subclassAsAnyArray as? [Subclass]) {
if let downcastBackToSubclass = expectNotNil(subclassAsAnyArray as? [Subclass]) {
expectEqual(subclass2, downcastBackToSubclass)
}
if let downcastToProtocols = expectNotEmpty(subclassAsAnyArray as? [Fooable]) {
if let downcastToProtocols = expectNotNil(subclassAsAnyArray as? [Fooable]) {
expectEqual(subclass2, downcastToProtocols.map { $0 as! Subclass })
}
if let downcastToProtocols = expectNotEmpty(subclassAsAnyArray as? [Barable]) {
if let downcastToProtocols = expectNotNil(subclassAsAnyArray as? [Barable]) {
expectEqual(subclass2, downcastToProtocols.map { $0 as! Subclass })
}
if let downcastToProtocols = expectNotEmpty(subclassAsAnyArray as? [Barable & Fooable]) {
if let downcastToProtocols = expectNotNil(subclassAsAnyArray as? [Barable & Fooable]) {
expectEqual(subclass2, downcastToProtocols.map { $0 as! Subclass })
}
@@ -364,7 +364,7 @@ tests.test("testExplicitlyBridged/${Any}") {
}
// Downcasts of up-casted arrays.
if let downcasted = expectNotEmpty(
if let downcasted = expectNotNil(
bridgeableValuesAsAnys as? [Subclass]
) {
expectEqualSequence(expectedSubclasses, downcasted)

View File

@@ -164,8 +164,8 @@ class C : B {}
tests.test("_getSuperclass") {
expectNil(_getSuperclass(A.self))
expectNil(_getSuperclass(Classy.self))
expectNotEmpty(_getSuperclass(B.self))
expectNotEmpty(_getSuperclass(C.self))
expectNotNil(_getSuperclass(B.self))
expectNotNil(_getSuperclass(C.self))
expectTrue(_getSuperclass(B.self)! == A.self)
expectTrue(_getSuperclass(C.self)! == B.self)
}

View File

@@ -26,12 +26,12 @@ DispatchAPI.test("OS_OBJECT support") {
expectTrue(mainQueue is DispatchQueue)
// This should not be optimized out, and should succeed.
expectNotEmpty(mainQueue as? DispatchQueue)
expectNotNil(mainQueue as? DispatchQueue)
}
DispatchAPI.test("DispatchGroup creation") {
let group = DispatchGroup()
expectNotEmpty(group)
expectNotNil(group)
}
DispatchAPI.test("dispatch_block_t conversions") {

View File

@@ -526,7 +526,7 @@ import SlurpFastEnumeration
with: &state, objects: AutoreleasingUnsafeMutablePointer(stackBuf.baseAddress),
count: stackBufLength)
expectNotEqual(0, state.state)
expectNotEmpty(state.mutationsPtr)
expectNotNil(state.mutationsPtr)
if returnedCount == 0 {
break
}
@@ -545,7 +545,7 @@ import SlurpFastEnumeration
with: &state, objects: AutoreleasingUnsafeMutablePointer(stackBuf.baseAddress),
count: stackBufLength)
expectNotEqual(0, state.state)
expectNotEmpty(state.mutationsPtr)
expectNotNil(state.mutationsPtr)
expectEqual(0, returnedCount)
}
}
@@ -568,7 +568,7 @@ typealias AnyObjectTuple2 = (AnyObject, AnyObject)
with: &state, objects: AutoreleasingUnsafeMutablePointer(stackBuf.baseAddress),
count: stackBufLength)
expectNotEqual(0, state.state)
expectNotEmpty(state.mutationsPtr)
expectNotNil(state.mutationsPtr)
if returnedCount == 0 {
break
}
@@ -778,7 +778,7 @@ typealias AnyObjectTuple2 = (AnyObject, AnyObject)
with: &state, objects: AutoreleasingUnsafeMutablePointer(stackBuf.baseAddress),
count: stackBufLength)
expectNotEqual(0, state.state)
expectNotEmpty(state.mutationsPtr)
expectNotNil(state.mutationsPtr)
if returnedCount == 0 {
break
}
@@ -797,7 +797,7 @@ typealias AnyObjectTuple2 = (AnyObject, AnyObject)
with: &state, objects: AutoreleasingUnsafeMutablePointer(stackBuf.baseAddress),
count: stackBufLength)
expectNotEqual(0, state.state)
expectNotEmpty(state.mutationsPtr)
expectNotNil(state.mutationsPtr)
expectEqual(0, returnedCount)
}
}

View File

@@ -91,7 +91,7 @@ mirrors.test("ForwardStructure") {
let description = w.testDescription
for c in letters.characters {
let expected = "nil: \"\(c)\""
expectNotEmpty(find(expected, within: description))
expectNotNil(find(expected, within: description))
}
}
@@ -202,7 +202,7 @@ mirrors.test("Legacy") {
expectEqual("dx", md.children.first?.label)
expectEqual(1, md.children.first?.value as? Int)
expectNotEmpty(md.superclassMirror)
expectNotNil(md.superclassMirror)
if let mb2 = md.superclassMirror { expectBMirror(mb2) }
}
@@ -215,7 +215,7 @@ mirrors.test("Legacy") {
expectEqual("dx", md.children.first?.label)
expectEqual(1, md.children.first?.value as? Int)
expectNotEmpty(md.superclassMirror)
expectNotNil(md.superclassMirror)
if let mb2 = md.superclassMirror { expectBMirror(mb2) }
}
}
@@ -275,13 +275,13 @@ mirrors.test("class/Plain/Plain") {
let b = Mirror(reflecting: B())
expectTrue(b.subjectType == B.self)
if let bChild = expectNotEmpty(b.children.first) {
if let bChild = expectNotNil(b.children.first) {
expectEqual("b", bChild.label)
expectEqual(42, bChild.value as? UInt)
}
if let a = expectNotEmpty(b.superclassMirror) {
if let a = expectNotNil(b.superclassMirror) {
expectTrue(a.subjectType == A.self)
if let aChild = expectNotEmpty(a.children.first) {
if let aChild = expectNotNil(a.children.first) {
expectEqual("a", aChild.label)
expectEqual(1, aChild.value as? Int)
expectNil(a.superclassMirror)
@@ -301,7 +301,7 @@ mirrors.test("class/UncustomizedSuper/Synthesized/Implicit") {
let b = Mirror(reflecting: B())
expectTrue(b.subjectType == B.self)
if let a = expectNotEmpty(b.superclassMirror) {
if let a = expectNotNil(b.superclassMirror) {
expectTrue(a.subjectType == A.self)
expectEqual("a", a.children.first?.label)
expectNil(a.superclassMirror)
@@ -321,7 +321,7 @@ mirrors.test("class/UncustomizedSuper/Synthesized/Explicit") {
let b = Mirror(reflecting: B())
expectTrue(b.subjectType == B.self)
if let a = expectNotEmpty(b.superclassMirror) {
if let a = expectNotNil(b.superclassMirror) {
expectTrue(a.subjectType == A.self)
expectEqual("a", a.children.first!.label)
expectNil(a.superclassMirror)
@@ -350,7 +350,7 @@ mirrors.test("class/CustomizedSuper/Synthesized") {
let b = Mirror(reflecting: B())
expectTrue(b.subjectType == B.self)
if let a = expectNotEmpty(b.superclassMirror) {
if let a = expectNotNil(b.superclassMirror) {
expectTrue(a.subjectType == A.self)
expectEqual("a", a.children.first!.label)
expectNil(a.superclassMirror)
@@ -369,16 +369,16 @@ mirrors.test("class/ObjCPlain/Plain") {
let b = Mirror(reflecting: B())
expectTrue(b.subjectType == B.self)
if let bChild = expectNotEmpty(b.children.first) {
if let bChild = expectNotNil(b.children.first) {
expectEqual("b", bChild.label)
expectEqual(42, bChild.value as? UInt)
}
if let a = expectNotEmpty(b.superclassMirror) {
if let a = expectNotNil(b.superclassMirror) {
expectTrue(a.subjectType == A.self)
if let aChild = expectNotEmpty(a.children.first) {
if let aChild = expectNotNil(a.children.first) {
expectEqual("a", aChild.label)
expectEqual(1, aChild.value as? Int)
if let o = expectNotEmpty(a.superclassMirror) {
if let o = expectNotNil(a.superclassMirror) {
expectEqual("NSObject", String(reflecting: o.subjectType))
}
}
@@ -397,10 +397,10 @@ mirrors.test("class/ObjCUncustomizedSuper/Synthesized/Implicit") {
let b = Mirror(reflecting: B())
expectTrue(b.subjectType == B.self)
if let a = expectNotEmpty(b.superclassMirror) {
if let a = expectNotNil(b.superclassMirror) {
expectTrue(a.subjectType == A.self)
expectEqual("a", a.children.first?.label)
if let o = expectNotEmpty(a.superclassMirror) {
if let o = expectNotNil(a.superclassMirror) {
expectTrue(o.subjectType == NSObject.self)
}
}
@@ -419,10 +419,10 @@ mirrors.test("class/ObjCUncustomizedSuper/Synthesized/Explicit") {
let b = Mirror(reflecting: B())
expectTrue(b.subjectType == B.self)
if let a = expectNotEmpty(b.superclassMirror) {
if let a = expectNotNil(b.superclassMirror) {
expectTrue(a.subjectType == A.self)
expectEqual("a", a.children.first!.label)
if let o = expectNotEmpty(a.superclassMirror) {
if let o = expectNotNil(a.superclassMirror) {
expectTrue(o.subjectType == NSObject.self)
}
}
@@ -450,14 +450,14 @@ mirrors.test("class/ObjCCustomizedSuper/Synthesized") {
let b = Mirror(reflecting: B())
expectTrue(b.subjectType == B.self)
if let a = expectNotEmpty(b.superclassMirror) {
if let a = expectNotNil(b.superclassMirror) {
expectTrue(a.subjectType == A.self)
expectEqual("a", a.children.first!.label)
if let d = expectNotEmpty(a.superclassMirror) {
if let d = expectNotNil(a.superclassMirror) {
expectTrue(d.subjectType == DateFormatter.self)
if let f = expectNotEmpty(d.superclassMirror) {
if let f = expectNotNil(d.superclassMirror) {
expectTrue(f.subjectType == Formatter.self)
if let o = expectNotEmpty(f.superclassMirror) {
if let o = expectNotNil(f.superclassMirror) {
expectTrue(o.subjectType == NSObject.self)
expectNil(o.superclassMirror)
}
@@ -543,7 +543,7 @@ mirrors.test("class/CustomizedSuper/SuperclassCustomMirror/Direct") {
let b = Mirror(reflecting: B())
expectTrue(b.subjectType == B.self)
if let a = expectNotEmpty(b.superclassMirror) {
if let a = expectNotNil(b.superclassMirror) {
expectTrue(a.subjectType == A.self)
expectEqual("aye", a.children.first!.label)
expectNil(a.superclassMirror)
@@ -575,14 +575,14 @@ mirrors.test("class/CustomizedSuper/SuperclassCustomMirror/Indirect") {
let b = Mirror(reflecting: B())
expectTrue(b.subjectType == B.self)
if let y = expectNotEmpty(b.superclassMirror) {
if let y = expectNotNil(b.superclassMirror) {
expectTrue(y.subjectType == Y.self)
if let x = expectNotEmpty(y.superclassMirror) {
if let x = expectNotNil(y.superclassMirror) {
expectTrue(x.subjectType == X.self)
expectEqual(0, x.children.count)
if let a = expectNotEmpty(x.superclassMirror) {
if let a = expectNotNil(x.superclassMirror) {
expectTrue(a.subjectType == A.self)
if let aye = expectNotEmpty(a.children.first) {
if let aye = expectNotNil(a.children.first) {
expectEqual("aye", aye.label)
}
}
@@ -616,9 +616,9 @@ mirrors.test("class/CustomizedSuper/SuperclassCustomMirror/Indirect2") {
let b = Mirror(reflecting: B())
expectTrue(b.subjectType == B.self)
if let a = expectNotEmpty(b.superclassMirror) {
if let a = expectNotNil(b.superclassMirror) {
expectTrue(a.subjectType == A.self)
if let aye = expectNotEmpty(a.children.first) {
if let aye = expectNotNil(a.children.first) {
expectEqual("aye", aye.label)
}
}
@@ -639,7 +639,7 @@ mirrors.test("class/Cluster") {
let a = Mirror(reflecting: Y())
expectTrue(a.subjectType == A.self)
if let aye = expectNotEmpty(a.children.first) {
if let aye = expectNotNil(a.children.first) {
expectEqual("aye", aye.label)
}
}
@@ -655,9 +655,9 @@ mirrors.test("Addressing") {
let m1 = Mirror(reflecting: (a: ["one", "two", "three"], b: 4))
let ott0 = m1.descendant(0) as? [String]
expectNotEmpty(ott0)
expectNotNil(ott0)
let ott1 = m1.descendant(".0") as? [String]
expectNotEmpty(ott1)
expectNotNil(ott1)
if ott0 != nil && ott1 != nil {
expectEqualSequence(ott0!, ott1!)
}

View File

@@ -213,7 +213,7 @@ func strideIteratorTest<
>(_ stride: Stride, nonNilResults: Int) {
var i = stride.makeIterator()
for _ in 0..<nonNilResults {
expectNotEmpty(i.next())
expectNotNil(i.next())
}
for _ in 0..<10 {
expectNil(i.next())

View File

@@ -106,11 +106,11 @@ class TestDateInterval : TestDateIntervalSuper {
let testInterval3 = DateInterval(start: start3, end: end3)
let intersection1 = testInterval2.intersection(with: testInterval1)
expectNotEmpty(intersection1)
expectNotNil(intersection1)
expectEqual(testInterval3, intersection1)
let intersection2 = testInterval1.intersection(with: testInterval2)
expectNotEmpty(intersection2)
expectNotNil(intersection2)
expectEqual(intersection1, intersection2)
}
}

View File

@@ -35,7 +35,7 @@ class TestURL : TestURLSuper {
if let isVolume = resourceValues.isVolume {
expectTrue(isVolume)
}
expectNotEmpty(resourceValues.name)
expectNotNil(resourceValues.name)
} catch {
expectTrue(false, "Should not have thrown")
}
@@ -56,7 +56,7 @@ class TestURL : TestURLSuper {
// Modify an existing resource values
do {
var resourceValues = try file.resourceValues(forKeys: [.nameKey])
expectNotEmpty(resourceValues.name)
expectNotNil(resourceValues.name)
expectEqual(resourceValues.name!, name)
let newName = "goodbye cruel " + UUID().uuidString
@@ -81,7 +81,7 @@ class TestURL : TestURLSuper {
do {
var resourceValues = try file.resourceValues(forKeys: [.labelNumberKey])
expectNotEmpty(resourceValues.labelNumber)
expectNotNil(resourceValues.labelNumber)
// set label number
resourceValues.labelNumber = 1
@@ -89,7 +89,7 @@ class TestURL : TestURLSuper {
// get label number
let _ = try file.resourceValues(forKeys: [.labelNumberKey])
expectNotEmpty(resourceValues.labelNumber)
expectNotNil(resourceValues.labelNumber)
expectEqual(resourceValues.labelNumber!, 1)
} catch (let e as NSError) {
expectTrue(false, "Unable to load or set resources \(e)")
@@ -104,7 +104,7 @@ class TestURL : TestURLSuper {
try file.setResourceValues(resourceValues)
let resourceValues2 = try file.resourceValues(forKeys: [.labelNumberKey])
expectNotEmpty(resourceValues2.labelNumber)
expectNotNil(resourceValues2.labelNumber)
expectEqual(resourceValues2.labelNumber!, 2)
} catch (let e as NSError) {
expectTrue(false, "Unable to load or set resources \(e)")
@@ -124,27 +124,27 @@ class TestURL : TestURLSuper {
// Not meant to be a test of all URL components functionality, just some basic bridging stuff
let s = "http://www.apple.com/us/search/ipad?src=globalnav"
let components = URLComponents(string: s)!
expectNotEmpty(components)
expectNotNil(components)
expectNotEmpty(components.host)
expectNotNil(components.host)
expectEqual("www.apple.com", components.host)
if #available(OSX 10.11, iOS 9.0, *) {
let rangeOfHost = components.rangeOfHost!
expectNotEmpty(rangeOfHost)
expectNotNil(rangeOfHost)
expectEqual(s[rangeOfHost], "www.apple.com")
}
if #available(OSX 10.10, iOS 8.0, *) {
let qi = components.queryItems!
expectNotEmpty(qi)
expectNotNil(qi)
expectEqual(1, qi.count)
let first = qi[0]
expectEqual("src", first.name)
expectNotEmpty(first.value)
expectNotNil(first.value)
expectEqual("globalnav", first.value)
}
}

View File

@@ -80,7 +80,7 @@ class TestUUID : TestUUIDSuper {
let valFromStr = UUID(uuidString: ref.uuidString)
expectEqual(ref.uuidString, valFromRef.uuidString)
expectEqual(ref.uuidString, valFromBytes.uuidString)
expectNotEmpty(valFromStr)
expectNotNil(valFromStr)
expectEqual(ref.uuidString, valFromStr!.uuidString)
}

View File

@@ -63,17 +63,17 @@ class TestUserInfo : TestUserInfoSuper {
AnyHashable(userInfoKey) : testStructure
]
let note = Notification(name: notifName, userInfo: info)
expectNotEmpty(note.userInfo)
expectNotNil(note.userInfo)
let nc = NotificationCenter.default
nc.addObserver(self, selector: #selector(TestUserInfo.notification(_:)), name: notifName, object: nil)
nc.post(note)
expectNotEmpty(posted)
expectNotNil(posted)
if let notification = posted {
let postedInfo = notification.userInfo
expectNotEmpty(postedInfo)
expectNotNil(postedInfo)
if let userInfo = postedInfo {
let postedValue = userInfo[AnyHashable(userInfoKey)] as? SomeStructure
expectNotEmpty(postedValue)
expectNotNil(postedValue)
if let value = postedValue {
validate(testStructure, value)
}

View File

@@ -60,7 +60,7 @@ UnmanagedTests.test("Opaque") {
let unknownPtr = Int(bitPattern: opaquePtr)
let voidPtr = UnsafeRawPointer(bitPattern: unknownPtr)
expectNotEmpty(voidPtr, "toOpaque must not return null pointer")
expectNotNil(voidPtr, "toOpaque must not return null pointer")
let unmanaged = Unmanaged<Foobar>.fromOpaque(voidPtr!)
expectEqual(

View File

@@ -65,7 +65,7 @@ ${SelfName}TestSuite.test("initFromOpaquePointer") {
let optionalOther: Optional = other
let optionalPointer = ${SelfType}(optionalOther)
expectNotEmpty(optionalPointer)
expectNotNil(optionalPointer)
expectEqual(0x12345678, unsafeBitCast(optionalPointer, to: Int.self))
let nilOther: Optional<OpaquePointer> = nil
@@ -85,7 +85,7 @@ UnsafeMutableRawPointerTestSuite.test("initFromMutating") {
let optionalOther: Optional = other
let optionalPointer = UnsafeMutableRawPointer(mutating: optionalOther)
expectNotEmpty(optionalPointer)
expectNotNil(optionalPointer)
expectEqual(0x12345678, unsafeBitCast(optionalPointer, to: Int.self))
let nilOther: Optional<UnsafeRawPointer> = nil
@@ -110,13 +110,13 @@ ${SelfName}TestSuite.test("initFromInteger") {
do {
let word: Int = 0x12345678
let ptr = ${SelfType}(bitPattern: word)
expectNotEmpty(ptr)
expectNotNil(ptr)
expectEqual(word, unsafeBitCast(ptr, to: Int.self))
}
do {
let uword: UInt = 0x12345678
let ptr = ${SelfType}(bitPattern: uword)
expectNotEmpty(ptr)
expectNotNil(ptr)
expectEqual(uword, unsafeBitCast(ptr, to: UInt.self))
}
}
@@ -185,7 +185,7 @@ ${SelfName}TestSuite.test("initFromUnsafeMutablePointer") {
let optionalOther: Optional = other
let optionalPointer = ${SelfType}(optionalOther)
expectNotEmpty(optionalPointer)
expectNotNil(optionalPointer)
expectEqual(0x12345678, unsafeBitCast(optionalPointer, to: Int.self))
let nilOther: Optional<UnsafeMutablePointer<Float>> = nil
@@ -206,7 +206,7 @@ ${SelfName}TestSuite.test("initFromUnsafePointer") {
let optionalOther: Optional = other
let optionalPointer = ${SelfType}(optionalOther)
expectNotEmpty(optionalPointer)
expectNotNil(optionalPointer)
expectEqual(0x12345678, unsafeBitCast(optionalPointer, to: Int.self))
let nilOther: Optional<UnsafePointer<Float>> = nil
@@ -223,7 +223,7 @@ UnsafeRawPointerTestSuite.test("initFromUnsafeMutableRawPointer") {
let optionalOther: Optional = other
let optionalPointer = UnsafeRawPointer(optionalOther)
expectNotEmpty(optionalPointer)
expectNotNil(optionalPointer)
expectEqual(0x12345678, unsafeBitCast(optionalPointer, to: Int.self))
let nilOther: Optional<UnsafeMutableRawPointer> = nil

View File

@@ -86,12 +86,12 @@ tests.test("${Collection}/Down/${method}/${Key1}=>${Key0}") {
% if method == 'Direct':
guard let downcasted = expectNotEmpty(source as? ${Collection}<${Key0}>)
guard let downcasted = expectNotNil(source as? ${Collection}<${Key0}>)
else { return }
% else:
guard let downcasted = expectNotEmpty(cast(source, to: ${Collection}<${Key0}>.self))
guard let downcasted = expectNotNil(cast(source, to: ${Collection}<${Key0}>.self))
else { return }
% end
@@ -126,18 +126,18 @@ tests.test(
% else:
let upcasted_ = source as Any as? [${Key1}:${Value1}]
guard let upcasted = expectNotEmpty(upcasted_) else { return }
guard let upcasted = expectNotNil(upcasted_) else { return }
% end
expectEqual(source.count, upcasted.count)
for (k0, v0) in source {
guard let v1 = expectNotEmpty(upcasted[k0]) else { continue }
guard let v1 = expectNotNil(upcasted[k0]) else { continue }
guard let dv0 = expectNotEmpty(
guard let dv0 = expectNotNil(
cast(v0, to: ${DynamicValue}.self)) else { continue }
guard let dv1 = expectNotEmpty(
guard let dv1 = expectNotNil(
cast(v1, to: ${DynamicValue}.self)) else { continue }
expectEqual(dv0, dv1)
@@ -156,18 +156,18 @@ tests.test(
${DynamicKey}(42) as ${Key1} : ${DynamicValue}(42) as ${Value1},
${DynamicKey}(17) as ${Key1} : ${DynamicValue}(17) as ${Value1}]
guard let downcasted = expectNotEmpty(source as? [${Key0}:${Value0}])
guard let downcasted = expectNotNil(source as? [${Key0}:${Value0}])
else { return }
expectEqual(source.count, downcasted.count)
for (k0, v0) in downcasted {
guard let v1 = expectNotEmpty(source[k0]) else { continue }
guard let v1 = expectNotNil(source[k0]) else { continue }
guard let dv0 = expectNotEmpty(
guard let dv0 = expectNotNil(
cast(v0, to: ${DynamicValue}.self)) else { continue }
guard let dv1 = expectNotEmpty(
guard let dv1 = expectNotNil(
cast(v1, to: ${DynamicValue}.self)) else { continue }
expectEqual(dv0, dv1)

View File

@@ -189,7 +189,7 @@ CoreAudioTestSuite.test(
do {
let ablPtrWrapper = UnsafeMutableAudioBufferListPointer(
UnsafeMutablePointer<AudioBufferList>(bitPattern: 0x1234_5678))
expectNotEmpty(ablPtrWrapper)
expectNotNil(ablPtrWrapper)
expectEqual(
UnsafePointer<AudioBufferList>(bitPattern: 0x1234_5678),
ablPtrWrapper!.unsafePointer)

View File

@@ -22,7 +22,7 @@ CoreDataTests.test("downcasting") {
expectType([NSFetchRequestResult].self, &dictionaries)
let casted = dictionaries as? [[NSObject: AnyObject]]
expectNotEmpty(casted)
expectNotNil(casted)
expectEqual([[:] as NSDictionary, [:] as NSDictionary] as NSArray, casted! as NSArray)
expectEqual([[:] as NSDictionary, [:] as NSDictionary] as NSArray, dictionaries as! [[NSObject: AnyObject]] as NSArray)
}
@@ -33,7 +33,7 @@ CoreDataTests.test("bridging") {
expectEqual([[:], [:]], dictionaries)
let casted = dictionaries as? [[NSObject: AnyObject]]
expectNotEmpty(casted)
expectNotNil(casted)
expectEqual([[:] as NSDictionary, [:] as NSDictionary] as NSArray, casted! as NSArray)
expectEqual([[:] as NSDictionary, [:] as NSDictionary] as NSArray, dictionaries as! [[NSObject: AnyObject]] as NSArray)
}

View File

@@ -359,7 +359,7 @@ tests.test("ForwardCollection") {
expectEqual(a0, a1)
for e in a0 {
let i = fc0.index(of: e)
expectNotEmpty(i)
expectNotNil(i)
expectEqual(e, fc0[i!])
}
for i in fc0.indices {
@@ -373,7 +373,7 @@ tests.test("BidirectionalCollection") {
let fc0 = AnyCollection(a0.lazy.reversed())
let bc0_ = AnyBidirectionalCollection(fc0) // upgrade!
expectNotEmpty(bc0_)
expectNotNil(bc0_)
let bc0 = bc0_!
expectTrue(storesSameUnderlyingCollection(fc0, bc0))
@@ -387,7 +387,7 @@ tests.test("BidirectionalCollection") {
expectEqual(a0, a1)
for e in a0 {
let i = bc0.index(of: e)
expectNotEmpty(i)
expectNotNil(i)
expectEqual(e, bc0[i!])
}
for i in bc0.indices {
@@ -408,7 +408,7 @@ tests.test("RandomAccessCollection") {
let a0: ContiguousArray = [1, 2, 3, 5, 8, 13, 21]
let fc0 = AnyCollection(a0.lazy.reversed())
let rc0_ = AnyRandomAccessCollection(fc0) // upgrade!
expectNotEmpty(rc0_)
expectNotNil(rc0_)
let rc0 = rc0_!
expectTrue(storesSameUnderlyingCollection(rc0, fc0))
@@ -422,7 +422,7 @@ tests.test("RandomAccessCollection") {
expectEqual(a0, a1)
for e in a0 {
let i = rc0.index(of: e)
expectNotEmpty(i)
expectNotNil(i)
expectEqual(e, rc0[i!])
}
for i in rc0.indices {

View File

@@ -88,7 +88,7 @@ FloatingPointConversionFailures.test("${OtherFloat}To${Self}FailableConversion")
input in
let result = ${Self}(exactly: input)
% if OtherSignificandBits <= SelfSignificandBits:
if let result = expectNotEmpty(result) {
if let result = expectNotNil(result) {
// FIXME: we should have a stronger postcondition here.
expectEqual(input, ${OtherFloat}(result))
}

View File

@@ -71,7 +71,7 @@ GamePlayKitTests.test("GKEntity.component(ofType)") {
var componentForOtherTestComponent_nil =
entity.component(ofType: OtherTestComponent.self)
expectNotEmpty(componentForTestComponent)
expectNotNil(componentForTestComponent)
expectType(Optional<TestComponent>.self, &componentForTestComponent)
expectNil(componentForOtherTestComponent_nil)
@@ -86,7 +86,7 @@ GamePlayKitTests.test("GKEntity.component(ofType)") {
var componentForTestComponent_nil =
entity.component(ofType: TestComponent.self)
expectNotEmpty(componentForOtherTestComponent)
expectNotNil(componentForOtherTestComponent)
expectType(Optional<OtherTestComponent>.self, &componentForOtherTestComponent)
expectNil(componentForTestComponent_nil)
@@ -104,7 +104,7 @@ GamePlayKitTests.test("GKStateMachine.state(forClass:)") {
var stateForTestState2_nil =
stateMachine.state(forClass: TestState2.self)
expectNotEmpty(stateForTestState1)
expectNotNil(stateForTestState1)
expectType(Optional<TestState1>.self, &stateForTestState1)
expectNil(stateForTestState2_nil)
@@ -120,7 +120,7 @@ GamePlayKitTests.test("GKStateMachine.state(forClass:)") {
var stateForTestState1_nil =
stateMachine.state(forClass: TestState1.self)
expectNotEmpty(stateForTestState2)
expectNotNil(stateForTestState2)
expectType(Optional<TestState2>.self, &stateForTestState2)
expectNil(stateForTestState1_nil)

View File

@@ -258,7 +258,7 @@ NSNumberTests.test("${Self} bridges to NSNumber (actually _SwiftTypePreservingNS
% else:
expectTrue(isTypePreservingNSNumber(bridgedNSNumber))
% end
expectNotEmpty(bridgedNSNumber._toCustomAnyHashable())
expectNotNil(bridgedNSNumber._toCustomAnyHashable())
// Explicitly constructed NSNumbers don't have a special AnyHashable
// representation.

View File

@@ -18,7 +18,7 @@ NSStringTests.test("NSString bridges to String with custom AnyHashable")
.forEach(in: ["", "a", "abc", "a\u{0301}", "\u{e1}"]) {
input in
let s = input._bridgeToObjectiveC()
expectNotEmpty(s._toCustomAnyHashable())
expectNotNil(s._toCustomAnyHashable())
expectEqual(String.self, type(of: AnyHashable(s).base))
}

View File

@@ -354,7 +354,7 @@ if #available(iOS 8.0, *) {
var unarchivedPlaneNode_nil =
sceneSource.entryWithIdentifier("plane-node", withClass: SCNNode.self)
expectNotEmpty(unarchivedPlaneGeometry)
expectNotNil(unarchivedPlaneGeometry)
expectType(Optional<SCNGeometry>.self, &unarchivedPlaneGeometry)
expectNil(unarchivedPlaneNode_nil)
@@ -366,7 +366,7 @@ if #available(iOS 8.0, *) {
var unarchivedBoxGeometry_nil =
sceneSource.entryWithIdentifier("box-node", withClass: SCNGeometry.self)
expectNotEmpty(unarchivedBoxGeometry)
expectNotNil(unarchivedBoxGeometry)
expectType(Optional<SCNGeometry>.self, &unarchivedBoxGeometry)
expectNil(unarchivedBoxGeometry_nil)
@@ -378,7 +378,7 @@ if #available(iOS 8.0, *) {
var unarchivedBoxNode_nil =
sceneSource.entryWithIdentifier("box", withClass: SCNNode.self)
expectNotEmpty(unarchivedBoxNode)
expectNotNil(unarchivedBoxNode)
expectType(Optional<SCNNode>.self, &unarchivedBoxNode)
expectNil(unarchivedBoxNode_nil)

View File

@@ -1005,7 +1005,7 @@ SetTestSuite.test("COW.Fast.FirstDoesNotReallocate") {
var s = getCOWFastSet()
var identity1 = s._rawIdentifier()
expectNotEmpty(s.first)
expectNotNil(s.first)
expectEqual(identity1, s._rawIdentifier())
}
@@ -1021,7 +1021,7 @@ SetTestSuite.test("COW.Slow.FirstDoesNotReallocate") {
var s = getCOWSlowSet()
var identity1 = s._rawIdentifier()
expectNotEmpty(s.first)
expectNotNil(s.first)
expectEqual(identity1, s._rawIdentifier())
}
@@ -1236,7 +1236,7 @@ SetTestSuite.test("BridgedFromObjC.Verbatim.SetIsCopied") {
expectTrue(isCocoaSet(s))
expectTrue(s.contains(TestObjCKeyTy(1010)))
expectNotEmpty(nss.member(TestObjCKeyTy(1010)))
expectNotNil(nss.member(TestObjCKeyTy(1010)))
nss.remove(TestObjCKeyTy(1010))
expectNil(nss.member(TestObjCKeyTy(1010)))
@@ -1249,7 +1249,7 @@ SetTestSuite.test("BridgedFromObjC.Nonverbatim.SetIsCopied") {
expectTrue(isNativeSet(s))
expectTrue(s.contains(TestBridgedKeyTy(1010)))
expectNotEmpty(nss.member(TestBridgedKeyTy(1010) as AnyObject))
expectNotNil(nss.member(TestBridgedKeyTy(1010) as AnyObject))
nss.remove(TestBridgedKeyTy(1010) as AnyObject)
expectNil(nss.member(TestBridgedKeyTy(1010) as AnyObject))

View File

@@ -35,7 +35,7 @@ func expectSortedCollection(_ sortedAry: [Int], _ originalAry: [Int]) {
}
// Now check if sets of elements are the same in both arrays.
for (key, value) in sortedVals {
expectNotEmpty(originalVals[key])
expectNotNil(originalVals[key])
expectEqual(originalVals[key]!, value)
}

View File

@@ -189,7 +189,7 @@ tests.test("index-mapping/utf16-to-utf8") {
} ?? []
}, sameValue: ==)
expectNotEmpty(winter.utf16.endIndex.samePosition(in: winter.utf8))
expectNotNil(winter.utf16.endIndex.samePosition(in: winter.utf8))
expectEqual(
winter.utf8.endIndex,
winter.utf16.endIndex.samePosition(in: winter.utf8)!)
@@ -201,7 +201,7 @@ tests.test("index-mapping/utf16-to-utf8") {
}
)
expectNotEmpty(summer.utf16.endIndex.samePosition(in: summer.utf8))
expectNotNil(summer.utf16.endIndex.samePosition(in: summer.utf8))
expectEqual(
summer.utf8.endIndex,
summer.utf16.endIndex.samePosition(in: summer.utf8)!)
@@ -229,7 +229,7 @@ tests.test("index-mapping/utf8-to-unicode-scalar") {
}, sameValue: ==
)
expectNotEmpty(winter.utf8.endIndex.samePosition(in: winter.unicodeScalars))
expectNotNil(winter.utf8.endIndex.samePosition(in: winter.unicodeScalars))
expectEqual(
winter.unicodeScalars.endIndex,
winter.utf8.endIndex.samePosition(in: winter.unicodeScalars)!)
@@ -243,7 +243,7 @@ tests.test("index-mapping/utf8-to-unicode-scalar") {
}, sameValue: ==
)
expectNotEmpty(summer.utf8.endIndex.samePosition(in: summer.unicodeScalars))
expectNotNil(summer.utf8.endIndex.samePosition(in: summer.unicodeScalars))
expectEqual(
summer.unicodeScalars.endIndex,
summer.utf8.endIndex.samePosition(in: summer.unicodeScalars)!)
@@ -269,7 +269,7 @@ tests.test("index-mapping/utf16-to-unicode-scalar") {
}, sameValue: ==
)
expectNotEmpty(winter.utf16.endIndex.samePosition(in: winter.unicodeScalars))
expectNotNil(winter.utf16.endIndex.samePosition(in: winter.unicodeScalars))
expectEqual(
winter.unicodeScalars.endIndex,
winter.utf16.endIndex.samePosition(in: winter.unicodeScalars)!)
@@ -283,7 +283,7 @@ tests.test("index-mapping/utf16-to-unicode-scalar") {
}, sameValue: ==
)
expectNotEmpty(summer.utf16.endIndex.samePosition(in: summer.unicodeScalars))
expectNotNil(summer.utf16.endIndex.samePosition(in: summer.unicodeScalars))
expectEqual(
summer.unicodeScalars.endIndex,
summer.utf16.endIndex.samePosition(in: summer.unicodeScalars)!)
@@ -376,7 +376,7 @@ tests.test("index-mapping/utf8-to-utf16") {
}
}, sameValue: ==)
expectNotEmpty(winter.utf8.endIndex.samePosition(in: winter.utf16))
expectNotNil(winter.utf8.endIndex.samePosition(in: winter.utf16))
expectEqual(
winter.utf16.endIndex,
winter.utf8.endIndex.samePosition(in: winter.utf16)!)
@@ -386,7 +386,7 @@ tests.test("index-mapping/utf8-to-utf16") {
summer.utf8.indices.map { summer.utf16[$0.samePosition(in: summer.utf16)!] }
)
expectNotEmpty(summer.utf8.endIndex.samePosition(in: summer.utf16))
expectNotNil(summer.utf8.endIndex.samePosition(in: summer.utf16))
expectEqual(
summer.utf16.endIndex,
summer.utf8.endIndex.samePosition(in: summer.utf16)!)
@@ -446,7 +446,7 @@ tests.test("index-mapping/utf8-to-unicode-scalar") {
}
}, sameValue: ==)
expectNotEmpty(winter.utf8.endIndex.samePosition(in: winter.unicodeScalars))
expectNotNil(winter.utf8.endIndex.samePosition(in: winter.unicodeScalars))
expectEqual(
winter.unicodeScalars.endIndex,
winter.utf8.endIndex.samePosition(in: winter.unicodeScalars)!)
@@ -459,7 +459,7 @@ tests.test("index-mapping/utf8-to-unicode-scalar") {
}
}, sameValue: ==)
expectNotEmpty(summer.utf8.endIndex.samePosition(in: summer.unicodeScalars))
expectNotNil(summer.utf8.endIndex.samePosition(in: summer.unicodeScalars))
expectEqual(
summer.unicodeScalars.endIndex,
summer.utf8.endIndex.samePosition(in: summer.unicodeScalars)!)
@@ -485,7 +485,7 @@ tests.test("index-mapping/utf16-to-unicode-scalar") {
}
}, sameValue: ==)
expectNotEmpty(winter.utf16.endIndex.samePosition(in: winter.unicodeScalars))
expectNotNil(winter.utf16.endIndex.samePosition(in: winter.unicodeScalars))
expectEqual(
winter.unicodeScalars.endIndex,
winter.utf16.endIndex.samePosition(in: winter.unicodeScalars)!)
@@ -498,7 +498,7 @@ tests.test("index-mapping/utf16-to-unicode-scalar") {
}
}, sameValue: ==)
expectNotEmpty(summer.utf16.endIndex.samePosition(in: summer.unicodeScalars))
expectNotNil(summer.utf16.endIndex.samePosition(in: summer.unicodeScalars))
expectEqual(
summer.unicodeScalars.endIndex,
summer.utf16.endIndex.samePosition(in: summer.unicodeScalars)!)
@@ -555,7 +555,7 @@ tests.test("index-mapping/utf8-to-character") {
}
}, sameValue: ==)
expectNotEmpty(winter.utf8.endIndex.samePosition(in: winter))
expectNotNil(winter.utf8.endIndex.samePosition(in: winter))
expectEqual(
winter.endIndex,
winter.utf8.endIndex.samePosition(in: winter)!)
@@ -565,7 +565,7 @@ tests.test("index-mapping/utf8-to-character") {
summer.utf8.indices.map { summer[$0.samePosition(in: summer)!] }
)
expectNotEmpty(summer.utf8.endIndex.samePosition(in: summer))
expectNotNil(summer.utf8.endIndex.samePosition(in: summer))
expectEqual(
summer.endIndex,
summer.utf8.endIndex.samePosition(in: summer)!)
@@ -585,7 +585,7 @@ tests.test("index-mapping/utf16-to-character") {
}
}, sameValue: ==)
expectNotEmpty(winter.utf16.endIndex.samePosition(in: winter))
expectNotNil(winter.utf16.endIndex.samePosition(in: winter))
expectEqual(
winter.endIndex,
winter.utf16.endIndex.samePosition(in: winter)!)
@@ -597,7 +597,7 @@ tests.test("index-mapping/utf16-to-character") {
}
)
expectNotEmpty(summer.utf16.endIndex.samePosition(in: summer))
expectNotNil(summer.utf16.endIndex.samePosition(in: summer))
expectEqual(
summer.endIndex,
summer.utf16.endIndex.samePosition(in: summer)!)