v / vlib / sync
Raw file | 13 loc (13 sloc) | 268 bytes | Latest commit hash 8a380f469
1fn test_channel_try_unbuffered() {
2 ch := chan int{}
3 for z in 5 .. 8 {
4 if ch.try_push(z) == .not_ready {
5 assert z == 5
6 break
7 }
8 panic('push on non-ready channel not detected')
9 }
10 mut obj := -17
11 for ch.try_pop(mut obj) == .success {}
12 assert obj == -17
13}