Files
swift-mirror/test/ModuleInterface/stored-properties-client.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

92 lines
3.8 KiB
Swift

// RUN: %empty-directory(%t)
// REQUIRES: executable_test
// REQUIRES: swift_feature_StructLetDestructuring
// 1. Build ../stored-properties.swift to a dylib and emit its interface in %t
// RUN: %target-build-swift-dylib(%t/%target-library-name(StoredProperties)) -enable-experimental-feature StructLetDestructuring -emit-module-interface-path %t/StoredProperties.swiftinterface %S/stored-properties.swift -module-name StoredProperties -swift-version 5
// RUN: %target-swift-typecheck-module-from-interface(%t/StoredProperties.swiftinterface) -module-name StoredProperties
// 2. Build this file and link with StoredProperties
// RUN: %target-build-swift -enable-experimental-feature StructLetDestructuring %s -I %t -L %t -lStoredProperties -o %t/stored-properties-client %target-rpath(%t)
// 3. Codesign and run this, and ensure it exits successfully.
// RUN: %target-codesign %t/stored-properties-client %t/%target-library-name(StoredProperties)
// RUN: %target-run %t/stored-properties-client %t/%target-library-name(StoredProperties)
// 4. Repeat these steps, with library evolution enabled.
// RUN: %empty-directory(%t)
// RUN: %target-build-swift-dylib(%t/%target-library-name(StoredProperties)) -enable-experimental-feature StructLetDestructuring -emit-module-interface-path %t/StoredProperties.swiftinterface %S/stored-properties.swift -module-name StoredProperties -swift-version 5 -enable-library-evolution
// RUN: %target-build-swift -enable-experimental-feature StructLetDestructuring %s -I %t -L %t -lStoredProperties -o %t/stored-properties-client %target-rpath(%t)
// RUN: %target-codesign %t/stored-properties-client %t/%target-library-name(StoredProperties)
// RUN: %target-run %t/stored-properties-client %t/%target-library-name(StoredProperties)
import StdlibUnittest
import StoredProperties
/// This test makes sure clients of a parseable interface see correct type
/// layout and use the right access patterns in the presence of a
/// .swiftinterface file, in both resilient and non-resilient cases.
/// Test that we call the correct accessors in a resilient module, and that
/// we use trivial storage accesses in a non-resilient module.
var StoredPropertyTests = TestSuite("StoredProperty")
StoredPropertyTests.test("Getting/NonFixedLayout") {
var value = HasStoredProperties()
expectEqual(3, value.computedGetter)
expectEqual(3, value.computedGetSet)
expectEqual(0, value.simpleStoredImmutable)
expectEqual(0, value.simpleStoredMutable)
expectEqual(false, value.storedWithObservers)
expectEqual(0, value.storedPrivateSet)
}
StoredPropertyTests.test("Setting/NonFixedLayout") {
var value = HasStoredProperties()
value.storedWithObservers = true
value.computedGetSet = 4
value.simpleStoredMutable = 4
expectEqual(3, value.computedGetter)
expectEqual(3, value.computedGetSet)
expectEqual(0, value.simpleStoredImmutable)
expectEqual(4, value.simpleStoredMutable)
expectEqual(true, value.storedWithObservers)
expectEqual(0, value.storedPrivateSet)
}
StoredPropertyTests.test("Getting/FixedLayout") {
var value = HasStoredPropertiesFixedLayout()
expectEqual(0, value.simpleStoredMutable.a)
expectEqual(false, value.simpleStoredMutable.b)
expectEqual(0, value.simpleStoredMutable.c)
expectEqual(0, value.storedWithObservers.a)
expectEqual(false, value.storedWithObservers.b)
expectEqual(0, value.storedWithObservers.c)
}
StoredPropertyTests.test("Setting/FixedLayout") {
var value = HasStoredPropertiesFixedLayout()
value.simpleStoredMutable = BagOfVariables()
expectEqual(0, value.simpleStoredMutable.a)
expectEqual(false, value.simpleStoredMutable.b)
expectEqual(0, value.simpleStoredMutable.c)
value.storedWithObservers = BagOfVariables()
expectEqual(0, value.storedWithObservers.a)
expectEqual(false, value.storedWithObservers.b)
expectEqual(0, value.storedWithObservers.c)
}
runAllTests()