Skip to content

Commit

Permalink
[clang-format][NFC] Remove some extraneous newlines at end of test cases
Browse files Browse the repository at this point in the history
  • Loading branch information
owenca committed Oct 26, 2023
1 parent 3fe8fd7 commit e3ecdf7
Showing 1 changed file with 44 additions and 44 deletions.
88 changes: 44 additions & 44 deletions clang/unittests/Format/SortImportsTestJS.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -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) {
Expand All @@ -193,20 +193,20 @@ 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"
"export {A, B} from 'apath';\n"
"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) {
Expand All @@ -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) {
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -308,20 +308,20 @@ 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) {
// basic operation
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"
Expand All @@ -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.
Expand All @@ -350,15 +350,15 @@ 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"
"import {Z} from 'z';\n"
"// 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"
Expand All @@ -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"
Expand All @@ -403,36 +403,36 @@ 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"
"import {B} from './b';\n",
"// 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"
"import {B} from './b';\n"
"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) {
Expand All @@ -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) {
Expand All @@ -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"
Expand All @@ -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) {
Expand Down

0 comments on commit e3ecdf7

Please sign in to comment.