mirror of
https://github.com/apple/swift.git
synced 2025-12-14 20:36:38 +01:00
This way we will compile the test program with `-Xlinker -headerpad_max_install_names`, which will allow `swift-darwin-postprocess.py` to amend the install names without errors. Take the chance to remove the `-target` parameter -- that is already provided by %target-swiftc_driver, and we have no need to enforce it to be at least `macosx10.11` (since by virtue of build-script defaults and Xcode in CI we don't support anything lower than `macosx10.13`) Addresses rdar://119907089
87 lines
1.8 KiB
Swift
87 lines
1.8 KiB
Swift
// RUN: %empty-directory(%t)
|
|
|
|
// RUN: %clang -arch %target-cpu -target %target-cpu-apple-macosx10.11 -isysroot %sdk -fobjc-arc %S/Inputs/ObjCClasses/ObjCClasses.m -c -o %t/ObjCClasses.o
|
|
|
|
// RUN: %target-swiftc_driver -sdk %sdk -I %S/Inputs/ObjCClasses/ %t/ObjCClasses.o %s -o %t/a.out
|
|
// RUN: %target-codesign %t/a.out
|
|
// RUN: %target-run %t/a.out
|
|
|
|
// REQUIRES: OS=macosx
|
|
// REQUIRES: executable_test
|
|
// REQUIRES: objc_interop
|
|
|
|
import Foundation
|
|
import StdlibUnittest
|
|
import ObjCClasses
|
|
|
|
class SwiftClass : ProtoWithClassProperty {
|
|
static var getCount = 0
|
|
static var setCount = 0
|
|
|
|
private static var _value: CInt = 0
|
|
|
|
@objc class func reset() {
|
|
getCount = 0
|
|
setCount = 0
|
|
_value = 0
|
|
}
|
|
|
|
@objc class var value: CInt {
|
|
get {
|
|
getCount += 1
|
|
return _value
|
|
}
|
|
set {
|
|
setCount += 1
|
|
_value = newValue
|
|
}
|
|
}
|
|
|
|
@objc class var optionalClassProp: Bool {
|
|
return true
|
|
}
|
|
}
|
|
|
|
class Subclass : ClassWithClassProperty {
|
|
static var getCount = 0
|
|
static var setCount = 0
|
|
|
|
override class func reset() {
|
|
getCount = 0
|
|
setCount = 0
|
|
super.reset()
|
|
}
|
|
|
|
override class var value: CInt {
|
|
get {
|
|
getCount += 1
|
|
return super.value
|
|
}
|
|
set {
|
|
setCount += 1
|
|
super.value = newValue
|
|
}
|
|
}
|
|
|
|
override class var optionalClassProp: Bool {
|
|
return true
|
|
}
|
|
}
|
|
|
|
var ClassProperties = TestSuite("ClassProperties")
|
|
|
|
ClassProperties.test("runtime")
|
|
.skip(.osxMinorRange(10, 0...10, reason: "not supported on 10.10 or below"))
|
|
.code {
|
|
let theClass: AnyObject = SwiftClass.self
|
|
let prop = class_getProperty(object_getClass(theClass), "value")
|
|
expectNotNil(prop)
|
|
|
|
let nameAsCString = property_getName(prop!)
|
|
expectNotNil(nameAsCString)
|
|
expectEqual("value", String(cString: nameAsCString))
|
|
}
|
|
|
|
runAllTests()
|
|
|