|
| 1 | +// RUN: rm -rf %t && mkdir -p %t |
| 2 | + |
| 3 | +// RUN: %target-clang %S/Inputs/CoreDataHelper/CoreDataHelper.m -c -o %t/CoreDataHelper.o -g -fmodules |
| 4 | +// RUN: %target-build-swift %s -import-objc-header %S/Inputs/CoreDataHelper/CoreDataHelper.h -Xlinker %t/CoreDataHelper.o -o %t/main |
| 5 | +// RUN: %target-run %t/main |
| 6 | + |
| 7 | +// REQUIRES: executable_test |
| 8 | +// REQUIRES: objc_interop |
| 9 | + |
| 10 | +import CoreData |
| 11 | +import StdlibUnittest |
| 12 | + |
| 13 | +var CoreDataTests = TestSuite("CoreData") |
| 14 | + |
| 15 | +CoreDataTests.test("conformsToProtocol") { |
| 16 | + expectTrue(NSDictionary.conforms(to: NSFetchRequestResult.self)) |
| 17 | + expectTrue(NSManagedObject.conforms(to: NSFetchRequestResult.self)) |
| 18 | +} |
| 19 | + |
| 20 | +CoreDataTests.test("downcasting") { |
| 21 | + var dictionaries = NSFetchRequest<NSFetchRequestResult>.testGettingSomeDictionaries() |
| 22 | + expectType([NSFetchRequestResult].self, &dictionaries) |
| 23 | + |
| 24 | + let casted = dictionaries as? [[NSObject: AnyObject]] |
| 25 | + expectNotEmpty(casted) |
| 26 | + expectEqual([[:], [:]], casted!) |
| 27 | + expectEqual([[:], [:]], dictionaries as! [[NSObject: AnyObject]]) |
| 28 | +} |
| 29 | + |
| 30 | +CoreDataTests.test("bridging") { |
| 31 | + var dictionaries = NSFetchRequest<NSDictionary>.testGettingSomeDictionaries() |
| 32 | + expectType([NSDictionary].self, &dictionaries) |
| 33 | + expectEqual([[:], [:]], dictionaries) |
| 34 | + |
| 35 | + let casted = dictionaries as? [[NSObject: AnyObject]] |
| 36 | + expectNotEmpty(casted) |
| 37 | + expectEqual([[:], [:]], casted!) |
| 38 | + expectEqual([[:], [:]], dictionaries as! [[NSObject: AnyObject]]) |
| 39 | +} |
| 40 | + |
| 41 | +runAllTests() |
0 commit comments