2020-09-12 02:29:11 +02:00
|
|
|
fn test_channel_try_unbuffered() {
|
|
|
|
ch := chan int{}
|
2021-05-08 12:32:29 +02:00
|
|
|
for z in 5 .. 8 {
|
2020-09-12 02:29:11 +02:00
|
|
|
if ch.try_push(z) == .not_ready {
|
|
|
|
assert z == 5
|
|
|
|
break
|
|
|
|
}
|
|
|
|
panic('push on non-ready channel not detected')
|
|
|
|
}
|
|
|
|
mut obj := -17
|
2021-04-19 10:41:21 +02:00
|
|
|
for ch.try_pop(mut obj) == .success {}
|
2020-09-12 02:29:11 +02:00
|
|
|
assert obj == -17
|
|
|
|
}
|