|
@@ -811,6 +811,11 @@ mod tests {
|
|
// simple ping-pong protocol:
|
|
// simple ping-pong protocol:
|
|
//
|
|
//
|
|
protocol! {
|
|
protocol! {
|
|
|
|
+ let name = PingPongProtocol;
|
|
|
|
+ let states = [
|
|
|
|
+ ClientInit, SentPing,
|
|
|
|
+ ServerInit, Listening,
|
|
|
|
+ ];
|
|
ClientInit?Activate -> SentPing, Listening!Ping;
|
|
ClientInit?Activate -> SentPing, Listening!Ping;
|
|
ServerInit?Activate -> Listening;
|
|
ServerInit?Activate -> Listening;
|
|
Listening?Ping -> End, SentPing!Ping::Reply;
|
|
Listening?Ping -> End, SentPing!Ping::Reply;
|
|
@@ -1016,8 +1021,15 @@ mod tests {
|
|
|
|
|
|
// Here's another protocol example. This is the Customer and Travel Agency protocol used as an
|
|
// Here's another protocol example. This is the Customer and Travel Agency protocol used as an
|
|
// example in the survey paper "Behavioral Types in Programming Languages."
|
|
// example in the survey paper "Behavioral Types in Programming Languages."
|
|
- //
|
|
|
|
|
|
+ // Note that the Choosing state can send messages at any time, not just in response to another
|
|
|
|
+ // message because there is a transition from Choosing that doesn't use the receive operator
|
|
|
|
+ // (`?`).
|
|
protocol! {
|
|
protocol! {
|
|
|
|
+ let name = TravelAgency;
|
|
|
|
+ let states = [
|
|
|
|
+ AgencyInit, Listening,
|
|
|
|
+ Choosing,
|
|
|
|
+ ];
|
|
AgencyInit?Activate -> Listening;
|
|
AgencyInit?Activate -> Listening;
|
|
Choosing -> Choosing, Listening!Query|Accept|Reject;
|
|
Choosing -> Choosing, Listening!Query|Accept|Reject;
|
|
Listening?Query -> Listening, Choosing!Query::Reply;
|
|
Listening?Query -> Listening, Choosing!Query::Reply;
|
|
@@ -1027,6 +1039,4 @@ mod tests {
|
|
Listening?Reject -> End, Choosing!Reject:Reply;
|
|
Listening?Reject -> End, Choosing!Reject:Reply;
|
|
Choosing?Reject::Reply -> End;
|
|
Choosing?Reject::Reply -> End;
|
|
}
|
|
}
|
|
- //
|
|
|
|
- // The Choice message is from the runtime itself. It represents receiving input from a user.
|
|
|
|
}
|
|
}
|