summaryrefslogtreecommitdiffstats
path: root/clang/unittests/Format/SortImportsTestJS.cpp
diff options
context:
space:
mode:
authorMartin Probst <martin@probst.io>2016-09-02 14:01:17 +0000
committerMartin Probst <martin@probst.io>2016-09-02 14:01:17 +0000
commitb480ffbcef2e0833b471d304861e20c2d6d9e963 (patch)
tree706f188e9e0fef68aad2ecdcbd5cf05f8250257b /clang/unittests/Format/SortImportsTestJS.cpp
parent7a78e5113a2334dbadd45f0c800312402d737b8b (diff)
downloadbcm5719-llvm-b480ffbcef2e0833b471d304861e20c2d6d9e963.tar.gz
bcm5719-llvm-b480ffbcef2e0833b471d304861e20c2d6d9e963.zip
clang-format: [JS] Sort all JavaScript imports if any changed.
Summary: User feedback is that they expect *all* imports to be sorted if any import was affected by a change, not just imports up to the first non-affected line, as clang-format currently does. Reviewers: djasper Subscribers: klimek, cfe-commits Differential Revision: https://reviews.llvm.org/D23972 llvm-svn: 280485
Diffstat (limited to 'clang/unittests/Format/SortImportsTestJS.cpp')
-rw-r--r--clang/unittests/Format/SortImportsTestJS.cpp25
1 files changed, 7 insertions, 18 deletions
diff --git a/clang/unittests/Format/SortImportsTestJS.cpp b/clang/unittests/Format/SortImportsTestJS.cpp
index 77c37e337dd..e43844c49cb 100644
--- a/clang/unittests/Format/SortImportsTestJS.cpp
+++ b/clang/unittests/Format/SortImportsTestJS.cpp
@@ -190,40 +190,29 @@ TEST_F(SortImportsTestJS, SideEffectImports) {
}
TEST_F(SortImportsTestJS, AffectedRange) {
- // Sort excluding a suffix.
- verifySort("import {sym} from 'b';\n"
+ // Affected range inside of import statements.
+ verifySort("import {sym} from 'a';\n"
+ "import {sym} from 'b';\n"
"import {sym} from 'c';\n"
- "import {sym} from 'a';\n"
+ "\n"
"let x = 1;",
"import {sym} from 'c';\n"
"import {sym} from 'b';\n"
"import {sym} from 'a';\n"
"let x = 1;",
0, 30);
- // Sort excluding a prefix.
+ // Affected range outside of import statements.
verifySort("import {sym} from 'c';\n"
- "import {sym} from 'a';\n"
- "import {sym} from 'b';\n"
- "\n"
- "let x = 1;",
- "import {sym} from 'c';\n"
"import {sym} from 'b';\n"
"import {sym} from 'a';\n"
"\n"
"let x = 1;",
- 30, 0);
- // Sort a range within imports.
- verifySort("import {sym} from 'c';\n"
- "import {sym} from 'a';\n"
- "import {sym} from 'b';\n"
- "import {sym} from 'c';\n"
- "let x = 1;",
"import {sym} from 'c';\n"
"import {sym} from 'b';\n"
"import {sym} from 'a';\n"
- "import {sym} from 'c';\n"
+ "\n"
"let x = 1;",
- 24, 30);
+ 70, 1);
}
TEST_F(SortImportsTestJS, SortingCanShrink) {
OpenPOWER on IntegriCloud