Files
swift-mirror/test/Interpreter/objc_class_properties_runtime.swift
Eric Miotto a566c10d3d Use %target-swiftc_driver in objc_class_properties_runtime.swift (#70689)
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
2024-01-04 07:16:59 -08:00

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()