Files
swift-mirror/test/Runtime/demangleToMetadataObjC.swift
Doug Gregor 9916fdf17e [Runtime] Support lookup of Objective-C protocols.
Protocols defined in Objective-C are mangled differently from
Swift-defined protocols. Recognize this mangling and search for the
appropriate Objective-C protocol using the Objective-C runtime.
2018-01-10 16:46:12 -08:00

37 lines
918 B
Swift

// RUN: %target-run-simple-swift
// REQUIRES: executable_test
// REQUIRES: objc_interop
import StdlibUnittest
import Foundation
let DemangleToMetadataTests = TestSuite("DemangleToMetadataObjC")
@objc class C : NSObject { }
@objc enum E: Int { case a }
@objc protocol P1 { }
DemangleToMetadataTests.test("@objc classes") {
expectEqual(type(of: C()), _typeByMangledName("4main1CC")!)
}
DemangleToMetadataTests.test("@objc enums") {
expectEqual(type(of: E.a), _typeByMangledName("4main1EO")!)
}
func f1_composition_objc_protocol(_: P1) { }
DemangleToMetadataTests.test("@objc protocols") {
expectEqual(type(of: f1_composition_objc_protocol),
_typeByMangledName("yy4main2P1_pc")!)
}
func f1_composition_NSCoding(_: NSCoding) { }
DemangleToMetadataTests.test("Objective-C protocols") {
expectEqual(type(of: f1_composition_NSCoding), _typeByMangledName("yySo8NSCoding_pc")!)
}
runAllTests()