From 45fdbc4df78baabc57bcf2cdf88a4fc5782342a9 Mon Sep 17 00:00:00 2001 From: Delyan Angelov Date: Sun, 5 Apr 2020 00:51:36 +0300 Subject: [PATCH] support pretty printing of StringInterLiteral in asserts too --- vlib/v/ast/str.v | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/vlib/v/ast/str.v b/vlib/v/ast/str.v index 015ec6efb0..dbf5fb3f58 100644 --- a/vlib/v/ast/str.v +++ b/vlib/v/ast/str.v @@ -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() }