v2 / vlib / v / tests / fns / go_wait_2_test.v
23 lines · 20 sloc · 267 bytes · 6488041a749df9762348d019c4223908c476f2e2
Raw
1import time
2
3struct St {
4mut:
5 x f64
6}
7
8fn f(x int, y f64, shared s St) {
9 time.sleep(50 * time.millisecond)
10 lock s {
11 s.x = x * y
12 }
13 return
14}
15
16fn test_go_return() {
17 shared t := &St{}
18 r := spawn f(3, 4.0, shared t)
19 r.wait()
20 rlock t {
21 assert t.x == 12.0
22 }
23}
24