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

vfmt: change all '$expr' to '${expr}' (#16428)

This commit is contained in:
yuyi
2022-11-15 21:53:13 +08:00
committed by GitHub
parent 56239b4a23
commit 017ace6ea7
859 changed files with 7156 additions and 7135 deletions

View File

@@ -58,9 +58,9 @@ fn main() {
}
elapsed := stopwatch.elapsed()
rate := f64(nobj) / elapsed * time.microsecond
println('$nobj objects in ${f64(elapsed) / time.second} s (${rate:.2f} objs/µs)')
println('${nobj} objects in ${f64(elapsed) / time.second} s (${rate:.2f} objs/µs)')
// use sum formula by Gauß to calculate the expected result
expected_sum := i64(nobj) * (nobj - 1) / 2
println('got: $sum, expected: $expected_sum')
println('got: ${sum}, expected: ${expected_sum}')
assert sum == expected_sum
}

View File

@@ -35,7 +35,7 @@ mut:
}
fn do_rec(ch chan int, id int, mut ctx Context) {
eprintln('start of do_rec id: $id')
eprintln('start of do_rec id: ${id}')
mut timer_sw_x := time.new_stopwatch()
mut tmp := int(0)
mut i := int(0)
@@ -68,7 +68,7 @@ fn do_rec(ch chan int, id int, mut ctx Context) {
}
fn do_send(ch chan int, id int, mut ctx Context) {
eprintln('start of do_send id: $id')
eprintln('start of do_send id: ${id}')
mut timer_sw_x := time.new_stopwatch()
n_iters := ctx.n_iters
base := n_iters * id // sender events can not overlap
@@ -100,12 +100,12 @@ fn main() {
n_readers := cmdline.option(args, '-readers', '1').int()
n_writers := cmdline.option(args, '-writers', '4').int()
chan_cap := cmdline.option(args, '-chan_cap', '100').int()
eprintln('> n_iters, $n_iters, n_writers, $n_writers, n_readers, $n_readers, chan_cap, $chan_cap')
eprintln('> n_iters, ${n_iters}, n_writers, ${n_writers}, n_readers, ${n_readers}, chan_cap, ${chan_cap}')
//
ch := chan int{cap: chan_cap}
max_number_of_pushes := n_writers * (n_iters + 2)
max_number_of_pops := max_number_of_pushes * n_readers
eprintln('> max_number_of_pushes, $max_number_of_pushes, max_number_of_pops (per receiver), $max_number_of_pops')
eprintln('> max_number_of_pushes, ${max_number_of_pushes}, max_number_of_pops (per receiver), ${max_number_of_pops}')
mut ctx := &Context{
n_iters: n_iters
n_readers: n_readers

View File

@@ -47,10 +47,10 @@ fn test_channel_polling() {
mut sum := i64(0)
for _ in 0 .. nrec {
sum += <-resch
println('> running sum: $sum')
println('> running sum: ${sum}')
}
// use sum formula by Gauß to calculate the expected result
expected_sum := i64(nobj) * (nobj - 1) / 2
println('expected sum: $expected_sum | sum: $sum')
println('expected sum: ${expected_sum} | sum: ${sum}')
assert sum == expected_sum
}

View File

@@ -43,7 +43,7 @@ fn g(ch chan int, res chan int) {
j++
}
println('done $j')
println('done ${j}')
res <- j
}

View File

@@ -81,7 +81,7 @@ fn test_select() {
sum += rb
}
else {
println('got $idx (timeout)')
println('got ${idx} (timeout)')
}
}
}

View File

@@ -116,7 +116,7 @@ fn new_channel_st_noscan(n u32, st u32) &Channel {
}
pub fn (ch &Channel) auto_str(typename string) string {
return 'chan $typename{cap: $ch.cap, closed: $ch.closed}'
return 'chan ${typename}{cap: ${ch.cap}, closed: ${ch.closed}}'
}
pub fn (mut ch Channel) close() {

View File

@@ -18,7 +18,7 @@ pub struct SResult {
fn sprocess(mut pp pool.PoolProcessor, idx int, wid int) &SResult {
item := pp.get_item<string>(idx)
println('idx: $idx, wid: $wid, item: ' + item)
println('idx: ${idx}, wid: ${wid}, item: ' + item)
return &SResult{item.reverse()}
}
@@ -27,7 +27,7 @@ fn main() {
pp.work_on_items(['1abc', '2abc', '3abc', '4abc', '5abc', '6abc', '7abc'])
// optionally, you can iterate over the results too:
for x in pp.get_results<SResult>() {
println('result: $x.s')
println('result: ${x.s}')
}
}
```

View File

@@ -11,14 +11,14 @@ pub struct IResult {
fn worker_s(mut p pool.PoolProcessor, idx int, worker_id int) &SResult {
item := p.get_item<string>(idx)
println('worker_s worker_id: $worker_id | idx: $idx | item: $item')
println('worker_s worker_id: ${worker_id} | idx: ${idx} | item: ${item}')
time.sleep(3 * time.millisecond)
return &SResult{'$item $item'}
return &SResult{'${item} ${item}'}
}
fn worker_i(mut p pool.PoolProcessor, idx int, worker_id int) &IResult {
item := p.get_item<int>(idx)
println('worker_i worker_id: $worker_id | idx: $idx | item: $item')
println('worker_i worker_id: ${worker_id} | idx: ${idx} | item: ${item}')
time.sleep(5 * time.millisecond)
return &IResult{item * 1000}
}

View File

@@ -76,7 +76,7 @@ fn test_select() {
assert j == 1100
}
else {
println('got $idx (timeout)')
println('got ${idx} (timeout)')
assert false
}
}

View File

@@ -2,18 +2,18 @@ import sync
fn simple_thread() u64 {
tid := sync.thread_id()
eprintln('simple_thread thread_id: $tid.hex()')
eprintln('simple_thread thread_id: ${tid.hex()}')
return tid
}
fn test_sync_thread_id() {
mtid := sync.thread_id()
eprintln('main thread_id: $sync.thread_id().hex()')
eprintln('main thread_id: ${sync.thread_id().hex()}')
x := spawn simple_thread()
y := spawn simple_thread()
xtid := x.wait()
ytid := y.wait()
eprintln('main thread_id: $sync.thread_id().hex()')
eprintln('main thread_id: ${sync.thread_id().hex()}')
dump(xtid.hex())
dump(ytid.hex())
assert mtid != xtid