mirror of
https://github.com/apple/swift.git
synced 2025-12-21 12:14:44 +01:00
[Distributed] More tests for local actor init, with specific transport type (#39788)
This commit is contained in:
committed by
GitHub
parent
338cc326ae
commit
c8b4e8ea17
@@ -4,10 +4,8 @@
|
||||
|
||||
import _Distributed
|
||||
|
||||
@available(SwiftStdlib 5.5, *)
|
||||
distributed actor OK0 { }
|
||||
|
||||
@available(SwiftStdlib 5.5, *)
|
||||
distributed actor OK1 {
|
||||
var x: Int = 1
|
||||
// ok, since all fields are initialized, the constructor can be synthesized
|
||||
@@ -15,21 +13,18 @@ distributed actor OK1 {
|
||||
|
||||
// TODO(distributed): test all the FIXITs in this file
|
||||
|
||||
@available(SwiftStdlib 5.5, *)
|
||||
distributed actor Bad1 {
|
||||
init() {
|
||||
// expected-error@-1 {{designated distributed actor initializer 'init()' is missing required ActorTransport parameter}}
|
||||
}
|
||||
}
|
||||
|
||||
@available(SwiftStdlib 5.5, *)
|
||||
distributed actor Bad12 {
|
||||
init(x: String) {
|
||||
// expected-error@-1 {{designated distributed actor initializer 'init(x:)' is missing required ActorTransport parameter}}
|
||||
}
|
||||
}
|
||||
|
||||
@available(SwiftStdlib 5.5, *)
|
||||
distributed actor OK2 {
|
||||
var x: Int
|
||||
|
||||
@@ -38,7 +33,6 @@ distributed actor OK2 {
|
||||
}
|
||||
}
|
||||
|
||||
@available(SwiftStdlib 5.5, *)
|
||||
distributed actor Bad2 {
|
||||
var x: Int = 1
|
||||
|
||||
@@ -47,7 +41,6 @@ distributed actor Bad2 {
|
||||
}
|
||||
}
|
||||
|
||||
@available(SwiftStdlib 5.5, *)
|
||||
distributed actor OK3 {
|
||||
var x: Int
|
||||
|
||||
@@ -56,7 +49,6 @@ distributed actor OK3 {
|
||||
}
|
||||
}
|
||||
|
||||
@available(SwiftStdlib 5.5, *)
|
||||
distributed actor OKMulti {
|
||||
|
||||
convenience init(y: Int, transport: ActorTransport) { // ok
|
||||
@@ -64,3 +56,53 @@ distributed actor OKMulti {
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
distributed actor OKMultiDefaultValues {
|
||||
|
||||
convenience init(y: Int, transport: ActorTransport, x: Int = 1234) { // ok
|
||||
self.init(transport: transport)
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// ==== ------------------------------------------------------------------------
|
||||
// MARK: Specific transport
|
||||
|
||||
struct ActorAddress: ActorIdentity {
|
||||
let address: String
|
||||
init(parse address : String) {
|
||||
self.address = address
|
||||
}
|
||||
}
|
||||
|
||||
struct FakeTransport: ActorTransport {
|
||||
func decodeIdentity(from decoder: Decoder) throws -> AnyActorIdentity {
|
||||
fatalError("not implemented \(#function)")
|
||||
}
|
||||
|
||||
func resolve<Act>(_ identity: AnyActorIdentity, as actorType: Act.Type) throws -> Act?
|
||||
where Act: DistributedActor {
|
||||
return nil
|
||||
}
|
||||
|
||||
func assignIdentity<Act>(_ actorType: Act.Type) -> AnyActorIdentity
|
||||
where Act: DistributedActor {
|
||||
.init(ActorAddress(parse: ""))
|
||||
}
|
||||
|
||||
public func actorReady<Act>(_ actor: Act)
|
||||
where Act: DistributedActor {
|
||||
print("\(#function):\(actor)")
|
||||
}
|
||||
|
||||
func resignIdentity(_ id: AnyActorIdentity) {}
|
||||
}
|
||||
|
||||
distributed actor OKSpecificTransportType {
|
||||
|
||||
init(y: Int, transport fake: FakeTransport) { // ok
|
||||
defer { fake.actorReady(self) }
|
||||
// nothing
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user