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

support pretty printing of StringInterLiteral in asserts too

This commit is contained in:
Delyan Angelov 2020-04-05 00:51:36 +03:00
parent e077cce103
commit 45fdbc4df7

View File

@ -77,6 +77,27 @@ pub fn (x Expr) str() string {
StringLiteral {
return '"$it.val"'
}
StringInterLiteral {
res := []string
res << "'"
for i, val in it.vals {
res << val
if i>=it.exprs.len {
continue
}
res << '$'
if it.expr_fmts[i].len > 0 {
res << '{'
res << it.exprs[i].str()
res << it.expr_fmts[i]
res << '}'
}else{
res << it.exprs[i].str()
}
}
res << "'"
return res.join('')
}
BoolLiteral {
return it.val.str()
}