v2 / vlib / v / tests / concurrency / shared_if_expr_test.v
19 lines · 18 sloc · 253 bytes · 6488041a749df9762348d019c4223908c476f2e2
Raw
1type AA = bool | int
2
3fn test_shared_if_expr() {
4 shared a := [1, 2, 3]
5 b := [4, 5, 6]
6 c := lock a {
7 if a == b { a } else { b }
8 }
9 assert c == [4, 5, 6]
10 d := lock a {
11 if a != b {
12 a << 5
13 a
14 } else {
15 b
16 }
17 }
18 assert d == [1, 2, 3, 5]
19}
20