fmt: use new const rule in tests

pull/8265/head
Alexander Medvednikov 2021-01-24 10:12:49 +01:00
parent 8bcb6c10cc
commit 2238bf9a83
3 changed files with 9 additions and 9 deletions

View File

@ -41,7 +41,7 @@ fn test_channel_array_mut() {
sem := sync.new_semaphore()
go do_rec_calc_send(chs, sem)
mut t := i64(100)
for _ in 0 .. num_iterations {
for _ in 0 .. main.num_iterations {
chs[0] <- t
t = <-chs[1]
}
@ -55,7 +55,7 @@ fn test_channel_array_mut() {
c := ch[1].cap
d := ch[o].len
sem.wait()
assert t == 100 + num_iterations
assert t == 100 + main.num_iterations
ch2 := chan mut St{cap: 10}
go g(ch2)
}

View File

@ -2,13 +2,13 @@ const n = 1000
fn f(ch chan int) {
mut s := 0
for _ in 0 .. n {
for _ in 0 .. main.n {
s += <-ch or {
println('Something went wrong:')
println('got $err')
}
}
assert s == n * (n + 1) / 2
assert s == main.n * (main.n + 1) / 2
ch.close()
}
@ -29,5 +29,5 @@ fn main() {
for {
s = do_send(ch, s) or { break }
}
assert s == n + 1
assert s == main.n + 1
}

View File

@ -6,7 +6,7 @@ mut:
}
fn (shared x St) f(shared z St) {
for _ in 0 .. reads_per_thread {
for _ in 0 .. main.reads_per_thread {
rlock x { // other instances may read at the same time
time.sleep_ms(1)
assert x.a == 7 || x.a == 5
@ -29,12 +29,12 @@ fn test_shared_lock() {
a: 5
}
shared z := &St{
a: read_threads
a: main.read_threads
}
for _ in 0 .. read_threads {
for _ in 0 .. main.read_threads {
go x.f(shared z)
}
for i in 0 .. writes {
for i in 0 .. main.writes {
lock x { // wait for ongoing reads to finish, don't start new ones
x.a = 17 // this value should never be read
time.sleep_ms(50)