diff options
author | Martin Probst <martin@probst.io> | 2016-06-08 14:04:04 +0000 |
---|---|---|
committer | Martin Probst <martin@probst.io> | 2016-06-08 14:04:04 +0000 |
commit | 14ea15614778ef140a5bd83e725412c0ee4b8800 (patch) | |
tree | d5132dd590a317bdbf6469598f8f93cdecb6abd9 /unittests/Format/SortImportsTestJS.cpp | |
parent | cab2aa4780f0bd994de2660f7a1e08a79447d745 (diff) |
clang-format: [JS] fix an assertion failure caused by shrinking sources.
Summary:
The JavaScript import sorter has a corner condition that can cause the overall
source text length to shrink. This change circumvents the issue by appending
trailing space in the line after the import blocks to match at least the
previous source code length.
This needs a better long term fix, but this fixes the immediate issue.
Reviewers: alexeagle, djasper
Subscribers: klimek
Differential Revision: http://reviews.llvm.org/D21108
git-svn-id: https://llvm.org/svn/llvm-project/cfe/trunk@272142 91177308-0d34-0410-b5e6-96231b3b80d8
Diffstat (limited to 'unittests/Format/SortImportsTestJS.cpp')
-rw-r--r-- | unittests/Format/SortImportsTestJS.cpp | 13 |
1 files changed, 13 insertions, 0 deletions
diff --git a/unittests/Format/SortImportsTestJS.cpp b/unittests/Format/SortImportsTestJS.cpp index 140fe4a746..17e73b0855 100644 --- a/unittests/Format/SortImportsTestJS.cpp +++ b/unittests/Format/SortImportsTestJS.cpp @@ -223,6 +223,19 @@ TEST_F(SortImportsTestJS, AffectedRange) { 24, 30); } +TEST_F(SortImportsTestJS, SortingCanShrink) { + // Sort excluding a suffix. + verifySort("import {B} from 'a';\n" + "import {A} from 'b';\n" + "\n" + "1;", + "import {A} from 'b';\n" + "\n" + "import {B} from 'a';\n" + "\n" + "1;"); +} + } // end namespace } // end namespace format } // end namespace clang |