|
| 1 | +// RUN: %empty-directory(%t) |
| 2 | +// RUN: %target-swift-frontend-emit-module -emit-module-path %t/FakeDistributedActorSystems.swiftmodule -module-name FakeDistributedActorSystems -disable-availability-checking %S/../Inputs/FakeDistributedActorSystems.swift |
| 3 | +// RUN: %target-build-swift -module-name main -Xfrontend -disable-availability-checking -j2 -parse-as-library -I %t %s %S/../Inputs/FakeDistributedActorSystems.swift -o %t/a.out |
| 4 | +// RUN: %target-codesign %t/a.out |
| 5 | +// RUN: %target-run %t/a.out | %FileCheck %s --color |
| 6 | + |
| 7 | +// REQUIRES: executable_test |
| 8 | +// REQUIRES: concurrency |
| 9 | +// REQUIRES: distributed |
| 10 | + |
| 11 | +// rdar://76038845 |
| 12 | +// UNSUPPORTED: use_os_stdlib |
| 13 | +// UNSUPPORTED: back_deployment_runtime |
| 14 | + |
| 15 | +// UNSUPPORTED: OS=windows-msvc |
| 16 | + |
| 17 | +import Distributed |
| 18 | +import FakeDistributedActorSystems |
| 19 | + |
| 20 | +typealias DefaultDistributedActorSystem = FakeRoundtripActorSystem |
| 21 | + |
| 22 | +distributed actor MyActor { |
| 23 | + distributed var computed: String { |
| 24 | + "Hello" |
| 25 | + } |
| 26 | + |
| 27 | + distributed func bar(other: MyActor) async throws { |
| 28 | + print("print inside bar(other:)") |
| 29 | + print(try await other.computed) |
| 30 | + } |
| 31 | +} |
| 32 | + |
| 33 | +func test() async throws { |
| 34 | + let system = DefaultDistributedActorSystem() |
| 35 | + |
| 36 | + let local = MyActor(actorSystem: system) |
| 37 | + let res = try await local.computed |
| 38 | + print("local response: \(res)") |
| 39 | + // CHECK: local response: Hello |
| 40 | + |
| 41 | + let ref = try MyActor.resolve(id: local.id, using: system) |
| 42 | + try await ref.computed |
| 43 | + // CHECK: >> remoteCall: on:main.MyActor, target:main.MyActor.computed(), invocation:FakeInvocationEncoder(genericSubs: [], arguments: [], returnType: Optional(Swift.String), errorType: nil), throwing:Swift.Never, returning:Swift.String |
| 44 | + // CHECK: << onReturn: Hello |
| 45 | + |
| 46 | + try await MyActor(actorSystem: system).bar(other: ref) |
| 47 | + // CHECK: print inside bar(other:) |
| 48 | + // CHECK: Hello |
| 49 | +} |
| 50 | + |
| 51 | +@main struct Main { |
| 52 | + static func main() async { |
| 53 | + try! await test() |
| 54 | + } |
| 55 | +} |
0 commit comments