summaryrefslogtreecommitdiff
path: root/unittests
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2015-07-02 13:08:28 +0000
committerDaniel Jasper <djasper@google.com>2015-07-02 13:08:28 +0000
commitb73f25667c9dfb5cf9a136b83c5ddfd9b03668fd (patch)
treef998b84d0b9626bd454f660a7b77e7fc4306dd44 /unittests
parenta8245d8fe2d5228413d2e5ae23e4a036e0072c70 (diff)
downloadclang-b73f25667c9dfb5cf9a136b83c5ddfd9b03668fd.tar.gz
clang-format: [JS] Fix character counting in template strings.
Some counts were off, we don't need to take the leading newlines of the first ` into account and some tests were just wrong. git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@241257 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests')
-rw-r--r--unittests/Format/FormatTestJS.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/unittests/Format/FormatTestJS.cpp b/unittests/Format/FormatTestJS.cpp
index 63bcfdc174..845ae5124b 100644
--- a/unittests/Format/FormatTestJS.cpp
+++ b/unittests/Format/FormatTestJS.cpp
@@ -795,15 +795,11 @@ TEST_F(FormatTestJS, TemplateStrings) {
" ${ name }\n"
" !`;"));
- // FIXME: +1 / -1 offsets are to work around clang-format miscalculating
- // widths for unknown tokens that are not whitespace (e.g. '`'). Remove when
- // the code is corrected.
-
verifyFormat("var x =\n"
" `hello ${world}` >= some();",
getGoogleJSStyleWithColumns(34)); // Barely doesn't fit.
verifyFormat("var x = `hello ${world}` >= some();",
- getGoogleJSStyleWithColumns(35 + 1)); // Barely fits.
+ getGoogleJSStyleWithColumns(35)); // Barely fits.
EXPECT_EQ("var x = `hello\n"
" ${world}` >=\n"
" some();",
@@ -818,10 +814,14 @@ TEST_F(FormatTestJS, TemplateStrings) {
" ${world}` >= some();",
getGoogleJSStyleWithColumns(22))); // Barely fits.
- verifyFormat("var x =\n `h`;", getGoogleJSStyleWithColumns(13 - 1));
+ verifyFormat("var x =\n"
+ " `h`;",
+ getGoogleJSStyleWithColumns(11));
EXPECT_EQ(
"var x =\n `multi\n line`;",
- format("var x = `multi\n line`;", getGoogleJSStyleWithColumns(14 - 1)));
+ format("var x = `multi\n line`;", getGoogleJSStyleWithColumns(13)));
+ verifyFormat("aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa(\n"
+ " `aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa`);");
// Make sure template strings get a proper ColumnWidth assigned, even if they
// are first token in line.