From 194f8f60b1f330dae0db3ac65fd628979673889f Mon Sep 17 00:00:00 2001 From: Hyeonjong Date: Sat, 2 Mar 2024 22:53:54 +0900 Subject: [PATCH] refactor: tidy up tests In fact, it was a task that should have been done in #26, but there were a lot of tests so I pretended not to know and passed it on at the time. --- tests/v2-test/babel/assignment/1tbs.test.ts | 174 +--- tests/v2-test/babel/assignment/allman.test.ts | 181 +--- .../babel/assignment/stroustrup.test.ts | 174 +--- tests/v2-test/babel/function/1tbs.test.ts | 158 ---- tests/v2-test/babel/function/allman.test.ts | 175 ---- .../v2-test/babel/function/stroustrup.test.ts | 158 ---- tests/v2-test/babel/if/1tbs.test.ts | 82 +- tests/v2-test/babel/if/allman.test.ts | 93 +- tests/v2-test/babel/if/stroustrup.test.ts | 84 +- .../babel/variable-declaration/1tbs.test.ts | 89 -- .../babel/variable-declaration/allman.test.ts | 89 -- .../variable-declaration/stroustrup.test.ts | 89 -- .../typescript/assignment/1tbs.test.ts | 174 +--- .../typescript/assignment/allman.test.ts | 181 +--- .../typescript/assignment/stroustrup.test.ts | 174 +--- .../v2-test/typescript/function/1tbs.test.ts | 158 ---- .../typescript/function/allman.test.ts | 175 ---- .../typescript/function/stroustrup.test.ts | 158 ---- tests/v2-test/typescript/if/1tbs.test.ts | 82 +- tests/v2-test/typescript/if/allman.test.ts | 93 +- .../v2-test/typescript/if/stroustrup.test.ts | 84 +- .../variable-declaration/1tbs.test.ts | 80 -- .../variable-declaration/allman.test.ts | 80 -- .../variable-declaration/stroustrup.test.ts | 80 -- tests/v2-test/vue/assignment/1tbs.test.ts | 666 +------------- tests/v2-test/vue/assignment/allman.test.ts | 693 +-------------- .../v2-test/vue/assignment/stroustrup.test.ts | 666 +------------- tests/v2-test/vue/function/1tbs.test.ts | 774 +--------------- tests/v2-test/vue/function/allman.test.ts | 829 +----------------- tests/v2-test/vue/function/stroustrup.test.ts | 774 +--------------- tests/v2-test/vue/if/1tbs.test.ts | 280 +----- tests/v2-test/vue/if/allman.test.ts | 308 +------ tests/v2-test/vue/if/stroustrup.test.ts | 284 +----- .../vue/variable-declaration/1tbs.test.ts | 210 ----- .../vue/variable-declaration/allman.test.ts | 214 ----- .../variable-declaration/stroustrup.test.ts | 210 ----- tests/v3-test/babel/assignment/1tbs.test.ts | 174 +--- tests/v3-test/babel/assignment/allman.test.ts | 181 +--- .../babel/assignment/stroustrup.test.ts | 174 +--- tests/v3-test/babel/function/1tbs.test.ts | 158 ---- tests/v3-test/babel/function/allman.test.ts | 175 ---- .../v3-test/babel/function/stroustrup.test.ts | 158 ---- tests/v3-test/babel/if/1tbs.test.ts | 82 +- tests/v3-test/babel/if/allman.test.ts | 93 +- tests/v3-test/babel/if/stroustrup.test.ts | 84 +- .../babel/variable-declaration/1tbs.test.ts | 89 -- .../babel/variable-declaration/allman.test.ts | 89 -- .../variable-declaration/stroustrup.test.ts | 89 -- .../typescript/assignment/1tbs.test.ts | 174 +--- .../typescript/assignment/allman.test.ts | 181 +--- .../typescript/assignment/stroustrup.test.ts | 174 +--- .../v3-test/typescript/function/1tbs.test.ts | 158 ---- .../typescript/function/allman.test.ts | 175 ---- .../typescript/function/stroustrup.test.ts | 158 ---- tests/v3-test/typescript/if/1tbs.test.ts | 82 +- tests/v3-test/typescript/if/allman.test.ts | 93 +- .../v3-test/typescript/if/stroustrup.test.ts | 84 +- .../variable-declaration/1tbs.test.ts | 80 -- .../variable-declaration/allman.test.ts | 80 -- .../variable-declaration/stroustrup.test.ts | 80 -- tests/v3-test/vue/assignment/1tbs.test.ts | 666 +------------- tests/v3-test/vue/assignment/allman.test.ts | 693 +-------------- .../v3-test/vue/assignment/stroustrup.test.ts | 666 +------------- tests/v3-test/vue/function/1tbs.test.ts | 774 +--------------- tests/v3-test/vue/function/allman.test.ts | 829 +----------------- tests/v3-test/vue/function/stroustrup.test.ts | 774 +--------------- tests/v3-test/vue/if/1tbs.test.ts | 280 +----- tests/v3-test/vue/if/allman.test.ts | 308 +------ tests/v3-test/vue/if/stroustrup.test.ts | 284 +----- .../vue/variable-declaration/1tbs.test.ts | 210 ----- .../vue/variable-declaration/allman.test.ts | 214 ----- .../variable-declaration/stroustrup.test.ts | 210 ----- 72 files changed, 134 insertions(+), 17812 deletions(-) delete mode 100644 tests/v2-test/babel/variable-declaration/1tbs.test.ts delete mode 100644 tests/v2-test/babel/variable-declaration/allman.test.ts delete mode 100644 tests/v2-test/babel/variable-declaration/stroustrup.test.ts delete mode 100644 tests/v2-test/typescript/variable-declaration/1tbs.test.ts delete mode 100644 tests/v2-test/typescript/variable-declaration/allman.test.ts delete mode 100644 tests/v2-test/typescript/variable-declaration/stroustrup.test.ts delete mode 100644 tests/v2-test/vue/variable-declaration/1tbs.test.ts delete mode 100644 tests/v2-test/vue/variable-declaration/allman.test.ts delete mode 100644 tests/v2-test/vue/variable-declaration/stroustrup.test.ts delete mode 100644 tests/v3-test/babel/variable-declaration/1tbs.test.ts delete mode 100644 tests/v3-test/babel/variable-declaration/allman.test.ts delete mode 100644 tests/v3-test/babel/variable-declaration/stroustrup.test.ts delete mode 100644 tests/v3-test/typescript/variable-declaration/1tbs.test.ts delete mode 100644 tests/v3-test/typescript/variable-declaration/allman.test.ts delete mode 100644 tests/v3-test/typescript/variable-declaration/stroustrup.test.ts delete mode 100644 tests/v3-test/vue/variable-declaration/1tbs.test.ts delete mode 100644 tests/v3-test/vue/variable-declaration/allman.test.ts delete mode 100644 tests/v3-test/vue/variable-declaration/stroustrup.test.ts diff --git a/tests/v2-test/babel/assignment/1tbs.test.ts b/tests/v2-test/babel/assignment/1tbs.test.ts index 40de1f7..826ed6d 100644 --- a/tests/v2-test/babel/assignment/1tbs.test.ts +++ b/tests/v2-test/babel/assignment/1tbs.test.ts @@ -37,84 +37,6 @@ const fixtures: Fixture[] = [ }, { name: 'object assignment (3)', - input: `const foo = /*comment1*/ { - bar: { - baz: 'baz' - } -}`, - output: `const foo = /*comment1*/ { - bar: { - baz: "baz", - }, -}; -`, - }, - { - name: 'object assignment (4)', - input: `const foo = -/*comment2*/ -{ - bar: { - baz: 'baz' - } -}`, - output: `const foo = - /*comment2*/ - { - bar: { - baz: "baz", - }, - }; -`, - }, - { - name: 'object assignment (5)', - input: `const foo = { - /*comment3*/ bar: { - baz: 'baz' - } -}`, - output: `const foo = { - /*comment3*/ bar: { - baz: "baz", - }, -}; -`, - }, - { - name: 'object assignment (6)', - input: `const foo = { - bar: /*comment4*/ { - baz: 'baz' - } -}`, - output: `const foo = { - bar: /*comment4*/ { - baz: "baz", - }, -}; -`, - }, - { - name: 'object assignment (7)', - input: `const foo = { - bar: - /*comment5*/ - { - baz: 'baz' - } -}`, - output: `const foo = { - bar: - /*comment5*/ - { - baz: "baz", - }, -}; -`, - }, - { - name: 'object assignment (8)', input: `const foo = { bar() {}, ['baz']() {} @@ -123,57 +45,6 @@ const fixtures: Fixture[] = [ bar() {}, ["baz"]() {}, }; -`, - }, - { - name: 'object assignment (9)', - input: `const foo = { - bar/*comment1*/() {}, - ['baz']() {} -}`, - output: `const foo = { - bar /*comment1*/() {}, - ["baz"]() {}, -}; -`, - }, - { - name: 'object assignment (10)', - input: `const foo = { - bar(/*comment2*/) {}, - ['baz']() {} -}`, - output: `const foo = { - bar(/*comment2*/) {}, - ["baz"]() {}, -}; -`, - }, - { - name: 'object assignment (11)', - input: `const foo = { - bar()/*comment3*/{}, - ['baz']() {} -}`, - output: `const foo = { - bar() /*comment3*/ {}, - ["baz"]() {}, -}; -`, - }, - { - name: 'object assignment (12)', - input: `const foo = { - bar() - /*comment4*/ - {}, - ['baz']() {} -}`, - output: `const foo = { - bar() /*comment4*/ - {}, - ["baz"]() {}, -}; `, }, { @@ -188,49 +59,6 @@ const fixtures: Fixture[] = [ }, { name: 'conditional assignment (2)', - input: `const foo =/*comment1*/true && { - bar: 'baz' -}`, - output: `const foo = /*comment1*/ true && { - bar: "baz", -}; -`, - }, - { - name: 'conditional assignment (3)', - input: `const foo = true/*comment2*/&& { - bar: 'baz' -}`, - output: `const foo = true /*comment2*/ && { - bar: "baz", -}; -`, - }, - { - name: 'conditional assignment (4)', - input: `const foo = true &&/*comment3*/{ - bar: 'baz' -}`, - output: `const foo = true && /*comment3*/ { - bar: "baz", -}; -`, - }, - { - name: 'conditional assignment (5)', - input: `const foo = true && -/*comment4*/ -{ - bar: 'baz' -}`, - output: `const foo = true && /*comment4*/ -{ - bar: "baz", -}; -`, - }, - { - name: 'conditional assignment (6)', input: `const foo = false || { bar: 'baz' }`, @@ -240,7 +68,7 @@ const fixtures: Fixture[] = [ `, }, { - name: 'conditional assignment (7)', + name: 'conditional assignment (3)', input: `const foo = null ?? { bar: 'baz' }`, diff --git a/tests/v2-test/babel/assignment/allman.test.ts b/tests/v2-test/babel/assignment/allman.test.ts index 8a09736..a0826e6 100644 --- a/tests/v2-test/babel/assignment/allman.test.ts +++ b/tests/v2-test/babel/assignment/allman.test.ts @@ -37,84 +37,6 @@ const fixtures: Fixture[] = [ }, { name: 'object assignment (3)', - input: `const foo = /*comment1*/ { - bar: { - baz: 'baz' - } -}`, - output: `const foo = /*comment1*/ { - bar: { - baz: "baz", - }, -}; -`, - }, - { - name: 'object assignment (4)', - input: `const foo = -/*comment2*/ -{ - bar: { - baz: 'baz' - } -}`, - output: `const foo = - /*comment2*/ - { - bar: { - baz: "baz", - }, - }; -`, - }, - { - name: 'object assignment (5)', - input: `const foo = { - /*comment3*/ bar: { - baz: 'baz' - } -}`, - output: `const foo = { - /*comment3*/ bar: { - baz: "baz", - }, -}; -`, - }, - { - name: 'object assignment (6)', - input: `const foo = { - bar: /*comment4*/ { - baz: 'baz' - } -}`, - output: `const foo = { - bar: /*comment4*/ { - baz: "baz", - }, -}; -`, - }, - { - name: 'object assignment (7)', - input: `const foo = { - bar: - /*comment5*/ - { - baz: 'baz' - } -}`, - output: `const foo = { - bar: - /*comment5*/ - { - baz: "baz", - }, -}; -`, - }, - { - name: 'object assignment (8)', input: `const foo = { bar() {}, ['baz']() {} @@ -125,64 +47,6 @@ const fixtures: Fixture[] = [ ["baz"]() {}, }; -`, - }, - { - name: 'object assignment (9)', - input: `const foo = { - bar/*comment1*/() {}, - ['baz']() {} -}`, - output: `const foo = { - bar /*comment1*/() - {}, - ["baz"]() - {}, -}; -`, - }, - { - name: 'object assignment (10)', - input: `const foo = { - bar(/*comment2*/) {}, - ['baz']() {} -}`, - output: `const foo = { - bar(/*comment2*/) - {}, - ["baz"]() - {}, -}; -`, - }, - { - name: 'object assignment (11)', - input: `const foo = { - bar()/*comment3*/{}, - ['baz']() {} -}`, - output: `const foo = { - bar() /*comment3*/ - {}, - ["baz"]() - {}, -}; -`, - }, - { - name: 'object assignment (12)', - input: `const foo = { - bar() - /*comment4*/ - {}, - ['baz']() {} -}`, - output: `const foo = { - bar() /*comment4*/ - {}, - ["baz"]() - {}, -}; `, }, { @@ -197,49 +61,6 @@ const fixtures: Fixture[] = [ }, { name: 'conditional assignment (2)', - input: `const foo =/*comment1*/true && { - bar: 'baz' -}`, - output: `const foo = /*comment1*/ true && { - bar: "baz", -}; -`, - }, - { - name: 'conditional assignment (3)', - input: `const foo = true/*comment2*/&& { - bar: 'baz' -}`, - output: `const foo = true /*comment2*/ && { - bar: "baz", -}; -`, - }, - { - name: 'conditional assignment (4)', - input: `const foo = true &&/*comment3*/{ - bar: 'baz' -}`, - output: `const foo = true && /*comment3*/ { - bar: "baz", -}; -`, - }, - { - name: 'conditional assignment (5)', - input: `const foo = true && -/*comment4*/ -{ - bar: 'baz' -}`, - output: `const foo = true && /*comment4*/ -{ - bar: "baz", -}; -`, - }, - { - name: 'conditional assignment (6)', input: `const foo = false || { bar: 'baz' }`, @@ -249,7 +70,7 @@ const fixtures: Fixture[] = [ `, }, { - name: 'conditional assignment (7)', + name: 'conditional assignment (3)', input: `const foo = null ?? { bar: 'baz' }`, diff --git a/tests/v2-test/babel/assignment/stroustrup.test.ts b/tests/v2-test/babel/assignment/stroustrup.test.ts index 5a9cd35..fc3f3d4 100644 --- a/tests/v2-test/babel/assignment/stroustrup.test.ts +++ b/tests/v2-test/babel/assignment/stroustrup.test.ts @@ -37,84 +37,6 @@ const fixtures: Fixture[] = [ }, { name: 'object assignment (3)', - input: `const foo = /*comment1*/ { - bar: { - baz: 'baz' - } -}`, - output: `const foo = /*comment1*/ { - bar: { - baz: "baz", - }, -}; -`, - }, - { - name: 'object assignment (4)', - input: `const foo = -/*comment2*/ -{ - bar: { - baz: 'baz' - } -}`, - output: `const foo = - /*comment2*/ - { - bar: { - baz: "baz", - }, - }; -`, - }, - { - name: 'object assignment (5)', - input: `const foo = { - /*comment3*/ bar: { - baz: 'baz' - } -}`, - output: `const foo = { - /*comment3*/ bar: { - baz: "baz", - }, -}; -`, - }, - { - name: 'object assignment (6)', - input: `const foo = { - bar: /*comment4*/ { - baz: 'baz' - } -}`, - output: `const foo = { - bar: /*comment4*/ { - baz: "baz", - }, -}; -`, - }, - { - name: 'object assignment (7)', - input: `const foo = { - bar: - /*comment5*/ - { - baz: 'baz' - } -}`, - output: `const foo = { - bar: - /*comment5*/ - { - baz: "baz", - }, -}; -`, - }, - { - name: 'object assignment (8)', input: `const foo = { bar() {}, ['baz']() {} @@ -123,57 +45,6 @@ const fixtures: Fixture[] = [ bar() {}, ["baz"]() {}, }; -`, - }, - { - name: 'object assignment (9)', - input: `const foo = { - bar/*comment1*/() {}, - ['baz']() {} -}`, - output: `const foo = { - bar /*comment1*/() {}, - ["baz"]() {}, -}; -`, - }, - { - name: 'object assignment (10)', - input: `const foo = { - bar(/*comment2*/) {}, - ['baz']() {} -}`, - output: `const foo = { - bar(/*comment2*/) {}, - ["baz"]() {}, -}; -`, - }, - { - name: 'object assignment (11)', - input: `const foo = { - bar()/*comment3*/{}, - ['baz']() {} -}`, - output: `const foo = { - bar() /*comment3*/ {}, - ["baz"]() {}, -}; -`, - }, - { - name: 'object assignment (12)', - input: `const foo = { - bar() - /*comment4*/ - {}, - ['baz']() {} -}`, - output: `const foo = { - bar() /*comment4*/ - {}, - ["baz"]() {}, -}; `, }, { @@ -188,49 +59,6 @@ const fixtures: Fixture[] = [ }, { name: 'conditional assignment (2)', - input: `const foo =/*comment1*/true && { - bar: 'baz' -}`, - output: `const foo = /*comment1*/ true && { - bar: "baz", -}; -`, - }, - { - name: 'conditional assignment (3)', - input: `const foo = true/*comment2*/&& { - bar: 'baz' -}`, - output: `const foo = true /*comment2*/ && { - bar: "baz", -}; -`, - }, - { - name: 'conditional assignment (4)', - input: `const foo = true &&/*comment3*/{ - bar: 'baz' -}`, - output: `const foo = true && /*comment3*/ { - bar: "baz", -}; -`, - }, - { - name: 'conditional assignment (5)', - input: `const foo = true && -/*comment4*/ -{ - bar: 'baz' -}`, - output: `const foo = true && /*comment4*/ -{ - bar: "baz", -}; -`, - }, - { - name: 'conditional assignment (6)', input: `const foo = false || { bar: 'baz' }`, @@ -240,7 +68,7 @@ const fixtures: Fixture[] = [ `, }, { - name: 'conditional assignment (7)', + name: 'conditional assignment (3)', input: `const foo = null ?? { bar: 'baz' }`, diff --git a/tests/v2-test/babel/function/1tbs.test.ts b/tests/v2-test/babel/function/1tbs.test.ts index 9e88080..62d160e 100644 --- a/tests/v2-test/babel/function/1tbs.test.ts +++ b/tests/v2-test/babel/function/1tbs.test.ts @@ -53,178 +53,20 @@ const sum = (a, b) => { }, { name: 'function declaration (2)', - input: ` -function foo(/* args here */) { - statement; -} -`, - output: `function foo(/* args here */) { - statement; -} -`, - }, - { - name: 'function declaration (3)', - input: ` -function foo( - /* args here */ -) { - statement; -} -`, - output: `function foo() { -/* args here */ - statement; -} -`, - }, - { - name: 'function declaration (4)', - input: ` -function foo( - // args here -) { - statement; -} -`, - output: `function foo() { -// args here - statement; -} -`, - }, - { - name: 'function declaration (5)', - input: ` -function foo(/* arg */ // arg - // arg -/* arg */) { - statement; -} -`, - output: `function foo /* arg */() { // arg -// arg -/* arg */ - statement; -} -`, - }, - { - name: 'function declaration (6)', input: `function foo() {}`, output: `function foo() {} -`, - }, - { - name: 'function declaration (7)', - input: `function /*comment1*/ foo() {}`, - output: `function /*comment1*/ foo() {} -`, - }, - { - name: 'function declaration (8)', - input: `function -/*comment2*/ -foo() {}`, - output: `function /*comment2*/ -foo() {} -`, - }, - { - name: 'function declaration (9)', - input: `function foo(/*comment3*/) {}`, - output: `function foo(/*comment3*/) {} -`, - }, - { - name: 'function declaration (10)', - input: `function foo() /*comment4*/ {}`, - output: `function foo() /*comment4*/ {} -`, - }, - { - name: 'function declaration (11)', - input: `function foo() {} /*comment5*/`, - output: `function foo() {} /*comment5*/ `, }, { name: 'function expression (2)', input: `const foo = function () {}`, output: `const foo = function () {}; -`, - }, - { - name: 'function expression (3)', - input: `const foo = function /*comment1*/ () {}`, - output: `const foo = function () /*comment1*/ {}; -`, - }, - { - name: 'function expression (4)', - input: `const foo = function (/*comment2*/) {}`, - output: `const foo = function (/*comment2*/) {}; -`, - }, - { - name: 'function expression (5)', - input: `const foo = function () /*comment3*/ {}`, - output: `const foo = function () /*comment3*/ {}; -`, - }, - { - name: 'function expression (6)', - input: `const foo = function () -/*comment4*/ -{}`, - output: `const foo = function () /*comment4*/ -{}; -`, - }, - { - name: 'function expression (7)', - input: `const foo = function () {} /*comment5*/`, - output: `const foo = function () {}; /*comment5*/ `, }, { name: 'arrow function expression (2)', input: `const foo = () => {}`, output: `const foo = () => {}; -`, - }, - { - name: 'arrow function expression (3)', - input: `const foo = (/*comment1*/) => {}`, - output: `const foo = (/*comment1*/) => {}; -`, - }, - { - name: 'arrow function expression (4)', - input: `const foo = () /*comment2*/ => {}`, - output: `const foo = () /*comment2*/ => {}; -`, - }, - { - name: 'arrow function expression (5)', - input: `const foo = () => /*comment3*/ {}`, - output: `const foo = () => /*comment3*/ {}; -`, - }, - { - name: 'arrow function expression (6)', - input: `const foo = () => -/*comment4*/ -{}`, - output: `const foo = () => - /*comment4*/ - {}; -`, - }, - { - name: 'arrow function expression (7)', - input: `const foo = () => {} /*comment5*/`, - output: `const foo = () => {}; /*comment5*/ `, }, { diff --git a/tests/v2-test/babel/function/allman.test.ts b/tests/v2-test/babel/function/allman.test.ts index a84c3db..1854dda 100644 --- a/tests/v2-test/babel/function/allman.test.ts +++ b/tests/v2-test/babel/function/allman.test.ts @@ -56,109 +56,9 @@ const sum = (a, b) => { }, { name: 'function declaration (2)', - input: ` -function foo(/* args here */) { - statement; -} -`, - output: `function foo(/* args here */) -{ - statement; -} -`, - }, - { - name: 'function declaration (3)', - input: ` -function foo( - /* args here */ -) { - statement; -} -`, - output: `function foo() -{ -/* args here */ - statement; -} -`, - }, - { - name: 'function declaration (4)', - input: ` -function foo( - // args here -) { - statement; -} -`, - output: `function foo() -{ -// args here - statement; -} -`, - }, - { - name: 'function declaration (5)', - input: ` -function foo(/* arg */ // arg - // arg -/* arg */) { - statement; -} -`, - output: `function foo /* arg */() -{ // arg -// arg -/* arg */ - statement; -} -`, - }, - { - name: 'function declaration (6)', input: `function foo() {}`, output: `function foo() {} -`, - }, - { - name: 'function declaration (7)', - input: `function /*comment1*/ foo() {}`, - output: `function /*comment1*/ foo() -{} -`, - }, - { - name: 'function declaration (8)', - input: `function -/*comment2*/ -foo() {}`, - output: `function /*comment2*/ -foo() -{} -`, - }, - { - name: 'function declaration (9)', - input: `function foo(/*comment3*/) {}`, - output: `function foo(/*comment3*/) -{} -`, - }, - { - name: 'function declaration (10)', - input: `function foo() /*comment4*/ {}`, - output: `function foo() /*comment4*/ -{} -`, - }, - { - name: 'function declaration (11)', - input: `function foo() {} /*comment5*/`, - output: `function foo() -{} /*comment5*/ `, }, { @@ -166,43 +66,6 @@ foo() input: `const foo = function () {}`, output: `const foo = function () {}; -`, - }, - { - name: 'function expression (3)', - input: `const foo = function /*comment1*/ () {}`, - output: `const foo = function () /*comment1*/ -{}; -`, - }, - { - name: 'function expression (4)', - input: `const foo = function (/*comment2*/) {}`, - output: `const foo = function (/*comment2*/) -{}; -`, - }, - { - name: 'function expression (5)', - input: `const foo = function () /*comment3*/ {}`, - output: `const foo = function () /*comment3*/ -{}; -`, - }, - { - name: 'function expression (6)', - input: `const foo = function () -/*comment4*/ -{}`, - output: `const foo = function () /*comment4*/ -{}; -`, - }, - { - name: 'function expression (7)', - input: `const foo = function () {} /*comment5*/`, - output: `const foo = function () -{}; /*comment5*/ `, }, { @@ -210,44 +73,6 @@ foo() input: `const foo = () => {}`, output: `const foo = () => {}; -`, - }, - { - name: 'arrow function expression (3)', - input: `const foo = (/*comment1*/) => {}`, - output: `const foo = (/*comment1*/) => -{}; -`, - }, - { - name: 'arrow function expression (4)', - input: `const foo = () /*comment2*/ => {}`, - output: `const foo = () /*comment2*/ => -{}; -`, - }, - { - name: 'arrow function expression (5)', - input: `const foo = () => /*comment3*/ {}`, - output: `const foo = () => /*comment3*/ -{}; -`, - }, - { - name: 'arrow function expression (6)', - input: `const foo = () => -/*comment4*/ -{}`, - output: `const foo = () => - /*comment4*/ - {}; -`, - }, - { - name: 'arrow function expression (7)', - input: `const foo = () => {} /*comment5*/`, - output: `const foo = () => -{}; /*comment5*/ `, }, { diff --git a/tests/v2-test/babel/function/stroustrup.test.ts b/tests/v2-test/babel/function/stroustrup.test.ts index 24dbae3..645d2d0 100644 --- a/tests/v2-test/babel/function/stroustrup.test.ts +++ b/tests/v2-test/babel/function/stroustrup.test.ts @@ -53,178 +53,20 @@ const sum = (a, b) => { }, { name: 'function declaration (2)', - input: ` -function foo(/* args here */) { - statement; -} -`, - output: `function foo(/* args here */) { - statement; -} -`, - }, - { - name: 'function declaration (3)', - input: ` -function foo( - /* args here */ -) { - statement; -} -`, - output: `function foo() { -/* args here */ - statement; -} -`, - }, - { - name: 'function declaration (4)', - input: ` -function foo( - // args here -) { - statement; -} -`, - output: `function foo() { -// args here - statement; -} -`, - }, - { - name: 'function declaration (5)', - input: ` -function foo(/* arg */ // arg - // arg -/* arg */) { - statement; -} -`, - output: `function foo /* arg */() { // arg -// arg -/* arg */ - statement; -} -`, - }, - { - name: 'function declaration (6)', input: `function foo() {}`, output: `function foo() {} -`, - }, - { - name: 'function declaration (7)', - input: `function /*comment1*/ foo() {}`, - output: `function /*comment1*/ foo() {} -`, - }, - { - name: 'function declaration (8)', - input: `function -/*comment2*/ -foo() {}`, - output: `function /*comment2*/ -foo() {} -`, - }, - { - name: 'function declaration (9)', - input: `function foo(/*comment3*/) {}`, - output: `function foo(/*comment3*/) {} -`, - }, - { - name: 'function declaration (10)', - input: `function foo() /*comment4*/ {}`, - output: `function foo() /*comment4*/ {} -`, - }, - { - name: 'function declaration (11)', - input: `function foo() {} /*comment5*/`, - output: `function foo() {} /*comment5*/ `, }, { name: 'function expression (2)', input: `const foo = function () {}`, output: `const foo = function () {}; -`, - }, - { - name: 'function expression (3)', - input: `const foo = function /*comment1*/ () {}`, - output: `const foo = function () /*comment1*/ {}; -`, - }, - { - name: 'function expression (4)', - input: `const foo = function (/*comment2*/) {}`, - output: `const foo = function (/*comment2*/) {}; -`, - }, - { - name: 'function expression (5)', - input: `const foo = function () /*comment3*/ {}`, - output: `const foo = function () /*comment3*/ {}; -`, - }, - { - name: 'function expression (6)', - input: `const foo = function () -/*comment4*/ -{}`, - output: `const foo = function () /*comment4*/ -{}; -`, - }, - { - name: 'function expression (7)', - input: `const foo = function () {} /*comment5*/`, - output: `const foo = function () {}; /*comment5*/ `, }, { name: 'arrow function expression (2)', input: `const foo = () => {}`, output: `const foo = () => {}; -`, - }, - { - name: 'arrow function expression (3)', - input: `const foo = (/*comment1*/) => {}`, - output: `const foo = (/*comment1*/) => {}; -`, - }, - { - name: 'arrow function expression (4)', - input: `const foo = () /*comment2*/ => {}`, - output: `const foo = () /*comment2*/ => {}; -`, - }, - { - name: 'arrow function expression (5)', - input: `const foo = () => /*comment3*/ {}`, - output: `const foo = () => /*comment3*/ {}; -`, - }, - { - name: 'arrow function expression (6)', - input: `const foo = () => -/*comment4*/ -{}`, - output: `const foo = () => - /*comment4*/ - {}; -`, - }, - { - name: 'arrow function expression (7)', - input: `const foo = () => {} /*comment5*/`, - output: `const foo = () => {}; /*comment5*/ `, }, { diff --git a/tests/v2-test/babel/if/1tbs.test.ts b/tests/v2-test/babel/if/1tbs.test.ts index 2161d24..67aab0d 100644 --- a/tests/v2-test/babel/if/1tbs.test.ts +++ b/tests/v2-test/babel/if/1tbs.test.ts @@ -16,7 +16,7 @@ const options = { const fixtures: Fixture[] = [ { - name: 'if (1)', + name: 'if', input: ` if (foo) { @@ -46,7 +46,7 @@ else { `, }, { - name: 'if...elseif...else (1)', + name: 'if...elseif...else', input: ` if (foo) { bar(); @@ -85,84 +85,6 @@ if (foo) { else { baz(); } -`, - }, - { - name: 'if (2) - containing only comments in brackets', - input: ` -if (condition) { - // statement -} -`, - output: `if (condition) { - // statement -} -`, - }, - { - name: 'if (3) - containing only comments in brackets', - input: ` -if (condition) { - /* statement */ -} -`, - output: `if (condition) { - /* statement */ -} -`, - }, - { - name: 'if (4) - containing only comments in brackets', - input: ` -if (condition) {/* statement */} -`, - output: `if (condition) { - /* statement */ -} -`, - }, - { - name: 'if (5) - containing only comments in brackets', - input: ` -if (condition) {/* statement */ - // statement -/* statement */} -`, - output: `if (condition) { - /* statement */ - // statement - /* statement */ -} -`, - }, - { - name: 'if...elseif...else (2) - containing only comments in brackets', - input: ` -if (condition1) {/* statement1 */} -else if (condition2) {/* statement2 */} -else {/* statement3 */} -`, - output: `if (condition1) { - /* statement1 */ -} else if (condition2) { - /* statement2 */ -} else { - /* statement3 */ -} -`, - }, - { - name: 'nested if - containing only comments in brackets', - input: ` -if (condition1) { - if (condition2) {/* statement */} -} -`, - output: `if (condition1) { - if (condition2) { - /* statement */ - } -} `, }, ]; diff --git a/tests/v2-test/babel/if/allman.test.ts b/tests/v2-test/babel/if/allman.test.ts index 2a95fa7..95ff542 100644 --- a/tests/v2-test/babel/if/allman.test.ts +++ b/tests/v2-test/babel/if/allman.test.ts @@ -16,7 +16,7 @@ const options = { const fixtures: Fixture[] = [ { - name: 'if (1)', + name: 'if', input: ` if (foo) { @@ -50,7 +50,7 @@ else `, }, { - name: 'if...elseif...else (1)', + name: 'if...elseif...else', input: ` if (foo) { bar(); @@ -96,95 +96,6 @@ else { baz(); } -`, - }, - { - name: 'if (2) - containing only comments in brackets', - input: ` -if (condition) { - // statement -} -`, - output: `if (condition) -{ - // statement -} -`, - }, - { - name: 'if (3) - containing only comments in brackets', - input: ` -if (condition) { - /* statement */ -} -`, - output: `if (condition) -{ - /* statement */ -} -`, - }, - { - name: 'if (4) - containing only comments in brackets', - input: ` -if (condition) {/* statement */} -`, - output: `if (condition) -{ - /* statement */ -} -`, - }, - { - name: 'if (5) - containing only comments in brackets', - input: ` -if (condition) {/* statement */ - // statement -/* statement */} -`, - output: `if (condition) -{ - /* statement */ - // statement - /* statement */ -} -`, - }, - { - name: 'if...elseif...else (2) - containing only comments in brackets', - input: ` -if (condition1) {/* statement1 */} -else if (condition2) {/* statement2 */} -else {/* statement3 */} -`, - output: `if (condition1) -{ - /* statement1 */ -} -else if (condition2) -{ - /* statement2 */ -} -else -{ - /* statement3 */ -} -`, - }, - { - name: 'nested if - containing only comments in brackets', - input: ` -if (condition1) { - if (condition2) {/* statement */} -} -`, - output: `if (condition1) -{ - if (condition2) - { - /* statement */ - } -} `, }, ]; diff --git a/tests/v2-test/babel/if/stroustrup.test.ts b/tests/v2-test/babel/if/stroustrup.test.ts index 7bf7c9b..acc46da 100644 --- a/tests/v2-test/babel/if/stroustrup.test.ts +++ b/tests/v2-test/babel/if/stroustrup.test.ts @@ -16,7 +16,7 @@ const options = { const fixtures: Fixture[] = [ { - name: 'if (1)', + name: 'if', input: ` if (foo) { @@ -47,7 +47,7 @@ else { `, }, { - name: 'if...elseif...else (1)', + name: 'if...elseif...else', input: ` if (foo) { bar(); @@ -88,86 +88,6 @@ if (foo) { else { baz(); } -`, - }, - { - name: 'if (2) - containing only comments in brackets', - input: ` -if (condition) { - // statement -} -`, - output: `if (condition) { - // statement -} -`, - }, - { - name: 'if (3) - containing only comments in brackets', - input: ` -if (condition) { - /* statement */ -} -`, - output: `if (condition) { - /* statement */ -} -`, - }, - { - name: 'if (4) - containing only comments in brackets', - input: ` -if (condition) {/* statement */} -`, - output: `if (condition) { - /* statement */ -} -`, - }, - { - name: 'if (5) - containing only comments in brackets', - input: ` -if (condition) {/* statement */ - // statement -/* statement */} -`, - output: `if (condition) { - /* statement */ - // statement - /* statement */ -} -`, - }, - { - name: 'if...elseif...else (2) - containing only comments in brackets', - input: ` -if (condition1) {/* statement1 */} -else if (condition2) {/* statement2 */} -else {/* statement3 */} -`, - output: `if (condition1) { - /* statement1 */ -} -else if (condition2) { - /* statement2 */ -} -else { - /* statement3 */ -} -`, - }, - { - name: 'nested if - containing only comments in brackets', - input: ` -if (condition1) { - if (condition2) {/* statement */} -} -`, - output: `if (condition1) { - if (condition2) { - /* statement */ - } -} `, }, ]; diff --git a/tests/v2-test/babel/variable-declaration/1tbs.test.ts b/tests/v2-test/babel/variable-declaration/1tbs.test.ts deleted file mode 100644 index 1e0567a..0000000 --- a/tests/v2-test/babel/variable-declaration/1tbs.test.ts +++ /dev/null @@ -1,89 +0,0 @@ -import { format } from 'prettier'; -import type { Fixture } from 'test-settings'; -import { baseOptions } from 'test-settings'; -import { oneTBSLinter } from 'test-settings/linter'; -import { describe, expect, test } from 'vitest'; - -// eslint-disable-next-line import/no-extraneous-dependencies -import * as thisPlugin from '@/packages/v2-plugin'; - -const options = { - ...baseOptions, - plugins: [thisPlugin], - parser: 'babel', - braceStyle: '1tbs', -}; - -const fixtures: Fixture[] = [ - { - name: 'variable declaration (1) - containing only comments in brackets', - input: ` -const foo = [ - // elements -]; -`, - output: `const foo = [ - // elements -]; -`, - }, - { - name: 'variable declaration (2) - containing only comments in brackets', - input: ` -const foo = [ - /* elements */ -]; -`, - output: `const foo = [ - /* elements */ -]; -`, - }, - { - name: 'variable declaration (3) - containing only comments in brackets', - input: ` -const foo = [/* elements */]; -`, - output: `const foo = [ - /* elements */ -]; -`, - }, - { - name: 'variable declaration (4) - containing only comments in brackets', - input: ` -const foo = [// element - /* element */ - // element -/* element */]; -`, - output: `const foo = [ - // element - /* element */ - // element - /* element */ -]; -`, - }, -]; - -describe('babel/variable-declaration/1tbs', () => { - for (const fixture of fixtures) { - const formattedText = format(fixture.input, { - ...options, - ...(fixture.options ?? {}), - }); - - describe(fixture.name, () => { - test('theoretical', async () => { - const [result] = await oneTBSLinter.lintText(formattedText); - - expect(result.fixableErrorCount).toBe(0); - }); - - test('practical', () => { - expect(formattedText).toBe(fixture.output); - }); - }); - } -}); diff --git a/tests/v2-test/babel/variable-declaration/allman.test.ts b/tests/v2-test/babel/variable-declaration/allman.test.ts deleted file mode 100644 index 8c93105..0000000 --- a/tests/v2-test/babel/variable-declaration/allman.test.ts +++ /dev/null @@ -1,89 +0,0 @@ -import { format } from 'prettier'; -import type { Fixture } from 'test-settings'; -import { baseOptions } from 'test-settings'; -import { allmanLinter } from 'test-settings/linter'; -import { describe, expect, test } from 'vitest'; - -// eslint-disable-next-line import/no-extraneous-dependencies -import * as thisPlugin from '@/packages/v2-plugin'; - -const options = { - ...baseOptions, - plugins: [thisPlugin], - parser: 'babel', - braceStyle: 'allman', -}; - -const fixtures: Fixture[] = [ - { - name: 'variable declaration (1) - containing only comments in brackets', - input: ` -const foo = [ - // elements -]; -`, - output: `const foo = [ - // elements -]; -`, - }, - { - name: 'variable declaration (2) - containing only comments in brackets', - input: ` -const foo = [ - /* elements */ -]; -`, - output: `const foo = [ - /* elements */ -]; -`, - }, - { - name: 'variable declaration (3) - containing only comments in brackets', - input: ` -const foo = [/* elements */]; -`, - output: `const foo = [ - /* elements */ -]; -`, - }, - { - name: 'variable declaration (4) - containing only comments in brackets', - input: ` -const foo = [// element - /* element */ - // element -/* element */]; -`, - output: `const foo = [ - // element - /* element */ - // element - /* element */ -]; -`, - }, -]; - -describe('babel/variable-declaration/allman', () => { - for (const fixture of fixtures) { - const formattedText = format(fixture.input, { - ...options, - ...(fixture.options ?? {}), - }); - - describe(fixture.name, () => { - test('theoretical', async () => { - const [result] = await allmanLinter.lintText(formattedText); - - expect(result.fixableErrorCount).toBe(0); - }); - - test('practical', () => { - expect(formattedText).toBe(fixture.output); - }); - }); - } -}); diff --git a/tests/v2-test/babel/variable-declaration/stroustrup.test.ts b/tests/v2-test/babel/variable-declaration/stroustrup.test.ts deleted file mode 100644 index 457a178..0000000 --- a/tests/v2-test/babel/variable-declaration/stroustrup.test.ts +++ /dev/null @@ -1,89 +0,0 @@ -import { format } from 'prettier'; -import type { Fixture } from 'test-settings'; -import { baseOptions } from 'test-settings'; -import { stroustrupLinter } from 'test-settings/linter'; -import { describe, expect, test } from 'vitest'; - -// eslint-disable-next-line import/no-extraneous-dependencies -import * as thisPlugin from '@/packages/v2-plugin'; - -const options = { - ...baseOptions, - plugins: [thisPlugin], - parser: 'babel', - braceStyle: 'stroustrup', -}; - -const fixtures: Fixture[] = [ - { - name: 'variable declaration (1) - containing only comments in brackets', - input: ` -const foo = [ - // elements -]; -`, - output: `const foo = [ - // elements -]; -`, - }, - { - name: 'variable declaration (2) - containing only comments in brackets', - input: ` -const foo = [ - /* elements */ -]; -`, - output: `const foo = [ - /* elements */ -]; -`, - }, - { - name: 'variable declaration (3) - containing only comments in brackets', - input: ` -const foo = [/* elements */]; -`, - output: `const foo = [ - /* elements */ -]; -`, - }, - { - name: 'variable declaration (4) - containing only comments in brackets', - input: ` -const foo = [// element - /* element */ - // element -/* element */]; -`, - output: `const foo = [ - // element - /* element */ - // element - /* element */ -]; -`, - }, -]; - -describe('babel/variable-declaration/stroustrup', () => { - for (const fixture of fixtures) { - const formattedText = format(fixture.input, { - ...options, - ...(fixture.options ?? {}), - }); - - describe(fixture.name, () => { - test('theoretical', async () => { - const [result] = await stroustrupLinter.lintText(formattedText); - - expect(result.fixableErrorCount).toBe(0); - }); - - test('practical', () => { - expect(formattedText).toBe(fixture.output); - }); - }); - } -}); diff --git a/tests/v2-test/typescript/assignment/1tbs.test.ts b/tests/v2-test/typescript/assignment/1tbs.test.ts index b6fd0a6..76142da 100644 --- a/tests/v2-test/typescript/assignment/1tbs.test.ts +++ b/tests/v2-test/typescript/assignment/1tbs.test.ts @@ -36,84 +36,6 @@ const fixtures: Fixture[] = [ }, { name: 'object assignment (3)', - input: `const foo = /*comment1*/ { - bar: { - baz: 'baz' - } -}`, - output: `const foo = /*comment1*/ { - bar: { - baz: "baz", - }, -}; -`, - }, - { - name: 'object assignment (4)', - input: `const foo = -/*comment2*/ -{ - bar: { - baz: 'baz' - } -}`, - output: `const foo = - /*comment2*/ - { - bar: { - baz: "baz", - }, - }; -`, - }, - { - name: 'object assignment (5)', - input: `const foo = { - /*comment3*/ bar: { - baz: 'baz' - } -}`, - output: `const foo = { - /*comment3*/ bar: { - baz: "baz", - }, -}; -`, - }, - { - name: 'object assignment (6)', - input: `const foo = { - bar: /*comment4*/ { - baz: 'baz' - } -}`, - output: `const foo = { - bar: /*comment4*/ { - baz: "baz", - }, -}; -`, - }, - { - name: 'object assignment (7)', - input: `const foo = { - bar: - /*comment5*/ - { - baz: 'baz' - } -}`, - output: `const foo = { - bar: - /*comment5*/ - { - baz: "baz", - }, -}; -`, - }, - { - name: 'object assignment (8)', input: `const foo = { bar() {}, ['baz']() {} @@ -122,57 +44,6 @@ const fixtures: Fixture[] = [ bar() {}, ["baz"]() {}, }; -`, - }, - { - name: 'object assignment (9)', - input: `const foo = { - bar/*comment1*/() {}, - ['baz']() {} -}`, - output: `const foo = { - bar /*comment1*/() {}, - ["baz"]() {}, -}; -`, - }, - { - name: 'object assignment (10)', - input: `const foo = { - bar(/*comment2*/) {}, - ['baz']() {} -}`, - output: `const foo = { - bar(/*comment2*/) {}, - ["baz"]() {}, -}; -`, - }, - { - name: 'object assignment (11)', - input: `const foo = { - bar()/*comment3*/{}, - ['baz']() {} -}`, - output: `const foo = { - bar() /*comment3*/ {}, - ["baz"]() {}, -}; -`, - }, - { - name: 'object assignment (12)', - input: `const foo = { - bar() - /*comment4*/ - {}, - ['baz']() {} -}`, - output: `const foo = { - bar() /*comment4*/ - {}, - ["baz"]() {}, -}; `, }, { @@ -187,49 +58,6 @@ const fixtures: Fixture[] = [ }, { name: 'conditional assignment (2)', - input: `const foo =/*comment1*/true && { - bar: 'baz' -}`, - output: `const foo = /*comment1*/ true && { - bar: "baz", -}; -`, - }, - { - name: 'conditional assignment (3)', - input: `const foo = true/*comment2*/&& { - bar: 'baz' -}`, - output: `const foo = true /*comment2*/ && { - bar: "baz", -}; -`, - }, - { - name: 'conditional assignment (4)', - input: `const foo = true &&/*comment3*/{ - bar: 'baz' -}`, - output: `const foo = true && /*comment3*/ { - bar: "baz", -}; -`, - }, - { - name: 'conditional assignment (5)', - input: `const foo = true && -/*comment4*/ -{ - bar: 'baz' -}`, - output: `const foo = true && /*comment4*/ -{ - bar: "baz", -}; -`, - }, - { - name: 'conditional assignment (6)', input: `const foo = false || { bar: 'baz' }`, @@ -239,7 +67,7 @@ const fixtures: Fixture[] = [ `, }, { - name: 'conditional assignment (7)', + name: 'conditional assignment (3)', input: `const foo = null ?? { bar: 'baz' }`, diff --git a/tests/v2-test/typescript/assignment/allman.test.ts b/tests/v2-test/typescript/assignment/allman.test.ts index 3345866..3650f0b 100644 --- a/tests/v2-test/typescript/assignment/allman.test.ts +++ b/tests/v2-test/typescript/assignment/allman.test.ts @@ -36,84 +36,6 @@ const fixtures: Fixture[] = [ }, { name: 'object assignment (3)', - input: `const foo = /*comment1*/ { - bar: { - baz: 'baz' - } -}`, - output: `const foo = /*comment1*/ { - bar: { - baz: "baz", - }, -}; -`, - }, - { - name: 'object assignment (4)', - input: `const foo = -/*comment2*/ -{ - bar: { - baz: 'baz' - } -}`, - output: `const foo = - /*comment2*/ - { - bar: { - baz: "baz", - }, - }; -`, - }, - { - name: 'object assignment (5)', - input: `const foo = { - /*comment3*/ bar: { - baz: 'baz' - } -}`, - output: `const foo = { - /*comment3*/ bar: { - baz: "baz", - }, -}; -`, - }, - { - name: 'object assignment (6)', - input: `const foo = { - bar: /*comment4*/ { - baz: 'baz' - } -}`, - output: `const foo = { - bar: /*comment4*/ { - baz: "baz", - }, -}; -`, - }, - { - name: 'object assignment (7)', - input: `const foo = { - bar: - /*comment5*/ - { - baz: 'baz' - } -}`, - output: `const foo = { - bar: - /*comment5*/ - { - baz: "baz", - }, -}; -`, - }, - { - name: 'object assignment (8)', input: `const foo = { bar() {}, ['baz']() {} @@ -124,64 +46,6 @@ const fixtures: Fixture[] = [ ["baz"]() {}, }; -`, - }, - { - name: 'object assignment (9)', - input: `const foo = { - bar/*comment1*/() {}, - ['baz']() {} -}`, - output: `const foo = { - bar /*comment1*/() - {}, - ["baz"]() - {}, -}; -`, - }, - { - name: 'object assignment (10)', - input: `const foo = { - bar(/*comment2*/) {}, - ['baz']() {} -}`, - output: `const foo = { - bar(/*comment2*/) - {}, - ["baz"]() - {}, -}; -`, - }, - { - name: 'object assignment (11)', - input: `const foo = { - bar()/*comment3*/{}, - ['baz']() {} -}`, - output: `const foo = { - bar() /*comment3*/ - {}, - ["baz"]() - {}, -}; -`, - }, - { - name: 'object assignment (12)', - input: `const foo = { - bar() - /*comment4*/ - {}, - ['baz']() {} -}`, - output: `const foo = { - bar() /*comment4*/ - {}, - ["baz"]() - {}, -}; `, }, { @@ -196,49 +60,6 @@ const fixtures: Fixture[] = [ }, { name: 'conditional assignment (2)', - input: `const foo =/*comment1*/true && { - bar: 'baz' -}`, - output: `const foo = /*comment1*/ true && { - bar: "baz", -}; -`, - }, - { - name: 'conditional assignment (3)', - input: `const foo = true/*comment2*/&& { - bar: 'baz' -}`, - output: `const foo = true /*comment2*/ && { - bar: "baz", -}; -`, - }, - { - name: 'conditional assignment (4)', - input: `const foo = true &&/*comment3*/{ - bar: 'baz' -}`, - output: `const foo = true && /*comment3*/ { - bar: "baz", -}; -`, - }, - { - name: 'conditional assignment (5)', - input: `const foo = true && -/*comment4*/ -{ - bar: 'baz' -}`, - output: `const foo = true && /*comment4*/ -{ - bar: "baz", -}; -`, - }, - { - name: 'conditional assignment (6)', input: `const foo = false || { bar: 'baz' }`, @@ -248,7 +69,7 @@ const fixtures: Fixture[] = [ `, }, { - name: 'conditional assignment (7)', + name: 'conditional assignment (3)', input: `const foo = null ?? { bar: 'baz' }`, diff --git a/tests/v2-test/typescript/assignment/stroustrup.test.ts b/tests/v2-test/typescript/assignment/stroustrup.test.ts index 0d2643d..b88366c 100644 --- a/tests/v2-test/typescript/assignment/stroustrup.test.ts +++ b/tests/v2-test/typescript/assignment/stroustrup.test.ts @@ -36,84 +36,6 @@ const fixtures: Fixture[] = [ }, { name: 'object assignment (3)', - input: `const foo = /*comment1*/ { - bar: { - baz: 'baz' - } -}`, - output: `const foo = /*comment1*/ { - bar: { - baz: "baz", - }, -}; -`, - }, - { - name: 'object assignment (4)', - input: `const foo = -/*comment2*/ -{ - bar: { - baz: 'baz' - } -}`, - output: `const foo = - /*comment2*/ - { - bar: { - baz: "baz", - }, - }; -`, - }, - { - name: 'object assignment (5)', - input: `const foo = { - /*comment3*/ bar: { - baz: 'baz' - } -}`, - output: `const foo = { - /*comment3*/ bar: { - baz: "baz", - }, -}; -`, - }, - { - name: 'object assignment (6)', - input: `const foo = { - bar: /*comment4*/ { - baz: 'baz' - } -}`, - output: `const foo = { - bar: /*comment4*/ { - baz: "baz", - }, -}; -`, - }, - { - name: 'object assignment (7)', - input: `const foo = { - bar: - /*comment5*/ - { - baz: 'baz' - } -}`, - output: `const foo = { - bar: - /*comment5*/ - { - baz: "baz", - }, -}; -`, - }, - { - name: 'object assignment (8)', input: `const foo = { bar() {}, ['baz']() {} @@ -122,57 +44,6 @@ const fixtures: Fixture[] = [ bar() {}, ["baz"]() {}, }; -`, - }, - { - name: 'object assignment (9)', - input: `const foo = { - bar/*comment1*/() {}, - ['baz']() {} -}`, - output: `const foo = { - bar /*comment1*/() {}, - ["baz"]() {}, -}; -`, - }, - { - name: 'object assignment (10)', - input: `const foo = { - bar(/*comment2*/) {}, - ['baz']() {} -}`, - output: `const foo = { - bar(/*comment2*/) {}, - ["baz"]() {}, -}; -`, - }, - { - name: 'object assignment (11)', - input: `const foo = { - bar()/*comment3*/{}, - ['baz']() {} -}`, - output: `const foo = { - bar() /*comment3*/ {}, - ["baz"]() {}, -}; -`, - }, - { - name: 'object assignment (12)', - input: `const foo = { - bar() - /*comment4*/ - {}, - ['baz']() {} -}`, - output: `const foo = { - bar() /*comment4*/ - {}, - ["baz"]() {}, -}; `, }, { @@ -187,49 +58,6 @@ const fixtures: Fixture[] = [ }, { name: 'conditional assignment (2)', - input: `const foo =/*comment1*/true && { - bar: 'baz' -}`, - output: `const foo = /*comment1*/ true && { - bar: "baz", -}; -`, - }, - { - name: 'conditional assignment (3)', - input: `const foo = true/*comment2*/&& { - bar: 'baz' -}`, - output: `const foo = true /*comment2*/ && { - bar: "baz", -}; -`, - }, - { - name: 'conditional assignment (4)', - input: `const foo = true &&/*comment3*/{ - bar: 'baz' -}`, - output: `const foo = true && /*comment3*/ { - bar: "baz", -}; -`, - }, - { - name: 'conditional assignment (5)', - input: `const foo = true && -/*comment4*/ -{ - bar: 'baz' -}`, - output: `const foo = true && /*comment4*/ -{ - bar: "baz", -}; -`, - }, - { - name: 'conditional assignment (6)', input: `const foo = false || { bar: 'baz' }`, @@ -239,7 +67,7 @@ const fixtures: Fixture[] = [ `, }, { - name: 'conditional assignment (7)', + name: 'conditional assignment (3)', input: `const foo = null ?? { bar: 'baz' }`, diff --git a/tests/v2-test/typescript/function/1tbs.test.ts b/tests/v2-test/typescript/function/1tbs.test.ts index ff31f5b..dd9cf04 100644 --- a/tests/v2-test/typescript/function/1tbs.test.ts +++ b/tests/v2-test/typescript/function/1tbs.test.ts @@ -52,178 +52,20 @@ const sum = (a, b) => { }, { name: 'function declaration (2)', - input: ` -function foo(/* args here */) { - statement; -} -`, - output: `function foo(/* args here */) { - statement; -} -`, - }, - { - name: 'function declaration (3)', - input: ` -function foo( - /* args here */ -) { - statement; -} -`, - output: `function foo() { -/* args here */ - statement; -} -`, - }, - { - name: 'function declaration (4)', - input: ` -function foo( - // args here -) { - statement; -} -`, - output: `function foo() { -// args here - statement; -} -`, - }, - { - name: 'function declaration (5)', - input: ` -function foo(/* arg */ // arg - // arg -/* arg */) { - statement; -} -`, - output: `function foo /* arg */() { // arg -// arg -/* arg */ - statement; -} -`, - }, - { - name: 'function declaration (6)', input: `function foo() {}`, output: `function foo() {} -`, - }, - { - name: 'function declaration (7)', - input: `function /*comment1*/ foo() {}`, - output: `function /*comment1*/ foo() {} -`, - }, - { - name: 'function declaration (8)', - input: `function -/*comment2*/ -foo() {}`, - output: `function /*comment2*/ -foo() {} -`, - }, - { - name: 'function declaration (9)', - input: `function foo(/*comment3*/) {}`, - output: `function foo(/*comment3*/) {} -`, - }, - { - name: 'function declaration (10)', - input: `function foo() /*comment4*/ {}`, - output: `function foo() /*comment4*/ {} -`, - }, - { - name: 'function declaration (11)', - input: `function foo() {} /*comment5*/`, - output: `function foo() {} /*comment5*/ `, }, { name: 'function expression (2)', input: `const foo = function () {}`, output: `const foo = function () {}; -`, - }, - { - name: 'function expression (3)', - input: `const foo = function /*comment1*/ () {}`, - output: `const foo = function () /*comment1*/ {}; -`, - }, - { - name: 'function expression (4)', - input: `const foo = function (/*comment2*/) {}`, - output: `const foo = function (/*comment2*/) {}; -`, - }, - { - name: 'function expression (5)', - input: `const foo = function () /*comment3*/ {}`, - output: `const foo = function () /*comment3*/ {}; -`, - }, - { - name: 'function expression (6)', - input: `const foo = function () -/*comment4*/ -{}`, - output: `const foo = function () /*comment4*/ -{}; -`, - }, - { - name: 'function expression (7)', - input: `const foo = function () {} /*comment5*/`, - output: `const foo = function () {}; /*comment5*/ `, }, { name: 'arrow function expression (2)', input: `const foo = () => {}`, output: `const foo = () => {}; -`, - }, - { - name: 'arrow function expression (3)', - input: `const foo = (/*comment1*/) => {}`, - output: `const foo = (/*comment1*/) => {}; -`, - }, - { - name: 'arrow function expression (4)', - input: `const foo = () /*comment2*/ => {}`, - output: `const foo = () /*comment2*/ => {}; -`, - }, - { - name: 'arrow function expression (5)', - input: `const foo = () => /*comment3*/ {}`, - output: `const foo = () => /*comment3*/ {}; -`, - }, - { - name: 'arrow function expression (6)', - input: `const foo = () => -/*comment4*/ -{}`, - output: `const foo = () => - /*comment4*/ - {}; -`, - }, - { - name: 'arrow function expression (7)', - input: `const foo = () => {} /*comment5*/`, - output: `const foo = () => {}; /*comment5*/ `, }, { diff --git a/tests/v2-test/typescript/function/allman.test.ts b/tests/v2-test/typescript/function/allman.test.ts index 25404a5..671b156 100644 --- a/tests/v2-test/typescript/function/allman.test.ts +++ b/tests/v2-test/typescript/function/allman.test.ts @@ -55,109 +55,9 @@ const sum = (a, b) => { }, { name: 'function declaration (2)', - input: ` -function foo(/* args here */) { - statement; -} -`, - output: `function foo(/* args here */) -{ - statement; -} -`, - }, - { - name: 'function declaration (3)', - input: ` -function foo( - /* args here */ -) { - statement; -} -`, - output: `function foo() -{ -/* args here */ - statement; -} -`, - }, - { - name: 'function declaration (4)', - input: ` -function foo( - // args here -) { - statement; -} -`, - output: `function foo() -{ -// args here - statement; -} -`, - }, - { - name: 'function declaration (5)', - input: ` -function foo(/* arg */ // arg - // arg -/* arg */) { - statement; -} -`, - output: `function foo /* arg */() -{ // arg -// arg -/* arg */ - statement; -} -`, - }, - { - name: 'function declaration (6)', input: `function foo() {}`, output: `function foo() {} -`, - }, - { - name: 'function declaration (7)', - input: `function /*comment1*/ foo() {}`, - output: `function /*comment1*/ foo() -{} -`, - }, - { - name: 'function declaration (8)', - input: `function -/*comment2*/ -foo() {}`, - output: `function /*comment2*/ -foo() -{} -`, - }, - { - name: 'function declaration (9)', - input: `function foo(/*comment3*/) {}`, - output: `function foo(/*comment3*/) -{} -`, - }, - { - name: 'function declaration (10)', - input: `function foo() /*comment4*/ {}`, - output: `function foo() /*comment4*/ -{} -`, - }, - { - name: 'function declaration (11)', - input: `function foo() {} /*comment5*/`, - output: `function foo() -{} /*comment5*/ `, }, { @@ -165,43 +65,6 @@ foo() input: `const foo = function () {}`, output: `const foo = function () {}; -`, - }, - { - name: 'function expression (3)', - input: `const foo = function /*comment1*/ () {}`, - output: `const foo = function () /*comment1*/ -{}; -`, - }, - { - name: 'function expression (4)', - input: `const foo = function (/*comment2*/) {}`, - output: `const foo = function (/*comment2*/) -{}; -`, - }, - { - name: 'function expression (5)', - input: `const foo = function () /*comment3*/ {}`, - output: `const foo = function () /*comment3*/ -{}; -`, - }, - { - name: 'function expression (6)', - input: `const foo = function () -/*comment4*/ -{}`, - output: `const foo = function () /*comment4*/ -{}; -`, - }, - { - name: 'function expression (7)', - input: `const foo = function () {} /*comment5*/`, - output: `const foo = function () -{}; /*comment5*/ `, }, { @@ -209,44 +72,6 @@ foo() input: `const foo = () => {}`, output: `const foo = () => {}; -`, - }, - { - name: 'arrow function expression (3)', - input: `const foo = (/*comment1*/) => {}`, - output: `const foo = (/*comment1*/) => -{}; -`, - }, - { - name: 'arrow function expression (4)', - input: `const foo = () /*comment2*/ => {}`, - output: `const foo = () /*comment2*/ => -{}; -`, - }, - { - name: 'arrow function expression (5)', - input: `const foo = () => /*comment3*/ {}`, - output: `const foo = () => /*comment3*/ -{}; -`, - }, - { - name: 'arrow function expression (6)', - input: `const foo = () => -/*comment4*/ -{}`, - output: `const foo = () => - /*comment4*/ - {}; -`, - }, - { - name: 'arrow function expression (7)', - input: `const foo = () => {} /*comment5*/`, - output: `const foo = () => -{}; /*comment5*/ `, }, { diff --git a/tests/v2-test/typescript/function/stroustrup.test.ts b/tests/v2-test/typescript/function/stroustrup.test.ts index 2afa36d..957531f 100644 --- a/tests/v2-test/typescript/function/stroustrup.test.ts +++ b/tests/v2-test/typescript/function/stroustrup.test.ts @@ -52,178 +52,20 @@ const sum = (a, b) => { }, { name: 'function declaration (2)', - input: ` -function foo(/* args here */) { - statement; -} -`, - output: `function foo(/* args here */) { - statement; -} -`, - }, - { - name: 'function declaration (3)', - input: ` -function foo( - /* args here */ -) { - statement; -} -`, - output: `function foo() { -/* args here */ - statement; -} -`, - }, - { - name: 'function declaration (4)', - input: ` -function foo( - // args here -) { - statement; -} -`, - output: `function foo() { -// args here - statement; -} -`, - }, - { - name: 'function declaration (5)', - input: ` -function foo(/* arg */ // arg - // arg -/* arg */) { - statement; -} -`, - output: `function foo /* arg */() { // arg -// arg -/* arg */ - statement; -} -`, - }, - { - name: 'function declaration (6)', input: `function foo() {}`, output: `function foo() {} -`, - }, - { - name: 'function declaration (7)', - input: `function /*comment1*/ foo() {}`, - output: `function /*comment1*/ foo() {} -`, - }, - { - name: 'function declaration (8)', - input: `function -/*comment2*/ -foo() {}`, - output: `function /*comment2*/ -foo() {} -`, - }, - { - name: 'function declaration (9)', - input: `function foo(/*comment3*/) {}`, - output: `function foo(/*comment3*/) {} -`, - }, - { - name: 'function declaration (10)', - input: `function foo() /*comment4*/ {}`, - output: `function foo() /*comment4*/ {} -`, - }, - { - name: 'function declaration (11)', - input: `function foo() {} /*comment5*/`, - output: `function foo() {} /*comment5*/ `, }, { name: 'function expression (2)', input: `const foo = function () {}`, output: `const foo = function () {}; -`, - }, - { - name: 'function expression (3)', - input: `const foo = function /*comment1*/ () {}`, - output: `const foo = function () /*comment1*/ {}; -`, - }, - { - name: 'function expression (4)', - input: `const foo = function (/*comment2*/) {}`, - output: `const foo = function (/*comment2*/) {}; -`, - }, - { - name: 'function expression (5)', - input: `const foo = function () /*comment3*/ {}`, - output: `const foo = function () /*comment3*/ {}; -`, - }, - { - name: 'function expression (6)', - input: `const foo = function () -/*comment4*/ -{}`, - output: `const foo = function () /*comment4*/ -{}; -`, - }, - { - name: 'function expression (7)', - input: `const foo = function () {} /*comment5*/`, - output: `const foo = function () {}; /*comment5*/ `, }, { name: 'arrow function expression (2)', input: `const foo = () => {}`, output: `const foo = () => {}; -`, - }, - { - name: 'arrow function expression (3)', - input: `const foo = (/*comment1*/) => {}`, - output: `const foo = (/*comment1*/) => {}; -`, - }, - { - name: 'arrow function expression (4)', - input: `const foo = () /*comment2*/ => {}`, - output: `const foo = () /*comment2*/ => {}; -`, - }, - { - name: 'arrow function expression (5)', - input: `const foo = () => /*comment3*/ {}`, - output: `const foo = () => /*comment3*/ {}; -`, - }, - { - name: 'arrow function expression (6)', - input: `const foo = () => -/*comment4*/ -{}`, - output: `const foo = () => - /*comment4*/ - {}; -`, - }, - { - name: 'arrow function expression (7)', - input: `const foo = () => {} /*comment5*/`, - output: `const foo = () => {}; /*comment5*/ `, }, { diff --git a/tests/v2-test/typescript/if/1tbs.test.ts b/tests/v2-test/typescript/if/1tbs.test.ts index a4e6ed4..75744e1 100644 --- a/tests/v2-test/typescript/if/1tbs.test.ts +++ b/tests/v2-test/typescript/if/1tbs.test.ts @@ -15,7 +15,7 @@ const options = { const fixtures: Fixture[] = [ { - name: 'if (1)', + name: 'if', input: ` if (foo) { @@ -45,7 +45,7 @@ else { `, }, { - name: 'if...elseif...else (1)', + name: 'if...elseif...else', input: ` if (foo) { bar(); @@ -84,84 +84,6 @@ if (foo) { else { baz(); } -`, - }, - { - name: 'if (2) - containing only comments in brackets', - input: ` -if (condition) { - // statement -} -`, - output: `if (condition) { - // statement -} -`, - }, - { - name: 'if (3) - containing only comments in brackets', - input: ` -if (condition) { - /* statement */ -} -`, - output: `if (condition) { - /* statement */ -} -`, - }, - { - name: 'if (4) - containing only comments in brackets', - input: ` -if (condition) {/* statement */} -`, - output: `if (condition) { - /* statement */ -} -`, - }, - { - name: 'if (5) - containing only comments in brackets', - input: ` -if (condition) {/* statement */ - // statement -/* statement */} -`, - output: `if (condition) { - /* statement */ - // statement - /* statement */ -} -`, - }, - { - name: 'if...elseif...else (2) - containing only comments in brackets', - input: ` -if (condition1) {/* statement1 */} -else if (condition2) {/* statement2 */} -else {/* statement3 */} -`, - output: `if (condition1) { - /* statement1 */ -} else if (condition2) { - /* statement2 */ -} else { - /* statement3 */ -} -`, - }, - { - name: 'nested if - containing only comments in brackets', - input: ` -if (condition1) { - if (condition2) {/* statement */} -} -`, - output: `if (condition1) { - if (condition2) { - /* statement */ - } -} `, }, ]; diff --git a/tests/v2-test/typescript/if/allman.test.ts b/tests/v2-test/typescript/if/allman.test.ts index 3d547be..acf2f85 100644 --- a/tests/v2-test/typescript/if/allman.test.ts +++ b/tests/v2-test/typescript/if/allman.test.ts @@ -15,7 +15,7 @@ const options = { const fixtures: Fixture[] = [ { - name: 'if (1)', + name: 'if', input: ` if (foo) { @@ -49,7 +49,7 @@ else `, }, { - name: 'if...elseif...else (1)', + name: 'if...elseif...else', input: ` if (foo) { bar(); @@ -95,95 +95,6 @@ else { baz(); } -`, - }, - { - name: 'if (2) - containing only comments in brackets', - input: ` -if (condition) { - // statement -} -`, - output: `if (condition) -{ - // statement -} -`, - }, - { - name: 'if (3) - containing only comments in brackets', - input: ` -if (condition) { - /* statement */ -} -`, - output: `if (condition) -{ - /* statement */ -} -`, - }, - { - name: 'if (4) - containing only comments in brackets', - input: ` -if (condition) {/* statement */} -`, - output: `if (condition) -{ - /* statement */ -} -`, - }, - { - name: 'if (5) - containing only comments in brackets', - input: ` -if (condition) {/* statement */ - // statement -/* statement */} -`, - output: `if (condition) -{ - /* statement */ - // statement - /* statement */ -} -`, - }, - { - name: 'if...elseif...else (2) - containing only comments in brackets', - input: ` -if (condition1) {/* statement1 */} -else if (condition2) {/* statement2 */} -else {/* statement3 */} -`, - output: `if (condition1) -{ - /* statement1 */ -} -else if (condition2) -{ - /* statement2 */ -} -else -{ - /* statement3 */ -} -`, - }, - { - name: 'nested if - containing only comments in brackets', - input: ` -if (condition1) { - if (condition2) {/* statement */} -} -`, - output: `if (condition1) -{ - if (condition2) - { - /* statement */ - } -} `, }, ]; diff --git a/tests/v2-test/typescript/if/stroustrup.test.ts b/tests/v2-test/typescript/if/stroustrup.test.ts index 4f95402..09e7f65 100644 --- a/tests/v2-test/typescript/if/stroustrup.test.ts +++ b/tests/v2-test/typescript/if/stroustrup.test.ts @@ -15,7 +15,7 @@ const options = { const fixtures: Fixture[] = [ { - name: 'if (1)', + name: 'if', input: ` if (foo) { @@ -46,7 +46,7 @@ else { `, }, { - name: 'if...elseif...else (1)', + name: 'if...elseif...else', input: ` if (foo) { bar(); @@ -87,86 +87,6 @@ if (foo) { else { baz(); } -`, - }, - { - name: 'if (2) - containing only comments in brackets', - input: ` -if (condition) { - // statement -} -`, - output: `if (condition) { - // statement -} -`, - }, - { - name: 'if (3) - containing only comments in brackets', - input: ` -if (condition) { - /* statement */ -} -`, - output: `if (condition) { - /* statement */ -} -`, - }, - { - name: 'if (4) - containing only comments in brackets', - input: ` -if (condition) {/* statement */} -`, - output: `if (condition) { - /* statement */ -} -`, - }, - { - name: 'if (5) - containing only comments in brackets', - input: ` -if (condition) {/* statement */ - // statement -/* statement */} -`, - output: `if (condition) { - /* statement */ - // statement - /* statement */ -} -`, - }, - { - name: 'if...elseif...else (2) - containing only comments in brackets', - input: ` -if (condition1) {/* statement1 */} -else if (condition2) {/* statement2 */} -else {/* statement3 */} -`, - output: `if (condition1) { - /* statement1 */ -} -else if (condition2) { - /* statement2 */ -} -else { - /* statement3 */ -} -`, - }, - { - name: 'nested if - containing only comments in brackets', - input: ` -if (condition1) { - if (condition2) {/* statement */} -} -`, - output: `if (condition1) { - if (condition2) { - /* statement */ - } -} `, }, ]; diff --git a/tests/v2-test/typescript/variable-declaration/1tbs.test.ts b/tests/v2-test/typescript/variable-declaration/1tbs.test.ts deleted file mode 100644 index 86e7ec9..0000000 --- a/tests/v2-test/typescript/variable-declaration/1tbs.test.ts +++ /dev/null @@ -1,80 +0,0 @@ -import { format } from 'prettier'; -import type { Fixture } from 'test-settings'; -import { baseOptions } from 'test-settings'; -import { describe, expect, test } from 'vitest'; - -// eslint-disable-next-line import/no-extraneous-dependencies -import * as thisPlugin from '@/packages/v2-plugin'; - -const options = { - ...baseOptions, - plugins: [thisPlugin], - parser: 'typescript', - braceStyle: '1tbs', -}; - -const fixtures: Fixture[] = [ - { - name: 'variable declaration (1) - containing only comments in brackets', - input: ` -const foo = [ - // elements -]; -`, - output: `const foo = [ - // elements -]; -`, - }, - { - name: 'variable declaration (2) - containing only comments in brackets', - input: ` -const foo = [ - /* elements */ -]; -`, - output: `const foo = [ - /* elements */ -]; -`, - }, - { - name: 'variable declaration (3) - containing only comments in brackets', - input: ` -const foo = [/* elements */]; -`, - output: `const foo = [ - /* elements */ -]; -`, - }, - { - name: 'variable declaration (4) - containing only comments in brackets', - input: ` -const foo = [// element - /* element */ - // element -/* element */]; -`, - output: `const foo = [ - // element - /* element */ - // element - /* element */ -]; -`, - }, -]; - -describe('typescript/variable-declaration/1tbs', () => { - for (const fixture of fixtures) { - test(fixture.name, () => { - expect( - format(fixture.input, { - ...options, - ...(fixture.options ?? {}), - }), - ).toBe(fixture.output); - }); - } -}); diff --git a/tests/v2-test/typescript/variable-declaration/allman.test.ts b/tests/v2-test/typescript/variable-declaration/allman.test.ts deleted file mode 100644 index 4487e79..0000000 --- a/tests/v2-test/typescript/variable-declaration/allman.test.ts +++ /dev/null @@ -1,80 +0,0 @@ -import { format } from 'prettier'; -import type { Fixture } from 'test-settings'; -import { baseOptions } from 'test-settings'; -import { describe, expect, test } from 'vitest'; - -// eslint-disable-next-line import/no-extraneous-dependencies -import * as thisPlugin from '@/packages/v2-plugin'; - -const options = { - ...baseOptions, - plugins: [thisPlugin], - parser: 'typescript', - braceStyle: 'allman', -}; - -const fixtures: Fixture[] = [ - { - name: 'variable declaration (1) - containing only comments in brackets', - input: ` -const foo = [ - // elements -]; -`, - output: `const foo = [ - // elements -]; -`, - }, - { - name: 'variable declaration (2) - containing only comments in brackets', - input: ` -const foo = [ - /* elements */ -]; -`, - output: `const foo = [ - /* elements */ -]; -`, - }, - { - name: 'variable declaration (3) - containing only comments in brackets', - input: ` -const foo = [/* elements */]; -`, - output: `const foo = [ - /* elements */ -]; -`, - }, - { - name: 'variable declaration (4) - containing only comments in brackets', - input: ` -const foo = [// element - /* element */ - // element -/* element */]; -`, - output: `const foo = [ - // element - /* element */ - // element - /* element */ -]; -`, - }, -]; - -describe('typescript/variable-declaration/allman', () => { - for (const fixture of fixtures) { - test(fixture.name, () => { - expect( - format(fixture.input, { - ...options, - ...(fixture.options ?? {}), - }), - ).toBe(fixture.output); - }); - } -}); diff --git a/tests/v2-test/typescript/variable-declaration/stroustrup.test.ts b/tests/v2-test/typescript/variable-declaration/stroustrup.test.ts deleted file mode 100644 index 5a7a7c6..0000000 --- a/tests/v2-test/typescript/variable-declaration/stroustrup.test.ts +++ /dev/null @@ -1,80 +0,0 @@ -import { format } from 'prettier'; -import type { Fixture } from 'test-settings'; -import { baseOptions } from 'test-settings'; -import { describe, expect, test } from 'vitest'; - -// eslint-disable-next-line import/no-extraneous-dependencies -import * as thisPlugin from '@/packages/v2-plugin'; - -const options = { - ...baseOptions, - plugins: [thisPlugin], - parser: 'typescript', - braceStyle: 'stroustrup', -}; - -const fixtures: Fixture[] = [ - { - name: 'variable declaration (1) - containing only comments in brackets', - input: ` -const foo = [ - // elements -]; -`, - output: `const foo = [ - // elements -]; -`, - }, - { - name: 'variable declaration (2) - containing only comments in brackets', - input: ` -const foo = [ - /* elements */ -]; -`, - output: `const foo = [ - /* elements */ -]; -`, - }, - { - name: 'variable declaration (3) - containing only comments in brackets', - input: ` -const foo = [/* elements */]; -`, - output: `const foo = [ - /* elements */ -]; -`, - }, - { - name: 'variable declaration (4) - containing only comments in brackets', - input: ` -const foo = [// element - /* element */ - // element -/* element */]; -`, - output: `const foo = [ - // element - /* element */ - // element - /* element */ -]; -`, - }, -]; - -describe('typescript/variable-declaration/stroustrup', () => { - for (const fixture of fixtures) { - test(fixture.name, () => { - expect( - format(fixture.input, { - ...options, - ...(fixture.options ?? {}), - }), - ).toBe(fixture.output); - }); - } -}); diff --git a/tests/v2-test/vue/assignment/1tbs.test.ts b/tests/v2-test/vue/assignment/1tbs.test.ts index e1916a2..abc37f2 100644 --- a/tests/v2-test/vue/assignment/1tbs.test.ts +++ b/tests/v2-test/vue/assignment/1tbs.test.ts @@ -106,429 +106,8 @@ const foo = { name: 'object assignment (3)', input: ` - - -`, - output: ` - - -`, - }, - { - name: 'object assignment (4)', - input: ` - - - -`, - output: ` - - -`, - }, - { - name: 'object assignment (5)', - input: ` - - - -`, - output: ` - - -`, - }, - { - name: 'object assignment (6)', - input: ` - - - -`, - output: ` - - -`, - }, - { - name: 'object assignment (7)', - input: ` - - - -`, - output: ` - - -`, - }, - { - name: 'object assignment (8)', - input: ` - - - - -`, - output: ` - - -`, - }, - { - name: 'object assignment (9)', - input: ` - - - -`, - output: ` - - -`, - }, - { - name: 'object assignment (10)', - input: ` - - - -`, - output: ` - - -`, - }, - { - name: 'object assignment (11)', - input: ` - @@ -538,7 +117,7 @@ const foo = { type="button" @click="() => { const foo = { - bar()/*comment3*/{}, + bar() {}, ['baz']() {} } }" @@ -546,63 +125,11 @@ const foo = { Click Me -`, - output: ` - - -`, - }, - { - name: 'object assignment (12)', - input: ` - - `, output: ` @@ -613,8 +140,7 @@ const foo = { @click=" () => { const foo = { - bar() /*comment4*/ - {}, + bar() {}, ['baz']() {}, }; } @@ -673,188 +199,6 @@ const foo = true && { name: 'conditional assignment (2)', input: ` - - -`, - output: ` - - -`, - }, - { - name: 'conditional assignment (3)', - input: ` - - - -`, - output: ` - - -`, - }, - { - name: 'conditional assignment (4)', - input: ` - - - -`, - output: ` - - -`, - }, - { - name: 'conditional assignment (5)', - input: ` - - - -`, - output: ` - - -`, - }, - { - name: 'conditional assignment (6)', - input: ` - - - -`, - output: ` - - -`, - }, - { - name: 'object assignment (4)', - input: ` - - - -`, - output: ` - - -`, - }, - { - name: 'object assignment (5)', - input: ` - - - -`, - output: ` - - -`, - }, - { - name: 'object assignment (6)', - input: ` - - - -`, - output: ` - - -`, - }, - { - name: 'object assignment (7)', - input: ` - - - -`, - output: ` - - -`, - }, - { - name: 'object assignment (8)', - input: ` - - - - -`, - output: ` - - -`, - }, - { - name: 'object assignment (9)', - input: ` - - - -`, - output: ` - - -`, - }, - { - name: 'object assignment (10)', - input: ` - - - -`, - output: ` - - -`, - }, - { - name: 'object assignment (11)', - input: ` - @@ -560,7 +119,7 @@ const foo = { type="button" @click="() => { const foo = { - bar()/*comment3*/{}, + bar() {}, ['baz']() {} } }" @@ -568,67 +127,11 @@ const foo = { Click Me -`, - output: ` - - -`, - }, - { - name: 'object assignment (12)', - input: ` - - `, output: ` - - -`, - output: ` - - -`, - }, - { - name: 'conditional assignment (3)', - input: ` - - - -`, - output: ` - - -`, - }, - { - name: 'conditional assignment (4)', - input: ` - - - -`, - output: ` - - -`, - }, - { - name: 'conditional assignment (5)', - input: ` - - - -`, - output: ` - - -`, - }, - { - name: 'conditional assignment (6)', - input: ` - - - -`, - output: ` - - -`, - }, - { - name: 'object assignment (4)', - input: ` - - - -`, - output: ` - - -`, - }, - { - name: 'object assignment (5)', - input: ` - - - -`, - output: ` - - -`, - }, - { - name: 'object assignment (6)', - input: ` - - - -`, - output: ` - - -`, - }, - { - name: 'object assignment (7)', - input: ` - - - -`, - output: ` - - -`, - }, - { - name: 'object assignment (8)', - input: ` - - - - -`, - output: ` - - -`, - }, - { - name: 'object assignment (9)', - input: ` - - - -`, - output: ` - - -`, - }, - { - name: 'object assignment (10)', - input: ` - - - -`, - output: ` - - -`, - }, - { - name: 'object assignment (11)', - input: ` - @@ -538,7 +117,7 @@ const foo = { type="button" @click="() => { const foo = { - bar()/*comment3*/{}, + bar() {}, ['baz']() {} } }" @@ -546,63 +125,11 @@ const foo = { Click Me -`, - output: ` - - -`, - }, - { - name: 'object assignment (12)', - input: ` - - `, output: ` @@ -613,8 +140,7 @@ const foo = { @click=" () => { const foo = { - bar() /*comment4*/ - {}, + bar() {}, ['baz']() {}, }; } @@ -673,188 +199,6 @@ const foo = true && { name: 'conditional assignment (2)', input: ` - - -`, - output: ` - - -`, - }, - { - name: 'conditional assignment (3)', - input: ` - - - -`, - output: ` - - -`, - }, - { - name: 'conditional assignment (4)', - input: ` - - - -`, - output: ` - - -`, - }, - { - name: 'conditional assignment (5)', - input: ` - - - -`, - output: ` - - -`, - }, - { - name: 'conditional assignment (6)', - input: ` - - - -`, - output: ` - - -`, - }, - { - name: 'function declaration (3)', - input: ` - - - -`, - output: ` - - -`, - }, - { - name: 'function declaration (4)', - input: ` - - - -`, - output: ` - - -`, - }, - { - name: 'function declaration (5)', - input: ` - - - -`, - output: ` - - -`, - }, - { - name: 'function declaration (6)', - input: ` - - - -`, - output: ` - - -`, - }, - { - name: 'function declaration (7)', - input: ` - - - -`, - output: ` - - -`, - }, - { - name: 'function declaration (8)', - input: ` - - - -`, - output: ` - - -`, - }, - { - name: 'function declaration (9)', - input: ` - - - -`, - output: ` - - -`, - }, - { - name: 'function declaration (10)', - input: ` - - - -`, - output: ` - - -`, - }, - { - name: 'function declaration (11)', - input: ` - - - -`, - output: ` - - -`, - }, - { - name: 'function expression (2)', - input: ` - - - -`, - output: ` - - -`, - }, - { - name: 'function expression (3)', - input: ` - - - -`, - output: ` - - -`, - }, - { - name: 'function expression (4)', - input: ` - - - -`, - output: ` - - -`, - }, - { - name: 'function expression (5)', - input: ` - - - -`, - output: ` - - -`, - }, - { - name: 'function expression (6)', - input: ` - `, output: `