diff options
| author | Martin Probst <martin@probst.io> | 2016-06-13 16:39:50 +0000 |
|---|---|---|
| committer | Martin Probst <martin@probst.io> | 2016-06-13 16:39:50 +0000 |
| commit | 0cd74ee87557836ca25604c9895c546e0a6e648e (patch) | |
| tree | 8a7ee83c3f079c67401530a1cb24e9a5555a5107 /clang/unittests/Format/FormatTestJS.cpp | |
| parent | db176c11dc3d78b3cfbf623eb3fe71532a80a91f (diff) | |
| download | bcm5719-llvm-0cd74ee87557836ca25604c9895c546e0a6e648e.tar.gz bcm5719-llvm-0cd74ee87557836ca25604c9895c546e0a6e648e.zip | |
clang-format: [JS] Introduce JavaScriptWrapImports option.
Summary:
When turned on, clang-format wraps JavaScript imports (and importing exports),
instead of forcing the entire import statement onto one line.
Reviewers: djasper
Subscribers: klimek, cfe-commits
Differential Revision: http://reviews.llvm.org/D21273
llvm-svn: 272558
Diffstat (limited to 'clang/unittests/Format/FormatTestJS.cpp')
| -rw-r--r-- | clang/unittests/Format/FormatTestJS.cpp | 27 |
1 files changed, 24 insertions, 3 deletions
diff --git a/clang/unittests/Format/FormatTestJS.cpp b/clang/unittests/Format/FormatTestJS.cpp index ffcc34d971f..36c3dd08cba 100644 --- a/clang/unittests/Format/FormatTestJS.cpp +++ b/clang/unittests/Format/FormatTestJS.cpp @@ -1007,9 +1007,6 @@ TEST_F(FormatTestJS, Modules) { verifyFormat("import SomeThing from 'some/module.js';"); verifyFormat("import {X, Y} from 'some/module.js';"); verifyFormat("import a, {X, Y} from 'some/module.js';"); - verifyFormat("import {VeryLongImportsAreAnnoying, VeryLongImportsAreAnnoying," - " VeryLongImportsAreAnnoying, VeryLongImportsAreAnnoying" - "} from 'some/module.js';"); verifyFormat("import {X, Y,} from 'some/module.js';"); verifyFormat("import {X as myLocalX, Y as myLocalY} from 'some/module.js';"); // Ensure Automatic Semicolon Insertion does not break on "as\n". @@ -1078,6 +1075,30 @@ TEST_F(FormatTestJS, Modules) { "}"); } +TEST_F(FormatTestJS, ImportWrapping) { + verifyFormat("import {VeryLongImportsAreAnnoying, VeryLongImportsAreAnnoying," + " VeryLongImportsAreAnnoying, VeryLongImportsAreAnnoying" + "} from 'some/module.js';"); + FormatStyle Style = getGoogleJSStyleWithColumns(80); + Style.JavaScriptWrapImports = true; + verifyFormat("import {\n" + " VeryLongImportsAreAnnoying,\n" + " VeryLongImportsAreAnnoying,\n" + " VeryLongImportsAreAnnoying,\n" + "} from 'some/module.js';", + Style); + verifyFormat("import {\n" + " A,\n" + " A,\n" + "} from 'some/module.js';", + Style); + verifyFormat("export {\n" + " A,\n" + " A,\n" + "} from 'some/module.js';", + Style); +} + TEST_F(FormatTestJS, TemplateStrings) { // Keeps any whitespace/indentation within the template string. verifyFormat("var x = `hello\n" |

