support pretty printing of StringInterLiteral in asserts too

pull/4253/head
Delyan Angelov 2020-04-05 00:51:36 +03:00
parent e077cce103
commit 45fdbc4df7
1 changed files with 21 additions and 0 deletions

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()
}