Files
swift-mirror/validation-test/stdlib/CoreData.swift
Joe Groff 11f03cd8b5 Sema: Don't try bridged classes as default literal types.
One last bit of SE-0072. We shouldn't fall back to bridged classes in the absence of type context for literals anymore. By itself, this kind of hoses the use of literals with NS types, but I think we can get most of the QoI back with overlay changes I plan to propose following this.
2016-07-29 15:18:31 -07:00

42 lines
1.6 KiB
Swift

// RUN: rm -rf %t && mkdir -p %t
// RUN: %target-clang %S/Inputs/CoreDataHelper/CoreDataHelper.m -c -o %t/CoreDataHelper.o -g -fmodules
// RUN: %target-build-swift %s -import-objc-header %S/Inputs/CoreDataHelper/CoreDataHelper.h -Xlinker %t/CoreDataHelper.o -o %t/main
// RUN: %target-run %t/main
// REQUIRES: executable_test
// REQUIRES: objc_interop
import CoreData
import StdlibUnittest
var CoreDataTests = TestSuite("CoreData")
CoreDataTests.test("conformsToProtocol") {
expectTrue(NSDictionary.conforms(to: NSFetchRequestResult.self))
expectTrue(NSManagedObject.conforms(to: NSFetchRequestResult.self))
}
CoreDataTests.test("downcasting") {
var dictionaries = NSFetchRequest<NSFetchRequestResult>.testGettingSomeDictionaries()
expectType([NSFetchRequestResult].self, &dictionaries)
let casted = dictionaries as? [[NSObject: AnyObject]]
expectNotEmpty(casted)
expectEqual([[:] as NSDictionary, [:] as NSDictionary] as NSArray, casted! as NSArray)
expectEqual([[:] as NSDictionary, [:] as NSDictionary] as NSArray, dictionaries as! [[NSObject: AnyObject]] as NSArray)
}
CoreDataTests.test("bridging") {
var dictionaries = NSFetchRequest<NSDictionary>.testGettingSomeDictionaries()
expectType([NSDictionary].self, &dictionaries)
expectEqual([[:], [:]], dictionaries)
let casted = dictionaries as? [[NSObject: AnyObject]]
expectNotEmpty(casted)
expectEqual([[:] as NSDictionary, [:] as NSDictionary] as NSArray, casted! as NSArray)
expectEqual([[:] as NSDictionary, [:] as NSDictionary] as NSArray, dictionaries as! [[NSObject: AnyObject]] as NSArray)
}
runAllTests()