Files
swift-mirror/test/ModuleInterface/stored-properties.swift
Daniel Rodríguez Troitiño ba68faaed5 [test] Mark tests that use experimental/upcoming features as such
Find all the usages of `--enable-experimental-feature` or
`--enable-upcoming-feature` in the tests and replace some of the
`REQUIRES: asserts` to use `REQUIRES: swift-feature-Foo` instead, which
should correctly apply to depending on the asserts/noasserts mode of the
toolchain for each feature.

Remove some comments that talked about enabling asserts since they don't
apply anymore (but I might had miss some).

All this was done with an automated script, so some formatting weirdness
might happen, but I hope I fixed most of those.

There might be some tests that were `REQUIRES: asserts` that might run
in `noasserts` toolchains now. This will normally be because their
feature went from experimental to upcoming/base and the tests were not
updated.
2024-11-02 11:46:46 -07:00

126 lines
4.9 KiB
Swift

// RUN: %empty-directory(%t)
// RUN: %target-swift-frontend -enable-experimental-feature StructLetDestructuring -typecheck -emit-module-interface-path %t.swiftinterface -module-name StoredProperties %s
// RUN: %target-swift-typecheck-module-from-interface(%t.swiftinterface) -module-name StoredProperties
// RUN: %FileCheck %s < %t.swiftinterface --check-prefix CHECK --check-prefix COMMON
// RUN: %target-swift-frontend -enable-experimental-feature StructLetDestructuring -typecheck -emit-module-interface-path %t-resilient.swiftinterface -module-name StoredProperties -enable-library-evolution %s
// RUN: %target-swift-typecheck-module-from-interface(%t-resilient.swiftinterface) -module-name StoredProperties
// RUN: %FileCheck %s < %t-resilient.swiftinterface --check-prefix RESILIENT --check-prefix COMMON
// RUN: %target-swift-frontend -enable-experimental-feature StructLetDestructuring -emit-module -o %t/Test.swiftmodule -module-name StoredProperties %t.swiftinterface -disable-objc-attr-requires-foundation-module
// RUN: %target-swift-frontend -enable-experimental-feature StructLetDestructuring -emit-module -o /dev/null -merge-modules %t/Test.swiftmodule -module-name StoredProperties -emit-module-interface-path - | %FileCheck %s --check-prefix CHECK --check-prefix COMMON
// RUN: %target-swift-frontend -enable-experimental-feature StructLetDestructuring -emit-module -o %t/TestResilient.swiftmodule -module-name StoredProperties -enable-library-evolution %t-resilient.swiftinterface -disable-objc-attr-requires-foundation-module
// RUN: %target-swift-frontend -enable-experimental-feature StructLetDestructuring -emit-module -o /dev/null -merge-modules %t/TestResilient.swiftmodule -module-name StoredProperties -enable-library-evolution -emit-module-interface-path - | %FileCheck %s --check-prefix RESILIENT --check-prefix COMMON
// REQUIRES: swift_feature_StructLetDestructuring
// COMMON: public struct HasStoredProperties {
public struct HasStoredProperties {
// COMMON: public var computedGetter: Swift.Int {
// COMMON-NEXT: get
// COMMON-NEXT: }
public var computedGetter: Int { return 3 }
// COMMON: public var computedGetSet: Swift.Int {
// COMMON-NEXT: get
// COMMON-NEXT: set
// COMMON-NEXT: }
public var computedGetSet: Int {
get { return 3 }
set {}
}
// COMMON: public let simpleStoredImmutable: Swift.Int{{$}}
public let simpleStoredImmutable: Int
// COMMON: public var simpleStoredMutable: Swift.Int{{$}}
public var simpleStoredMutable: Int
// CHECK: @_hasStorage public var storedWithObservers: Swift.Bool {
// RESILIENT: {{^}} public var storedWithObservers: Swift.Bool {
// CHECK-NEXT: {{^}} @_transparent get
// RESILIENT-NEXT: {{^}} get
// COMMON-NEXT: {{^}} set
// COMMON-NEXT: {{^}} }
public var storedWithObservers: Bool {
willSet {}
}
// CHECK: @_hasStorage public var storedPrivateSet: Swift.Int {
// RESILIENT: {{^}} public var storedPrivateSet: Swift.Int {
// COMMON-NEXT: {{^}} get
// COMMON-NEXT: {{^}} }
public private(set) var storedPrivateSet: Int
// CHECK: private var privateVar: Swift.Bool
// RESILIENT-NOT: private var privateVar: Swift.Bool
private var privateVar: Bool
// CHECK: @_hasStorage @_hasInitialValue public var storedWithObserversInitialValue: Swift.Int {
// RESILIENT: {{^}} public var storedWithObserversInitialValue: Swift.Int {
// COMMON-NEXT: {{^}} get
// COMMON-NEXT: {{^}} set
// COMMON-NEXT: {{^}} }
public var storedWithObserversInitialValue: Int = 0 {
didSet {}
}
// COMMON: public init(){{$}}
public init() {
self.simpleStoredImmutable = 0
self.simpleStoredMutable = 0
self.storedPrivateSet = 0
self.storedWithObservers = false
self.privateVar = false
}
// COMMON: }
}
// COMMON: @frozen public struct BagOfVariables {
@frozen
public struct BagOfVariables {
// COMMON: private let hidden: Swift.Int = 0
private let hidden: Int = 0
// COMMON: public let a: Swift.Int = 0
public let a: Int = 0
// COMMON: public let (x, y): (Swift.Int, Swift.Int) = (0, 0)
public let (x, y) = (0, 0)
// COMMON: public var b: Swift.Bool = false
public var b: Bool = false
// COMMON: public var c: Swift.Int = 0
public var c: Int = 0
// COMMON: public init()
public init() {}
// COMMON: }
}
// COMMON: @frozen public struct HasStoredPropertiesFixedLayout {
@frozen
public struct HasStoredPropertiesFixedLayout {
// COMMON: public var simpleStoredMutable: StoredProperties.BagOfVariables
public var simpleStoredMutable: BagOfVariables
// COMMON: {{^}} @_hasStorage public var storedWithObservers: StoredProperties.BagOfVariables {
// COMMON-NEXT: {{^}} get
// COMMON-NEXT: {{^}} set
// COMMON-NEXT: {{^}} }
public var storedWithObservers: BagOfVariables {
didSet {}
}
// COMMON: public init(){{$}}
public init() {
self.simpleStoredMutable = BagOfVariables()
self.storedWithObservers = BagOfVariables()
}
}