mirror of
https://github.com/vlang/v.git
synced 2025-09-14 06:52:36 +03:00
vfmt: change all '$expr' to '${expr}' (#16428)
This commit is contained in:
parent
56239b4a23
commit
017ace6ea7
859 changed files with 7156 additions and 7135 deletions
|
@ -486,11 +486,11 @@ fn (ta []Test2) str() string {
|
|||
}
|
||||
|
||||
fn (t Test2) str() string {
|
||||
return '{$t.one $t.two}'
|
||||
return '{${t.one} ${t.two}}'
|
||||
}
|
||||
|
||||
fn (t Test) str() string {
|
||||
return '{$t.a $t.b}'
|
||||
return '{${t.a} ${t.b}}'
|
||||
}
|
||||
|
||||
fn test_struct_print() {
|
||||
|
@ -659,7 +659,7 @@ fn test_map() {
|
|||
// type switch
|
||||
assert nums.map(it * 10) == [10, 20, 30, 40, 50, 60]
|
||||
assert nums.map(it * it) == [1, 4, 9, 16, 25, 36]
|
||||
assert nums.map('$it') == ['1', '2', '3', '4', '5', '6']
|
||||
assert nums.map('${it}') == ['1', '2', '3', '4', '5', '6']
|
||||
assert nums.map(it % 2 == 0) == [false, true, false, true, false, true]
|
||||
assert strs.map(it.to_upper()) == ['V', 'IS', 'AWESOME']
|
||||
assert strs.map(it == 'awesome') == [false, false, true]
|
||||
|
@ -673,13 +673,13 @@ fn test_map() {
|
|||
assert []int{len: 0}.map(it * 2) == []
|
||||
// nested maps (where it is of same type)
|
||||
assert nums.map(strs.map(int(7)) == [7, 7, 7]) == [true, true, true, true, true, true]
|
||||
assert nums.map('$it' + strs.map('a')[0]) == ['1a', '2a', '3a', '4a', '5a', '6a']
|
||||
assert nums.map('${it}' + strs.map('a')[0]) == ['1a', '2a', '3a', '4a', '5a', '6a']
|
||||
assert nums.map(it + strs.map(int(7))[0]) == [8, 9, 10, 11, 12, 13]
|
||||
assert nums.map(it + strs.map(it.len)[0]) == [2, 3, 4, 5, 6, 7]
|
||||
assert strs.map(it.len + strs.map(it.len)[0]) == [2, 3, 8]
|
||||
// nested (different it types)
|
||||
assert strs.map(it[nums.map(it - it)[0]]) == [u8(`v`), `i`, `a`]
|
||||
assert nums[0..3].map('$it' + strs.map(it)[it - 1]) == ['1v', '2is', '3awesome']
|
||||
assert nums[0..3].map('${it}' + strs.map(it)[it - 1]) == ['1v', '2is', '3awesome']
|
||||
assert nums.map(map_test_helper_1) == [1, 4, 9, 16, 25, 36]
|
||||
assert [1, 5, 10].map(map_test_helper_1) == [1, 25, 100]
|
||||
assert nums == [1, 2, 3, 4, 5, 6]
|
||||
|
@ -1076,7 +1076,7 @@ fn test_array_with_cap() {
|
|||
fn test_multi_array_index() {
|
||||
mut a := [][]int{len: 2, init: []int{len: 3, init: 0}}
|
||||
a[0][0] = 1
|
||||
assert '$a' == '[[1, 0, 0], [0, 0, 0]]'
|
||||
assert '${a}' == '[[1, 0, 0], [0, 0, 0]]'
|
||||
// mut b := [[0].repeat(3)].repeat(2)
|
||||
// b[0][0] = 1
|
||||
// assert '$b' == '[[1, 0, 0], [0, 0, 0]]'
|
||||
|
@ -1381,7 +1381,7 @@ fn test_array_struct_contains() {
|
|||
coords << coord_1
|
||||
exists := coord_1 in coords
|
||||
not_exists := coord_1 !in coords
|
||||
println('`exists`: $exists and `not exists`: $not_exists')
|
||||
println('`exists`: ${exists} and `not exists`: ${not_exists}')
|
||||
assert exists == true
|
||||
assert not_exists == false
|
||||
}
|
||||
|
@ -1416,7 +1416,7 @@ fn test_array_of_array_append() {
|
|||
println(x) // OK
|
||||
x[2] << 123 // RTE
|
||||
println(x)
|
||||
assert '$x' == '[[], [], [123], []]'
|
||||
assert '${x}' == '[[], [], [123], []]'
|
||||
}
|
||||
|
||||
fn test_array_of_map_insert() {
|
||||
|
@ -1430,7 +1430,7 @@ fn test_array_of_map_insert() {
|
|||
|
||||
fn test_multi_fixed_array_init() {
|
||||
a := [3][3]int{}
|
||||
assert '$a' == '[[0, 0, 0], [0, 0, 0], [0, 0, 0]]'
|
||||
assert '${a}' == '[[0, 0, 0], [0, 0, 0], [0, 0, 0]]'
|
||||
}
|
||||
|
||||
struct Numbers {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue