diff options
| author | Martin Probst <martin@probst.io> | 2017-01-09 08:56:36 +0000 |
|---|---|---|
| committer | Martin Probst <martin@probst.io> | 2017-01-09 08:56:36 +0000 |
| commit | d40bca431dfab7deae906fae9eea72dbdd81de2c (patch) | |
| tree | cd033ee0d1abe60916029787a9f807cc823ae11c /clang/unittests/Format/FormatTestJS.cpp | |
| parent | 6eedfe77c15fa95b421b413bb6b09f405e212196 (diff) | |
| download | bcm5719-llvm-d40bca431dfab7deae906fae9eea72dbdd81de2c.tar.gz bcm5719-llvm-d40bca431dfab7deae906fae9eea72dbdd81de2c.zip | |
clang-format: [JS] ASI after imports
Summary:
Automatic semicolon insertion should break import and export statements:
Before, this would format on one line:
// Note: no semi after 'x' below!
import {x} from 'x'
export function foo() {}
Into:
import {x} from 'x' export function foo() {}
With this change, the statements get separated.
This also improves automatic semicolon insertion to consider closing
braces preceding declarations and statements.
Reviewers: klimek
Subscribers: cfe-commits
Differential Revision: https://reviews.llvm.org/D28465
llvm-svn: 291428
Diffstat (limited to 'clang/unittests/Format/FormatTestJS.cpp')
| -rw-r--r-- | clang/unittests/Format/FormatTestJS.cpp | 18 |
1 files changed, 18 insertions, 0 deletions
diff --git a/clang/unittests/Format/FormatTestJS.cpp b/clang/unittests/Format/FormatTestJS.cpp index 59f4a4f6dcf..12554a1dc23 100644 --- a/clang/unittests/Format/FormatTestJS.cpp +++ b/clang/unittests/Format/FormatTestJS.cpp @@ -858,6 +858,24 @@ TEST_F(FormatTestJS, AutomaticSemicolonInsertionHeuristic) { "return 1", "a = null\n" " return 1"); + verifyFormat( + "x = {a: 1}\n" + "class Y {}", + " x = {a : 1}\n" + " class Y { }"); +} + +TEST_F(FormatTestJS, ImportExportASI) { + verifyFormat( + "import {x} from 'y'\n" + "export function z() {}", + "import {x} from 'y'\n" + " export function z() {}"); + verifyFormat( + "export {x}\n" + "class Y {}", + " export {x}\n" + " class Y {\n}"); } TEST_F(FormatTestJS, ClosureStyleCasts) { |

