summaryrefslogtreecommitdiffstats
path: root/clang/unittests/Format/FormatTestJS.cpp
diff options
context:
space:
mode:
authorMartin Probst <martin@probst.io>2016-05-17 06:29:29 +0000
committerMartin Probst <martin@probst.io>2016-05-17 06:29:29 +0000
commite71b4cbdd140f059667f84464bd0ac0ebc348387 (patch)
treef1c6c347e4da7ed025f8a5a2b735d006c8932bb1 /clang/unittests/Format/FormatTestJS.cpp
parent8c18e1120d8d37c6c22846ed53d1e21099318877 (diff)
downloadbcm5719-llvm-e71b4cbdd140f059667f84464bd0ac0ebc348387.tar.gz
bcm5719-llvm-e71b4cbdd140f059667f84464bd0ac0ebc348387.zip
clang-format: [JS] fix template string width counting.
Summary: Simply looking at the final text greatly simplifies the algorithm and also fixes a reported issue. This requires duplicating the "actual encoding width" logic, but that seems cleaner than the column acrobatics before. Reviewers: djasper, bkramer Subscribers: cfe-commits, klimek Differential Revision: http://reviews.llvm.org/D20208 llvm-svn: 269747
Diffstat (limited to 'clang/unittests/Format/FormatTestJS.cpp')
-rw-r--r--clang/unittests/Format/FormatTestJS.cpp9
1 files changed, 9 insertions, 0 deletions
diff --git a/clang/unittests/Format/FormatTestJS.cpp b/clang/unittests/Format/FormatTestJS.cpp
index 72d8948bb7a..485e8224c32 100644
--- a/clang/unittests/Format/FormatTestJS.cpp
+++ b/clang/unittests/Format/FormatTestJS.cpp
@@ -1076,6 +1076,8 @@ TEST_F(FormatTestJS, TemplateStrings) {
getGoogleJSStyleWithColumns(34)); // Barely doesn't fit.
verifyFormat("var x = `hello ${world}` >= some();",
getGoogleJSStyleWithColumns(35)); // Barely fits.
+ verifyFormat("var x = `hellö ${wörld}` >= söme();",
+ getGoogleJSStyleWithColumns(35)); // Fits due to UTF-8.
verifyFormat("var x = `hello\n"
" ${world}` >=\n"
" some();",
@@ -1097,6 +1099,13 @@ TEST_F(FormatTestJS, TemplateStrings) {
getGoogleJSStyleWithColumns(13));
verifyFormat("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n"
" `aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa`);");
+ // Repro for an obscure width-miscounting issue with template strings.
+ verifyFormat(
+ "someLongVariable =\n"
+ " "
+ "`${logPrefix[11]}/${logPrefix[12]}/${logPrefix[13]}${logPrefix[14]}`;",
+ "someLongVariable = "
+ "`${logPrefix[11]}/${logPrefix[12]}/${logPrefix[13]}${logPrefix[14]}`;");
// Make sure template strings get a proper ColumnWidth assigned, even if they
// are first token in line.
OpenPOWER on IntegriCloud