Files
swift-mirror/validation-test/stdlib/CoreData.swift
2016-06-23 12:47:22 -07:00

42 lines
1.4 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([[:], [:]], casted!)
expectEqual([[:], [:]], dictionaries as! [[NSObject: AnyObject]])
}
CoreDataTests.test("bridging") {
var dictionaries = NSFetchRequest<NSDictionary>.testGettingSomeDictionaries()
expectType([NSDictionary].self, &dictionaries)
expectEqual([[:], [:]], dictionaries)
let casted = dictionaries as? [[NSObject: AnyObject]]
expectNotEmpty(casted)
expectEqual([[:], [:]], casted!)
expectEqual([[:], [:]], dictionaries as! [[NSObject: AnyObject]])
}
runAllTests()