|
| 1 | +// RUN: %empty-directory(%t) |
| 2 | +// RUN: %target-build-swift -emit-module-path %t -enable-library-evolution -module-name moveonly_resilient_type -parse-as-library %S/Inputs/moveonly_resilient_type.swift -c -o %t/moveonly_resilient_type.o |
| 3 | +// RUN: %target-build-swift -enable-library-evolution -module-name moveonly_resilient_type -parse-as-library %S/Inputs/moveonly_resilient_type.swift -c -o %t/moveonly_resilient_type.o |
| 4 | +// RUN: %target-build-swift -o %t/a.out -I %t %s %t/moveonly_resilient_type.o |
| 5 | +// RUN: %target-run %t/a.out | %FileCheck %s |
| 6 | + |
| 7 | +import moveonly_resilient_type |
| 8 | + |
| 9 | +// CHECK: start |
| 10 | + |
| 11 | +func test1a() throws { |
| 12 | + // CHECK-NEXT: resilient capture in deinit 0 |
| 13 | + _ = ResilientCapturesInDeinit(nonthrowing: ()) |
| 14 | +} |
| 15 | +func test1b() throws { |
| 16 | + // CHECK-NEXT: resilient capture in deinit 1 |
| 17 | + let x = ResilientCapturesInDeinit(nonthrowing: ()) |
| 18 | +} |
| 19 | +func test2a() throws { |
| 20 | + // CHECK-NEXT: resilient capture in deinit 2 |
| 21 | + _ = try ResilientCapturesInDeinit(throwing: false) |
| 22 | +} |
| 23 | +func test2b() throws { |
| 24 | + // CHECK-NEXT: resilient capture in deinit 3 |
| 25 | + let x = try ResilientCapturesInDeinit(throwing: false) |
| 26 | +} |
| 27 | +func test3a() throws { |
| 28 | + _ = try ResilientCapturesInDeinit(throwing: true) |
| 29 | +} |
| 30 | +func test3b() throws { |
| 31 | + let x = try ResilientCapturesInDeinit(throwing: true) |
| 32 | +} |
| 33 | +func test4a() throws { |
| 34 | + // CHECK-NEXT: resilient capture in deinit 4 |
| 35 | + _ = try ResilientCapturesInDeinit(throwingAfterInit: false) |
| 36 | +} |
| 37 | +func test4b() throws { |
| 38 | + // CHECK-NEXT: resilient capture in deinit 5 |
| 39 | + let x = try ResilientCapturesInDeinit(throwingAfterInit: false) |
| 40 | +} |
| 41 | +func test5a() throws { |
| 42 | + // CHECK-NEXT: resilient capture in deinit 6 |
| 43 | + _ = try ResilientCapturesInDeinit(throwingAfterInit: true) |
| 44 | +} |
| 45 | +func test5b() throws { |
| 46 | + // CHECK-NEXT: resilient capture in deinit 7 |
| 47 | + let x = try ResilientCapturesInDeinit(throwingAfterInit: true) |
| 48 | +} |
| 49 | + |
| 50 | +func main() { |
| 51 | + print("start") |
| 52 | + |
| 53 | + _ = try? test1a() |
| 54 | + _ = try? test1b() |
| 55 | + _ = try? test2a() |
| 56 | + _ = try? test2b() |
| 57 | + _ = try? test3a() |
| 58 | + _ = try? test3b() |
| 59 | + _ = try? test4a() |
| 60 | + _ = try? test4b() |
| 61 | + _ = try? test5a() |
| 62 | + _ = try? test5b() |
| 63 | + |
| 64 | + // CHECK-NEXT: total 8 |
| 65 | + print("total \(ResilientCapturesInDeinit.instanceCount())") |
| 66 | +} |
| 67 | +main() |
0 commit comments