1
1
import { describe , test , expect } from "vitest" ;
2
2
3
- import { Choreography , Located , Runner } from "./core" ;
3
+ import { Choreography , MultiplyLocated , Runner } from "./core" ;
4
4
5
5
const runner = new Runner ( ) ;
6
6
@@ -13,7 +13,7 @@ describe("core", () => {
13
13
const choreography : Choreography <
14
14
"alice" | "bob" ,
15
15
[ ] ,
16
- [ Located < string , "bob" > ]
16
+ [ MultiplyLocated < string , "bob" > ]
17
17
> = async ( { locally, comm } ) => {
18
18
const msg = await locally ( "alice" , ( ) => "Hello, world!" ) ;
19
19
const msgAtBob = await comm ( "alice" , "bob" , msg ) ;
@@ -22,7 +22,7 @@ describe("core", () => {
22
22
23
23
const f = runner . compile ( choreography ) ;
24
24
const [ msgAtBob ] = await f ( [ ] ) ;
25
- expect ( msgAtBob ) . toEqual ( "Hello, world!" ) ;
25
+ expect ( runner . unwrap ( msgAtBob ) ) . toEqual ( "Hello, world!" ) ;
26
26
} ) ;
27
27
test ( "Global arguments" , async ( ) => {
28
28
const p = "GLOBAL ARGUMENT" ;
@@ -38,17 +38,16 @@ describe("core", () => {
38
38
} ) ;
39
39
test ( "Located arguments" , async ( ) => {
40
40
const p = "Alice's Secret Message" ;
41
- const c : Choreography < Locations , [ Located < string , "alice" > ] > = async (
42
- { locally } ,
43
- [ msg ] ,
44
- ) => {
41
+ const c : Choreography <
42
+ Locations ,
43
+ MultiplyLocated < string , "alice" >
44
+ > = async ( { locally } , msg ) => {
45
45
await locally ( "alice" , ( unwrap ) => {
46
46
expect ( unwrap ( msg ) ) . toBe ( p ) ;
47
47
} ) ;
48
- return [ ] ;
49
48
} ;
50
49
const g = runner . compile ( c ) ;
51
- await g ( [ p ] ) ;
50
+ await g ( runner . local ( p ) ) ;
52
51
} ) ;
53
52
test ( "Async locally" , async ( ) => {
54
53
let count = 0 ;
@@ -60,10 +59,9 @@ describe("core", () => {
60
59
expect ( unwrap ( msg ) ) . toBe ( 5 ) ;
61
60
count += 1 ;
62
61
} ) ;
63
- return [ ] ;
64
62
} ;
65
63
const g = runner . compile ( c ) ;
66
- await g ( [ ] ) ;
64
+ await g ( void 0 ) ;
67
65
expect ( count ) . toBe ( 1 ) ;
68
66
} ) ;
69
67
test ( "multicast" , async ( ) => {
@@ -83,10 +81,9 @@ describe("core", () => {
83
81
expect ( unwrap ( msgAtSelectedTwo ) ) . toBe ( "Hello, world!" ) ;
84
82
count += 1 ;
85
83
} ) ;
86
- return [ ] ;
87
84
} ;
88
85
const g = runner . compile ( test ) ;
89
- await g ( [ ] ) ;
86
+ await g ( void 0 ) ;
90
87
expect ( count ) . toBe ( 2 ) ;
91
88
} ) ;
92
89
test ( "naked" , async ( ) => {
@@ -109,10 +106,9 @@ describe("core", () => {
109
106
} ,
110
107
[ ] ,
111
108
) ;
112
- return [ ] ;
113
109
} ;
114
110
const g = runner . compile ( test ) ;
115
- await g ( [ ] ) ;
111
+ await g ( void 0 ) ;
116
112
expect ( check ) . toBe ( "Hello, world!" ) ;
117
113
} ) ;
118
114
test ( "broadcast" , async ( ) => {
@@ -122,10 +118,9 @@ describe("core", () => {
122
118
const msg = await broadcast ( "alice" , localMsg ) ;
123
119
expect ( msg ) . toBe ( "Hello everyone!" ) ;
124
120
count += 1 ;
125
- return [ ] ;
126
121
} ;
127
122
const g = runner . compile ( test ) ;
128
- await g ( [ ] ) ;
123
+ await g ( void 0 ) ;
129
124
expect ( count ) . toBe ( 1 ) ;
130
125
} ) ;
131
126
test ( "enclave" , async ( ) => {
@@ -138,14 +133,12 @@ describe("core", () => {
138
133
const msg = await broadcast ( "bob" , msgAtBob ) ;
139
134
expect ( msg ) . toBe ( "Hello, world!" ) ;
140
135
count += 1 ;
141
- return [ ] ;
142
136
} ,
143
- [ ] ,
137
+ void 0 ,
144
138
) ;
145
- return [ ] ;
146
139
} ;
147
140
const g = runner . compile ( test ) ;
148
- await g ( [ ] ) ;
141
+ await g ( void 0 ) ;
149
142
expect ( count ) . toBe ( 1 ) ;
150
143
} ) ;
151
144
} ) ;
0 commit comments