summaryrefslogtreecommitdiffstats
path: root/clang/unittests/Format/FormatTestJS.cpp
diff options
context:
space:
mode:
authorDaniel Jasper <djasper@google.com>2015-02-19 16:07:32 +0000
committerDaniel Jasper <djasper@google.com>2015-02-19 16:07:32 +0000
commit354aa515878cf0b456701f3a0f6db27bdf561e86 (patch)
treef723bff48f1d5aaef03c288f02573d43b83506fc /clang/unittests/Format/FormatTestJS.cpp
parent6fa9ec788508472e8e07a2c6f0ccbdbd64f1ade7 (diff)
downloadbcm5719-llvm-354aa515878cf0b456701f3a0f6db27bdf561e86.tar.gz
bcm5719-llvm-354aa515878cf0b456701f3a0f6db27bdf561e86.zip
clang-format: [js] Support ES6 module imports.
Patch by Martin Probst. llvm-svn: 229863
Diffstat (limited to 'clang/unittests/Format/FormatTestJS.cpp')
-rw-r--r--clang/unittests/Format/FormatTestJS.cpp26
1 files changed, 26 insertions, 0 deletions
diff --git a/clang/unittests/Format/FormatTestJS.cpp b/clang/unittests/Format/FormatTestJS.cpp
index b60e47083ef..ab4af8090bf 100644
--- a/clang/unittests/Format/FormatTestJS.cpp
+++ b/clang/unittests/Format/FormatTestJS.cpp
@@ -525,5 +525,31 @@ TEST_F(FormatTestJS, MetadataAnnotations) {
"class Y {}");
}
+TEST_F(FormatTestJS, Modules) {
+ verifyFormat("import SomeThing from 'some/module.js';");
+ verifyFormat("import {X, Y} from 'some/module.js';");
+ verifyFormat("import {\n"
+ " VeryLongImportsAreAnnoying,\n"
+ " VeryLongImportsAreAnnoying,\n"
+ " VeryLongImportsAreAnnoying,\n"
+ " VeryLongImportsAreAnnoying\n"
+ "} from 'some/module.js';");
+ verifyFormat("import {\n"
+ " X,\n"
+ " Y,\n"
+ "} from 'some/module.js';");
+ verifyFormat("import {\n"
+ " X,\n"
+ " Y,\n"
+ "} from 'some/long/module.js';",
+ getGoogleJSStyleWithColumns(20));
+ verifyFormat("import {X as myLocalX, Y as myLocalY} from 'some/module.js';");
+ verifyFormat("import * as lib from 'some/module.js';");
+ verifyFormat("var x = {\n import: 1\n};\nx.import = 2;");
+ verifyFormat("export function fn() {\n return 'fn';\n}");
+ verifyFormat("export const x = 12;");
+ verifyFormat("export default class X {}");
+}
+
} // end namespace tooling
} // end namespace clang
OpenPOWER on IntegriCloud