1
0
mirror of https://github.com/vlang/v.git synced 2023-08-10 21:13:21 +03:00

parser: enable module auto import (of sync) (#6271)

This commit is contained in:
Uwe Krüger
2020-08-31 10:44:39 +02:00
committed by GitHub
parent b1a8e1e5b2
commit cbcba2e4cf
17 changed files with 88 additions and 93 deletions

View File

@ -1,23 +1,19 @@
import sync
const (
num_iterations = 10000
)
fn do_send(mut ch sync.Channel) {
fn do_send(ch chan int) {
for i in 0 .. num_iterations {
ch.push(&i)
ch <- i
}
}
fn test_channel_unbuffered() {
mut ch := sync.new_channel<int>(0)
go do_send(mut ch)
ch := chan int{}
go do_send(ch)
mut sum := i64(0)
for _ in 0 .. num_iterations {
a := 0
ch.pop(&a)
sum += a
sum += <-ch
}
assert sum == u64(num_iterations)*(num_iterations-1)/2
}