v / vlib / sync
Raw file | 22 loc (19 sloc) | 359 bytes | Latest commit hash e81e0ac70
1import sync
2
3const (
4 queue_len = 1000
5 queue_fill = 763
6)
7
8fn do_send(ch chan int, mut fin sync.Semaphore) {
9 for i in 0 .. queue_fill {
10 ch <- i
11 }
12 fin.post()
13}
14
15fn test_channel_len_cap() {
16 ch := chan int{cap: queue_len}
17 mut sem := sync.new_semaphore()
18 spawn do_send(ch, mut sem)
19 sem.wait()
20 assert ch.cap == queue_len
21 assert ch.len == queue_fill
22}