aboutsummaryrefslogtreecommitdiff
path: root/v_windows/v/vlib/sync/channel_1_test.v
blob: 17588fd48800bf6d0b6f268f1a3f0e63ca9ee26c (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
const (
	num_iterations = 10000
)

fn do_send(ch chan int) {
	for i in 0 .. num_iterations {
		ch <- i
	}
}

fn test_channel_buffered() {
	ch := chan int{cap: 1000}
	go do_send(ch)
	mut sum := i64(0)
	for _ in 0 .. num_iterations {
		sum += <-ch
	}
	assert sum == u64(num_iterations) * (num_iterations - 1) / 2
}

fn test_builtin_enum() {
	x := ChanState.closed
	assert x == .closed
	println(x)
}