vfmt: fix string interpolation formatting with multiple ',",\' and \" .
parent
258be508f4
commit
bd539b6427
|
@ -152,7 +152,7 @@ fn (c Context) compare_v_performance(label string, commands []string) string {
|
||||||
println(cmd)
|
println(cmd)
|
||||||
}
|
}
|
||||||
for cmd in commands {
|
for cmd in commands {
|
||||||
hyperfine_commands_arguments << " \'cd ${c.b:-34s} ; ./$cmd \' ".replace_each([
|
hyperfine_commands_arguments << ' \'cd ${c.b:-34s} ; ./$cmd \' '.replace_each([
|
||||||
'@COMPILER@',
|
'@COMPILER@',
|
||||||
source_location_b,
|
source_location_b,
|
||||||
'@DEBUG@',
|
'@DEBUG@',
|
||||||
|
@ -160,7 +160,7 @@ fn (c Context) compare_v_performance(label string, commands []string) string {
|
||||||
])
|
])
|
||||||
}
|
}
|
||||||
for cmd in commands {
|
for cmd in commands {
|
||||||
hyperfine_commands_arguments << " \'cd ${c.a:-34s} ; ./$cmd \' ".replace_each([
|
hyperfine_commands_arguments << ' \'cd ${c.a:-34s} ; ./$cmd \' '.replace_each([
|
||||||
'@COMPILER@',
|
'@COMPILER@',
|
||||||
source_location_a,
|
source_location_a,
|
||||||
'@DEBUG@',
|
'@DEBUG@',
|
||||||
|
|
|
@ -792,8 +792,8 @@ fn test_raw_with_quotes() {
|
||||||
|
|
||||||
fn test_escape() {
|
fn test_escape() {
|
||||||
a := 10
|
a := 10
|
||||||
println('\"$a')
|
println("\"$a")
|
||||||
assert '\"$a' == '"10'
|
assert "\"$a" == '"10'
|
||||||
}
|
}
|
||||||
|
|
||||||
fn test_atoi() {
|
fn test_atoi() {
|
||||||
|
|
|
@ -171,7 +171,7 @@ pub fn (mut c Checker) check_matching_function_symbols(got_type_sym &ast.TypeSym
|
||||||
if exp_arg_is_ptr != got_arg_is_ptr {
|
if exp_arg_is_ptr != got_arg_is_ptr {
|
||||||
exp_arg_pointedness := if exp_arg_is_ptr { 'a pointer' } else { 'NOT a pointer' }
|
exp_arg_pointedness := if exp_arg_is_ptr { 'a pointer' } else { 'NOT a pointer' }
|
||||||
got_arg_pointedness := if got_arg_is_ptr { 'a pointer' } else { 'NOT a pointer' }
|
got_arg_pointedness := if got_arg_is_ptr { 'a pointer' } else { 'NOT a pointer' }
|
||||||
c.add_error_detail("`$exp_fn.name`\'s expected fn argument: `$exp_arg.name` is $exp_arg_pointedness, but the passed fn argument: `$got_arg.name` is $got_arg_pointedness")
|
c.add_error_detail('`$exp_fn.name`\'s expected fn argument: `$exp_arg.name` is $exp_arg_pointedness, but the passed fn argument: `$got_arg.name` is $got_arg_pointedness')
|
||||||
return false
|
return false
|
||||||
}
|
}
|
||||||
if !c.check_basic(got_arg.typ, exp_arg.typ) {
|
if !c.check_basic(got_arg.typ, exp_arg.typ) {
|
||||||
|
|
|
@ -2343,12 +2343,19 @@ pub fn (mut f Fmt) string_inter_literal(node ast.StringInterLiteral) {
|
||||||
// TODO: this code is very similar to ast.Expr.str()
|
// TODO: this code is very similar to ast.Expr.str()
|
||||||
mut quote := "'"
|
mut quote := "'"
|
||||||
for val in node.vals {
|
for val in node.vals {
|
||||||
if val.contains("'") {
|
if val.contains('\\"') {
|
||||||
quote = '"'
|
quote = '"'
|
||||||
|
break
|
||||||
|
}
|
||||||
|
if val.contains("\\'") {
|
||||||
|
quote = "'"
|
||||||
|
break
|
||||||
}
|
}
|
||||||
if val.contains('"') {
|
if val.contains('"') {
|
||||||
quote = "'"
|
quote = "'"
|
||||||
break
|
}
|
||||||
|
if val.contains("'") {
|
||||||
|
quote = '"'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
f.write(quote)
|
f.write(quote)
|
||||||
|
|
|
@ -0,0 +1,9 @@
|
||||||
|
struct Container {
|
||||||
|
id string
|
||||||
|
}
|
||||||
|
|
||||||
|
container := Container{}
|
||||||
|
docker_pubkey := '1234657890'
|
||||||
|
|
||||||
|
cmd := "docker exec $container.id sh -c 'echo \"$docker_pubkey\" >> ~/.ssh/authorized_keys'"
|
||||||
|
println(cmd)
|
|
@ -938,7 +938,7 @@ fn (mut g JsGen) gen_for_in_stmt(it ast.ForInStmt) {
|
||||||
if it.kind == .string {
|
if it.kind == .string {
|
||||||
g.write('Array.from(')
|
g.write('Array.from(')
|
||||||
g.expr(it.cond)
|
g.expr(it.cond)
|
||||||
g.write(".str.split(\'\').entries(), ([$it.key_var, $val]) => [$it.key_var, ")
|
g.write('.str.split(\'\').entries(), ([$it.key_var, $val]) => [$it.key_var, ')
|
||||||
if g.ns.name == 'builtin' {
|
if g.ns.name == 'builtin' {
|
||||||
g.write('new ')
|
g.write('new ')
|
||||||
}
|
}
|
||||||
|
|
|
@ -8,7 +8,7 @@ struct Boss {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn (b Boss) say_hello() string {
|
fn (b Boss) say_hello() string {
|
||||||
return "Hello, My name is $b.name and I\'m the bawz"
|
return 'Hello, My name is $b.name and I\'m the bawz'
|
||||||
}
|
}
|
||||||
|
|
||||||
fn (b Boss) speak(msg string) {
|
fn (b Boss) speak(msg string) {
|
||||||
|
|
|
@ -100,7 +100,7 @@ fn test_parse_multipart_form() {
|
||||||
file := 'bar.v'
|
file := 'bar.v'
|
||||||
ct := 'application/octet-stream'
|
ct := 'application/octet-stream'
|
||||||
contents := ['baz', 'buzz']
|
contents := ['baz', 'buzz']
|
||||||
data := '--------------------------$boundary
|
data := "--------------------------$boundary
|
||||||
Content-Disposition: form-data; name=\"${names[0]}\"; filename=\"$file\"
|
Content-Disposition: form-data; name=\"${names[0]}\"; filename=\"$file\"
|
||||||
Content-Type: $ct
|
Content-Type: $ct
|
||||||
|
|
||||||
|
@ -110,7 +110,7 @@ Content-Disposition: form-data; name=\"${names[1]}\"
|
||||||
|
|
||||||
${contents[1]}
|
${contents[1]}
|
||||||
--------------------------$boundary--
|
--------------------------$boundary--
|
||||||
'
|
"
|
||||||
form, files := parse_multipart_form(data, boundary)
|
form, files := parse_multipart_form(data, boundary)
|
||||||
assert files == map{
|
assert files == map{
|
||||||
names[0]: [FileData{
|
names[0]: [FileData{
|
||||||
|
|
|
@ -213,12 +213,12 @@ fn test_http_client_multipart_form_data() ? {
|
||||||
name := 'foo'
|
name := 'foo'
|
||||||
ct := 'multipart/form-data; boundary=------------------------$boundary'
|
ct := 'multipart/form-data; boundary=------------------------$boundary'
|
||||||
contents := 'baz buzz'
|
contents := 'baz buzz'
|
||||||
data := '--------------------------$boundary
|
data := "--------------------------$boundary
|
||||||
Content-Disposition: form-data; name=\"$name\"
|
Content-Disposition: form-data; name=\"$name\"
|
||||||
|
|
||||||
$contents
|
$contents
|
||||||
--------------------------$boundary--
|
--------------------------$boundary--
|
||||||
'
|
"
|
||||||
mut x := http.fetch('http://127.0.0.1:$sport/form_echo',
|
mut x := http.fetch('http://127.0.0.1:$sport/form_echo',
|
||||||
method: .post
|
method: .post
|
||||||
header: http.new_header(
|
header: http.new_header(
|
||||||
|
|
Loading…
Reference in New Issue