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:
parent
e077cce103
commit
45fdbc4df7
@ -77,6 +77,27 @@ pub fn (x Expr) str() string {
|
|||||||
StringLiteral {
|
StringLiteral {
|
||||||
return '"$it.val"'
|
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 {
|
BoolLiteral {
|
||||||
return it.val.str()
|
return it.val.str()
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user