From f5c4671bfbad96bf346bd7e9a21fc4317b4959df Mon Sep 17 00:00:00 2001 From: Indrajith K L Date: Sat, 3 Dec 2022 17:00:20 +0530 Subject: Adds most of the tools --- v_windows/v/vlib/sync/channel_1_test.v | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 v_windows/v/vlib/sync/channel_1_test.v (limited to 'v_windows/v/vlib/sync/channel_1_test.v') diff --git a/v_windows/v/vlib/sync/channel_1_test.v b/v_windows/v/vlib/sync/channel_1_test.v new file mode 100644 index 0000000..17588fd --- /dev/null +++ b/v_windows/v/vlib/sync/channel_1_test.v @@ -0,0 +1,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) +} -- cgit v1.2.3