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

@ -331,5 +331,5 @@ fn strip_newlines(src []u8) []u8 {
fn corrupt_input_error_msg(e int) string {
// return error('illegal base32 data at input byte ' + strconv.FormatInt(int64(e), 10)
return 'illegal base32 data at input byte $e'
return 'illegal base32 data at input byte ${e}'
}

View File

@ -8,7 +8,7 @@ fn test_encode_and_decode() {
encoded := base32.encode_string_to_string(input)
assert encoded == 'NBSWY3DPEB3A===='
decoded := base32.decode_string_to_string(encoded) or { panic('error decoding: $err') }
decoded := base32.decode_string_to_string(encoded) or { panic('error decoding: ${err}') }
assert decoded == input
encoder_no_padding := base32.new_std_encoding_with_padding(base32.no_padding)
@ -16,7 +16,7 @@ fn test_encode_and_decode() {
assert encoded2 == 'NBSWY3DPEB3A'
decoded2 := encoder_no_padding.decode_string_to_string(encoded2) or {
panic('error decoding: $err')
panic('error decoding: ${err}')
}
assert decoded2 == input
}

View File

@ -164,10 +164,10 @@ pub fn decode_walpha_bytes(input []u8, alphabet Alphabet) ![]u8 {
for _, r in input {
if r > 127 {
panic(@MOD + '.' + @FN +
': high-bit set on invalid digit; outside of ascii range ($r). This should never happen.')
': high-bit set on invalid digit; outside of ascii range (${r}). This should never happen.')
}
if alphabet.decode[r] == -1 {
return error(@MOD + '.' + @FN + ': invalid base58 digit ($r)')
return error(@MOD + '.' + @FN + ': invalid base58 digit (${r})')
}
c = u64(alphabet.decode[r])

View File

@ -57,26 +57,26 @@ fn test_fails() ! {
a := -238
b := 0
if z := encode_int(a) {
return error(@MOD + '.' + @FN + ': expected encode_int to fail, got $z')
return error(@MOD + '.' + @FN + ': expected encode_int to fail, got ${z}')
}
if z := encode_int(b) {
return error(@MOD + '.' + @FN + ': expected encode_int to fail, got $z')
return error(@MOD + '.' + @FN + ': expected encode_int to fail, got ${z}')
}
c := '!'
if z := decode_int(c) {
return error(@MOD + '.' + @FN + ': expected decode_int to fail, got $z')
return error(@MOD + '.' + @FN + ': expected decode_int to fail, got ${z}')
}
if z := decode(c) {
return error(@MOD + '.' + @FN + ': expected decode to fail, got $z')
return error(@MOD + '.' + @FN + ': expected decode to fail, got ${z}')
}
// repeating character
if abc := new_alphabet('aaaaafghij\$lmnopqrstuvwxyz0123456789_ABCDEFGHIJLMNOPQRSTUV') {
return error(@MOD + '.' + @FN + ': expected new_alphabet to fail, got $abc')
return error(@MOD + '.' + @FN + ': expected new_alphabet to fail, got ${abc}')
}
// more than 58 characters long
if abc := new_alphabet('abcdefghij\$lmnopqrstuvwxyz0123456789_ABCDEFGHIJLMNOPQRSTUVWXYZ') {
return error(@MOD + '.' + @FN + ': expected new_alphabet to fail, got $abc')
return error(@MOD + '.' + @FN + ': expected new_alphabet to fail, got ${abc}')
}
}

View File

@ -9,7 +9,7 @@ fn test_encode() {
'\x00\x00hello world': '11StV1DL6CwTryKyV'
} {
output := base58.encode(input)
println('> input: `$input` | $input.bytes().hex() | => output: `$output`')
println('> input: `${input}` | ${input.bytes().hex()} | => output: `${output}`')
assert output == expected
}
}
@ -22,7 +22,7 @@ fn test_encode_int() {
0x636363: 'aPEr'
} {
output := base58.encode_int(input)!
println('> input: 0x${input:x} | => output: `$output`')
println('> input: 0x${input:x} | => output: `${output}`')
assert output == expected
}
}
@ -36,7 +36,7 @@ fn test_decode() {
'3vQB7B6MrGQZaxCuFg4oh': hex.decode('68656c6c6f20776f726c64bc62d4b8')?.bytestr()
} {
input := base58.decode(output)!
println('> output: `$output` | decoded input: `$input` | bytes: $input.bytes().hex()')
println('> output: `${output}` | decoded input: `${input}` | bytes: ${input.bytes().hex()}')
assert input.bytes().hex() == expected.bytes().hex()
}
}

View File

@ -54,6 +54,6 @@ fn test_long_encoding() {
assert resultsize == s_decoded.len
}
println('Final s: $s')
println('Final s: ${s}')
// assert s == 39147008
}

View File

@ -44,7 +44,7 @@ fn test_decode() {
for i, p in pairs {
got := base64.decode(p.encoded)
if got != p.decoded.bytes() {
eprintln('pairs[$i]: expected = $p.decoded, got = $got')
eprintln('pairs[${i}]: expected = ${p.decoded}, got = ${got}')
assert false
}
}
@ -61,7 +61,7 @@ fn test_decode_str() {
for i, p in pairs {
got := base64.decode_str(p.encoded)
if got != p.decoded {
eprintln('pairs[$i]: expected = $p.decoded, got = $got')
eprintln('pairs[${i}]: expected = ${p.decoded}, got = ${got}')
assert false
}
}
@ -73,7 +73,7 @@ fn test_encode() {
for i, p in pairs {
got := base64.encode(p.decoded.bytes())
if got != p.encoded {
eprintln('pairs[$i]: expected = $p.encoded, got = $got')
eprintln('pairs[${i}]: expected = ${p.encoded}, got = ${got}')
assert false
}
}
@ -85,7 +85,7 @@ fn test_encode_str() {
for i, p in pairs {
got := base64.encode_str(p.decoded)
if got != p.encoded {
eprintln('pairs[$i]: expected = $p.encoded, got = $got')
eprintln('pairs[${i}]: expected = ${p.encoded}, got = ${got}')
assert false
}
}

View File

@ -57,6 +57,6 @@ fn char2nibble(b u8) !u8 {
`0`...`9` { return b - u8(`0`) }
`A`...`F` { return b - u8(`A`) + 10 }
`a`...`f` { return b - u8(`a`) + 10 }
else { return error('invalid hex char $b.ascii_str()') }
else { return error('invalid hex char ${b.ascii_str()}') }
}
}

View File

@ -15,19 +15,19 @@ fn test_decode() {
fn test_decode_fails() ! {
if x := decode('foo') {
return error('expected decode to fail, got $x')
return error('expected decode to fail, got ${x}')
}
if x := decode('g') {
return error('expected decode to fail, got $x')
return error('expected decode to fail, got ${x}')
}
if x := decode('000000000g') {
return error('expected decode to fail, got $x')
return error('expected decode to fail, got ${x}')
}
if x := decode('_') {
return error('expected decode to fail, got $x')
return error('expected decode to fail, got ${x}')
}
if x := decode('!') {
return error('expected decode to fail, got $x')
return error('expected decode to fail, got ${x}')
}
}