Files
swift-mirror/test/embedded/classes-arrays.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

72 lines
1.8 KiB
Swift

// RUN: %empty-directory(%t)
// RUN: %target-swift-frontend %s -parse-as-library -enable-experimental-feature Embedded -c -o %t/main.o
// RUN: %target-clang %t/main.o -o %t/a.out -dead_strip
// RUN: %target-run %t/a.out | %FileCheck %s
// REQUIRES: swift_in_compiler
// REQUIRES: executable_test
// REQUIRES: optimized_stdlib
// REQUIRES: OS=macosx || OS=linux-gnu
// REQUIRES: swift_feature_Embedded
class MyClass {
init() { print("MyClass.init") }
deinit { print("MyClass.deinit") }
func foo() { print("MyClass.foo") }
}
class MySubClass: MyClass {
override init() { print("MySubClass.init") }
deinit { print("MySubClass.deinit") }
override func foo() { print("MySubClass.foo") }
}
class MySubSubClass: MySubClass {
override init() { print("MySubSubClass.init") }
deinit { print("MySubSubClass.deinit") }
override func foo() { print("MySubSubClass.foo") }
}
@main
struct Main {
static var objects: [MyClass] = []
static func main() {
print("1") // CHECK: 1
objects.append(MyClass())
// CHECK: MyClass.init
print("")
print("2") // CHECK: 2
objects.append(MySubClass())
// CHECK: MySubClass.init
// CHECK: MyClass.init
print("")
print("3") // CHECK: 3
objects.append(MySubSubClass())
// CHECK: MySubSubClass.init
// CHECK: MySubClass.init
// CHECK: MyClass.init
print("")
print("4") // CHECK: 4
for o in objects {
o.foo()
// CHECK: MyClass.foo
// CHECK: MySubClass.foo
// CHECK: MySubSubClass.foo
}
print("")
print("5") // CHECK: 5
objects = []
// CHECK: MyClass.deinit
// CHECK: MySubClass.deinit
// CHECK: MyClass.deinit
// CHECK: MySubSubClass.deinit
// CHECK: MySubClass.deinit
// CHECK: MyClass.deinit
print("")
}
}