summaryrefslogtreecommitdiffstats
path: root/clang/unittests/Format/FormatTestJS.cpp
diff options
context:
space:
mode:
authorMartin Probst <martin@probst.io>2017-08-14 16:08:16 +0000
committerMartin Probst <martin@probst.io>2017-08-14 16:08:16 +0000
commit83e0220b3ff81cd265e93d3d6029cb330b3fd87a (patch)
tree82aba455466e8699dc04fc7676b5d1f42d1eefa5 /clang/unittests/Format/FormatTestJS.cpp
parent6e01dc1b840139e07b60759a5cfa42d99bef8a43 (diff)
downloadbcm5719-llvm-83e0220b3ff81cd265e93d3d6029cb330b3fd87a.tar.gz
bcm5719-llvm-83e0220b3ff81cd265e93d3d6029cb330b3fd87a.zip
clang-format: [JS] do not insert whitespace in call positions.
Summary: In JavaScript, may keywords can be used in method names and thus call sites: foo.delete(); foo.instanceof(); clang-format would previously insert whitespace after the `instanceof`. This change generically skips inserting whitespace between a keyword and a parenthesis if preceded by a dot, i.e. in a callsite. Reviewers: djasper Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D36142 llvm-svn: 310851
Diffstat (limited to 'clang/unittests/Format/FormatTestJS.cpp')
-rw-r--r--clang/unittests/Format/FormatTestJS.cpp20
1 files changed, 13 insertions, 7 deletions
diff --git a/clang/unittests/Format/FormatTestJS.cpp b/clang/unittests/Format/FormatTestJS.cpp
index fb035066d68..57dc7c1119d 100644
--- a/clang/unittests/Format/FormatTestJS.cpp
+++ b/clang/unittests/Format/FormatTestJS.cpp
@@ -271,14 +271,21 @@ TEST_F(FormatTestJS, ReservedWords) {
verifyFormat("x.case = 1;");
verifyFormat("x.interface = 1;");
verifyFormat("x.for = 1;");
- verifyFormat("x.of() = 1;");
+ verifyFormat("x.of();");
verifyFormat("of(null);");
verifyFormat("import {of} from 'x';");
- verifyFormat("x.in() = 1;");
- verifyFormat("x.let() = 1;");
- verifyFormat("x.var() = 1;");
- verifyFormat("x.for() = 1;");
- verifyFormat("x.as() = 1;");
+ verifyFormat("x.in();");
+ verifyFormat("x.let();");
+ verifyFormat("x.var();");
+ verifyFormat("x.for();");
+ verifyFormat("x.as();");
+ verifyFormat("x.instanceof();");
+ verifyFormat("x.switch();");
+ verifyFormat("x.case();");
+ verifyFormat("x.delete();");
+ verifyFormat("x.throw();");
+ verifyFormat("x.throws();");
+ verifyFormat("x.if();");
verifyFormat("x = {\n"
" a: 12,\n"
" interface: 1,\n"
@@ -1228,7 +1235,6 @@ TEST_F(FormatTestJS, TryCatch) {
// But, of course, "catch" is a perfectly fine function name in JavaScript.
verifyFormat("someObject.catch();");
verifyFormat("someObject.new();");
- verifyFormat("someObject.delete();");
}
TEST_F(FormatTestJS, StringLiteralConcatenation) {
OpenPOWER on IntegriCloud