aboutsummaryrefslogtreecommitdiff
path: root/v_windows/v/old/vlib/sync/channel_try_buf_test.v
blob: e5213148072b7e227f2f5ac838e70e2babe642e3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
fn test_channel_try_buffered() {
	ch := chan int{cap: 5}
	for z in 2 .. 13 {
		if ch.try_push(z) == .not_ready {
			assert z == 7
			break
		}
	}
	mut obj := int(0)
	for ch.try_pop(mut obj) == .success {
		println(obj)
	}
	assert obj == 6
	ch <- 17
	obj = <-ch
	assert obj == 17
}