|
| 1 | +// RUN: %empty-directory(%t) |
| 2 | +// RUN: %target-swift-frontend -enable-experimental-concurrency -emit-module-path %t/a.swiftmodule -module-name a %s |
| 3 | +// RUN: %target-swift-ide-test -print-module -module-to-print a -source-filename x -I %t | %FileCheck -check-prefix MODULE-CHECK %s |
| 4 | +// RUN: %target-swift-frontend -enable-experimental-concurrency -emit-module-path %t/b.swiftmodule -module-name a %t/a.swiftmodule |
| 5 | +// RUN: cmp -s %t/a.swiftmodule %t/b.swiftmodule |
| 6 | + |
| 7 | +// REQUIRES: concurrency |
| 8 | + |
| 9 | +/////////// |
| 10 | +// This test checks for correct serialization & deserialization of |
| 11 | +// effectful properties and subscripts |
| 12 | + |
| 13 | +// look for correct members in module's deserialization pretty-print: |
| 14 | + |
| 15 | +// MODULE-CHECK: actor A { |
| 16 | +// MODULE-CHECK-NEXT: var normalProp: Int |
| 17 | +// MODULE-CHECK-NEXT: var computedProp: Int { get } |
| 18 | +// MODULE-CHECK-NEXT: var asyncProp: Int { get async } |
| 19 | + |
| 20 | +// MODULE-CHECK: class C { |
| 21 | +// MODULE-CHECK-NEXT: var prop_asyncThrows: Int { get async throws } |
| 22 | +// MODULE-CHECK-NEXT: var prop_async: Int { get async } |
| 23 | +// MODULE-CHECK-NEXT: var prop_throws: Int { get throws } |
| 24 | + |
| 25 | +// MODULE-CHECK: enum E { |
| 26 | +// MODULE-CHECK-NEXT: subscript(e: Int) -> Int { get async throws } |
| 27 | + |
| 28 | +// MODULE-CHECK: protocol P { |
| 29 | +// MODULE-CHECK-NEXT: var propA: Int { get async } |
| 30 | +// MODULE-CHECK-NEXT: var propT: Int { get throws } |
| 31 | +// MODULE-CHECK-NEXT: var propAT: Int { get async throws } |
| 32 | +// MODULE-CHECK-NEXT: subscript(p: Int) -> Int { get async } |
| 33 | +// MODULE-CHECK-NEXT: subscript(p: Double) -> Int { get throws } |
| 34 | +// MODULE-CHECK-NEXT: subscript(p: String) -> Int { get async throws } |
| 35 | + |
| 36 | +// MODULE-CHECK: struct S { |
| 37 | +// MODULE-CHECK-NEXT: subscript(s: Int) -> Int { get async } |
| 38 | +// MODULE-CHECK-NEXT: subscript(s: Double) -> Int { get throws } |
| 39 | + |
| 40 | +class C { |
| 41 | + var prop_asyncThrows : Int { |
| 42 | + get async throws { 0 } |
| 43 | + } |
| 44 | + |
| 45 | + var prop_async : Int { |
| 46 | + get async { 1 } |
| 47 | + } |
| 48 | + |
| 49 | + var prop_throws : Int { |
| 50 | + get throws { 2 } |
| 51 | + } |
| 52 | +} |
| 53 | + |
| 54 | +struct S { |
| 55 | + subscript(_ s : Int) -> Int { |
| 56 | + get async { 0 } |
| 57 | + } |
| 58 | + |
| 59 | + subscript(_ s : Double) -> Int { |
| 60 | + get throws { 0 } |
| 61 | + } |
| 62 | +} |
| 63 | + |
| 64 | +enum E { |
| 65 | + subscript(_ e : Int) -> Int { |
| 66 | + get async throws { 0 } |
| 67 | + } |
| 68 | +} |
| 69 | + |
| 70 | +actor A { |
| 71 | + var normalProp : Int = 0 |
| 72 | + var computedProp : Int { get { 0 } } |
| 73 | + var asyncProp : Int { |
| 74 | + get async { 0 } |
| 75 | + } |
| 76 | +} |
| 77 | + |
| 78 | +protocol P { |
| 79 | + var propA : Int { get async } |
| 80 | + var propT : Int { get throws } |
| 81 | + var propAT : Int { get async throws } |
| 82 | + |
| 83 | + subscript(_ p : Int) -> Int { get async } |
| 84 | + |
| 85 | + subscript(_ p : Double) -> Int { get throws } |
| 86 | + |
| 87 | + subscript(_ p : String) -> Int { get async throws } |
| 88 | +} |
0 commit comments