Author: Owen Pan Date: 2023-10-26T13:37:23-07:00 New Revision: e3ecdf7d3b7ec8fa2c3c594ff39b20788e75eaf2
URL: https://github.com/llvm/llvm-project/commit/e3ecdf7d3b7ec8fa2c3c594ff39b20788e75eaf2 DIFF: https://github.com/llvm/llvm-project/commit/e3ecdf7d3b7ec8fa2c3c594ff39b20788e75eaf2.diff LOG: [clang-format][NFC] Remove some extraneous newlines at end of test cases Added: Modified: clang/unittests/Format/SortImportsTestJS.cpp Removed: ################################################################################ diff --git a/clang/unittests/Format/SortImportsTestJS.cpp b/clang/unittests/Format/SortImportsTestJS.cpp index c724fcc073f59e2..f423cdd21d1ac2c 100644 --- a/clang/unittests/Format/SortImportsTestJS.cpp +++ b/clang/unittests/Format/SortImportsTestJS.cpp @@ -111,8 +111,8 @@ TEST_F(SortImportsTestJS, WrappedImportStatements) { TEST_F(SortImportsTestJS, SeparateMainCodeBody) { verifySort("import {sym} from 'a';" "\n" - "let x = 1;\n", - "import {sym} from 'a'; let x = 1;\n"); + "let x = 1;", + "import {sym} from 'a'; let x = 1;"); } TEST_F(SortImportsTestJS, Comments) { @@ -123,17 +123,17 @@ TEST_F(SortImportsTestJS, Comments) { "/** @fileoverview This is a great file. */\n" "import {sym} from 'b'; // from //foo:bar\n" "// A very important import follows.\n" - "import {sym} from 'a'; /* more comments */\n"); + "import {sym} from 'a'; /* more comments */"); verifySort("import {sym} from 'a';\n" "import {sym} from 'b';\n" "\n" "/** Comment on variable. */\n" - "const x = 1;\n", + "const x = 1;", "import {sym} from 'b';\n" "import {sym} from 'a';\n" "\n" "/** Comment on variable. */\n" - "const x = 1;\n"); + "const x = 1;"); } TEST_F(SortImportsTestJS, SortStar) { @@ -142,26 +142,26 @@ TEST_F(SortImportsTestJS, SortStar) { "import * as bar from 'b';\n", "import {sym} from 'a';\n" "import * as foo from 'a';\n" - "import * as bar from 'b';\n"); + "import * as bar from 'b';"); } TEST_F(SortImportsTestJS, AliasesSymbols) { verifySort("import {sym1 as alias1} from 'b';\n" "import {sym2 as alias2, sym3 as alias3} from 'c';\n", "import {sym2 as alias2, sym3 as alias3} from 'c';\n" - "import {sym1 as alias1} from 'b';\n"); + "import {sym1 as alias1} from 'b';"); } TEST_F(SortImportsTestJS, SortSymbols) { verifySort("import {sym1, sym2 as a, sym3} from 'b';\n", - "import {sym2 as a, sym1, sym3} from 'b';\n"); + "import {sym2 as a, sym1, sym3} from 'b';"); verifySort("import {sym1 /* important! */, /*!*/ sym2 as a} from 'b';\n", - "import {/*!*/ sym2 as a, sym1 /* important! */} from 'b';\n"); + "import {/*!*/ sym2 as a, sym1 /* important! */} from 'b';"); verifySort("import {sym1, sym2} from 'b';\n", "import {\n" " sym2 \n" ",\n" " sym1 \n" - "} from 'b';\n"); + "} from 'b';"); } TEST_F(SortImportsTestJS, GroupImports) { @@ -173,13 +173,13 @@ TEST_F(SortImportsTestJS, GroupImports) { "import {b} from './relative/path';\n" "import {b} from './relative/path/nested';\n" "\n" - "let x = 1;\n", + "let x = 1;", "import {b} from './relative/path/nested';\n" "import {b} from './relative/path';\n" "import {b} from '../parent/nested';\n" "import {b} from '../parent';\n" "import {a} from 'absolute';\n" - "let x = 1;\n"); + "let x = 1;"); } TEST_F(SortImportsTestJS, Exports) { @@ -193,7 +193,7 @@ TEST_F(SortImportsTestJS, Exports) { "export {S};\n" "\n" "let x = 1;\n" - "export y = 1;\n", + "export y = 1;", "export {R} from './relative';\n" "import {T} from './cpath';\n" "export {S};\n" @@ -201,12 +201,12 @@ TEST_F(SortImportsTestJS, Exports) { "import {S} from 'bpath';\n" "export {P} from '../parent';\n" "let x = 1;\n" - "export y = 1;\n"); + "export y = 1;"); verifySort("import {S} from 'bpath';\n" "\n" "export {T} from 'epath';\n", "export {T} from 'epath';\n" - "import {S} from 'bpath';\n"); + "import {S} from 'bpath';"); } TEST_F(SortImportsTestJS, SideEffectImports) { @@ -219,7 +219,7 @@ TEST_F(SortImportsTestJS, SideEffectImports) { "import {R} from './relative';\n" "import 'ZZside-effect';\n" "import {A} from 'absolute';\n" - "import 'AAside-effect';\n"); + "import 'AAside-effect';"); } TEST_F(SortImportsTestJS, AffectedRange) { @@ -262,7 +262,7 @@ TEST_F(SortImportsTestJS, SortingCanShrink) { } TEST_F(SortImportsTestJS, TrailingComma) { - verifySort("import {A, B,} from 'aa';\n", "import {B, A,} from 'aa';\n"); + verifySort("import {A, B,} from 'aa';\n", "import {B, A,} from 'aa';"); } TEST_F(SortImportsTestJS, SortCaseInsensitive) { @@ -308,7 +308,7 @@ TEST_F(SortImportsTestJS, SortDefaultImports) { verifySort("import {A} from 'a';\n" "import {default as B} from 'b';\n", "import {default as B} from 'b';\n" - "import {A} from 'a';\n"); + "import {A} from 'a';"); } TEST_F(SortImportsTestJS, MergeImports) { @@ -316,12 +316,12 @@ TEST_F(SortImportsTestJS, MergeImports) { verifySort("import {X, Y} from 'a';\n" "import {Z} from 'z';\n" "\n" - "X + Y + Z;\n", + "X + Y + Z;", "import {X} from 'a';\n" "import {Z} from 'z';\n" "import {Y} from 'a';\n" "\n" - "X + Y + Z;\n"); + "X + Y + Z;"); // merge only, no resorting. verifySort("import {A, B} from 'foo';\n", "import {A} from 'foo';\n" @@ -333,15 +333,15 @@ TEST_F(SortImportsTestJS, MergeImports) { // ignores import * verifySort("import * as foo from 'foo';\n" - "import {A} from 'foo';\n", + "import {A} from 'foo';", "import * as foo from 'foo';\n" - "import {A} from 'foo';\n"); + "import {A} from 'foo';"); // ignores default import verifySort("import X from 'foo';\n" - "import {A} from 'foo';\n", + "import {A} from 'foo';", "import X from 'foo';\n" - "import {A} from 'foo';\n"); + "import {A} from 'foo';"); // keeps comments // known issue: loses the 'also a' comment. @@ -350,7 +350,7 @@ TEST_F(SortImportsTestJS, MergeImports) { "// z\n" "import {Z} from 'z';\n" "\n" - "X + Y + Z;\n", + "X + Y + Z;", "// a\n" "import {/* y */ Y} from 'a';\n" "// z\n" @@ -358,7 +358,7 @@ TEST_F(SortImportsTestJS, MergeImports) { "// also a\n" "import {/* x */ X} from 'a';\n" "\n" - "X + Y + Z;\n"); + "X + Y + Z;"); // do not merge imports and exports verifySort("import {A} from 'foo';\n" @@ -375,18 +375,18 @@ TEST_F(SortImportsTestJS, MergeImports) { "\n" "import {bar} from './a';\n", "import {bar} from './a';\n" - "import './a';\n"); + "import './a';"); } TEST_F(SortImportsTestJS, RespectsClangFormatOff) { verifySort("// clang-format off\n" "import {B} from './b';\n" "import {A} from './a';\n" - "// clang-format on\n", + "// clang-format on", "// clang-format off\n" "import {B} from './b';\n" "import {A} from './a';\n" - "// clang-format on\n"); + "// clang-format on"); verifySort("import {A} from './sorted1_a';\n" "import {B} from './sorted1_b';\n" @@ -403,15 +403,15 @@ TEST_F(SortImportsTestJS, RespectsClangFormatOff) { "import {A} from './unsorted_a';\n" "// clang-format on\n" "import {B} from './sorted2_b';\n" - "import {A} from './sorted2_a';\n"); + "import {A} from './sorted2_a';"); // Boundary cases - verifySort("// clang-format on\n", "// clang-format on\n"); - verifySort("// clang-format off\n", "// clang-format off\n"); + verifySort("// clang-format on", "// clang-format on"); + verifySort("// clang-format off", "// clang-format off"); verifySort("// clang-format on\n" - "// clang-format off\n", + "// clang-format off", "// clang-format on\n" - "// clang-format off\n"); + "// clang-format off"); verifySort("// clang-format off\n" "// clang-format on\n" "import {A} from './a';\n" @@ -419,7 +419,7 @@ TEST_F(SortImportsTestJS, RespectsClangFormatOff) { "// clang-format off\n" "// clang-format on\n" "import {B} from './b';\n" - "import {A} from './a';\n"); + "import {A} from './a';"); // section ends with comment verifySort("// clang-format on\n" "import {A} from './a';\n" @@ -427,12 +427,12 @@ TEST_F(SortImportsTestJS, RespectsClangFormatOff) { "import {C} from './c';\n" "\n" // inserted empty line is working as intended: splits imports // section from main code body - "// clang-format off\n", + "// clang-format off", "// clang-format on\n" "import {C} from './c';\n" "import {B} from './b';\n" "import {A} from './a';\n" - "// clang-format off\n"); + "// clang-format off"); } TEST_F(SortImportsTestJS, RespectsClangFormatOffInNamedImports) { @@ -455,14 +455,14 @@ TEST_F(SortImportsTestJS, ImportEqAliases) { "\n" "export {Z};\n" "\n" - "console.log(Z);\n", + "console.log(Z);", "import {A} from 'foo';\n" "import Z = A.C;\n" "export {Z};\n" "import {B} from 'bar';\n" "import Y = B.C.Z;\n" "\n" - "console.log(Z);\n"); + "console.log(Z);"); } TEST_F(SortImportsTestJS, ImportExportType) { @@ -482,18 +482,18 @@ TEST_F(SortImportsTestJS, ImportExportType) { // Symbols within import statement verifySort("import {type sym1, type sym2 as a, sym3} from 'b';\n", - "import {type sym2 as a, type sym1, sym3} from 'b';\n"); + "import {type sym2 as a, type sym1, sym3} from 'b';"); // Merging verifySort("import {X, type Z} from 'a';\n" "import type {Y} from 'a';\n" "\n" - "X + Y + Z;\n", + "X + Y + Z;", "import {X} from 'a';\n" "import {type Z} from 'a';\n" "import type {Y} from 'a';\n" "\n" - "X + Y + Z;\n"); + "X + Y + Z;"); // Merging: empty imports verifySort("import type {A} from 'foo';\n", "import type {} from 'foo';\n" @@ -508,10 +508,10 @@ TEST_F(SortImportsTestJS, ImportExportType) { // statements should therefore not merge. verifySort("export type A = B;\n" "export {X};\n" - "export {Y};\n", + "export {Y};", "export type A = B;\n" "export {X};\n" - "export {Y};\n"); + "export {Y};"); } TEST_F(SortImportsTestJS, TemplateKeyword) { _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits