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

cgen: fix math/complex_test.v

This commit is contained in:
yuyi 2020-04-14 13:44:19 +08:00 committed by GitHub
parent 682c619456
commit 956651384c
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 7 additions and 5 deletions

View File

@ -16,7 +16,6 @@ const (
'vlib/eventbus/eventbus_test.v',
'vlib/flag/flag_test.v',
'vlib/json/json_test.v',
'vlib/math/complex/complex_test.v',
'vlib/net/ftp/ftp_test.v',
'vlib/net/http/http_httpbin_test.v',
'vlib/net/http/http_test.v',

View File

@ -2189,9 +2189,11 @@ fn (g mut Gen) string_inter_literal(node ast.StringInterLiteral) {
verror('only V strings can be formatted with a ${sfmt} format')
}
g.write('%' + sfmt[1..])
} else if node.expr_types[i] in [table.string_type, table.bool_type, table.f32_type,
table.f64_type] || sym.kind in [.enum_, .array, .array_fixed] {
} else if node.expr_types[i] in [table.string_type, table.bool_type] ||
sym.kind in [.enum_, .array, .array_fixed] {
g.write('%.*s')
} else if node.expr_types[i] in [table.f32_type, table.f64_type] {
g.write('%f')
} else {
g.write('%d')
}
@ -2219,6 +2221,8 @@ fn (g mut Gen) string_inter_literal(node ast.StringInterLiteral) {
g.write(' ? 4 : 5, ')
g.expr(expr)
g.write(' ? "true" : "false"')
} else if node.expr_types[i] in [table.f32_type, table.f64_type] {
g.expr(expr)
} else {
sym := g.table.get_type_symbol(node.expr_types[i])
if sym.kind == .enum_ {
@ -2252,8 +2256,7 @@ fn (g mut Gen) string_inter_literal(node ast.StringInterLiteral) {
g.enum_expr(expr)
g.write('"')
}
} else if node.expr_types[i] in [table.f32_type, table.f64_type, table.array_type,
table.map_type] || sym.kind in [.array, .array_fixed] {
} else if sym.kind in [.array, .array_fixed] {
styp := g.typ(node.expr_types[i])
g.write('${styp}_str(')
g.expr(expr)