diff options
author | Martin Probst <martin@probst.io> | 2016-06-01 15:19:53 +0000 |
---|---|---|
committer | Martin Probst <martin@probst.io> | 2016-06-01 15:19:53 +0000 |
commit | 081f176a6227e8081ac875d278fb66e2d1d1dbde (patch) | |
tree | f9da69a00d5015538145793b8304773767d121ad /clang/unittests/Format/SortImportsTestJS.cpp | |
parent | 256845036d0cf816a0a644f14e0a0513be25c931 (diff) | |
download | bcm5719-llvm-081f176a6227e8081ac875d278fb66e2d1d1dbde.tar.gz bcm5719-llvm-081f176a6227e8081ac875d278fb66e2d1d1dbde.zip |
clang-format: [JS] Sort imported symbols.
Summary: E.g. sort `import {b, a} from 'x';` into `import {a, b} from 'x';`.
Reviewers: djasper
Subscribers: cfe-commits, klimek
Differential Revision: http://reviews.llvm.org/D20798
llvm-svn: 271400
Diffstat (limited to 'clang/unittests/Format/SortImportsTestJS.cpp')
-rw-r--r-- | clang/unittests/Format/SortImportsTestJS.cpp | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/clang/unittests/Format/SortImportsTestJS.cpp b/clang/unittests/Format/SortImportsTestJS.cpp index ad692e600d3..140fe4a7466 100644 --- a/clang/unittests/Format/SortImportsTestJS.cpp +++ b/clang/unittests/Format/SortImportsTestJS.cpp @@ -67,6 +67,21 @@ TEST_F(SortImportsTestJS, BasicSorting) { "let x = 1;"); } +TEST_F(SortImportsTestJS, WrappedImportStatements) { + verifySort("import {sym1, sym2} from 'a';\n" + "import {sym} from 'b';\n" + "\n" + "1;", + "import\n" + " {sym}\n" + " from 'b';\n" + "import {\n" + " sym1,\n" + " sym2\n" + "} from 'a';\n" + "1;"); +} + TEST_F(SortImportsTestJS, SeparateMainCodeBody) { verifySort("import {sym} from 'a';" "\n" @@ -101,6 +116,18 @@ TEST_F(SortImportsTestJS, AliasesSymbols) { "import {sym1 as alias1} from 'b';\n"); } +TEST_F(SortImportsTestJS, SortSymbols) { + verifySort("import {sym1, sym2 as a, sym3} from 'b';\n", + "import {sym2 as a, sym1, sym3} from 'b';\n"); + verifySort("import {sym1 /* important! */, /*!*/ sym2 as a} from 'b';\n", + "import {/*!*/ sym2 as a, sym1 /* important! */} from 'b';\n"); + verifySort("import {sym1, sym2} from 'b';\n", "import {\n" + " sym2 \n" + ",\n" + " sym1 \n" + "} from 'b';\n"); +} + TEST_F(SortImportsTestJS, GroupImports) { verifySort("import {a} from 'absolute';\n" "\n" |