diff --git a/tests/array_spread/__snapshots__/jsfmt.spec.js.snap b/tests/array_spread/__snapshots__/jsfmt.spec.js.snap index 3ec2ed4d2..40037c63f 100644 --- a/tests/array_spread/__snapshots__/jsfmt.spec.js.snap +++ b/tests/array_spread/__snapshots__/jsfmt.spec.js.snap @@ -8,12 +8,3 @@ exports[`multiple.js 1`] = ` [...a, ...b]; " `; - -exports[`multiple.js 2`] = ` -"[...a, ...b,]; -[...a, ...b]; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -[...a, ...b]; -[...a, ...b]; -" -`; diff --git a/tests/array_spread/jsfmt.spec.js b/tests/array_spread/jsfmt.spec.js index e98b84204..7580dfab0 100644 --- a/tests/array_spread/jsfmt.spec.js +++ b/tests/array_spread/jsfmt.spec.js @@ -1,2 +1 @@ -run_spec(__dirname); -run_spec(__dirname, {parser: 'typescript'}); +run_spec(__dirname, null, ["typescript"]); diff --git a/tests/arrays/__snapshots__/jsfmt.spec.js.snap b/tests/arrays/__snapshots__/jsfmt.spec.js.snap index 5c9618de2..a999aea07 100644 --- a/tests/arrays/__snapshots__/jsfmt.spec.js.snap +++ b/tests/arrays/__snapshots__/jsfmt.spec.js.snap @@ -13,19 +13,6 @@ exports[`last.js 1`] = ` " `; -exports[`last.js 2`] = ` -"[,]; -[,,]; -[,,1,]; -[,,1,1]; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -[,]; -[, ,]; -[, , 1]; -[, , 1, 1]; -" -`; - exports[`preserve_empty_lines.js 1`] = ` "a = [ @@ -43,21 +30,3 @@ exports[`preserve_empty_lines.js 1`] = ` a = [1, 2, 3, 4]; " `; - -exports[`preserve_empty_lines.js 2`] = ` -"a = [ - - 1, - 2, - - 3, - - - 4, - - -] -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -a = [1, 2, 3, 4]; -" -`; diff --git a/tests/arrays/jsfmt.spec.js b/tests/arrays/jsfmt.spec.js index 1161d7bfb..7580dfab0 100644 --- a/tests/arrays/jsfmt.spec.js +++ b/tests/arrays/jsfmt.spec.js @@ -1,2 +1 @@ -run_spec(__dirname); -run_spec(__dirname, {parser: 'typescript'}); \ No newline at end of file +run_spec(__dirname, null, ["typescript"]); diff --git a/tests/arrows/jsfmt.spec.js b/tests/arrows/jsfmt.spec.js index 939578260..f974ed6c7 100644 --- a/tests/arrows/jsfmt.spec.js +++ b/tests/arrows/jsfmt.spec.js @@ -1 +1 @@ -run_spec(__dirname, {parser: 'babylon'}); +run_spec(__dirname, { parser: "babylon" }); diff --git a/tests/assignment_comments/__snapshots__/jsfmt.spec.js.snap b/tests/assignment_comments/__snapshots__/jsfmt.spec.js.snap index 46a2055e0..2992463f7 100644 --- a/tests/assignment_comments/__snapshots__/jsfmt.spec.js.snap +++ b/tests/assignment_comments/__snapshots__/jsfmt.spec.js.snap @@ -119,123 +119,3 @@ let f = ( ) => {}; " `; - -exports[`assignment_comments.js 2`] = ` -"fnString = - // Comment - 'some' + 'long' + 'string'; - -var fnString = - // Comment - 'some' + 'long' + 'string'; - -var fnString = - // Comment - - 'some' + 'long' + 'string'; - -var fnString = - - // Comment - - 'some' + 'long' + 'string'; - -var fnString = - /* comment */ - 'some' + 'long' + 'string'; - -var fnString = - /** - * multi-line - */ - 'some' + 'long' + 'string'; - -var fnString = - /* inline */ 'some' + 'long' + 'string' + 'some' + 'long' + 'string' + 'some' + 'long' + 'string' + 'some' + 'long' + 'string'; - -var fnString = // Comment - // Comment - 'some' + 'long' + 'string'; - -var fnString = // Comment - 'some' + 'long' + 'string'; - -let f = ( - a = - //comment - b -) => {}; - -let f = ( - a = //comment - b -) => {}; - -let f = ( - a = - b //comment -) => {}; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -fnString = - // Comment - \\"some\\" + \\"long\\" + \\"string\\"; - -var fnString = - // Comment - \\"some\\" + \\"long\\" + \\"string\\"; - -var fnString = - // Comment - - \\"some\\" + \\"long\\" + \\"string\\"; - -var fnString = - // Comment - - \\"some\\" + \\"long\\" + \\"string\\"; - -var fnString = - /* comment */ - \\"some\\" + \\"long\\" + \\"string\\"; - -var fnString = - /** - * multi-line - */ - \\"some\\" + \\"long\\" + \\"string\\"; - -var fnString = - /* inline */ \\"some\\" + - \\"long\\" + - \\"string\\" + - \\"some\\" + - \\"long\\" + - \\"string\\" + - \\"some\\" + - \\"long\\" + - \\"string\\" + - \\"some\\" + - \\"long\\" + - \\"string\\"; - -var fnString = // Comment - // Comment - \\"some\\" + \\"long\\" + \\"string\\"; - -var fnString = // Comment - \\"some\\" + \\"long\\" + \\"string\\"; - -let f = ( - //comment - a = b -) => {}; - -let f = ( - a = b //comment -) => {}; - -let f = ( - a = b //comment -) => {}; -" -`; diff --git a/tests/assignment_comments/jsfmt.spec.js b/tests/assignment_comments/jsfmt.spec.js index 1161d7bfb..7580dfab0 100644 --- a/tests/assignment_comments/jsfmt.spec.js +++ b/tests/assignment_comments/jsfmt.spec.js @@ -1,2 +1 @@ -run_spec(__dirname); -run_spec(__dirname, {parser: 'typescript'}); \ No newline at end of file +run_spec(__dirname, null, ["typescript"]); diff --git a/tests/async/__snapshots__/jsfmt.spec.js.snap b/tests/async/__snapshots__/jsfmt.spec.js.snap index 01749e485..4ec14ed9e 100644 --- a/tests/async/__snapshots__/jsfmt.spec.js.snap +++ b/tests/async/__snapshots__/jsfmt.spec.js.snap @@ -29,35 +29,6 @@ async function f() { " `; -exports[`await_parse.js 2`] = ` -"async function f() { (await f()).length } -async function g() { - invariant( - (await driver.navigator.getUrl()).substr(-7) - ); -} -function *f(){ - !(yield a); -} -async function f() { - a = !(await f()); -} -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -async function f() { - (await f()).length; -} -async function g() { - invariant((await driver.navigator.getUrl()).substr(-7)); -} -function* f() { - !(yield a); -} -async function f() { - a = !await f(); -} -" -`; - exports[`conditional-expression.js 1`] = ` "async function f() { const result = typeof fn === 'function' ? await fn() : null; @@ -78,24 +49,3 @@ async function f() { })(); " `; - -exports[`conditional-expression.js 2`] = ` -"async function f() { - const result = typeof fn === 'function' ? await fn() : null; -} - -(async function() { - console.log( - await (true ? Promise.resolve(\\"A\\") : Promise.resolve(\\"B\\")) - ); -})() -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -async function f() { - const result = typeof fn === \\"function\\" ? await fn() : null; -} - -(async function() { - console.log(await (true ? Promise.resolve(\\"A\\") : Promise.resolve(\\"B\\"))); -})(); -" -`; diff --git a/tests/async/jsfmt.spec.js b/tests/async/jsfmt.spec.js index e98b84204..7580dfab0 100644 --- a/tests/async/jsfmt.spec.js +++ b/tests/async/jsfmt.spec.js @@ -1,2 +1 @@ -run_spec(__dirname); -run_spec(__dirname, {parser: 'typescript'}); +run_spec(__dirname, null, ["typescript"]); diff --git a/tests/bracketSpacing/__snapshots__/jsfmt.spec.js.snap b/tests/bracketSpacing/__snapshots__/jsfmt.spec.js.snap index a5546b251..be1f1b9e5 100644 --- a/tests/bracketSpacing/__snapshots__/jsfmt.spec.js.snap +++ b/tests/bracketSpacing/__snapshots__/jsfmt.spec.js.snap @@ -18,24 +18,6 @@ const arr2 = [1, 2, 3, 4]; " `; -exports[`array.js 3`] = ` -"const arr1 = [1,2,3,4]; -const arr2 = [1, 2, 3, 4]; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -const arr1 = [1, 2, 3, 4]; -const arr2 = [1, 2, 3, 4]; -" -`; - -exports[`array.js 4`] = ` -"const arr1 = [1,2,3,4]; -const arr2 = [1, 2, 3, 4]; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -const arr1 = [1, 2, 3, 4]; -const arr2 = [1, 2, 3, 4]; -" -`; - exports[`object.js 1`] = ` "const obj1 = {a:1, b:2, c:3} const obj2 = { a:1, b:2, c:3 }; @@ -53,21 +35,3 @@ const obj1 = {a: 1, b: 2, c: 3}; const obj2 = {a: 1, b: 2, c: 3}; " `; - -exports[`object.js 3`] = ` -"const obj1 = {a:1, b:2, c:3} -const obj2 = { a:1, b:2, c:3 }; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -const obj1 = { a: 1, b: 2, c: 3 }; -const obj2 = { a: 1, b: 2, c: 3 }; -" -`; - -exports[`object.js 4`] = ` -"const obj1 = {a:1, b:2, c:3} -const obj2 = { a:1, b:2, c:3 }; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -const obj1 = {a: 1, b: 2, c: 3}; -const obj2 = {a: 1, b: 2, c: 3}; -" -`; diff --git a/tests/bracketSpacing/jsfmt.spec.js b/tests/bracketSpacing/jsfmt.spec.js index ee11f0138..bb1d92705 100644 --- a/tests/bracketSpacing/jsfmt.spec.js +++ b/tests/bracketSpacing/jsfmt.spec.js @@ -1,5 +1,2 @@ -run_spec(__dirname); -run_spec(__dirname, { bracketSpacing: false }); - -run_spec(__dirname, {parser: 'typescript'}); -run_spec(__dirname, { parser: 'typescript', bracketSpacing: false }); \ No newline at end of file +run_spec(__dirname, null, ["typescript"]); +run_spec(__dirname, { bracketSpacing: false }, ["typescript"]); \ No newline at end of file diff --git a/tests/break-calls/__snapshots__/jsfmt.spec.js.snap b/tests/break-calls/__snapshots__/jsfmt.spec.js.snap index 1782e5aa5..7f209a315 100644 --- a/tests/break-calls/__snapshots__/jsfmt.spec.js.snap +++ b/tests/break-calls/__snapshots__/jsfmt.spec.js.snap @@ -80,86 +80,6 @@ expect( " `; -exports[`break.js 2`] = ` -"h(f(g(() => { - a -}))) - -deepCopyAndAsyncMapLeavesA( - { source: sourceValue, destination: destination[sourceKey] }, - { valueMapper, overwriteExistingKeys } -) - -deepCopyAndAsyncMapLeavesB( - 1337, - { source: sourceValue, destination: destination[sourceKey] }, - { valueMapper, overwriteExistingKeys } -) - -deepCopyAndAsyncMapLeavesC( - { source: sourceValue, destination: destination[sourceKey] }, - 1337, - { valueMapper, overwriteExistingKeys } -) - -function someFunction(url) { - return get(url) - .then( - json => dispatch(success(json)), - error => dispatch(failed(error)) - ); -} - -const mapChargeItems = fp.flow( - l => l < 10 ? l: 1, - l => Immutable.Range(l).toMap() -); - -expect(new LongLongLongLongLongRange([0, 0], [0, 0])).toEqualAtomLongLongLongLongRange(new LongLongLongRange([0, 0], [0, 0])); -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -h( - f( - g(() => { - a; - }) - ) -); - -deepCopyAndAsyncMapLeavesA( - { source: sourceValue, destination: destination[sourceKey] }, - { valueMapper, overwriteExistingKeys } -); - -deepCopyAndAsyncMapLeavesB( - 1337, - { source: sourceValue, destination: destination[sourceKey] }, - { valueMapper, overwriteExistingKeys } -); - -deepCopyAndAsyncMapLeavesC( - { source: sourceValue, destination: destination[sourceKey] }, - 1337, - { valueMapper, overwriteExistingKeys } -); - -function someFunction(url) { - return get(url).then( - json => dispatch(success(json)), - error => dispatch(failed(error)) - ); -} - -const mapChargeItems = fp.flow( - l => l < 10 ? l : 1, - l => Immutable.Range(l).toMap() -); - -expect( - new LongLongLongLongLongRange([0, 0], [0, 0]) -).toEqualAtomLongLongLongLongRange(new LongLongLongRange([0, 0], [0, 0])); -" -`; - exports[`parent.js 1`] = ` "runtimeAgent.getProperties( objectId, @@ -182,26 +102,3 @@ runtimeAgent.getProperties( ); " `; - -exports[`parent.js 2`] = ` -"runtimeAgent.getProperties( - objectId, - false, // ownProperties - false, // accessorPropertiesOnly - false, // generatePreview - (error, properties, internalProperties) => { - return 1 - }, -); -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -runtimeAgent.getProperties( - objectId, - false, // ownProperties - false, // accessorPropertiesOnly - false, // generatePreview - (error, properties, internalProperties) => { - return 1; - } -); -" -`; diff --git a/tests/break-calls/jsfmt.spec.js b/tests/break-calls/jsfmt.spec.js index 1161d7bfb..7580dfab0 100644 --- a/tests/break-calls/jsfmt.spec.js +++ b/tests/break-calls/jsfmt.spec.js @@ -1,2 +1 @@ -run_spec(__dirname); -run_spec(__dirname, {parser: 'typescript'}); \ No newline at end of file +run_spec(__dirname, null, ["typescript"]); diff --git a/tests/class_comment/__snapshots__/jsfmt.spec.js.snap b/tests/class_comment/__snapshots__/jsfmt.spec.js.snap index 386a8d6aa..e30bc141a 100644 --- a/tests/class_comment/__snapshots__/jsfmt.spec.js.snap +++ b/tests/class_comment/__snapshots__/jsfmt.spec.js.snap @@ -70,74 +70,3 @@ class x { } " `; - -exports[`comments.js 2`] = ` -"class A // comment 1 - // comment 2 - extends B {} - -class A extends B // comment1 -// comment2 -// comment3 -{} - -class A /* a */ extends B {} -class A extends B /* a */ {} -class A extends /* a */ B {} - -(class A // comment 1 - // comment 2 - extends B {}); - -(class A extends B // comment1 -// comment2 -// comment3 -{}); - -(class A /* a */ extends B {}); -(class A extends B /* a */ {}); -(class A extends /* a */ B {}); - -class x { - focus() // do nothing - { - // do nothing - } -} -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -// comment 1 -// comment 2 -class A extends B {} - -// comment1 -// comment2 -// comment3 -class A extends B {} - -class A /* a */ extends B {} -class A extends B /* a */ { -} -class A extends /* a */ B {} - -// comment 1 -// comment 2 -(class A extends B {}); - -// comment1 -// comment2 -// comment3 -(class A extends B {}); - -(class A /* a */ extends B {}); -(class A extends B /* a */ { -}); -(class A extends /* a */ B {}); - -class x { - focus() // do nothing - { - // do nothing - } -} -" -`; diff --git a/tests/class_comment/jsfmt.spec.js b/tests/class_comment/jsfmt.spec.js index 1161d7bfb..7580dfab0 100644 --- a/tests/class_comment/jsfmt.spec.js +++ b/tests/class_comment/jsfmt.spec.js @@ -1,2 +1 @@ -run_spec(__dirname); -run_spec(__dirname, {parser: 'typescript'}); \ No newline at end of file +run_spec(__dirname, null, ["typescript"]); diff --git a/tests/class_extends/__snapshots__/jsfmt.spec.js.snap b/tests/class_extends/__snapshots__/jsfmt.spec.js.snap index 5713ceea5..5e48be6d2 100644 --- a/tests/class_extends/__snapshots__/jsfmt.spec.js.snap +++ b/tests/class_extends/__snapshots__/jsfmt.spec.js.snap @@ -118,122 +118,3 @@ function* f() { x = class extends (++b) {}; " `; - -exports[`extends.js 2`] = ` -"// \\"ArrowFunctionExpression\\" -class a extends (() => {}) {} - -// \\"AssignmentExpression\\" -class a extends (b = c) {} - -// \\"AwaitExpression\\" -async function f() { - class a extends (await b) {} -} - -// \\"BinaryExpression\\" -class a extends (b + c) {} - -// \\"CallExpression\\" -class a extends b() {} - -// \\"ClassExpression\\" -class a extends class {} {} - -// \\"ConditionalExpression\\" -class a extends (b ? c : d) {} - -// \\"FunctionExpression\\" -class a extends (function() {}) {} - -// \\"LogicalExpression\\" -class a extends (b || c) {} - -// \\"MemberExpression\\" -class a extends b.c {} - -// \\"NewExpression\\" -class a extends (new B()) {} - -// \\"ObjectExpression\\" -class a extends ({}) {} - -// \\"SequenceExpression\\" -class a extends (b, c) {} - -// \\"TaggedTemplateExpression\\" -class a extends \`\` {} - -// \\"UnaryExpression\\" -class a extends (void b) {} - -// \\"UpdateExpression\\" -class a extends (++b) {} - -// \\"YieldExpression\\" -function* f() { - // Flow has a bug parsing it. - // class a extends (yield 1) {} -} - -x = class extends (++b) {} -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -// \\"ArrowFunctionExpression\\" -class a extends (() => {}) {} - -// \\"AssignmentExpression\\" -class a extends (b = c) {} - -// \\"AwaitExpression\\" -async function f() { - class a extends (await b) {} -} - -// \\"BinaryExpression\\" -class a extends (b + c) {} - -// \\"CallExpression\\" -class a extends b() {} - -// \\"ClassExpression\\" -class a extends class {} {} - -// \\"ConditionalExpression\\" -class a extends (b ? c : d) {} - -// \\"FunctionExpression\\" -class a extends function() {} {} - -// \\"LogicalExpression\\" -class a extends (b || c) {} - -// \\"MemberExpression\\" -class a extends b.c {} - -// \\"NewExpression\\" -class a extends (new B()) {} - -// \\"ObjectExpression\\" -class a extends ({}) {} - -// \\"SequenceExpression\\" -class a extends (b, c) {} - -// \\"TaggedTemplateExpression\\" -class a extends \`\` {} - -// \\"UnaryExpression\\" -class a extends (void b) {} - -// \\"UpdateExpression\\" -class a extends (++b) {} - -// \\"YieldExpression\\" -function* f() { - // Flow has a bug parsing it. - // class a extends (yield 1) {} -} - -x = class extends (++b) {}; -" -`; diff --git a/tests/class_extends/jsfmt.spec.js b/tests/class_extends/jsfmt.spec.js index 1161d7bfb..7580dfab0 100644 --- a/tests/class_extends/jsfmt.spec.js +++ b/tests/class_extends/jsfmt.spec.js @@ -1,2 +1 @@ -run_spec(__dirname); -run_spec(__dirname, {parser: 'typescript'}); \ No newline at end of file +run_spec(__dirname, null, ["typescript"]); diff --git a/tests/comments/__snapshots__/jsfmt.spec.js.snap b/tests/comments/__snapshots__/jsfmt.spec.js.snap index 675a0790f..37bdc08cb 100644 --- a/tests/comments/__snapshots__/jsfmt.spec.js.snap +++ b/tests/comments/__snapshots__/jsfmt.spec.js.snap @@ -18,24 +18,6 @@ let { " `; -exports[`assignment-pattern.js 2`] = ` -"const { a /* comment */ = 1 } = b; - -const { c = 1 /* comment */ } = d; - -let {a //comment -= b} = c -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -const { a /* comment */ = 1 } = b; - -const { c = 1 /* comment */ } = d; - -let { - a = b //comment -} = c; -" -`; - exports[`blank.js 1`] = ` "// This file only // has comments. This comment @@ -83,53 +65,6 @@ exports[`blank.js 1`] = ` " `; -exports[`blank.js 2`] = ` -"// This file only -// has comments. This comment -// should still exist -// -// when printed. - -/** - * @typedef {DataDrivenMapping|ConstantMapping} Mapping - */ -/** - * @typedef {Object.} ConfigurationMapping - */ - -/** - * @typedef {Function} D3Scale - a D3 scale - * @property {Function} ticks - * @property {Function} tickFormat - */ -// comment - -// comment -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -// This file only -// has comments. This comment -// should still exist -// -// when printed. - -/** - * @typedef {DataDrivenMapping|ConstantMapping} Mapping - */ -/** - * @typedef {Object.} ConfigurationMapping - */ - -/** - * @typedef {Function} D3Scale - a D3 scale - * @property {Function} ticks - * @property {Function} tickFormat - */ -// comment - -// comment -" -`; - exports[`call_comment.js 1`] = ` "render( // Warm any cache , @@ -155,31 +90,6 @@ React.render( " `; -exports[`call_comment.js 2`] = ` -"render( // Warm any cache - , - container -); - -React.render( // Warm any cache - , - container -); -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -render( - // Warm any cache - , - container -); - -React.render( - // Warm any cache - , - container -); -" -`; - exports[`dangling.js 1`] = ` "var x = {/* dangling */}; var x = { @@ -211,37 +121,6 @@ export /* dangling */{}; " `; -exports[`dangling.js 2`] = ` -"var x = {/* dangling */}; -var x = { - // dangling -}; -var x = [/* dangling */]; -function x() { - /* dangling */ -} -declare class Foo extends Qux {/* dangling */} -export /* dangling */{}; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -var x = { - /* dangling */ -}; -var x = { - // dangling -}; -var x = [ - /* dangling */ -]; -function x() { - /* dangling */ -} -declare class Foo extends Qux { - /* dangling */ -} -export /* dangling */{}; -" -`; - exports[`dangling_array.js 1`] = ` "expect(() => {}).toTriggerReadyStateChanges([ // Nothing. @@ -259,23 +138,6 @@ expect(() => {}).toTriggerReadyStateChanges( " `; -exports[`dangling_array.js 2`] = ` -"expect(() => {}).toTriggerReadyStateChanges([ - // Nothing. -]); - -[1 /* first comment */, 2 /* second comment */, 3]; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -expect(() => {}).toTriggerReadyStateChanges( - [ - // Nothing. - ] -); - -[1 /* first comment */, 2 /* second comment */, 3]; -" -`; - exports[`dangling_for.js 1`] = ` "for // comment (;;); @@ -290,20 +152,6 @@ for (;;); " `; -exports[`dangling_for.js 2`] = ` -"for // comment -(;;); - -for /* comment */(;;); -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -// comment -for (;;); - -/* comment */ -for (;;); -" -`; - exports[`export.js 1`] = ` "export //comment {} @@ -313,15 +161,6 @@ export {}; " `; -exports[`export.js 2`] = ` -"export //comment -{} -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -//comment -export {}; -" -`; - exports[`first-line.js 1`] = ` "a // comment b @@ -331,15 +170,6 @@ b; " `; -exports[`first-line.js 2`] = ` -"a // comment -b -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -a; // comment -b; -" -`; - exports[`flow_union.js 1`] = ` "type UploadState // The upload hasnt begun yet @@ -383,49 +213,6 @@ type UploadState = " `; -exports[`flow_union.js 2`] = ` -"type UploadState - // The upload hasnt begun yet - = {type: \\"Not_begun\\"} - // The upload timed out - | {type: \\"Timed_out\\"} - // Failed somewhere on the line - | {type: \\"Failed\\", error: E, errorMsg: EM} - // Uploading to aws3 and CreatePostMutation succeeded - | {type: \\"Success\\", data: D}; - -type UploadState - // The upload hasnt begun yet - = A - // The upload timed out - | B - // Failed somewhere on the line - | C - // Uploading to aws3 and CreatePostMutation succeeded - | D; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -type UploadState = - // The upload hasnt begun yet - | { type: \\"Not_begun\\" } - // The upload timed out - | { type: \\"Timed_out\\" } - // Failed somewhere on the line - | { type: \\"Failed\\", error: E, errorMsg: EM } - // Uploading to aws3 and CreatePostMutation succeeded - | { type: \\"Success\\", data: D }; - -type UploadState = - // The upload hasnt begun yet - | A - // The upload timed out - | B - // Failed somewhere on the line - | C - // Uploading to aws3 and CreatePostMutation succeeded - | D; -" -`; - exports[`function-declaration.js 1`] = ` "function a(/* comment */) {} // comment function b() {} // comment @@ -437,17 +224,6 @@ function c(/* comment */ argA, argB, argC) {} // comment " `; -exports[`function-declaration.js 2`] = ` -"function a(/* comment */) {} // comment -function b() {} // comment -function c(/* comment */ argA, argB, argC) {} // comment -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -function a(/* comment */) {} // comment -function b() {} // comment -function c(/* comment */ argA, argB, argC) {} // comment -" -`; - exports[`if.js 1`] = ` "if (1) // comment @@ -492,50 +268,6 @@ else if (4) { " `; -exports[`if.js 2`] = ` -"if (1) -// comment -{ - false -} -// comment -else if (2) - true -// multi -// ple -// lines -else if (3) - // existing comment - true -// okay? -else if (4) { - // empty with existing comment -} -// comment -else { -} -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -if (1) { - // comment - false; -} else if (2) - // comment - true; -else if (3) - // multi - // ple - // lines - // existing comment - true; -else if (4) { - // okay? - // empty with existing comment -} else { - // comment -} -" -`; - exports[`issues.js 1`] = ` "// Does not need to break as it fits in 80 columns this.call(a, /* comment */ b); @@ -762,232 +494,6 @@ foo( " `; -exports[`issues.js 2`] = ` -"// Does not need to break as it fits in 80 columns -this.call(a, /* comment */ b); - -function f( - someReallyLongArgument: WithSomeLongType, - someReallyLongArgument2: WithSomeLongType, - // Trailing comment should stay after -) {} - -// Comments should either stay at the end of the line or always before, but -// not one before and one after. -throw new ProcessSystemError({ - code: acc.error.code, // Alias of errno - originalError: acc.error, // Just in case. -}); - -// Adding a comment stops the pretty printing process and everything is -// squished in a single line afterward -export type BuckWebSocketMessage = { - // Not actually from Buck - this is to let the receiver know that the socket is connected. - type: 'SocketConnected', -} | { - type: 'BuildProgressUpdated', - progressValue: number, -} | { - type: 'BuildFinished', - exitCode: number, -} | { - type: 'BuildStarted', -} | { - type: 'ParseStarted', -} | { - type: 'ParseFinished', -} | { - type: 'RunStarted', -} | { - type: 'RunComplete', -}; - -// Missing one level of indentation because of the comment -const rootEpic = (actions, store) => ( - combineEpics(...epics)(actions, store) - // Log errors and continue. - .catch((err, stream) => { - getLogger().error(err); - return stream; - }) -); - -// Two extra levels of indentation because of the comment -export type AsyncExecuteOptions = child_process$execFileOpts & { - // The contents to write to stdin. - stdin?: ?string, - dontLogInNuclide?: ?boolean, -}; - -// optional trailing comma gets moved all the way to the beginning -const regex = new RegExp( - '^\\\\\\\\s*' + // beginning of the line - 'name\\\\\\\\s*=\\\\\\\\s*' + // name = - '[\\\\'\\"]' + // opening quotation mark - escapeStringRegExp(target.name) + // target name - '[\\\\'\\"]' + // closing quotation mark - ',?$', // optional trailing comma -); - -// The comment is moved and doesn't trigger the eslint rule anymore -import path from 'path'; // eslint-disable-line nuclide-internal/prefer-nuclide-uri - -// Comments disappear in-between MemberExpressions -Observable.of(process) - // Don't complete until we say so! - .merge(Observable.never()) - // Get the errors. - .takeUntil(throwOnError ? errors.flatMap(Observable.throw) : errors) - .takeUntil(exit); - -// Comments disappear inside of JSX -
- {/* Some comment */} -
; - -// Comments in JSX tag are placed in a non optimal way -
; - -// Comments disappear in empty blocks -if (1) { - // Comment -} - -// Comments trigger invalid JavaScript in-between else if -if (1) { -} -// Comment -else { - -} - -// The comment makes the line break in a weird way -const result = asyncExecute('non_existing_command', /* args */ []); - -// The closing paren is printed on the same line as the comment -foo({} - // Hi -); -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -// Does not need to break as it fits in 80 columns -this.call(a, /* comment */ b); - -function f( - someReallyLongArgument: WithSomeLongType, - someReallyLongArgument2: WithSomeLongType -) // Trailing comment should stay after -{ -} - -// Comments should either stay at the end of the line or always before, but -// not one before and one after. -throw new ProcessSystemError({ - code: acc.error.code, // Alias of errno - originalError: acc.error // Just in case. -}); - -// Adding a comment stops the pretty printing process and everything is -// squished in a single line afterward -export type BuckWebSocketMessage = - | { - // Not actually from Buck - this is to let the receiver know that the socket is connected. - type: \\"SocketConnected\\" - } - | { - type: \\"BuildProgressUpdated\\", - progressValue: number - } - | { - type: \\"BuildFinished\\", - exitCode: number - } - | { - type: \\"BuildStarted\\" - } - | { - type: \\"ParseStarted\\" - } - | { - type: \\"ParseFinished\\" - } - | { - type: \\"RunStarted\\" - } - | { - type: \\"RunComplete\\" - }; - -// Missing one level of indentation because of the comment -const rootEpic = (actions, store) => - combineEpics(...epics)(actions, store) - // Log errors and continue. - .catch((err, stream) => { - getLogger().error(err); - return stream; - }); - -// Two extra levels of indentation because of the comment -export type AsyncExecuteOptions = child_process$execFileOpts & { - // The contents to write to stdin. - stdin?: ?string, - dontLogInNuclide?: ?boolean -}; - -// optional trailing comma gets moved all the way to the beginning -const regex = new RegExp( - \\"^\\\\\\\\s*\\" + // beginning of the line - \\"name\\\\\\\\s*=\\\\\\\\s*\\" + // name = - \\"['\\\\\\"]\\" + // opening quotation mark - escapeStringRegExp(target.name) + // target name - \\"['\\\\\\"]\\" + // closing quotation mark - \\",?$\\" // optional trailing comma -); - -// The comment is moved and doesn't trigger the eslint rule anymore -import path from \\"path\\"; // eslint-disable-line nuclide-internal/prefer-nuclide-uri - -// Comments disappear in-between MemberExpressions -Observable.of(process) - // Don't complete until we say so! - .merge(Observable.never()) - // Get the errors. - .takeUntil(throwOnError ? errors.flatMap(Observable.throw) : errors) - .takeUntil(exit); - -// Comments disappear inside of JSX -
- {/* Some comment */} -
; - -// Comments in JSX tag are placed in a non optimal way -
; - -// Comments disappear in empty blocks -if (1) { - // Comment -} - -// Comments trigger invalid JavaScript in-between else if -if (1) { -} else { - // Comment -} - -// The comment makes the line break in a weird way -const result = asyncExecute(\\"non_existing_command\\", /* args */ []); - -// The closing paren is printed on the same line as the comment -foo( - {} - // Hi -); -" -`; - exports[`jsx.js 1`] = ` "
{ @@ -1126,144 +632,6 @@ exports[`jsx.js 1`] = ` " `; -exports[`jsx.js 2`] = ` -"
- { - /* comment */ - } -
; - -
- {/* comment */ - } -
; - -
- {/* comment -*/ - } -
; - -
- {a/* comment -*/ - } -
; - -
- {/* comment -*/ - a - } -
; - -
- {/* comment */ - } -
; - -
- {/* comment */} -
; - -
- { - // single line comment - } -
; - -
- { - // multiple line comments 1 - // multiple line comments 2 - } -
; - -
- { - // multiple mixed comments 1 - /* multiple mixed comments 2 */ - /* multiple mixed comments 3 */ - // multiple mixed comments 4 - } -
; - -
- { - // Some very v ery very very merry (xmas) very very long line to break line width limit - } -
; - -
{/*
Some very v ery very very long line to break line width limit
*/}
; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -
- {/* comment */} -
; - -
- {/* comment */} -
; - -
- {/* comment -*/} -
; - -
- {a /* comment -*/} -
; - -
- { - /* comment -*/ - a - } -
; - -
- {/* comment */} -
; - -
- {/* comment */} -
; - -
- { - // single line comment - } -
; - -
- { - // multiple line comments 1 - // multiple line comments 2 - } -
; - -
- { - // multiple mixed comments 1 - /* multiple mixed comments 2 */ - /* multiple mixed comments 3 */ - // multiple mixed comments 4 - } -
; - -
- { - // Some very v ery very very merry (xmas) very very long line to break line width limit - } -
; - -
- {/*
Some very v ery very very long line to break line width limit
*/} -
; -" -`; - exports[`last-arg.js 1`] = ` "type f = ( currentRequest: {a: number}, @@ -1321,63 +689,6 @@ class X { " `; -exports[`last-arg.js 2`] = ` -"type f = ( - currentRequest: {a: number}, - // TODO this is a very very very very long comment that makes it go > 80 columns -) => number; - -f = ( - currentRequest: {a: number}, - // TODO this is a very very very very long comment that makes it go > 80 columns -): number => {}; - -f = ( - currentRequest: {a: number}, - // TODO this is a very very very very long comment that makes it go > 80 columns -) => {}; - -f = function( - currentRequest: {a: number}, - // TODO this is a very very very very long comment that makes it go > 80 columns -) {}; - -class X { - f( - currentRequest: {a: number}, - // TODO this is a very very very very long comment that makes it go > 80 columns - ) {} -} -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -type f = ( - currentRequest: { a: number } - // TODO this is a very very very very long comment that makes it go > 80 columns -) => number; - -f = ( - currentRequest: { a: number } - // TODO this is a very very very very long comment that makes it go > 80 columns -): number => {}; - -f = ( - currentRequest: { a: number } - // TODO this is a very very very very long comment that makes it go > 80 columns -) => {}; - -f = function( - currentRequest: { a: number } - // TODO this is a very very very very long comment that makes it go > 80 columns -) {}; - -class X { - f( - currentRequest: { a: number } - // TODO this is a very very very very long comment that makes it go > 80 columns - ) {} -} -" -`; - exports[`preserve-new-line-last.js 1`] = ` "function f() { a @@ -1425,53 +736,6 @@ function name() { " `; -exports[`preserve-new-line-last.js 2`] = ` -"function f() { - a - /* eslint-disable */ -} - -function f() { - a - - /* eslint-disable */ -} - -function name() { - // comment1 - func1() - - // comment2 - func2() - - // comment3 why func3 commented - // func3() -} -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -function f() { - a; - /* eslint-disable */ -} - -function f() { - a; - - /* eslint-disable */ -} - -function name() { - // comment1 - func1(); - - // comment2 - func2(); - - // comment3 why func3 commented - // func3() -} -" -`; - exports[`return-statement.js 1`] = ` "function jsx() { return ( @@ -1712,246 +976,6 @@ function inlineComment() { " `; -exports[`return-statement.js 2`] = ` -"function jsx() { - return ( - // Comment -
- ); -} - -function unary() { - return ( - // Comment - !!x - ); -} - -function numericLiteralNoParen() { - return 1337; // Comment -} - -function logical() { - return ( - // Reason for 42 - 42 - ) && 84 -} - -function binary() { - return ( - // Reason for 42 - 42 - ) * 84 -} - -function binaryInBinaryLeft() { - return ( - // Reason for 42 - 42 - ) * 84 + 2 -} - -function binaryInBinaryRight() { - return ( - // Reason for 42 - 42 - ) + 84 * 2 -} - -function conditional() { - return ( - // Reason for 42 - 42 - ) ? 1 : 2 -} - -function binaryInConditional() { - return ( - // Reason for 42 - 42 - ) * 3 ? 1 : 2 -} - -function call() { - return ( - // Reason for a - a - )() -} - -function memberInside() { - return ( - // Reason for a.b - a.b - ).c -} - -function memberOutside() { - return ( - // Reason for a - a - ).b.c -} - -function memberInAndOutWithCalls() { - return ( - // Reason for a - a.b() - ).c.d() -} - -function excessiveEverything() { - return ( - // Reason for stuff - a.b() * 3 + 4 ? (a\`hi\`, 1) ? 1 : 1 : 1 - ) -} - -function sequenceExpression() { - return ( - // Reason for a - a - ), b -} - -function taggedTemplate() { - return ( - // Reason for a - a - )\`b\` -} - -function inlineComment() { - return ( - /* hi */ 42 - ) || 42 -} -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -function jsx() { - return ( - // Comment -
- ); -} - -function unary() { - return ( - // Comment - !!x - ); -} - -function numericLiteralNoParen() { - return 1337; // Comment -} - -function logical() { - return ( - // Reason for 42 - 42 && 84 - ); -} - -function binary() { - return ( - // Reason for 42 - 42 * 84 - ); -} - -function binaryInBinaryLeft() { - return ( - // Reason for 42 - 42 * - 84 + - 2 - ); -} - -function binaryInBinaryRight() { - return ( - // Reason for 42 - 42 + - 84 * 2 - ); -} - -function conditional() { - return ( - // Reason for 42 - 42 - ? 1 - : 2 - ); -} - -function binaryInConditional() { - return ( - // Reason for 42 - 42 * 3 - ? 1 - : 2 - ); -} - -function call() { - return ( - // Reason for a - a() - ); -} - -function memberInside() { - return ( - // Reason for a.b - a.b.c - ); -} - -function memberOutside() { - return ( - // Reason for a - a.b.c - ); -} - -function memberInAndOutWithCalls() { - return ( - a - .b// Reason for a - () - .c.d() - ); -} - -function excessiveEverything() { - return ( - // Reason for stuff - a.b() * 3 + 4 ? (a\`hi\`, 1) ? 1 : 1 : 1 - ); -} - -function sequenceExpression() { - return ( - // Reason for a - a, b - ); -} - -function taggedTemplate() { - return ( - // Reason for a - a\`b\` - ); -} - -function inlineComment() { - return /* hi */ 42 || 42; -} -" -`; - exports[`switch.js 1`] = ` "switch (node && node.type) { case \\"Property\\": @@ -1995,49 +1019,6 @@ switch (foo) { " `; -exports[`switch.js 2`] = ` -"switch (node && node.type) { - case \\"Property\\": - case \\"MethodDefinition\\": - prop = node.key; - break; - - case \\"MemberExpression\\": - prop = node.property; - break; - - // no default -} - -switch (foo) { - case \\"bar\\": - doThing() - - // no default -} -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -switch (node && node.type) { - case \\"Property\\": - case \\"MethodDefinition\\": - prop = node.key; - break; - - case \\"MemberExpression\\": - prop = node.property; - break; - - // no default -} - -switch (foo) { - case \\"bar\\": - doThing(); - - // no default -} -" -`; - exports[`template-literal.js 1`] = ` "\` \${a // comment @@ -2067,35 +1048,6 @@ d}; " `; -exports[`template-literal.js 2`] = ` -"\` -\${a // comment -} - -\${b /* comment */} - -\${/* comment */ c /* comment */} - -\${// comment -d //comment -}; -\` -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -\` -\${/* comment*/ -a} - -\${/* comment */ b} - -\${/* comment */ /* comment */ c} - -\${/* comment*/ -/*comment*/ -d}; -\`; -" -`; - exports[`try.js 1`] = ` "// comment 1 try { @@ -2123,31 +1075,3 @@ try { } " `; - -exports[`try.js 2`] = ` -"// comment 1 -try { - // comment 2 -} -// comment 3 -catch(e) { - // comment 4 -} -// comment 5 -finally // comment 6 -{ - // comment 7 -} -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -// comment 1 -try { - // comment 2 -} catch (e) { - // comment 3 - // comment 4 -} finally { // comment 6 - // comment 5 - // comment 7 -} -" -`; diff --git a/tests/comments/jsfmt.spec.js b/tests/comments/jsfmt.spec.js index d5ec770a9..1840e9d36 100644 --- a/tests/comments/jsfmt.spec.js +++ b/tests/comments/jsfmt.spec.js @@ -1,2 +1 @@ -run_spec(__dirname); -run_spec(__dirname, {parser: 'babylon'}); +run_spec(__dirname, null, ["babylon"]); diff --git a/tests/computed_props/__snapshots__/jsfmt.spec.js.snap b/tests/computed_props/__snapshots__/jsfmt.spec.js.snap index ee18c93da..fafd502e9 100644 --- a/tests/computed_props/__snapshots__/jsfmt.spec.js.snap +++ b/tests/computed_props/__snapshots__/jsfmt.spec.js.snap @@ -10,14 +10,3 @@ class c { } " `; - -exports[`classes.js 2`] = ` -"class c { - [\\"i\\"]() {} -} -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -class c { - [\\"i\\"]() {} -} -" -`; diff --git a/tests/computed_props/jsfmt.spec.js b/tests/computed_props/jsfmt.spec.js index e98b84204..7580dfab0 100644 --- a/tests/computed_props/jsfmt.spec.js +++ b/tests/computed_props/jsfmt.spec.js @@ -1,2 +1 @@ -run_spec(__dirname); -run_spec(__dirname, {parser: 'typescript'}); +run_spec(__dirname, null, ["typescript"]); diff --git a/tests/conditional/__snapshots__/jsfmt.spec.js.snap b/tests/conditional/__snapshots__/jsfmt.spec.js.snap index 4bebfd114..bce41884e 100644 --- a/tests/conditional/__snapshots__/jsfmt.spec.js.snap +++ b/tests/conditional/__snapshots__/jsfmt.spec.js.snap @@ -79,85 +79,6 @@ const { configureStore } = process.env.NODE_ENV === \\"production\\" " `; -exports[`comments.js 2`] = ` -"var inspect = 4 === util.inspect.length - ? // node <= 0.8.x - (function(v, colors) { - return util.inspect(v, void 0, void 0, colors); - }) - : // node > 0.8.x - (function(v, colors) { - return util.inspect(v, { colors: colors }); - }); - -var inspect = 4 === util.inspect.length - ? // node <= 0.8.x - (function(v, colors) { - return util.inspect(v, void 0, void 0, colors); - }) - : // node > 0.8.x - (function(v, colors) { - return util.inspect(v, { colors: colors }); - }); - -const extractTextPluginOptions = shouldUseRelativeAssetPaths - // Making sure that the publicPath goes back to to build folder. - ? { publicPath: Array(cssFilename.split('/').length).join('../') } : - {}; - -const extractTextPluginOptions = shouldUseRelativeAssetPaths - ? // Making sure that the publicPath goes back to to build folder. - { publicPath: Array(cssFilename.split(\\"/\\").length).join(\\"../\\") } - : {}; - -const extractTextPluginOptions = shouldUseRelativeAssetPaths // Making sure that the publicPath goes back to to build folder. - ? { publicPath: Array(cssFilename.split(\\"/\\").length).join(\\"../\\") } - : {}; - -const { configureStore } = process.env.NODE_ENV === \\"production\\" - ? require(\\"./configureProdStore\\") // a - : require(\\"./configureDevStore\\"); // b -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -var inspect = 4 === util.inspect.length - ? // node <= 0.8.x - function(v, colors) { - return util.inspect(v, void 0, void 0, colors); - } - : // node > 0.8.x - function(v, colors) { - return util.inspect(v, { colors: colors }); - }; - -var inspect = 4 === util.inspect.length - ? // node <= 0.8.x - function(v, colors) { - return util.inspect(v, void 0, void 0, colors); - } - : // node > 0.8.x - function(v, colors) { - return util.inspect(v, { colors: colors }); - }; - -const extractTextPluginOptions = shouldUseRelativeAssetPaths - ? // Making sure that the publicPath goes back to to build folder. - { publicPath: Array(cssFilename.split(\\"/\\").length).join(\\"../\\") } - : {}; - -const extractTextPluginOptions = shouldUseRelativeAssetPaths - ? // Making sure that the publicPath goes back to to build folder. - { publicPath: Array(cssFilename.split(\\"/\\").length).join(\\"../\\") } - : {}; - -const extractTextPluginOptions = shouldUseRelativeAssetPaths // Making sure that the publicPath goes back to to build folder. - ? { publicPath: Array(cssFilename.split(\\"/\\").length).join(\\"../\\") } - : {}; - -const { configureStore } = process.env.NODE_ENV === \\"production\\" - ? require(\\"./configureProdStore\\") // a - : require(\\"./configureDevStore\\"); // b -" -`; - exports[`new-expression.js 1`] = ` "const testConsole = new TestConsole( config.useStderr ? process.stderr : process.stdout @@ -168,14 +89,3 @@ const testConsole = new TestConsole( ); " `; - -exports[`new-expression.js 2`] = ` -"const testConsole = new TestConsole( - config.useStderr ? process.stderr : process.stdout -); -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -const testConsole = new TestConsole( - config.useStderr ? process.stderr : process.stdout -); -" -`; diff --git a/tests/conditional/jsfmt.spec.js b/tests/conditional/jsfmt.spec.js index e98b84204..7580dfab0 100644 --- a/tests/conditional/jsfmt.spec.js +++ b/tests/conditional/jsfmt.spec.js @@ -1,2 +1 @@ -run_spec(__dirname); -run_spec(__dirname, {parser: 'typescript'}); +run_spec(__dirname, null, ["typescript"]); diff --git a/tests/decorators/jsfmt.spec.js b/tests/decorators/jsfmt.spec.js index 939578260..f974ed6c7 100644 --- a/tests/decorators/jsfmt.spec.js +++ b/tests/decorators/jsfmt.spec.js @@ -1 +1 @@ -run_spec(__dirname, {parser: 'babylon'}); +run_spec(__dirname, { parser: "babylon" }); diff --git a/tests/directives/__snapshots__/jsfmt.spec.js.snap b/tests/directives/__snapshots__/jsfmt.spec.js.snap index 3a93b3aa9..ba98973cb 100644 --- a/tests/directives/__snapshots__/jsfmt.spec.js.snap +++ b/tests/directives/__snapshots__/jsfmt.spec.js.snap @@ -6,18 +6,6 @@ exports[`last-line-0.js 1`] = ` " `; -exports[`last-line-0.js 2`] = ` -"'use strict';~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -\\"use strict\\"; -" -`; - -exports[`last-line-0.js 3`] = ` -"'use strict';~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -\\"use strict\\"; -" -`; - exports[`last-line-1.js 1`] = ` "'use strict'; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -25,20 +13,6 @@ exports[`last-line-1.js 1`] = ` " `; -exports[`last-line-1.js 2`] = ` -"'use strict'; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -\\"use strict\\"; -" -`; - -exports[`last-line-1.js 3`] = ` -"'use strict'; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -\\"use strict\\"; -" -`; - exports[`last-line-2.js 1`] = ` "'use strict'; @@ -47,22 +21,6 @@ exports[`last-line-2.js 1`] = ` " `; -exports[`last-line-2.js 2`] = ` -"'use strict'; - -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -\\"use strict\\"; -" -`; - -exports[`last-line-2.js 3`] = ` -"'use strict'; - -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -\\"use strict\\"; -" -`; - exports[`newline.js 1`] = ` "/* @flow */ @@ -82,44 +40,6 @@ a(); " `; -exports[`newline.js 2`] = ` -"/* @flow */ - -\\"use strict\\"; - -import a from \\"a\\"; - -a(); -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -/* @flow */ - -\\"use strict\\"; - -import a from \\"a\\"; - -a(); -" -`; - -exports[`newline.js 3`] = ` -"/* @flow */ - -\\"use strict\\"; - -import a from \\"a\\"; - -a(); -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -/* @flow */ - -\\"use strict\\"; - -import a from \\"a\\"; - -a(); -" -`; - exports[`no-newline.js 1`] = ` "\\"use strict\\"; a @@ -129,24 +49,6 @@ a; " `; -exports[`no-newline.js 2`] = ` -"\\"use strict\\"; -a -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -\\"use strict\\"; -a; -" -`; - -exports[`no-newline.js 3`] = ` -"\\"use strict\\"; -a -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -\\"use strict\\"; -a; -" -`; - exports[`test.js 1`] = ` "\\"use strict\\"; @@ -161,33 +63,3 @@ function fn() { } " `; - -exports[`test.js 2`] = ` -"\\"use strict\\"; - -function fn() { - \\"use strict\\"; -} -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -\\"use strict\\"; - -function fn() { - \\"use strict\\"; -} -" -`; - -exports[`test.js 3`] = ` -"\\"use strict\\"; - -function fn() { - \\"use strict\\"; -} -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -\\"use strict\\"; - -function fn() { - \\"use strict\\"; -} -" -`; diff --git a/tests/directives/jsfmt.spec.js b/tests/directives/jsfmt.spec.js index d6e0ca05a..320b4cfe1 100644 --- a/tests/directives/jsfmt.spec.js +++ b/tests/directives/jsfmt.spec.js @@ -1,3 +1 @@ -run_spec(__dirname); -run_spec(__dirname, {parser: 'typescript'}); -run_spec(__dirname, {parser: 'babylon'}); +run_spec(__dirname, null, ["typescript", "babylon"]); diff --git a/tests/do/jsfmt.spec.js b/tests/do/jsfmt.spec.js index 939578260..f974ed6c7 100644 --- a/tests/do/jsfmt.spec.js +++ b/tests/do/jsfmt.spec.js @@ -1 +1 @@ -run_spec(__dirname, {parser: 'babylon'}); +run_spec(__dirname, { parser: "babylon" }); diff --git a/tests/dynamic_import/jsfmt.spec.js b/tests/dynamic_import/jsfmt.spec.js index 939578260..f974ed6c7 100644 --- a/tests/dynamic_import/jsfmt.spec.js +++ b/tests/dynamic_import/jsfmt.spec.js @@ -1 +1 @@ -run_spec(__dirname, {parser: 'babylon'}); +run_spec(__dirname, { parser: "babylon" }); diff --git a/tests/empty_paren_comment/__snapshots__/jsfmt.spec.js.snap b/tests/empty_paren_comment/__snapshots__/jsfmt.spec.js.snap index 3e0a3efc2..bd4d43e25 100644 --- a/tests/empty_paren_comment/__snapshots__/jsfmt.spec.js.snap +++ b/tests/empty_paren_comment/__snapshots__/jsfmt.spec.js.snap @@ -54,58 +54,3 @@ f(a, /* ... */ b); f(/* ... */ a, b); " `; - -exports[`empty_paren_comment.js 2`] = ` -"let f = (/* ... */) => {} -(function (/* ... */) {})(/* ... */) -function f(/* ... */) {} - -const obj = { - f(/* ... */) {}, - f: (/* ... */) => {}, - f: function(/* ... */) {}, - f: function f(/* ... */) {} -} - -class Foo { - f(/* ... */) {} - f = (/* ... */) => {}; - static f(/* ... */) {}; - static f = (/* ... */) => {}; - static f = function(/* ... */) {}; - static f = function f(/* ... */) {}; - static f /* ... */() {}; -} - -f(/* ... */); -f(a, /* ... */); -f(a, /* ... */ b); -f(/* ... */ a, b); -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -let f = (/* ... */) => {}; -(function(/* ... */) {})(/* ... */); -function f(/* ... */) {} - -const obj = { - f(/* ... */) {}, - f: (/* ... */) => {}, - f: function(/* ... */) {}, - f: function f(/* ... */) {} -}; - -class Foo { - f(/* ... */) {} - f = (/* ... */) => {}; - static f(/* ... */) {} - static f = (/* ... */) => {}; - static f = function(/* ... */) {}; - static f = function f(/* ... */) {}; - static f(/* ... */) {} -} - -f(/* ... */); -f(a /* ... */); -f(a, /* ... */ b); -f(/* ... */ a, b); -" -`; diff --git a/tests/empty_paren_comment/jsfmt.spec.js b/tests/empty_paren_comment/jsfmt.spec.js index d5ec770a9..1840e9d36 100644 --- a/tests/empty_paren_comment/jsfmt.spec.js +++ b/tests/empty_paren_comment/jsfmt.spec.js @@ -1,2 +1 @@ -run_spec(__dirname); -run_spec(__dirname, {parser: 'babylon'}); +run_spec(__dirname, null, ["babylon"]); diff --git a/tests/empty_statement/__snapshots__/jsfmt.spec.js.snap b/tests/empty_statement/__snapshots__/jsfmt.spec.js.snap index 4e237c71b..42e607bca 100644 --- a/tests/empty_statement/__snapshots__/jsfmt.spec.js.snap +++ b/tests/empty_statement/__snapshots__/jsfmt.spec.js.snap @@ -21,25 +21,3 @@ do; while (1); " `; - -exports[`body.js 2`] = ` -"with (a); -if (1); else if (2); else; -for (;;); -while (1); -for (var i in o); -for (var i of o); -do; while(1); -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -with (a); -if (1); -else if (2); -else; -for (;;); -while (1); -for (var i in o); -for (var i of o); -do; -while (1); -" -`; diff --git a/tests/empty_statement/jsfmt.spec.js b/tests/empty_statement/jsfmt.spec.js index 1161d7bfb..7580dfab0 100644 --- a/tests/empty_statement/jsfmt.spec.js +++ b/tests/empty_statement/jsfmt.spec.js @@ -1,2 +1 @@ -run_spec(__dirname); -run_spec(__dirname, {parser: 'typescript'}); \ No newline at end of file +run_spec(__dirname, null, ["typescript"]); diff --git a/tests/es6modules/jsfmt.spec.js b/tests/es6modules/jsfmt.spec.js index cd6102665..668c3f6f4 100644 --- a/tests/es6modules/jsfmt.spec.js +++ b/tests/es6modules/jsfmt.spec.js @@ -1,2 +1,3 @@ run_spec(__dirname); -run_spec(__dirname, { parser: 'babylon' }); +// FIXME export_default_function_declaration_async.js flow != babylon output +run_spec(__dirname, { parser: "babylon" }); \ No newline at end of file diff --git a/tests/export/__snapshots__/jsfmt.spec.js.snap b/tests/export/__snapshots__/jsfmt.spec.js.snap index 3b651180e..560bd6874 100644 --- a/tests/export/__snapshots__/jsfmt.spec.js.snap +++ b/tests/export/__snapshots__/jsfmt.spec.js.snap @@ -54,60 +54,6 @@ export {fitsIn, oneLine}; " `; -exports[`bracket.js 3`] = ` -"export { - runTaskForChanged, - description, - someOtherLabel, - thatMakes, - itGo, - multiLine, - andMore, - soWeCanGetItTo80Columns -}; -export {fitsIn, oneLine}; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -export { - runTaskForChanged, - description, - someOtherLabel, - thatMakes, - itGo, - multiLine, - andMore, - soWeCanGetItTo80Columns -}; -export { fitsIn, oneLine }; -" -`; - -exports[`bracket.js 4`] = ` -"export { - runTaskForChanged, - description, - someOtherLabel, - thatMakes, - itGo, - multiLine, - andMore, - soWeCanGetItTo80Columns -}; -export {fitsIn, oneLine}; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -export { - runTaskForChanged, - description, - someOtherLabel, - thatMakes, - itGo, - multiLine, - andMore, - soWeCanGetItTo80Columns -}; -export {fitsIn, oneLine}; -" -`; - exports[`empty.js 1`] = ` "export {}; export {} from \\".\\"; @@ -125,21 +71,3 @@ export {}; export {} from \\".\\"; " `; - -exports[`empty.js 3`] = ` -"export {}; -export {} from \\".\\"; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -export {}; -export {} from \\".\\"; -" -`; - -exports[`empty.js 4`] = ` -"export {}; -export {} from \\".\\"; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -export {}; -export {} from \\".\\"; -" -`; diff --git a/tests/export/jsfmt.spec.js b/tests/export/jsfmt.spec.js index 6bf31d0c1..bb1d92705 100644 --- a/tests/export/jsfmt.spec.js +++ b/tests/export/jsfmt.spec.js @@ -1,5 +1,2 @@ -run_spec(__dirname); -run_spec(__dirname, {bracketSpacing: false}); - -run_spec(__dirname, {parser: 'typescript'}); -run_spec(__dirname, {parser: 'typescript', bracketSpacing: false}); \ No newline at end of file +run_spec(__dirname, null, ["typescript"]); +run_spec(__dirname, { bracketSpacing: false }, ["typescript"]); \ No newline at end of file diff --git a/tests/export_default/__snapshots__/jsfmt.spec.js.snap b/tests/export_default/__snapshots__/jsfmt.spec.js.snap index d54eaf6dc..27dbfe849 100644 --- a/tests/export_default/__snapshots__/jsfmt.spec.js.snap +++ b/tests/export_default/__snapshots__/jsfmt.spec.js.snap @@ -6,10 +6,3 @@ exports[`body.js 1`] = ` export default (class {}[1] = 1); " `; - -exports[`body.js 2`] = ` -"export default (class {}[1] = 1); -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -export default (class {}[1] = 1); -" -`; diff --git a/tests/export_default/jsfmt.spec.js b/tests/export_default/jsfmt.spec.js index 1161d7bfb..7580dfab0 100644 --- a/tests/export_default/jsfmt.spec.js +++ b/tests/export_default/jsfmt.spec.js @@ -1,2 +1 @@ -run_spec(__dirname); -run_spec(__dirname, {parser: 'typescript'}); \ No newline at end of file +run_spec(__dirname, null, ["typescript"]); diff --git a/tests/export_extension/jsfmt.spec.js b/tests/export_extension/jsfmt.spec.js index 939578260..f974ed6c7 100644 --- a/tests/export_extension/jsfmt.spec.js +++ b/tests/export_extension/jsfmt.spec.js @@ -1 +1 @@ -run_spec(__dirname, {parser: 'babylon'}); +run_spec(__dirname, { parser: "babylon" }); diff --git a/tests/exports/jsfmt.spec.js b/tests/exports/jsfmt.spec.js index 939578260..f974ed6c7 100644 --- a/tests/exports/jsfmt.spec.js +++ b/tests/exports/jsfmt.spec.js @@ -1 +1 @@ -run_spec(__dirname, {parser: 'babylon'}); +run_spec(__dirname, { parser: "babylon" }); diff --git a/tests/expression_statement/jsfmt.spec.js b/tests/expression_statement/jsfmt.spec.js index 67caec390..486444aac 100755 --- a/tests/expression_statement/jsfmt.spec.js +++ b/tests/expression_statement/jsfmt.spec.js @@ -1,2 +1,2 @@ // TODO: Re-enable Flow when the following fix is merged facebook/flow#3234. -run_spec(__dirname, {parser: 'babylon'}); +run_spec(__dirname, { parser: "babylon" }); diff --git a/tests/flow/async_iteration/__snapshots__/jsfmt.spec.js.snap b/tests/flow/async_iteration/__snapshots__/jsfmt.spec.js.snap index 5849be1b9..5a62f4532 100644 --- a/tests/flow/async_iteration/__snapshots__/jsfmt.spec.js.snap +++ b/tests/flow/async_iteration/__snapshots__/jsfmt.spec.js.snap @@ -57,63 +57,6 @@ async function* delegate_return() { " `; -exports[`delegate_yield.js 2`] = ` -"async function *delegate_next() { - async function *inner() { - var x: void = yield; // error: number ~> void - } - yield *inner(); -} -delegate_next().next(0); - -async function *delegate_yield() { - async function *inner() { - yield 0; - } - yield *inner(); -} -(async () => { - for await (const x of delegate_yield()) { - (x: void); // error: number ~> void - } -}); - -async function *delegate_return() { - async function *inner() { - return 0; - } - var x: void = yield *inner(); // error: number ~> void -} -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -async function* delegate_next() { - async function* inner() { - var x: void = yield; // error: number ~> void - } - yield* inner(); -} -delegate_next().next(0); - -async function* delegate_yield() { - async function* inner() { - yield 0; - } - yield* inner(); -} -async () => { - for await (const x of delegate_yield()) { - (x: void); // error: number ~> void - } -}; - -async function* delegate_return() { - async function* inner() { - return 0; - } - var x: void = yield* inner(); // error: number ~> void -} -" -`; - exports[`generator.js 1`] = ` "declare interface File { readLine(): Promise; @@ -169,61 +112,6 @@ async function f() { " `; -exports[`generator.js 2`] = ` -"declare interface File { - readLine(): Promise; - close(): void; - EOF: boolean; -} - -declare function fileOpen(path: string): Promise; - -async function* readLines(path) { - let file: File = await fileOpen(path); - - try { - while (!file.EOF) { - yield await file.readLine(); - } - } finally { - file.close(); - } -} - -async function f() { - for await (const line of readLines(\\"/path/to/file\\")) { - (line: void); // error: string ~> void - } -} -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -declare interface File { - readLine(): Promise, - close(): void, - EOF: boolean -} - -declare function fileOpen(path: string): Promise; - -async function* readLines(path) { - let file: File = await fileOpen(path); - - try { - while (!file.EOF) { - yield await file.readLine(); - } - } finally { - file.close(); - } -} - -async function f() { - for await (const line of readLines(\\"/path/to/file\\")) { - (line: void); // error: string ~> void - } -} -" -`; - exports[`return.js 1`] = ` "declare var gen: AsyncGenerator; @@ -273,55 +161,6 @@ refuse_return().return(\\"string\\").then(result => { " `; -exports[`return.js 2`] = ` -"declare var gen: AsyncGenerator; - -// You can pass whatever you like to return, it doesn't need to be related to -// the AsyncGenerator's return type -gen.return(0).then(result => { - (result.value: void); // error: string | number ~> void -}); - -// However, a generator can \\"refuse\\" the return by catching an exception and -// yielding or returning internally. -async function *refuse_return() { - try { - yield 1; - } finally { - return 0; - } -} -refuse_return().return(\\"string\\").then(result => { - if (result.done) { - (result.value: string); // error: number | void ~> string - } -}); -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -declare var gen: AsyncGenerator; - -// You can pass whatever you like to return, it doesn't need to be related to -// the AsyncGenerator's return type -gen.return(0).then(result => { - (result.value: void); // error: string | number ~> void -}); - -// However, a generator can \\"refuse\\" the return by catching an exception and -// yielding or returning internally. -async function* refuse_return() { - try { - yield 1; - } finally { - return 0; - } -} -refuse_return().return(\\"string\\").then(result => { - if (result.done) { - (result.value: string); // error: number | void ~> string - } -}); -" -`; - exports[`throw.js 1`] = ` "async function *catch_return() { try { @@ -390,72 +229,3 @@ async () => { }; " `; - -exports[`throw.js 2`] = ` -"async function *catch_return() { - try { - yield 0; - } catch (e) { - return e; - } -} - -(async () => { - catch_return().throw(\\"\\").then(({value}) => { - if (value !== undefined) { - (value: void); // error: number ~> void - } - }); -}); - -async function *yield_return() { - try { - yield 0; - return; - } catch (e) { - yield e; - } -} - -(async () => { - yield_return().throw(\\"\\").then(({value}) => { - if (value !== undefined) { - (value: void); // error: number ~> void - } - }); -}); -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -async function* catch_return() { - try { - yield 0; - } catch (e) { - return e; - } -} - -async () => { - catch_return().throw(\\"\\").then(({ value }) => { - if (value !== undefined) { - (value: void); // error: number ~> void - } - }); -}; - -async function* yield_return() { - try { - yield 0; - return; - } catch (e) { - yield e; - } -} - -async () => { - yield_return().throw(\\"\\").then(({ value }) => { - if (value !== undefined) { - (value: void); // error: number ~> void - } - }); -}; -" -`; diff --git a/tests/flow/async_iteration/jsfmt.spec.js b/tests/flow/async_iteration/jsfmt.spec.js index cd6102665..1840e9d36 100644 --- a/tests/flow/async_iteration/jsfmt.spec.js +++ b/tests/flow/async_iteration/jsfmt.spec.js @@ -1,2 +1 @@ -run_spec(__dirname); -run_spec(__dirname, { parser: 'babylon' }); +run_spec(__dirname, null, ["babylon"]); diff --git a/tests/flow/def_site_variance/__snapshots__/jsfmt.spec.js.snap b/tests/flow/def_site_variance/__snapshots__/jsfmt.spec.js.snap index b567bb066..954911aa7 100644 --- a/tests/flow/def_site_variance/__snapshots__/jsfmt.spec.js.snap +++ b/tests/flow/def_site_variance/__snapshots__/jsfmt.spec.js.snap @@ -67,71 +67,3 @@ class PropVariance<+Out, -In> { } " `; - -exports[`test.js 2`] = ` -"class Variance<+Out,-In> { - foo(x: Out): Out { return x; } - bar(y: In): In { return y; } -} - -class A { } -class B extends A { } - -function subtyping( - v1: Variance, - v2: Variance -) { - (v1: Variance); // error on both targs (A ~/~> B) - (v2: Variance); // OK for both targs (B ~> A) -} - -class PropVariance<+Out,-In> { - inv1: Out; // error - inv2: In; // error - -co1: Out; // error - -co2: In; // ok - +con1: Out; // ok - +con2: In; // error - - inv_dict1: {[k:string]: Out}; // error - inv_dict2: {[k:string]: In}; // error - co_dict1: {+[k:string]: Out}; // ok - co_dict2: {+[k:string]: In}; // error - con_dict1: {-[k:string]: Out}; // error - con_dict2: {-[k:string]: In}; // ok -} -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -class Variance<+Out, -In> { - foo(x: Out): Out { - return x; - } - bar(y: In): In { - return y; - } -} - -class A {} -class B extends A {} - -function subtyping(v1: Variance, v2: Variance) { - (v1: Variance); // error on both targs (A ~/~> B) - (v2: Variance); // OK for both targs (B ~> A) -} - -class PropVariance<+Out, -In> { - inv1: Out; // error - inv2: In; // error - -co1: Out; // error - -co2: In; // ok - +con1: Out; // ok - +con2: In; // error - - inv_dict1: { [k: string]: Out }; // error - inv_dict2: { [k: string]: In }; // error - co_dict1: { +[k: string]: Out }; // ok - co_dict2: { +[k: string]: In }; // error - con_dict1: { -[k: string]: Out }; // error - con_dict2: { -[k: string]: In }; // ok -} -" -`; diff --git a/tests/flow/def_site_variance/jsfmt.spec.js b/tests/flow/def_site_variance/jsfmt.spec.js index cd6102665..1840e9d36 100644 --- a/tests/flow/def_site_variance/jsfmt.spec.js +++ b/tests/flow/def_site_variance/jsfmt.spec.js @@ -1,2 +1 @@ -run_spec(__dirname); -run_spec(__dirname, { parser: 'babylon' }); +run_spec(__dirname, null, ["babylon"]); diff --git a/tests/flow/dictionary/__snapshots__/jsfmt.spec.js.snap b/tests/flow/dictionary/__snapshots__/jsfmt.spec.js.snap index 167d93a60..e73ef3f1e 100644 --- a/tests/flow/dictionary/__snapshots__/jsfmt.spec.js.snap +++ b/tests/flow/dictionary/__snapshots__/jsfmt.spec.js.snap @@ -15,21 +15,6 @@ const val: string = dict[k]; // error: number incompatible with string " `; -exports[`any.js 2`] = ` -"/* @flow */ - -const dict: {[key: string]: number} = {} -const k: any = 'foo' -const val: string = dict[k] // error: number incompatible with string -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -/* @flow */ - -const dict: { [key: string]: number } = {}; -const k: any = \\"foo\\"; -const val: string = dict[k]; // error: number incompatible with string -" -`; - exports[`compatible.js 1`] = ` "/* @flow */ @@ -67,43 +52,6 @@ function foo2( " `; -exports[`compatible.js 2`] = ` -"/* @flow */ - -function foo0(x: Array<{[key: string]: mixed}>): Array<{[key: string]: mixed}> { - // this adds a fooBar property to the param type, which should NOT cause - // an error in the return type because it is a dictionary. - x[0].fooBar = 'foobar'; - return x; -} - -function foo2( - x: {[key: string]: number} -): {[key: string]: number, +toString: () => string} { - // x's prototype has a toString method - return x; -} -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -/* @flow */ - -function foo0( - x: Array<{ [key: string]: mixed }> -): Array<{ [key: string]: mixed }> { - // this adds a fooBar property to the param type, which should NOT cause - // an error in the return type because it is a dictionary. - x[0].fooBar = \\"foobar\\"; - return x; -} - -function foo2( - x: { [key: string]: number } -): { [key: string]: number, +toString: () => string } { - // x's prototype has a toString method - return x; -} -" -`; - exports[`dictionary.js 1`] = ` "/* Dictionary types are object types that include an indexer, which specifies a * key type and a value type. The presence of an indexer makes the object type @@ -704,606 +652,6 @@ function subtype_optional_c_to_dict(x: { p?: C }): { [k: string]: B } { " `; -exports[`dictionary.js 2`] = ` -"/* Dictionary types are object types that include an indexer, which specifies a - * key type and a value type. The presence of an indexer makes the object type - * unsealed, but all added properties must be consistent with the indexer - * signature. - * - * Dictionaries can be used to represent the common idiom of objects used as - * maps. They can also be used to represent array-like objects, e.g., NodeList - * from the DOM API. - * - * A dictionary is assumed to have every property described by it's key type. - * This behavior is similar to the behavior of arrays, which are assumed to have - * a value at every index. - * - * @flow - */ - -// Some logic is variance-sensitive. -class A {} -class B extends A {} -class C extends B {} - -// Just a couple of short type names. Compare to string/number. -class X {} -class Y {} - -// Any property can be set on a dict with string keys. -function set_prop_to_string_key( - o: {[k:string]:any}, -) { - o.prop = \\"ok\\"; -} - -// **UNSOUND** -// This is allowed by design. We don't track get/set and we don't wrap the -// return type in a maybe. -function unsound_dict_has_every_key( - o: {[k:string]:X}, -) { - (o.p: X); // ok - (o[\\"p\\"]: X); // ok -} - -// As with any object type, we can assign subtypes to properties. -function set_prop_covariant( - o: {[k:string]:B}, -) { - o.p = new A; // error, A ~> B - o.p = new B; // ok - o.p = new C; // ok -} - -// This isn't specific behavior to dictionaries, but for completeness... -function get_prop_contravariant( - o: {[k:string]:B}, -) { - (o.p: A); // ok - (o.p: B); // ok - (o.p: C); // error, C ~> B -} - -// Dot-notation can not be used to add properties to dictionaries with -// non-string keys, because keys are strings. -function add_prop_to_nonstring_key_dot( - o: {[k:number]:any}, -) { - o.prop = \\"err\\"; // error: string ~> number -} - -// Bracket notation can be used to add properties to dictionaries with -// non-string keys, even though all keys are strings. This is a convenient -// affordance. -function add_prop_to_nonstring_key_bracket( - o: {[k:number]:any}, -) { - o[0] = \\"ok\\"; -} - -// Objects can be part dict, part not by mixing an indexer with declared props. -function mix_with_declared_props( - o: {[k:number]:X,p:Y}, - x: X, - y: Y, -) { - (o[0]: X); // ok - (o.p: Y); // ok - o[0] = x; // ok - o.p = y; // ok -} - -// Indeed, dict types are still Objects and have Object.prototype stuff -function object_prototype( - o: {[k:string]:number}, -): {[k:string]:number, +toString: () => string} { - (o.toString(): boolean); // error: string ~> boolean - return o; // ok -} - -// **UNSOUND** -// Because we support non-string props w/ bracket notation, it's possible to -// write into a declared prop unsoundly. -function unsound_string_conversion_alias_declared_prop( - o: {[k:number]:any, \\"0\\":X}, -) { - o[0] = \\"not-x\\"; // a[\\"0\\"] no longer X -} - -function unification_dict_values_invariant( - x: Array<{[k:string]:B}>, -) { - let a: Array<{[k:string]:A}> = x; // error - a[0].p = new A; // in[0].p no longer B - - let b: Array<{[k:string]:B}> = x; // ok - - let c: Array<{[k:string]:C}> = x; // error - (x[0].p: C); // not true -} - -function subtype_dict_values_invariant( - x: {[k:string]:B}, -) { - let a: {[k:string]:A} = x; // error - a.p = new A; // x[0].p no longer B - - let b: {[k:string]:B} = x; // ok - - let c: {[k:string]:C} = x; // error - (x.p: C); // not true -} - -function subtype_dict_values_fresh_exception() { - let a: {[k:string]:A} = { - a: new A, // ok, A == A - b: new B, // ok, B <: A - c: new C, // ok, C <: A - }; - - let b: {[k:string]:B} = { - a: new A, // error, A not <: B - b: new B, // ok, B == B - c: new C, // ok, C <: A - }; - - let c: {[k:string]:C} = { - a: new A, // error, A not <: C - b: new B, // error, A not <: C - c: new C, // ok, C == C - }; -} - -// Actually, unsound_string_conversion_alias_declared_prop behavior makes an -// argument that we shouldn't really care about this, since we ignore the fact -// that coercing values to string keys can cause unintended aliasing in general. -// Barring some compelling use case for that in this context, though, we choose -// to be strict. -function unification_dict_keys_invariant( - x: Array<{[k:B]:any}>, -) { - let a: Array<{[k:A]:any}> = x; // error - let b: Array<{[k:B]:any}> = x; // ok - let c: Array<{[k:C]:any}> = x; // error -} - -function subtype_dict_keys_invariant( - x: {[k:B]:any}, -) { - let a: {[k:A]:any} = x; // error - let b: {[k:B]:any} = x; // ok - let c: {[k:C]:any} = x; // error -} - -function unification_mix_with_declared_props_invariant_l( - x: Array<{[k:string]:B}>, -) { - let a: Array<{[k:string]:B, p:A}> = x; // error: A ~> B - a[0].p = new A; // x[0].p no longer B - - let b: Array<{[k:string]:B, p:B}> = x; // ok - - let c: Array<{[k:string]:B, p:C}> = x; // error - (x[0].p: C); // not true -} - -function unification_mix_with_declared_props_invariant_r( - xa: Array<{[k:string]:A, p:B}>, - xb: Array<{[k:string]:B, p:B}>, - xc: Array<{[k:string]:C, p:B}>, -) { - let a: Array<{[k:string]:A}> = xa; // error - a[0].p = new A; // xa[0].p no longer B - - let b: Array<{[k:string]:B}> = xb; // ok - - let c: Array<{[k:string]:C}> = xc; // error - (xc[0].p: C); // not true -} - -function subtype_mix_with_declared_props_invariant_l( - x: {[k:string]:B}, -) { - let a: {[k:string]:B, p:A} = x; // error: A ~> B - a.p = new A; // x.p no longer B - - let b: {[k:string]:B, p:B} = x; // ok - - let c: {[k:string]:B, p:C} = x; // error - (x.p: C); // not true -} - -function subtype_mix_with_declared_props_invariant_r( - xa: {[k:string]:A, p:B}, - xb: {[k:string]:B, p:B}, - xc: {[k:string]:C, p:B}, -) { - let a: {[k:string]:A} = xa; // error - a.p = new A; // xa.p no longer B - - let b: {[k:string]:B} = xb; // ok - - let c: {[k:string]:C} = xc; // error - (xc.p: C); // not true -} - -function unification_dict_to_obj( - x: Array<{[k:string]:X}>, -): Array<{p:X}> { - return x; // error: if allowed, could write {p:X,q:Y} into \`x\` -} - -function unification_obj_to_dict( - x: Array<{p:X}>, -): Array<{[k:string]:X}> { - return x; // error: if allowed, could write {p:X,q:Y} into returned array -} - -function subtype_dict_to_obj( - x: {[k:string]:B}, -) { - let a: {p:A} = x; // error - a.p = new A; // x.p no longer B - - let b: {p:B} = x; // ok - - let c: {p:C} = x; // error - (x.p: C); // not true -} - -function subtype_obj_to_dict( - x: {p:B}, -) { - let a: {[k:string]:A} = x; // error - a.p = new A; // x.p no longer B - - let b: {[k:string]:B} = x; - - let c: {[k:string]:C} = x; // error - (x.p: C); // not true -} - -// Only props in l which are not in u must match indexer, but must do so -// exactly. -function subtype_obj_to_mixed( - x: {p:B, x:X}, -) { - let a: {[k:string]:A,x:X} = x; // error (as above), but exclusive of x - let b: {[k:string]:B,x:X} = x; // ok, - let c: {[k:string]:C,x:X} = x; // error (as above), but exclusive of x -} - -function unification_dict_to_mixed( - x: Array<{[k:string]:B}>, -) { - let a: Array<{[k:string]:B, p:A}> = x; // error - let b: Array<{[k:string]:B, p:B}> = x; // ok - let c: Array<{[k:string]:B, p:C}> = x; // error -} - -function subtype_dict_to_mixed( - x: {[k:string]:B}, -) { - let a: {[k:string]:B, p:A} = x; // error - let b: {[k:string]:B, p:B} = x; // ok - let c: {[k:string]:B, p:C} = x; // error -} - -function subtype_dict_to_optional_a( - x: {[k:string]:B}, -) { - let a: {p?:A} = x; // error -} - -function subtype_dict_to_optional_b( - x: {[k:string]:B}, -) { - let b: {p?:B} = x; // ok -} - -function subtype_dict_to_optional_c( - x: {[k:string]:B}, -) { - let c: {p?:C} = x; // error -} - -function subtype_optional_a_to_dict( - x: {p?:A}, -): {[k:string]:B} { // error: A ~> B - return x; -} - -function subtype_optional_b_to_dict( - x: {p?:B}, -): {[k:string]:B} { // ok - return x; -} - -function subtype_optional_c_to_dict( - x: {p?:C}, -): {[k:string]:B} { // error: C ~> B - return x; -} -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -/* Dictionary types are object types that include an indexer, which specifies a - * key type and a value type. The presence of an indexer makes the object type - * unsealed, but all added properties must be consistent with the indexer - * signature. - * - * Dictionaries can be used to represent the common idiom of objects used as - * maps. They can also be used to represent array-like objects, e.g., NodeList - * from the DOM API. - * - * A dictionary is assumed to have every property described by it's key type. - * This behavior is similar to the behavior of arrays, which are assumed to have - * a value at every index. - * - * @flow - */ - -// Some logic is variance-sensitive. -class A {} -class B extends A {} -class C extends B {} - -// Just a couple of short type names. Compare to string/number. -class X {} -class Y {} - -// Any property can be set on a dict with string keys. -function set_prop_to_string_key(o: { [k: string]: any }) { - o.prop = \\"ok\\"; -} - -// **UNSOUND** -// This is allowed by design. We don't track get/set and we don't wrap the -// return type in a maybe. -function unsound_dict_has_every_key(o: { [k: string]: X }) { - (o.p: X); // ok - (o[\\"p\\"]: X); // ok -} - -// As with any object type, we can assign subtypes to properties. -function set_prop_covariant(o: { [k: string]: B }) { - o.p = new A(); // error, A ~> B - o.p = new B(); // ok - o.p = new C(); // ok -} - -// This isn't specific behavior to dictionaries, but for completeness... -function get_prop_contravariant(o: { [k: string]: B }) { - (o.p: A); // ok - (o.p: B); // ok - (o.p: C); // error, C ~> B -} - -// Dot-notation can not be used to add properties to dictionaries with -// non-string keys, because keys are strings. -function add_prop_to_nonstring_key_dot(o: { [k: number]: any }) { - o.prop = \\"err\\"; // error: string ~> number -} - -// Bracket notation can be used to add properties to dictionaries with -// non-string keys, even though all keys are strings. This is a convenient -// affordance. -function add_prop_to_nonstring_key_bracket(o: { [k: number]: any }) { - o[0] = \\"ok\\"; -} - -// Objects can be part dict, part not by mixing an indexer with declared props. -function mix_with_declared_props(o: { [k: number]: X, p: Y }, x: X, y: Y) { - (o[0]: X); // ok - (o.p: Y); // ok - o[0] = x; // ok - o.p = y; // ok -} - -// Indeed, dict types are still Objects and have Object.prototype stuff -function object_prototype( - o: { [k: string]: number } -): { [k: string]: number, +toString: () => string } { - (o.toString(): boolean); // error: string ~> boolean - return o; // ok -} - -// **UNSOUND** -// Because we support non-string props w/ bracket notation, it's possible to -// write into a declared prop unsoundly. -function unsound_string_conversion_alias_declared_prop( - o: { [k: number]: any, \\"0\\": X } -) { - o[0] = \\"not-x\\"; // a[\\"0\\"] no longer X -} - -function unification_dict_values_invariant(x: Array<{ [k: string]: B }>) { - let a: Array<{ [k: string]: A }> = x; // error - a[0].p = new A(); // in[0].p no longer B - - let b: Array<{ [k: string]: B }> = x; // ok - - let c: Array<{ [k: string]: C }> = x; // error - (x[0].p: C); // not true -} - -function subtype_dict_values_invariant(x: { [k: string]: B }) { - let a: { [k: string]: A } = x; // error - a.p = new A(); // x[0].p no longer B - - let b: { [k: string]: B } = x; // ok - - let c: { [k: string]: C } = x; // error - (x.p: C); // not true -} - -function subtype_dict_values_fresh_exception() { - let a: { [k: string]: A } = { - a: new A(), // ok, A == A - b: new B(), // ok, B <: A - c: new C() // ok, C <: A - }; - - let b: { [k: string]: B } = { - a: new A(), // error, A not <: B - b: new B(), // ok, B == B - c: new C() // ok, C <: A - }; - - let c: { [k: string]: C } = { - a: new A(), // error, A not <: C - b: new B(), // error, A not <: C - c: new C() // ok, C == C - }; -} - -// Actually, unsound_string_conversion_alias_declared_prop behavior makes an -// argument that we shouldn't really care about this, since we ignore the fact -// that coercing values to string keys can cause unintended aliasing in general. -// Barring some compelling use case for that in this context, though, we choose -// to be strict. -function unification_dict_keys_invariant(x: Array<{ [k: B]: any }>) { - let a: Array<{ [k: A]: any }> = x; // error - let b: Array<{ [k: B]: any }> = x; // ok - let c: Array<{ [k: C]: any }> = x; // error -} - -function subtype_dict_keys_invariant(x: { [k: B]: any }) { - let a: { [k: A]: any } = x; // error - let b: { [k: B]: any } = x; // ok - let c: { [k: C]: any } = x; // error -} - -function unification_mix_with_declared_props_invariant_l( - x: Array<{ [k: string]: B }> -) { - let a: Array<{ [k: string]: B, p: A }> = x; // error: A ~> B - a[0].p = new A(); // x[0].p no longer B - - let b: Array<{ [k: string]: B, p: B }> = x; // ok - - let c: Array<{ [k: string]: B, p: C }> = x; // error - (x[0].p: C); // not true -} - -function unification_mix_with_declared_props_invariant_r( - xa: Array<{ [k: string]: A, p: B }>, - xb: Array<{ [k: string]: B, p: B }>, - xc: Array<{ [k: string]: C, p: B }> -) { - let a: Array<{ [k: string]: A }> = xa; // error - a[0].p = new A(); // xa[0].p no longer B - - let b: Array<{ [k: string]: B }> = xb; // ok - - let c: Array<{ [k: string]: C }> = xc; // error - (xc[0].p: C); // not true -} - -function subtype_mix_with_declared_props_invariant_l(x: { [k: string]: B }) { - let a: { [k: string]: B, p: A } = x; // error: A ~> B - a.p = new A(); // x.p no longer B - - let b: { [k: string]: B, p: B } = x; // ok - - let c: { [k: string]: B, p: C } = x; // error - (x.p: C); // not true -} - -function subtype_mix_with_declared_props_invariant_r( - xa: { [k: string]: A, p: B }, - xb: { [k: string]: B, p: B }, - xc: { [k: string]: C, p: B } -) { - let a: { [k: string]: A } = xa; // error - a.p = new A(); // xa.p no longer B - - let b: { [k: string]: B } = xb; // ok - - let c: { [k: string]: C } = xc; // error - (xc.p: C); // not true -} - -function unification_dict_to_obj( - x: Array<{ [k: string]: X }> -): Array<{ p: X }> { - return x; // error: if allowed, could write {p:X,q:Y} into \`x\` -} - -function unification_obj_to_dict( - x: Array<{ p: X }> -): Array<{ [k: string]: X }> { - return x; // error: if allowed, could write {p:X,q:Y} into returned array -} - -function subtype_dict_to_obj(x: { [k: string]: B }) { - let a: { p: A } = x; // error - a.p = new A(); // x.p no longer B - - let b: { p: B } = x; // ok - - let c: { p: C } = x; // error - (x.p: C); // not true -} - -function subtype_obj_to_dict(x: { p: B }) { - let a: { [k: string]: A } = x; // error - a.p = new A(); // x.p no longer B - - let b: { [k: string]: B } = x; - - let c: { [k: string]: C } = x; // error - (x.p: C); // not true -} - -// Only props in l which are not in u must match indexer, but must do so -// exactly. -function subtype_obj_to_mixed(x: { p: B, x: X }) { - let a: { [k: string]: A, x: X } = x; // error (as above), but exclusive of x - let b: { [k: string]: B, x: X } = x; // ok, - let c: { [k: string]: C, x: X } = x; // error (as above), but exclusive of x -} - -function unification_dict_to_mixed(x: Array<{ [k: string]: B }>) { - let a: Array<{ [k: string]: B, p: A }> = x; // error - let b: Array<{ [k: string]: B, p: B }> = x; // ok - let c: Array<{ [k: string]: B, p: C }> = x; // error -} - -function subtype_dict_to_mixed(x: { [k: string]: B }) { - let a: { [k: string]: B, p: A } = x; // error - let b: { [k: string]: B, p: B } = x; // ok - let c: { [k: string]: B, p: C } = x; // error -} - -function subtype_dict_to_optional_a(x: { [k: string]: B }) { - let a: { p?: A } = x; // error -} - -function subtype_dict_to_optional_b(x: { [k: string]: B }) { - let b: { p?: B } = x; // ok -} - -function subtype_dict_to_optional_c(x: { [k: string]: B }) { - let c: { p?: C } = x; // error -} - -function subtype_optional_a_to_dict(x: { p?: A }): { [k: string]: B } { - // error: A ~> B - return x; -} - -function subtype_optional_b_to_dict(x: { p?: B }): { [k: string]: B } { - // ok - return x; -} - -function subtype_optional_c_to_dict(x: { p?: C }): { [k: string]: B } { - // error: C ~> B - return x; -} -" -`; - exports[`incompatible.js 1`] = ` "/* @flow */ @@ -1427,129 +775,6 @@ function foo8(x: { [key: string]: number }) { " `; -exports[`incompatible.js 2`] = ` -"/* @flow */ - -var x : {[key: string]: string} = {}; -var y : {[key: string]: number} = x; // 2 errors, number !~> string & vice versa -var z : {[key: number]: string} = x; // 2 errors, string !~> number & vice versa - -var a : {[key: string]: ?string} = {}; -var b : {[key: string]: string} = a; // 2 errors (null & undefined) -var c : {[key: string]: ?string} = b; // 2 errors, since c['x'] = null updates b - -// 2 errors (number !~> string, string !~> number) -function foo0(x: Array<{[key: string]: number}>): Array<{[key: string]: string}> { - return x; -} - -// error, fooBar:string !~> number (x's dictionary) -function foo1( - x: Array<{[key: string]: number}> -): Array<{[key: string]: number, fooBar: string}> { - return x; -} - -function foo2( - x: Array<{[key: string]: mixed}> -): Array<{[key: string]: mixed, fooBar: string}> { - x[0].fooBar = 123; // OK, since number ~> mixed (x elem's dictionary) - return x; // error: mixed ~> string -} - -// OK, since we assume dictionaries have every key -function foo3(x: {[key: string]: number}): {foo: number} { - return x; -} - -// error: foo can't exist in x -function foo4(x: {[key: string]: number}): {[key: string]: number, foo: string} { - return x; -} - -// error, some prop in x could be incompatible (covariance) -function foo5(x: Array<{[key: string]: number}>): Array<{foo: number}> { - return x; -} - -// error, some prop in return could be incompatible -function foo6(x: Array<{foo: number}>): Array<{[key: string]: number}> { - return x; -} - -function foo7(x: {bar: string, [key: string]: number}) { - (x.bar: string); -} - -function foo8(x: {[key: string]: number}) { - (x.foo: string); // error - (x.foo: number); -} -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -/* @flow */ - -var x: { [key: string]: string } = {}; -var y: { [key: string]: number } = x; // 2 errors, number !~> string & vice versa -var z: { [key: number]: string } = x; // 2 errors, string !~> number & vice versa - -var a: { [key: string]: ?string } = {}; -var b: { [key: string]: string } = a; // 2 errors (null & undefined) -var c: { [key: string]: ?string } = b; // 2 errors, since c['x'] = null updates b - -// 2 errors (number !~> string, string !~> number) -function foo0( - x: Array<{ [key: string]: number }> -): Array<{ [key: string]: string }> { - return x; -} - -// error, fooBar:string !~> number (x's dictionary) -function foo1( - x: Array<{ [key: string]: number }> -): Array<{ [key: string]: number, fooBar: string }> { - return x; -} - -function foo2( - x: Array<{ [key: string]: mixed }> -): Array<{ [key: string]: mixed, fooBar: string }> { - x[0].fooBar = 123; // OK, since number ~> mixed (x elem's dictionary) - return x; // error: mixed ~> string -} - -// OK, since we assume dictionaries have every key -function foo3(x: { [key: string]: number }): { foo: number } { - return x; -} - -// error: foo can't exist in x -function foo4( - x: { [key: string]: number } -): { [key: string]: number, foo: string } { - return x; -} - -// error, some prop in x could be incompatible (covariance) -function foo5(x: Array<{ [key: string]: number }>): Array<{ foo: number }> { - return x; -} - -// error, some prop in return could be incompatible -function foo6(x: Array<{ foo: number }>): Array<{ [key: string]: number }> { - return x; -} - -function foo7(x: { [key: string]: number, bar: string }) { - (x.bar: string); -} - -function foo8(x: { [key: string]: number }) { - (x.foo: string); // error - (x.foo: number); -} -" -`; - exports[`issue-1745.js 1`] = ` "/* @flow */ @@ -1605,61 +830,6 @@ class B { " `; -exports[`issue-1745.js 2`] = ` -"/* @flow */ - -class A { - x: {[k:string]: number}; - - m1() { - this.x = { bar: 0 }; // no error - } - - m2() { - this.x.foo = 0; // no error - } -} - -class B { - x: {[k:string]: number}; - - m2() { - this.x.foo = 0; // no error - } - - m1() { - this.x = { bar: 0 }; // no error - } -} -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -/* @flow */ - -class A { - x: { [k: string]: number }; - - m1() { - this.x = { bar: 0 }; // no error - } - - m2() { - this.x.foo = 0; // no error - } -} - -class B { - x: { [k: string]: number }; - - m2() { - this.x.foo = 0; // no error - } - - m1() { - this.x = { bar: 0 }; // no error - } -} -" -`; - exports[`test.js 1`] = ` "type Params = {count: number; [name: string]: string}; type QueryFunction = (params: Params) => string; @@ -1685,31 +855,6 @@ module.exports = o; " `; -exports[`test.js 2`] = ` -"type Params = {count: number; [name: string]: string}; -type QueryFunction = (params: Params) => string; - -var o: { foo: QueryFunction } = { - foo(params) { - return params.count; // error, number ~/~ string - } -}; - -module.exports = o; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -type Params = { [name: string]: string, count: number }; -type QueryFunction = (params: Params) => string; - -var o: { foo: QueryFunction } = { - foo(params) { - return params.count; // error, number ~/~ string - } -}; - -module.exports = o; -" -`; - exports[`test_client.js 1`] = ` "var o = require('./test'); @@ -1724,18 +869,3 @@ o.foo = function(params) { }; " `; - -exports[`test_client.js 2`] = ` -"var o = require('./test'); - -o.foo = function (params) { - return params.count; // error, number ~/~ string -} -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -var o = require(\\"./test\\"); - -o.foo = function(params) { - return params.count; // error, number ~/~ string -}; -" -`; diff --git a/tests/flow/dictionary/jsfmt.spec.js b/tests/flow/dictionary/jsfmt.spec.js index cd6102665..1840e9d36 100644 --- a/tests/flow/dictionary/jsfmt.spec.js +++ b/tests/flow/dictionary/jsfmt.spec.js @@ -1,2 +1 @@ -run_spec(__dirname); -run_spec(__dirname, { parser: 'babylon' }); +run_spec(__dirname, null, ["babylon"]); diff --git a/tests/flow/getters_and_setters_enabled/__snapshots__/jsfmt.spec.js.snap b/tests/flow/getters_and_setters_enabled/__snapshots__/jsfmt.spec.js.snap index ee4ec2e1f..4e80b1e76 100644 --- a/tests/flow/getters_and_setters_enabled/__snapshots__/jsfmt.spec.js.snap +++ b/tests/flow/getters_and_setters_enabled/__snapshots__/jsfmt.spec.js.snap @@ -133,139 +133,6 @@ foo.propOverriddenWithSetter = 123; // Error number ~> string " `; -exports[`class.js 2`] = ` -"/** - * @flow - */ - -var z: number = 123; - -class Foo { - get goodGetterNoAnnotation() { return 4; } - get goodGetterWithAnnotation(): number { return 4; } - - set goodSetterNoAnnotation(x) { z = x; } - set goodSetterWithAnnotation(x: number) { z = x; } - - get propWithMatchingGetterAndSetter(): number { return 4; } - set propWithMatchingGetterAndSetter(x: number) { } - - // The getter and setter need not have the same type - no error - get propWithSubtypingGetterAndSetter(): ?number { return 4; } - set propWithSubtypingGetterAndSetter(x: number) { } - - // The getter and setter need not have the same type - no error - set propWithSubtypingGetterAndSetterReordered(x: number) { } - get propWithSubtypingGetterAndSetterReordered(): ?number { return 4; } - - get propWithMismatchingGetterAndSetter(): number { return 4; } - set propWithMismatchingGetterAndSetter(x: string) { } // doesn't match getter (OK) - - propOverriddenWithGetter: number; - get propOverriddenWithGetter() { return \\"hello\\"; } - - propOverriddenWithSetter: number; - set propOverriddenWithSetter(x: string) { } -}; - -var foo = new Foo(); - -// Test getting properties with getters -var testGetterNoError1: number = foo.goodGetterNoAnnotation; -var testGetterNoError2: number = foo.goodGetterWithAnnotation; - -var testGetterWithError1: string = foo.goodGetterNoAnnotation; // Error number ~> string -var testGetterWithError2: string = foo.goodGetterWithAnnotation; // Error number ~> string - -// Test setting properties with getters -foo.goodSetterNoAnnotation = 123; -foo.goodSetterWithAnnotation = 123; - -// TODO: Why does no annotation mean no error? -foo.goodSetterNoAnnotation = \\"hello\\"; // Error string ~> number -foo.goodSetterWithAnnotation = \\"hello\\"; // Error string ~> number - -var testSubtypingGetterAndSetter: number = foo.propWithSubtypingGetterAndSetter; // Error ?number ~> number - -var testPropOverridenWithGetter: number = foo.propOverriddenWithGetter; // Error string ~> number -foo.propOverriddenWithSetter = 123; // Error number ~> string -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -/** - * @flow - */ - -var z: number = 123; - -class Foo { - get goodGetterNoAnnotation() { - return 4; - } - get goodGetterWithAnnotation(): number { - return 4; - } - - set goodSetterNoAnnotation(x) { - z = x; - } - set goodSetterWithAnnotation(x: number) { - z = x; - } - - get propWithMatchingGetterAndSetter(): number { - return 4; - } - set propWithMatchingGetterAndSetter(x: number) {} - - // The getter and setter need not have the same type - no error - get propWithSubtypingGetterAndSetter(): ?number { - return 4; - } - set propWithSubtypingGetterAndSetter(x: number) {} - - // The getter and setter need not have the same type - no error - set propWithSubtypingGetterAndSetterReordered(x: number) {} - get propWithSubtypingGetterAndSetterReordered(): ?number { - return 4; - } - - get propWithMismatchingGetterAndSetter(): number { - return 4; - } - set propWithMismatchingGetterAndSetter(x: string) {} // doesn't match getter (OK) - - propOverriddenWithGetter: number; - get propOverriddenWithGetter() { - return \\"hello\\"; - } - - propOverriddenWithSetter: number; - set propOverriddenWithSetter(x: string) {} -} - -var foo = new Foo(); - -// Test getting properties with getters -var testGetterNoError1: number = foo.goodGetterNoAnnotation; -var testGetterNoError2: number = foo.goodGetterWithAnnotation; - -var testGetterWithError1: string = foo.goodGetterNoAnnotation; // Error number ~> string -var testGetterWithError2: string = foo.goodGetterWithAnnotation; // Error number ~> string - -// Test setting properties with getters -foo.goodSetterNoAnnotation = 123; -foo.goodSetterWithAnnotation = 123; - -// TODO: Why does no annotation mean no error? -foo.goodSetterNoAnnotation = \\"hello\\"; // Error string ~> number -foo.goodSetterWithAnnotation = \\"hello\\"; // Error string ~> number - -var testSubtypingGetterAndSetter: number = foo.propWithSubtypingGetterAndSetter; // Error ?number ~> number - -var testPropOverridenWithGetter: number = foo.propOverriddenWithGetter; // Error string ~> number -foo.propOverriddenWithSetter = 123; // Error number ~> string -" -`; - exports[`object.js 1`] = ` "/** * @flow @@ -406,146 +273,6 @@ var testExampleOrOrderOfGetterAndSetterReordered: number = obj.exampleOfOrderOfG " `; -exports[`object.js 2`] = ` -"/** - * @flow - */ - -var z: number = 123; - -class A {} -class B extends A {} -class C extends A {} - -var obj = { - get goodGetterNoAnnotation() { return 4; }, - get goodGetterWithAnnotation(): number { return 4; }, - - set goodSetterNoAnnotation(x) { z = x; }, - set goodSetterWithAnnotation(x: number) { z = x; }, - - get propWithMatchingGetterAndSetter(): number { return 4; }, - set propWithMatchingGetterAndSetter(x: number) { }, - - // The getter and setter need not have the same type - get propWithSubtypingGetterAndSetter(): ?number { return 4; }, // OK - set propWithSubtypingGetterAndSetter(x: number) { }, - - set propWithSubtypingGetterAndSetterReordered(x: number) { }, // OK - get propWithSubtypingGetterAndSetterReordered(): ?number { return 4; }, - - get exampleOfOrderOfGetterAndSetter(): A { return new A(); }, - set exampleOfOrderOfGetterAndSetter(x: B) {}, - - set exampleOfOrderOfGetterAndSetterReordered(x: B) {}, - get exampleOfOrderOfGetterAndSetterReordered(): A { return new A(); }, -}; - - - -// Test getting properties with getters -var testGetterNoError1: number = obj.goodGetterNoAnnotation; -var testGetterNoError2: number = obj.goodGetterWithAnnotation; - -var testGetterWithError1: string = obj.goodGetterNoAnnotation; // Error number ~> string -var testGetterWithError2: string = obj.goodGetterWithAnnotation; // Error number ~> string - -// Test setting properties with getters -obj.goodSetterNoAnnotation = 123; -obj.goodSetterWithAnnotation = 123; - -obj.goodSetterNoAnnotation = \\"hello\\"; // Error string ~> number -obj.goodSetterWithAnnotation = \\"hello\\"; // Error string ~> number - -var testSubtypingGetterAndSetter: number = obj.propWithSubtypingGetterAndSetter; // Error ?number ~> number - -// When building this feature, it was tempting to flow the setter into the -// getter and then use either the getter or setter as the type of the property. -// This example shows the danger of using the getter's type -obj.exampleOfOrderOfGetterAndSetter = new C(); // Error C ~> B - -// And this example shows the danger of using the setter's type. -var testExampleOrOrderOfGetterAndSetterReordered: number = - obj.exampleOfOrderOfGetterAndSetterReordered; // Error A ~> B -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -/** - * @flow - */ - -var z: number = 123; - -class A {} -class B extends A {} -class C extends A {} - -var obj = { - get goodGetterNoAnnotation() { - return 4; - }, - get goodGetterWithAnnotation(): number { - return 4; - }, - - set goodSetterNoAnnotation(x) { - z = x; - }, - set goodSetterWithAnnotation(x: number) { - z = x; - }, - - get propWithMatchingGetterAndSetter(): number { - return 4; - }, - set propWithMatchingGetterAndSetter(x: number) {}, - - // The getter and setter need not have the same type - get propWithSubtypingGetterAndSetter(): ?number { - return 4; - }, // OK - set propWithSubtypingGetterAndSetter(x: number) {}, - - set propWithSubtypingGetterAndSetterReordered(x: number) {}, // OK - get propWithSubtypingGetterAndSetterReordered(): ?number { - return 4; - }, - - get exampleOfOrderOfGetterAndSetter(): A { - return new A(); - }, - set exampleOfOrderOfGetterAndSetter(x: B) {}, - - set exampleOfOrderOfGetterAndSetterReordered(x: B) {}, - get exampleOfOrderOfGetterAndSetterReordered(): A { - return new A(); - } -}; - -// Test getting properties with getters -var testGetterNoError1: number = obj.goodGetterNoAnnotation; -var testGetterNoError2: number = obj.goodGetterWithAnnotation; - -var testGetterWithError1: string = obj.goodGetterNoAnnotation; // Error number ~> string -var testGetterWithError2: string = obj.goodGetterWithAnnotation; // Error number ~> string - -// Test setting properties with getters -obj.goodSetterNoAnnotation = 123; -obj.goodSetterWithAnnotation = 123; - -obj.goodSetterNoAnnotation = \\"hello\\"; // Error string ~> number -obj.goodSetterWithAnnotation = \\"hello\\"; // Error string ~> number - -var testSubtypingGetterAndSetter: number = obj.propWithSubtypingGetterAndSetter; // Error ?number ~> number - -// When building this feature, it was tempting to flow the setter into the -// getter and then use either the getter or setter as the type of the property. -// This example shows the danger of using the getter's type -obj.exampleOfOrderOfGetterAndSetter = new C(); // Error C ~> B - -// And this example shows the danger of using the setter's type. -var testExampleOrOrderOfGetterAndSetterReordered: number = obj.exampleOfOrderOfGetterAndSetterReordered; // Error A ~> B -" -`; - exports[`react.js 1`] = ` "/** * @flow @@ -577,37 +304,6 @@ React.createClass({ " `; -exports[`react.js 2`] = ` -"/** - * @flow - */ - -React.createClass({ - propTypes: { - get a() { return 4; }, - set b(x: number) { this.c = x; }, - c: 10, - } -}); -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -/** - * @flow - */ - -React.createClass({ - propTypes: { - get a() { - return 4; - }, - set b(x: number) { - this.c = x; - }, - c: 10 - } -}); -" -`; - exports[`variance.js 1`] = ` "/* @flow */ @@ -768,164 +464,3 @@ class Base { }); " `; - -exports[`variance.js 2`] = ` -"/* @flow */ - -class A {} -class B extends A {} -class C extends B {} - -declare var a: A; -declare var b: B; -declare var c: C; - -class Base { - x: B; - +pos: B; - -neg: B; - get get(): B { return this.x }; - set set(value: B): void { this.x = value }; - get getset(): B { return this.x }; - set getset(value: B): void { this.x = value }; -} - -(class extends Base { - // error: getter incompatible with read/write property - get x(): B { return b } -}); - -(class extends Base { - // error: setter incompatible with read/write property - set x(value: B): void {} -}); - -(class extends Base { - // ok: get/set co/contra with read/write property, resp. - get x(): C { return c } - set x(value: A): void {} -}); - -(class extends Base { - // error: setter incompatible with read-only property - set pos(value: B): void {} -}); - -(class extends Base { - // ok: getter covariant with read-only property - get pos(): C { return c } -}); - -(class extends Base { - // error: getter incompatible with write-only property - get neg(): B { return b } -}); - -(class extends Base { - // ok: setter contravariant with write-only property - set neg(value: A): void {} -}); - -(class extends Base { - // ok: read/write covariant with getter - get: C; -}); - -(class extends Base { - // ok: read/write contravariant with setter - set: A; -}); - -(class extends Base { - // ok: read/write invariant with get/set - getset: B; -}); -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -/* @flow */ - -class A {} -class B extends A {} -class C extends B {} - -declare var a: A; -declare var b: B; -declare var c: C; - -class Base { - x: B; - +pos: B; - -neg: B; - get get(): B { - return this.x; - } - set set(value: B): void { - this.x = value; - } - get getset(): B { - return this.x; - } - set getset(value: B): void { - this.x = value; - } -} - -(class extends Base { - // error: getter incompatible with read/write property - get x(): B { - return b; - } -}); - -(class extends Base { - // error: setter incompatible with read/write property - set x(value: B): void {} -}); - -(class extends Base { - // ok: get/set co/contra with read/write property, resp. - get x(): C { - return c; - } - set x(value: A): void {} -}); - -(class extends Base { - // error: setter incompatible with read-only property - set pos(value: B): void {} -}); - -(class extends Base { - // ok: getter covariant with read-only property - get pos(): C { - return c; - } -}); - -(class extends Base { - // error: getter incompatible with write-only property - get neg(): B { - return b; - } -}); - -(class extends Base { - // ok: setter contravariant with write-only property - set neg(value: A): void {} -}); - -(class extends Base { - // ok: read/write covariant with getter - get: C; -}); - -(class extends Base { - // ok: read/write contravariant with setter - set: A; -}); - -(class extends Base { - // ok: read/write invariant with get/set - getset: B; -}); -" -`; diff --git a/tests/flow/getters_and_setters_enabled/jsfmt.spec.js b/tests/flow/getters_and_setters_enabled/jsfmt.spec.js index cd6102665..1840e9d36 100644 --- a/tests/flow/getters_and_setters_enabled/jsfmt.spec.js +++ b/tests/flow/getters_and_setters_enabled/jsfmt.spec.js @@ -1,2 +1 @@ -run_spec(__dirname); -run_spec(__dirname, { parser: 'babylon' }); +run_spec(__dirname, null, ["babylon"]); diff --git a/tests/flow/more_annot/__snapshots__/jsfmt.spec.js.snap b/tests/flow/more_annot/__snapshots__/jsfmt.spec.js.snap index 7cb819d6d..6862ec586 100644 --- a/tests/flow/more_annot/__snapshots__/jsfmt.spec.js.snap +++ b/tests/flow/more_annot/__snapshots__/jsfmt.spec.js.snap @@ -11,17 +11,6 @@ var a: number = o.w.z.y; " `; -exports[`client_object.js 2`] = ` -"var o = require('./object'); - -var a:number = o.w.z.y; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -var o = require(\\"./object\\"); - -var a: number = o.w.z.y; -" -`; - exports[`object.js 1`] = ` "var o1 = { x: 0, y: \\"\\" }; var o2 = { z: o1 } @@ -45,29 +34,6 @@ module.exports = o3; " `; -exports[`object.js 2`] = ` -"var o1 = { x: 0, y: \\"\\" }; -var o2 = { z: o1 } - -var o3 = {}; -o3.w = o2; - -//declare var exports: { w: any }; - -module.exports = o3; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -var o1 = { x: 0, y: \\"\\" }; -var o2 = { z: o1 }; - -var o3 = {}; -o3.w = o2; - -//declare var exports: { w: any }; - -module.exports = o3; -" -`; - exports[`proto.js 1`] = ` "function Foo() { this.x = 0; } Foo.prototype.m = function() { } @@ -87,25 +53,6 @@ var o2: Foo = new Foo(); " `; -exports[`proto.js 2`] = ` -"function Foo() { this.x = 0; } -Foo.prototype.m = function() { } - -var o1: { x: number; m(): void } = new Foo(); - -var o2: Foo = new Foo(); -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -function Foo() { - this.x = 0; -} -Foo.prototype.m = function() {}; - -var o1: { x: number, m(): void } = new Foo(); - -var o2: Foo = new Foo(); -" -`; - exports[`super.js 1`] = ` "class C { m() { } } class D extends C { } @@ -120,18 +67,3 @@ class D extends C {} var d: { +m: () => void } = new D(); " `; - -exports[`super.js 2`] = ` -"class C { m() { } } -class D extends C { } - -var d: { +m: () => void } = new D(); -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -class C { - m() {} -} -class D extends C {} - -var d: { +m: () => void } = new D(); -" -`; diff --git a/tests/flow/more_annot/jsfmt.spec.js b/tests/flow/more_annot/jsfmt.spec.js index cd6102665..1840e9d36 100644 --- a/tests/flow/more_annot/jsfmt.spec.js +++ b/tests/flow/more_annot/jsfmt.spec.js @@ -1,2 +1 @@ -run_spec(__dirname); -run_spec(__dirname, { parser: 'babylon' }); +run_spec(__dirname, null, ["babylon"]); diff --git a/tests/flow/object-method/__snapshots__/jsfmt.spec.js.snap b/tests/flow/object-method/__snapshots__/jsfmt.spec.js.snap index 4a9097b82..5d1dad11a 100644 --- a/tests/flow/object-method/__snapshots__/jsfmt.spec.js.snap +++ b/tests/flow/object-method/__snapshots__/jsfmt.spec.js.snap @@ -11,17 +11,6 @@ module.exports = id; " `; -exports[`id.js 2`] = ` -"declare function id(_: X): X; - -module.exports = id; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -declare function id(_: X): X; - -module.exports = id; -" -`; - exports[`subtype.js 1`] = ` "interface Interface { m(): void; @@ -41,25 +30,6 @@ function subtypeCheck(x: Interface): ObjectType { " `; -exports[`subtype.js 2`] = ` -"interface Interface { - m(): void; -} -import type { ObjectType } from './test'; - -function subtypeCheck(x: Interface): ObjectType { return x; } -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -interface Interface { - m(): void -} -import type { ObjectType } from \\"./test\\"; - -function subtypeCheck(x: Interface): ObjectType { - return x; -} -" -`; - exports[`test.js 1`] = ` "const id = require('./id'); @@ -89,35 +59,6 @@ module.exports = id(methodCaller); " `; -exports[`test.js 2`] = ` -"const id = require('./id'); - -export type ObjectType = { - +m: () => void, -}; - -function methodCaller(x: ObjectType) { - x.m(); -}; - -module.exports = id( - methodCaller -); -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -const id = require(\\"./id\\"); - -export type ObjectType = { - +m: () => void -}; - -function methodCaller(x: ObjectType) { - x.m(); -} - -module.exports = id(methodCaller); -" -`; - exports[`test2.js 1`] = ` "/* @flow */ @@ -157,45 +98,6 @@ b.f(); // error, property \`p\` not found " `; -exports[`test2.js 2`] = ` -"/* @flow */ - -function f() { - return this.p; -} - -var a = { - p: 0, - f -} - -var b = { - f -} - -a.f(); // okey-dokie -b.f(); // error, property \`p\` not found -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -/* @flow */ - -function f() { - return this.p; -} - -var a = { - p: 0, - f -}; - -var b = { - f -}; - -a.f(); // okey-dokie -b.f(); // error, property \`p\` not found -" -`; - exports[`test3.js 1`] = ` "/* @flow */ @@ -236,44 +138,3 @@ function qux(o: { f: () => void }) { qux({ f: foo }); // error, since \`this\` is used non-trivially in \`foo\` " `; - -exports[`test3.js 2`] = ` -"/* @flow */ - -function foo() { - this.m(); -} - -function bar(f: () => void) { - f(); // passing global object as \`this\` - ({ f }).f(); // passing container object as \`this\` -} - -bar(foo); // error, since \`this\` is used non-trivially in \`foo\` - -function qux(o: { f: () => void }) { - o.f(); // passing o as \`this\` -} - -qux({ f: foo }); // error, since \`this\` is used non-trivially in \`foo\` -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -/* @flow */ - -function foo() { - this.m(); -} - -function bar(f: () => void) { - f(); // passing global object as \`this\` - ({ f }.f()); // passing container object as \`this\` -} - -bar(foo); // error, since \`this\` is used non-trivially in \`foo\` - -function qux(o: { f: () => void }) { - o.f(); // passing o as \`this\` -} - -qux({ f: foo }); // error, since \`this\` is used non-trivially in \`foo\` -" -`; diff --git a/tests/flow/object-method/jsfmt.spec.js b/tests/flow/object-method/jsfmt.spec.js index cd6102665..1840e9d36 100644 --- a/tests/flow/object-method/jsfmt.spec.js +++ b/tests/flow/object-method/jsfmt.spec.js @@ -1,2 +1 @@ -run_spec(__dirname); -run_spec(__dirname, { parser: 'babylon' }); +run_spec(__dirname, null, ["babylon"]); diff --git a/tests/flow/typeapp_perf/__snapshots__/jsfmt.spec.js.snap b/tests/flow/typeapp_perf/__snapshots__/jsfmt.spec.js.snap index 6f49b23c1..8ed5aa972 100644 --- a/tests/flow/typeapp_perf/__snapshots__/jsfmt.spec.js.snap +++ b/tests/flow/typeapp_perf/__snapshots__/jsfmt.spec.js.snap @@ -45,51 +45,6 @@ declare var b: B; " `; -exports[`test1.js 2`] = ` -"/* This test ensures that the code below does not take a long time to check. If - * this test is taking a very long time to complete, there is a bug. */ - -class A {} - -type B = A & { - +a: () => B; - +b: () => B; - +c: () => B; - +d: () => B; - +e: () => B; - +f: () => B; - +g: () => B; - +h: () => B; - +i: () => B; -}; - -declare var b: B; - -(b: B); -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -/* This test ensures that the code below does not take a long time to check. If - * this test is taking a very long time to complete, there is a bug. */ - -class A {} - -type B = A & { - +a: () => B, - +b: () => B, - +c: () => B, - +d: () => B, - +e: () => B, - +f: () => B, - +g: () => B, - +h: () => B, - +i: () => B -}; - -declare var b: B; - -(b: B); -" -`; - exports[`test2.js 1`] = ` "/* This test ensures that the code below does not take a long time to check. If * this test is taking a very long time to complete, there is a bug. */ @@ -134,48 +89,3 @@ declare var b: B; (b: B); " `; - -exports[`test2.js 2`] = ` -"/* This test ensures that the code below does not take a long time to check. If - * this test is taking a very long time to complete, there is a bug. */ - -class A {} - -type B = A & { - +a: (x: B) => void; - +b: (x: B) => void; - +c: (x: B) => void; - +d: (x: B) => void; - +e: (x: B) => void; - +f: (x: B) => void; - +g: (x: B) => void; - +h: (x: B) => void; - +i: (x: B) => void; -}; - -declare var b: B; - -(b: B); -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -/* This test ensures that the code below does not take a long time to check. If - * this test is taking a very long time to complete, there is a bug. */ - -class A {} - -type B = A & { - +a: (x: B) => void, - +b: (x: B) => void, - +c: (x: B) => void, - +d: (x: B) => void, - +e: (x: B) => void, - +f: (x: B) => void, - +g: (x: B) => void, - +h: (x: B) => void, - +i: (x: B) => void -}; - -declare var b: B; - -(b: B); -" -`; diff --git a/tests/flow/typeapp_perf/jsfmt.spec.js b/tests/flow/typeapp_perf/jsfmt.spec.js index cd6102665..1840e9d36 100644 --- a/tests/flow/typeapp_perf/jsfmt.spec.js +++ b/tests/flow/typeapp_perf/jsfmt.spec.js @@ -1,2 +1 @@ -run_spec(__dirname); -run_spec(__dirname, { parser: 'babylon' }); +run_spec(__dirname, null, ["babylon"]); diff --git a/tests/flow_comments/jsfmt.spec.js b/tests/flow_comments/jsfmt.spec.js index d5ec770a9..51588ad1e 100644 --- a/tests/flow_comments/jsfmt.spec.js +++ b/tests/flow_comments/jsfmt.spec.js @@ -1,2 +1,3 @@ run_spec(__dirname); -run_spec(__dirname, {parser: 'babylon'}); +// FIXME arrow.js flow != babylon output +run_spec(__dirname, { parser: "babylon" }); \ No newline at end of file diff --git a/tests/for/__snapshots__/jsfmt.spec.js.snap b/tests/for/__snapshots__/jsfmt.spec.js.snap index d9a722cae..6de23f3f1 100644 --- a/tests/for/__snapshots__/jsfmt.spec.js.snap +++ b/tests/for/__snapshots__/jsfmt.spec.js.snap @@ -67,73 +67,6 @@ for (x of y); " `; -exports[`comment.js 2`] = ` -"for (x -/*a*/ -in //b -y) //c -; - -for (x in /*a*/ //b -y); //c - -for (x /*a*/ in y); //b //c - -for (x -//a -in y); - -for(x in -//a -y); - -for (x -/*a*/ -of //b -y) //c -; - -for (x of /*a*/ //b -y); //c - -for (x /*a*/ of y); //b //c - -for (x -//a -of y); - -for(x of -//a -y); -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -/*a*/ -for (x in y); //b //c - -for (x /*a*/ in y); //b //c - -for (x /*a*/ in y); //b //c - -//a -for (x in y); - -//a -for (x in y); - -/*a*/ -for (x of y); //b //c - -for (x /*a*/ of y); //b //c - -for (x /*a*/ of y); //b //c - -//a -for (x of y); - -//a -for (x of y); -" -`; - exports[`for.js 1`] = ` "for (;;) {} for (var i = 0; i < 10; ++i) {} @@ -145,17 +78,6 @@ for (var i = 0; i < 10; ++i) { " `; -exports[`for.js 2`] = ` -"for (;;) {} -for (var i = 0; i < 10; ++i) {} -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -for (;;) { -} -for (var i = 0; i < 10; ++i) { -} -" -`; - exports[`in.js 1`] = ` "for ((x in a);;) {} for (a=(a in b);;) {} @@ -185,35 +107,6 @@ async function f() { " `; -exports[`in.js 2`] = ` -"for ((x in a);;) {} -for (a=(a in b);;) {} -for (let a = (b in c); ; ); -for (a && (b in c); ; ); -for (a => (b in c); ; ); -function* g() { - for (yield (a in b); ; ); -} -async function f() { - for (await (a in b); ; ); -} -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -for ((x in a); ; ) { -} -for (a = (a in b); ; ) { -} -for (let a = (b in c); ; ); -for (a && (b in c); ; ); -for (a => (b in c); ; ); -function* g() { - for (yield (a in b); ; ); -} -async function f() { - for (await (a in b); ; ); -} -" -`; - exports[`var.js 1`] = ` "for (a in b) var c = {}; []; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -222,12 +115,3 @@ for (a in b) []; " `; - -exports[`var.js 2`] = ` -"for (a in b) var c = {}; []; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -for (a in b) - var c = {}; -[]; -" -`; diff --git a/tests/for/jsfmt.spec.js b/tests/for/jsfmt.spec.js index e98b84204..7580dfab0 100644 --- a/tests/for/jsfmt.spec.js +++ b/tests/for/jsfmt.spec.js @@ -1,2 +1 @@ -run_spec(__dirname); -run_spec(__dirname, {parser: 'typescript'}); +run_spec(__dirname, null, ["typescript"]); diff --git a/tests/function/__snapshots__/jsfmt.spec.js.snap b/tests/function/__snapshots__/jsfmt.spec.js.snap index e5d39150b..7c5a63a4f 100644 --- a/tests/function/__snapshots__/jsfmt.spec.js.snap +++ b/tests/function/__snapshots__/jsfmt.spec.js.snap @@ -26,30 +26,3 @@ a + function() {}; new function() {}(); " `; - -exports[`function_expression.js 2`] = ` -"(function() {}).length -typeof (function() {}); -export default (function() {})(); -(function() {})()\`\`; -(function() {})\`\`; -new (function() {}); -(function() {}); -a = function f() {} || b; -(function() {} && a); -a + function() {}; -new function() {}; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -(function() {}.length); -typeof function() {}; -export default (function() {})(); -(function() {})()\`\`; -(function() {})\`\`; -new function() {}(); -(function() {}); -a = function f() {} || b; -(function() {} && a); -a + function() {}; -new function() {}(); -" -`; diff --git a/tests/function/jsfmt.spec.js b/tests/function/jsfmt.spec.js index 1161d7bfb..7580dfab0 100644 --- a/tests/function/jsfmt.spec.js +++ b/tests/function/jsfmt.spec.js @@ -1,2 +1 @@ -run_spec(__dirname); -run_spec(__dirname, {parser: 'typescript'}); \ No newline at end of file +run_spec(__dirname, null, ["typescript"]); diff --git a/tests/if/__snapshots__/jsfmt.spec.js.snap b/tests/if/__snapshots__/jsfmt.spec.js.snap index a961d8bfc..38a14999b 100644 --- a/tests/if/__snapshots__/jsfmt.spec.js.snap +++ b/tests/if/__snapshots__/jsfmt.spec.js.snap @@ -42,48 +42,6 @@ function f() { " `; -exports[`else.js 2`] = ` -"// Both functions below should be formatted exactly the same - -function f() { - if (position) - return {name: pair}; - else - return {name: pair.substring(0, position), value: pair.substring(position + 1)}; -} - -function f() { - if (position) - return {name: pair}; - else - return { - name: pair.substring(0, position), - value: pair.substring(position + 1) - }; -} -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -// Both functions below should be formatted exactly the same - -function f() { - if (position) return { name: pair }; - else - return { - name: pair.substring(0, position), - value: pair.substring(position + 1) - }; -} - -function f() { - if (position) return { name: pair }; - else - return { - name: pair.substring(0, position), - value: pair.substring(position + 1) - }; -} -" -`; - exports[`if_comments.js 1`] = ` "async function f() { if (untrackedChoice === 0) /* Cancel */ { @@ -157,77 +115,3 @@ async function f() { } " `; - -exports[`if_comments.js 2`] = ` -"async function f() { - if (untrackedChoice === 0) /* Cancel */ { - return null; - } else if (untrackedChoice === 1) /* Add */ { - await repository.addAll(Array.from(untrackedChanges.keys())); - shouldAmend = true; - } else if (untrackedChoice === 2) /* Allow Untracked */ { - allowUntracked = true; - } -} - -async function f() { - if (untrackedChoice === 0) - /* Cancel */ { - return null; - } - else if (untrackedChoice === 1) - /* Add */ { - await repository.addAll(Array.from(untrackedChanges.keys())); - shouldAmend = true; - } - else if (untrackedChoice === 2) - /* Allow Untracked */ { - allowUntracked = true; - } -} - -async function f() { - if (untrackedChoice === 0) { - /* Cancel */ return null; - } else if (untrackedChoice === 1) { - /* Add */ await repository.addAll(Array.from(untrackedChanges.keys())); - shouldAmend = true; - } else if (untrackedChoice === 2) { - /* Allow Untracked */ allowUntracked = true; - } -} -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -async function f() { - if (untrackedChoice === 0) { - /* Cancel */ return null; - } else if (untrackedChoice === 1) { - /* Add */ await repository.addAll(Array.from(untrackedChanges.keys())); - shouldAmend = true; - } else if (untrackedChoice === 2) { - /* Allow Untracked */ allowUntracked = true; - } -} - -async function f() { - if (untrackedChoice === 0) { - /* Cancel */ return null; - } else if (untrackedChoice === 1) { - /* Add */ await repository.addAll(Array.from(untrackedChanges.keys())); - shouldAmend = true; - } else if (untrackedChoice === 2) { - /* Allow Untracked */ allowUntracked = true; - } -} - -async function f() { - if (untrackedChoice === 0) { - /* Cancel */ return null; - } else if (untrackedChoice === 1) { - /* Add */ await repository.addAll(Array.from(untrackedChanges.keys())); - shouldAmend = true; - } else if (untrackedChoice === 2) { - /* Allow Untracked */ allowUntracked = true; - } -} -" -`; diff --git a/tests/if/jsfmt.spec.js b/tests/if/jsfmt.spec.js index 1161d7bfb..7580dfab0 100644 --- a/tests/if/jsfmt.spec.js +++ b/tests/if/jsfmt.spec.js @@ -1,2 +1 @@ -run_spec(__dirname); -run_spec(__dirname, {parser: 'typescript'}); \ No newline at end of file +run_spec(__dirname, null, ["typescript"]); diff --git a/tests/import/__snapshots__/jsfmt.spec.js.snap b/tests/import/__snapshots__/jsfmt.spec.js.snap index d35e1dc29..b91d05625 100644 --- a/tests/import/__snapshots__/jsfmt.spec.js.snap +++ b/tests/import/__snapshots__/jsfmt.spec.js.snap @@ -54,60 +54,6 @@ import {fitsIn, oneLine} from \\".\\"; " `; -exports[`brackets.js 3`] = ` -"import { - runTaskForChanged, - description, - someOtherLabel, - thatMakes, - itGo, - multiLine, - andMore, - soWeCanGetItTo80Columns -} from '.'; -import {fitsIn, oneLine} from '.'; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -import { - runTaskForChanged, - description, - someOtherLabel, - thatMakes, - itGo, - multiLine, - andMore, - soWeCanGetItTo80Columns -} from \\".\\"; -import { fitsIn, oneLine } from \\".\\"; -" -`; - -exports[`brackets.js 4`] = ` -"import { - runTaskForChanged, - description, - someOtherLabel, - thatMakes, - itGo, - multiLine, - andMore, - soWeCanGetItTo80Columns -} from '.'; -import {fitsIn, oneLine} from '.'; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -import { - runTaskForChanged, - description, - someOtherLabel, - thatMakes, - itGo, - multiLine, - andMore, - soWeCanGetItTo80Columns -} from \\".\\"; -import {fitsIn, oneLine} from \\".\\"; -" -`; - exports[`comments.js 1`] = ` "import { a //comment1 //comment2 @@ -250,148 +196,6 @@ import { " `; -exports[`comments.js 3`] = ` -"import { a //comment1 -//comment2 -//comment3 -as b} from \\"\\"; - -import { - a as //comment1 - //comment2 - //comment3 - b -} from \\"\\"; - -import { - a as //comment2 //comment1 - //comment3 - b -} from \\"\\"; - -import { - a as //comment3 //comment2 //comment1 - b -} from \\"\\"; - -import { - // comment 1 - FN1, // comment 2 - /* comment 3 */ FN2, - // FN3, - FN4 /* comment 4 */ - // FN4, - // FN5 -} from \\"./module\\"; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -import { - //comment1 - //comment2 - //comment3 - a as b -} from \\"\\"; - -import { - //comment1 - //comment2 - //comment3 - a as b -} from \\"\\"; - -import { - //comment2 //comment1 - //comment3 - a as b -} from \\"\\"; - -import { - //comment3 //comment2 //comment1 - a as b -} from \\"\\"; - -import { - // comment 1 - FN1, // comment 2 - /* comment 3 */ FN2, - // FN3, - FN4 /* comment 4 */ - // FN4, - // FN5 -} from \\"./module\\"; -" -`; - -exports[`comments.js 4`] = ` -"import { a //comment1 -//comment2 -//comment3 -as b} from \\"\\"; - -import { - a as //comment1 - //comment2 - //comment3 - b -} from \\"\\"; - -import { - a as //comment2 //comment1 - //comment3 - b -} from \\"\\"; - -import { - a as //comment3 //comment2 //comment1 - b -} from \\"\\"; - -import { - // comment 1 - FN1, // comment 2 - /* comment 3 */ FN2, - // FN3, - FN4 /* comment 4 */ - // FN4, - // FN5 -} from \\"./module\\"; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -import { - //comment1 - //comment2 - //comment3 - a as b -} from \\"\\"; - -import { - //comment1 - //comment2 - //comment3 - a as b -} from \\"\\"; - -import { - //comment2 //comment1 - //comment3 - a as b -} from \\"\\"; - -import { - //comment3 //comment2 //comment1 - a as b -} from \\"\\"; - -import { - // comment 1 - FN1, // comment 2 - /* comment 3 */ FN2, - // FN3, - FN4 /* comment 4 */ - // FN4, - // FN5 -} from \\"./module\\"; -" -`; - exports[`long-line.js 1`] = ` "import someCoolUtilWithARatherLongName from '../../../../utils/someCoolUtilWithARatherLongName'; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -408,22 +212,6 @@ import someCoolUtilWithARatherLongName " `; -exports[`long-line.js 3`] = ` -"import someCoolUtilWithARatherLongName from '../../../../utils/someCoolUtilWithARatherLongName'; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -import someCoolUtilWithARatherLongName - from \\"../../../../utils/someCoolUtilWithARatherLongName\\"; -" -`; - -exports[`long-line.js 4`] = ` -"import someCoolUtilWithARatherLongName from '../../../../utils/someCoolUtilWithARatherLongName'; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -import someCoolUtilWithARatherLongName - from \\"../../../../utils/someCoolUtilWithARatherLongName\\"; -" -`; - exports[`multiple_standalones.js 1`] = ` "import a, * as b from 'a'; ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ @@ -437,17 +225,3 @@ exports[`multiple_standalones.js 2`] = ` import a, * as b from \\"a\\"; " `; - -exports[`multiple_standalones.js 3`] = ` -"import a, * as b from 'a'; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -import a, * as b from \\"a\\"; -" -`; - -exports[`multiple_standalones.js 4`] = ` -"import a, * as b from 'a'; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -import a, * as b from \\"a\\"; -" -`; diff --git a/tests/import/jsfmt.spec.js b/tests/import/jsfmt.spec.js index 3dc54d59d..deb0fd82a 100644 --- a/tests/import/jsfmt.spec.js +++ b/tests/import/jsfmt.spec.js @@ -1,5 +1,2 @@ -run_spec(__dirname); -run_spec(__dirname, {bracketSpacing: false}); - -run_spec(__dirname, {parser: 'typescript'}); -run_spec(__dirname, {parser: 'typescript', bracketSpacing: false}); +run_spec(__dirname, null, ["typescript"]); +run_spec(__dirname, { bracketSpacing: false }, ["typescript"]); diff --git a/tests/jsx-multiline-assign/__snapshots__/jsfmt.spec.js.snap b/tests/jsx-multiline-assign/__snapshots__/jsfmt.spec.js.snap index f3c81c431..081bf0d14 100644 --- a/tests/jsx-multiline-assign/__snapshots__/jsfmt.spec.js.snap +++ b/tests/jsx-multiline-assign/__snapshots__/jsfmt.spec.js.snap @@ -52,56 +52,3 @@ const comp4 = ( const comp5 =
Keep it on one line.
; " `; - -exports[`test.js 2`] = ` -"const comp1 = ( -
- Keep the wrapping parens. -
-); - -const comp2 =
- Create wrapping parens. -
; - -comp2A =
- Create wrapping parens. -
; - -const comp3 =
Bump to next line without parens
; - -const comp4 =
Create wrapping parens and indent all the things.
; - -const comp5 =
Keep it on one line.
; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -const comp1 = ( -
- Keep the wrapping parens. -
-); - -const comp2 = ( -
- Create wrapping parens. -
-); - -comp2A = ( -
- Create wrapping parens. -
-); - -const comp3 = ( -
Bump to next line without parens
-); - -const comp4 = ( -
- Create wrapping parens and indent all the things. -
-); - -const comp5 =
Keep it on one line.
; -" -`; diff --git a/tests/jsx-multiline-assign/jsfmt.spec.js b/tests/jsx-multiline-assign/jsfmt.spec.js index 1161d7bfb..7580dfab0 100644 --- a/tests/jsx-multiline-assign/jsfmt.spec.js +++ b/tests/jsx-multiline-assign/jsfmt.spec.js @@ -1,2 +1 @@ -run_spec(__dirname); -run_spec(__dirname, {parser: 'typescript'}); \ No newline at end of file +run_spec(__dirname, null, ["typescript"]); diff --git a/tests/jsx-newlines/__snapshots__/jsfmt.spec.js.snap b/tests/jsx-newlines/__snapshots__/jsfmt.spec.js.snap index 74e727aa2..2638cada8 100644 --- a/tests/jsx-newlines/__snapshots__/jsfmt.spec.js.snap +++ b/tests/jsx-newlines/__snapshots__/jsfmt.spec.js.snap @@ -187,191 +187,3 @@ regression_extra_newline_2 = ( ); " `; - -exports[`test.js 2`] = ` -"keep =

- Welcome to the Universal React Starter-kyt. - This starter kyt should serve as the base for an advanced, - server-rendered React app. -

- -newlines_text = -
- hi - there - how - - are you - - - are you fine today? -
- -newlines_text_spaced = -
- - space above - - space below - -
- -newlines_elems_spaced = -
- - space above - - space below - -
- -newlines_mixed = -
- hi - there - - how - - are you - - - are you fine today? -
- -newlines_elems = -
-
- - -
- - -
- - - hi - - -
- - - - - - - - -
- -regression_extra_newline = ( -
- - New Messages -
-); - - -regression_extra_newline_2 = ( -
- ( - - ) -
-); -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -keep = ( -

- Welcome to the Universal React Starter-kyt. - This starter kyt should serve as the base for an advanced, - server-rendered React app. -

-); - -newlines_text = ( -
- hi - there - how - - are you - - are you fine today? -
-); - -newlines_text_spaced = ( -
- - space above - - space below - -
-); - -newlines_elems_spaced = ( -
- - space above - - space below - -
-); - -newlines_mixed = ( -
- hi - there - - how - - are you - - are you fine today? -
-); - -newlines_elems = ( -
-
- -
- -
- - hi - -
- - - - - -
-); - -regression_extra_newline = ( -
- - New Messages -
-); - -regression_extra_newline_2 = ( -
- ( - - ) -
-); -" -`; diff --git a/tests/jsx-newlines/jsfmt.spec.js b/tests/jsx-newlines/jsfmt.spec.js index 1161d7bfb..7580dfab0 100644 --- a/tests/jsx-newlines/jsfmt.spec.js +++ b/tests/jsx-newlines/jsfmt.spec.js @@ -1,2 +1 @@ -run_spec(__dirname); -run_spec(__dirname, {parser: 'typescript'}); \ No newline at end of file +run_spec(__dirname, null, ["typescript"]); diff --git a/tests/jsx-significant-space/__snapshots__/jsfmt.spec.js.snap b/tests/jsx-significant-space/__snapshots__/jsfmt.spec.js.snap index 301b52b6d..36c0f42c9 100644 --- a/tests/jsx-significant-space/__snapshots__/jsfmt.spec.js.snap +++ b/tests/jsx-significant-space/__snapshots__/jsfmt.spec.js.snap @@ -198,202 +198,3 @@ not_broken_begin = ( ); " `; - -exports[`test.js 2`] = ` -"after = - - foo bar - - -before = - - bar foo - - -before_break1 = - - foo - - -before_break2 = - - foo - - -after_break = - - foo - - -within = - - foo bar - - -break_components = -
- - -

foobar bar bar

yep

-
-

nope

-
- -var x =
- hello hi sdkflsdfjk -
; - -nest_plz = -
-
-
-
-
- -regression_not_transformed_1 = - ; - -regression_not_transformed_2 = - ; - -similar_1 = - ; - -similar_2 = - ; - -similar_3 = - ; - -not_broken_end = -
- long text long text long text long text long text long text long text long text url long text long text -
- -not_broken_begin = -
-
long text long text long text long text long text long text long text long texturl long text long text -
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -after = ( - - foo bar - -); - -before = ( - - bar foo - -); - -before_break1 = ( - - - {\\" \\"} - foo - -); - -before_break2 = ( - - - {\\" \\"} - foo - -); - -after_break = ( - - foo - {\\" \\"} - - -); - -within = ( - - foo bar - -); - -break_components = ( -
- - -

foobar bar bar

yep

-
-

nope

-
-); - -var x = ( -
- hello hi sdkflsdfjk -
-); - -nest_plz = ( -
-
-
-
-
-); - -regression_not_transformed_1 = ( - - {\\" \\"} - -); - -regression_not_transformed_2 = ( - - {\\" \\"} - -); - -similar_1 = ( - - {\\" \\"} - - -); - -similar_2 = ( - - - {\\" \\"} - -); - -similar_3 = ( - - - -); - -not_broken_end = ( -
- long text long text long text long text long text long text long text long text - {\\" \\"} - url - {\\" \\"} - long text long text -
-); - -not_broken_begin = ( -
-
- {\\" \\"} - long text long text long text long text long text long text long text long text - url - {\\" \\"} - long text long text -
-); -" -`; diff --git a/tests/jsx-significant-space/jsfmt.spec.js b/tests/jsx-significant-space/jsfmt.spec.js index 1161d7bfb..7580dfab0 100644 --- a/tests/jsx-significant-space/jsfmt.spec.js +++ b/tests/jsx-significant-space/jsfmt.spec.js @@ -1,2 +1 @@ -run_spec(__dirname); -run_spec(__dirname, {parser: 'typescript'}); \ No newline at end of file +run_spec(__dirname, null, ["typescript"]); diff --git a/tests/jsx-split-attrs/__snapshots__/jsfmt.spec.js.snap b/tests/jsx-split-attrs/__snapshots__/jsfmt.spec.js.snap index 4b1f99702..efb23b71d 100644 --- a/tests/jsx-split-attrs/__snapshots__/jsfmt.spec.js.snap +++ b/tests/jsx-split-attrs/__snapshots__/jsfmt.spec.js.snap @@ -212,216 +212,3 @@ long_obj = ( ); " `; - -exports[`test.js 2`] = ` -"long_closed = - - -long_open = - - hello - - -long_open_long_children = - - - Hello world - -
hey hiya how are ya
-
-
-
-
- d - - - -short_closed = - - -short_open = - - hello - - -make_self_closing = -
- - - -
- -leave_opening = - - -long_string = -
hello world
- -long_string_with_extra_param = -
hello world
- -long_obj = -
hello world
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -long_closed = ( - -); - -long_open = ( - - hello - -); - -long_open_long_children = ( - - - Hello world - -
-
hey hiya how are ya
-
-
-
-
-
-
-
-
-
-
-
-
-
- - - d - - - - - -); - -short_closed = ; - -short_open = ( - - hello - -); - -make_self_closing = ( -
- - -
-); - -leave_opening = ( - - {\\" \\"} - -); - -long_string = ( -
- hello world -
-); - -long_string_with_extra_param = ( -
- hello world -
-); - -long_obj = ( -
- hello world -
-); -" -`; diff --git a/tests/jsx-split-attrs/jsfmt.spec.js b/tests/jsx-split-attrs/jsfmt.spec.js index 1161d7bfb..7580dfab0 100644 --- a/tests/jsx-split-attrs/jsfmt.spec.js +++ b/tests/jsx-split-attrs/jsfmt.spec.js @@ -1,2 +1 @@ -run_spec(__dirname); -run_spec(__dirname, {parser: 'typescript'}); \ No newline at end of file +run_spec(__dirname, null, ["typescript"]); diff --git a/tests/jsx-stateless-arrow-fn/__snapshots__/jsfmt.spec.js.snap b/tests/jsx-stateless-arrow-fn/__snapshots__/jsfmt.spec.js.snap index 953856572..21a7ac786 100644 --- a/tests/jsx-stateless-arrow-fn/__snapshots__/jsfmt.spec.js.snap +++ b/tests/jsx-stateless-arrow-fn/__snapshots__/jsfmt.spec.js.snap @@ -232,236 +232,3 @@ const renderTernary = props => ( ); " `; - -exports[`test.js 2`] = ` -"const render1 = ({ styles }) => ( -
- Keep the wrapping parens. Put each key on its own line. -
-); - -const render2 = ({ styles }) =>
- Create wrapping parens. -
; - -const render3 = ({ styles }) =>
Bump to next line without parens
; - -const render4 = ({ styles }) =>
Create wrapping parens and indent all the things.
; - -const render5 = ({ styles }) =>
Keep it on one line.
; - -const render6 = ({ styles }) => ( -
-
ddd d dd d d dddd dddd hello
-
ddd d dd d d dddd dddd hello
-
-
ddd d dd d d dddd dddd hello
hello
-
-) - -const render7 = () => -
- Dont break each elem onto its own line. -
-
- -const render7A = () => ( -
-
-
-) - -const render7B = () => ( -
- Dont break plz - Dont break plz - Dont break plz -
-) - -const render8 = (props) =>
{props.text}
-const render9 = (props) =>
{props.looooooooooooooooooooooooooooooong_text}
-const render10 = (props) =>
{props.even_looooooooooooooooooooooooooooooooooooooooooonger_contents}
- -const notJSX = (aaaaaaaaaaaaaaaaa, bbbbbbbbbbb) => this.someLongCallWithParams(aaaaaa, bbbbbbb).anotherLongCallWithParams(cccccccccccc, dddddddddddddddddddddd) - -React.render( - - , document.querySelector('#react-root') -) - - -const renderTernary = (props) => - - {props.showTheThing ? - Hello world - : \\"hello \\" + \\"howdy! \\"} - {props.showTheThing ? - Hello world - : - null - } - {props.showTheThing ? null : - Hello world - } - {props.showTheOtherThing ?
I am here
:
} - {props.showTheOtherThing ?
I am here!!
: null} - -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -const render1 = ({ styles }) => ( -
- Keep the wrapping parens. Put each key on its own line. -
-); - -const render2 = ({ styles }) => ( -
- Create wrapping parens. -
-); - -const render3 = ({ styles }) => ( -
Bump to next line without parens
-); - -const render4 = ({ styles }) => ( -
- Create wrapping parens and indent all the things. -
-); - -const render5 = ({ styles }) =>
Keep it on one line.
; - -const render6 = ({ styles }) => ( -
-
- ddd d dd d d dddd dddd hello -
-
- ddd d dd d d dddd dddd hello -
-
-
- ddd d dd d d dddd dddd hello -
- {\\" \\"} - hello -
-
-); - -const render7 = () => ( -
- Dont break each elem onto its own line. -
-
-); - -const render7A = () => ( -
-
-
-); - -const render7B = () => ( -
- Dont break plz - Dont break plz - Dont break plz -
-); - -const render8 = props =>
{props.text}
; -const render9 = props => ( -
{props.looooooooooooooooooooooooooooooong_text}
-); -const render10 = props => ( -
- {props.even_looooooooooooooooooooooooooooooooooooooooooonger_contents} -
-); - -const notJSX = (aaaaaaaaaaaaaaaaa, bbbbbbbbbbb) => - this.someLongCallWithParams(aaaaaa, bbbbbbb).anotherLongCallWithParams( - cccccccccccc, - dddddddddddddddddddddd - ); - -React.render( - , - document.querySelector(\\"#react-root\\") -); - -const renderTernary = props => ( - - {props.showTheThing - ? - Hello world - - : \\"hello \\" + \\"howdy! \\"} - {props.showTheThing - ? - Hello world - - : null} - {props.showTheThing - ? null - : - Hello world - } - {props.showTheOtherThing ?
I am here
:
} - {props.showTheOtherThing ?
I am here!!
: null} - -); -" -`; diff --git a/tests/jsx-stateless-arrow-fn/jsfmt.spec.js b/tests/jsx-stateless-arrow-fn/jsfmt.spec.js index 1161d7bfb..7580dfab0 100644 --- a/tests/jsx-stateless-arrow-fn/jsfmt.spec.js +++ b/tests/jsx-stateless-arrow-fn/jsfmt.spec.js @@ -1,2 +1 @@ -run_spec(__dirname); -run_spec(__dirname, {parser: 'typescript'}); \ No newline at end of file +run_spec(__dirname, null, ["typescript"]); diff --git a/tests/jsx/__snapshots__/jsfmt.spec.js.snap b/tests/jsx/__snapshots__/jsfmt.spec.js.snap index a24d5d571..317844174 100644 --- a/tests/jsx/__snapshots__/jsfmt.spec.js.snap +++ b/tests/jsx/__snapshots__/jsfmt.spec.js.snap @@ -139,145 +139,6 @@ exports[`expression.js 1`] = ` " `; -exports[`expression.js 2`] = ` -"; - -; - - - {() => ( - - - - )} -; - - - {items.map(item => ( - - - - ))} -; - - - {function() { - return ( - - - - ); - }} -; - -; - - - test - -}/>; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -; - -; - - - {() => ( - - - - )} -; - - - {items.map(item => ( - - - - ))} -; - - - {function() { - return ( - - - - ); - }} -; - -; - - - test - - } -/>; -" -`; - exports[`hug.js 1`] = ` "
{__DEV__ @@ -348,76 +209,6 @@ exports[`hug.js 1`] = ` " `; -exports[`hug.js 2`] = ` -"
- {__DEV__ - ? this.renderDevApp() - :
- {routes.map(route => ( - - ))} -
} -
; - -
- {__DEV__ &&
- {routes.map(route => ( - - ))} -
} -
; - -
- {member.memberName.memberSomething + - (member.memberDef.memberSomething.signatures ? '()' : '')} -
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -
- {__DEV__ - ? this.renderDevApp() - :
- {routes.map(route => ( - - ))} -
} -
; - -
- {__DEV__ && -
- {routes.map(route => ( - - ))} -
} -
; - -
- {member.memberName.memberSomething + - (member.memberDef.memberSomething.signatures ? \\"()\\" : \\"\\")} -
; -" -`; - exports[`object-property.js 1`] = ` "const tabs = [ { @@ -449,37 +240,6 @@ const tabs = [ " `; -exports[`object-property.js 2`] = ` -"const tabs = [ - { - title: \\"General Info\\", - content: ( - - ) - } -]; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -const tabs = [ - { - title: \\"General Info\\", - content: ( - - ) - } -]; -" -`; - exports[`open-break.js 1`] = ` " { @@ -510,36 +270,6 @@ onClick={() => { " `; -exports[`open-break.js 2`] = ` -" { - a -}}>{header}{showSort}; - - { - a -}}>{header}; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - { - a; - }} -> - {header}{showSort} -; - - { - a; - }} -> - {header} - -; -" -`; - exports[`parens.js 1`] = ` "a = [ , - , -]; - -
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -a = [ - , - -]; - -
; -" -`; - exports[`quotes.js 1`] = ` "
&quot;\\" />;
; @@ -608,14 +309,3 @@ exports[`quotes.js 1`] = `
&quot;\\"} />; " `; - -exports[`quotes.js 2`] = ` -"
&quot;\\" />; -
; -
&quot;'} />; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -
&quot;\\" />; -
&quot;\\" />; -
&quot;\\"} />; -" -`; diff --git a/tests/jsx/jsfmt.spec.js b/tests/jsx/jsfmt.spec.js index 1161d7bfb..7580dfab0 100644 --- a/tests/jsx/jsfmt.spec.js +++ b/tests/jsx/jsfmt.spec.js @@ -1,2 +1 @@ -run_spec(__dirname); -run_spec(__dirname, {parser: 'typescript'}); \ No newline at end of file +run_spec(__dirname, null, ["typescript"]); diff --git a/tests/jsx_escape/jsfmt.spec.js b/tests/jsx_escape/jsfmt.spec.js index 7b8a9e6ab..69acff871 100644 --- a/tests/jsx_escape/jsfmt.spec.js +++ b/tests/jsx_escape/jsfmt.spec.js @@ -1,2 +1,3 @@ -run_spec(__dirname, {parser: 'flow'}); -run_spec(__dirname, {parser: 'babylon'}); +run_spec(__dirname) +// FIXME nbsp.js flow != babylon output, waiting for: https://github.com/babel/babylon/pull/344 +run_spec(__dirname, { parser: "babylon" }); diff --git a/tests/jsx_last_line/__snapshots__/jsfmt.spec.js.snap b/tests/jsx_last_line/__snapshots__/jsfmt.spec.js.snap index d56dd3e59..706d39b71 100644 --- a/tests/jsx_last_line/__snapshots__/jsfmt.spec.js.snap +++ b/tests/jsx_last_line/__snapshots__/jsfmt.spec.js.snap @@ -48,52 +48,3 @@ exports[`last_line.js 2`] = ` ; " `; - -exports[`last_line.js 3`] = ` -" -
and the children go here
-
and here too
-
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -
and the children go here
-
and here too
-
; -" -`; - -exports[`last_line.js 4`] = ` -" -
and the children go here
-
and here too
-
-~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ - -
and the children go here
-
and here too
-
; -" -`; diff --git a/tests/jsx_last_line/jsfmt.spec.js b/tests/jsx_last_line/jsfmt.spec.js index eeb2ed9fe..64f83817d 100644 --- a/tests/jsx_last_line/jsfmt.spec.js +++ b/tests/jsx_last_line/jsfmt.spec.js @@ -1,5 +1,2 @@ -run_spec(__dirname, {jsxBracketSameLine: true}); -run_spec(__dirname, {jsxBracketSameLine: false}); - -run_spec(__dirname, {parser: 'typescript', jsxBracketSameLine: true}); -run_spec(__dirname, {parser: 'typescript', jsxBracketSameLine: false}); +run_spec(__dirname, { jsxBracketSameLine: true }, ["typescript"]); +run_spec(__dirname, { jsxBracketSameLine: false }, ["typescript"]); diff --git a/tests/label/__snapshots__/jsfmt.spec.js.snap b/tests/label/__snapshots__/jsfmt.spec.js.snap index 179cda189..2be86bcb4 100644 --- a/tests/label/__snapshots__/jsfmt.spec.js.snap +++ b/tests/label/__snapshots__/jsfmt.spec.js.snap @@ -8,12 +8,3 @@ a:; b; " `; - -exports[`empty_label.js 2`] = ` -"a:; -b -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -a:; -b; -" -`; diff --git a/tests/label/jsfmt.spec.js b/tests/label/jsfmt.spec.js index 1161d7bfb..7580dfab0 100644 --- a/tests/label/jsfmt.spec.js +++ b/tests/label/jsfmt.spec.js @@ -1,2 +1 @@ -run_spec(__dirname); -run_spec(__dirname, {parser: 'typescript'}); \ No newline at end of file +run_spec(__dirname, null, ["typescript"]); diff --git a/tests/line/__snapshots__/jsfmt.spec.js.snap b/tests/line/__snapshots__/jsfmt.spec.js.snap index 6d76a8fbf..2869d3af8 100644 --- a/tests/line/__snapshots__/jsfmt.spec.js.snap +++ b/tests/line/__snapshots__/jsfmt.spec.js.snap @@ -14,18 +14,3 @@ let outChannel; let _commands; " `; - -exports[`windows.js 2`] = ` -"const vscode = require(\\"vscode\\"); -const {getDir, getActiveFile, uint8arrayToString} = require(\\"./utils\\"); - -let outChannel; -let _commands; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -const vscode = require(\\"vscode\\"); -const { getDir, getActiveFile, uint8arrayToString } = require(\\"./utils\\"); - -let outChannel; -let _commands; -" -`; diff --git a/tests/line/jsfmt.spec.js b/tests/line/jsfmt.spec.js index 1161d7bfb..7580dfab0 100644 --- a/tests/line/jsfmt.spec.js +++ b/tests/line/jsfmt.spec.js @@ -1,2 +1 @@ -run_spec(__dirname); -run_spec(__dirname, {parser: 'typescript'}); \ No newline at end of file +run_spec(__dirname, null, ["typescript"]); diff --git a/tests/line_suffix_boundary/__snapshots__/jsfmt.spec.js.snap b/tests/line_suffix_boundary/__snapshots__/jsfmt.spec.js.snap index e4fc91e72..50b989f51 100644 --- a/tests/line_suffix_boundary/__snapshots__/jsfmt.spec.js.snap +++ b/tests/line_suffix_boundary/__snapshots__/jsfmt.spec.js.snap @@ -50,54 +50,3 @@ ExampleStory.getFragment(\\"story\\")}
; " `; - -exports[`boundary.js 2`] = ` -"\`\${ -a + // a - a -} - -\${a // comment -} - -\${b /* comment */} - -\${/* comment */ c /* comment */} - -\${// comment -d //comment -} - -\${// $FlowFixMe found when converting React.createClass to ES6 -ExampleStory.getFragment('story')} -\`; - -
-{ExampleStory.getFragment('story') // $FlowFixMe found when converting React.createClass to ES6 -} -
; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -\`\${a + a // a -} - -\${/* comment*/ -a} - -\${/* comment */ b} - -\${/* comment */ /* comment */ c} - -\${/* comment*/ -/*comment*/ -d} - -\${/* $FlowFixMe found when converting React.createClass to ES6*/ -ExampleStory.getFragment(\\"story\\")} -\`; - -
- {ExampleStory.getFragment(\\"story\\") // $FlowFixMe found when converting React.createClass to ES6 - } -
; -" -`; diff --git a/tests/line_suffix_boundary/jsfmt.spec.js b/tests/line_suffix_boundary/jsfmt.spec.js index d5ec770a9..1840e9d36 100644 --- a/tests/line_suffix_boundary/jsfmt.spec.js +++ b/tests/line_suffix_boundary/jsfmt.spec.js @@ -1,2 +1 @@ -run_spec(__dirname); -run_spec(__dirname, {parser: 'babylon'}); +run_spec(__dirname, null, ["babylon"]); diff --git a/tests/member/__snapshots__/jsfmt.spec.js.snap b/tests/member/__snapshots__/jsfmt.spec.js.snap index 4263d57b0..bdf546b4c 100644 --- a/tests/member/__snapshots__/jsfmt.spec.js.snap +++ b/tests/member/__snapshots__/jsfmt.spec.js.snap @@ -9,13 +9,3 @@ const veryVeryVeryVeryVeryVeryVeryLong = doc.expandedStates[ const small = doc.expandedStates[doc.expandedStates.length - 1]; " `; - -exports[`expand.js 2`] = ` -"const veryVeryVeryVeryVeryVeryVeryLong = doc.expandedStates[doc.expandedStates.length - 1]; -const small = doc.expandedStates[doc.expandedStates.length - 1];~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -const veryVeryVeryVeryVeryVeryVeryLong = doc.expandedStates[ - doc.expandedStates.length - 1 -]; -const small = doc.expandedStates[doc.expandedStates.length - 1]; -" -`; diff --git a/tests/member/jsfmt.spec.js b/tests/member/jsfmt.spec.js index 1161d7bfb..7580dfab0 100644 --- a/tests/member/jsfmt.spec.js +++ b/tests/member/jsfmt.spec.js @@ -1,2 +1 @@ -run_spec(__dirname); -run_spec(__dirname, {parser: 'typescript'}); \ No newline at end of file +run_spec(__dirname, null, ["typescript"]); diff --git a/tests/new_expression/__snapshots__/jsfmt.spec.js.snap b/tests/new_expression/__snapshots__/jsfmt.spec.js.snap index 1445f2e48..8d096e8b6 100644 --- a/tests/new_expression/__snapshots__/jsfmt.spec.js.snap +++ b/tests/new_expression/__snapshots__/jsfmt.spec.js.snap @@ -8,12 +8,3 @@ new (memoize.Cache || MapCache)(); new (typeof this == \\"function\\" ? this : Dict())(); " `; - -exports[`new_expression.js 2`] = ` -"new (memoize.Cache || MapCache) -new (typeof this == \\"function\\" ? this : Dict()) -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -new (memoize.Cache || MapCache)(); -new (typeof this == \\"function\\" ? this : Dict())(); -" -`; diff --git a/tests/new_expression/jsfmt.spec.js b/tests/new_expression/jsfmt.spec.js index 1161d7bfb..7580dfab0 100644 --- a/tests/new_expression/jsfmt.spec.js +++ b/tests/new_expression/jsfmt.spec.js @@ -1,2 +1 @@ -run_spec(__dirname); -run_spec(__dirname, {parser: 'typescript'}); \ No newline at end of file +run_spec(__dirname, null, ["typescript"]); diff --git a/tests/object-prop-break-in/__snapshots__/jsfmt.spec.js.snap b/tests/object-prop-break-in/__snapshots__/jsfmt.spec.js.snap index 8227b17ad..051df4d55 100644 --- a/tests/object-prop-break-in/__snapshots__/jsfmt.spec.js.snap +++ b/tests/object-prop-break-in/__snapshots__/jsfmt.spec.js.snap @@ -17,23 +17,6 @@ function foo() { " `; -exports[`comment.js 2`] = ` -"function foo() { - return { - // this comment causes the problem - bar: baz() + 1 - }; -} -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -function foo() { - return { - // this comment causes the problem - bar: baz() + 1 - }; -} -" -`; - exports[`test.js 1`] = ` "const a = classnames({ \\"some-prop\\": this.state.longLongLongLongLongLongLongLongLongTooLongProp @@ -94,64 +77,3 @@ const g = classnames({ }); " `; - -exports[`test.js 2`] = ` -"const a = classnames({ - \\"some-prop\\": this.state.longLongLongLongLongLongLongLongLongTooLongProp -}); - -const b = classnames({ - \\"some-prop\\": this.state.longLongLongLongLongLongLongLongLongTooLongProp === true -}); - -const c = classnames({ - \\"some-prop\\": [ \\"foo\\", \\"bar\\", \\"foo\\", \\"bar\\", \\"foo\\", \\"bar\\", \\"foo\\", \\"bar\\", \\"foo\\" ] -}); - -const d = classnames({ - \\"some-prop\\": () => {} -}); - -const e = classnames({ - \\"some-prop\\": function bar() {} -}); - -const f = classnames({ - \\"some-prop\\": { foo: \\"bar\\", bar: \\"foo\\", foo: \\"bar\\", bar: \\"foo\\", foo: \\"bar\\" } -}); - -const g = classnames({ - \\"some-prop\\": longLongLongLongLongLongLongLongLongLongLongLongLongTooLongVar || 1337 -}); -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -const a = classnames({ - \\"some-prop\\": this.state.longLongLongLongLongLongLongLongLongTooLongProp -}); - -const b = classnames({ - \\"some-prop\\": this.state.longLongLongLongLongLongLongLongLongTooLongProp === - true -}); - -const c = classnames({ - \\"some-prop\\": [\\"foo\\", \\"bar\\", \\"foo\\", \\"bar\\", \\"foo\\", \\"bar\\", \\"foo\\", \\"bar\\", \\"foo\\"] -}); - -const d = classnames({ - \\"some-prop\\": () => {} -}); - -const e = classnames({ - \\"some-prop\\": function bar() {} -}); - -const f = classnames({ - \\"some-prop\\": { foo: \\"bar\\", bar: \\"foo\\", foo: \\"bar\\", bar: \\"foo\\", foo: \\"bar\\" } -}); - -const g = classnames({ - \\"some-prop\\": longLongLongLongLongLongLongLongLongLongLongLongLongTooLongVar || - 1337 -}); -" -`; diff --git a/tests/object-prop-break-in/jsfmt.spec.js b/tests/object-prop-break-in/jsfmt.spec.js index 1161d7bfb..7580dfab0 100644 --- a/tests/object-prop-break-in/jsfmt.spec.js +++ b/tests/object-prop-break-in/jsfmt.spec.js @@ -1,2 +1 @@ -run_spec(__dirname); -run_spec(__dirname, {parser: 'typescript'}); \ No newline at end of file +run_spec(__dirname, null, ["typescript"]); diff --git a/tests/object_colon_bug/__snapshots__/jsfmt.spec.js.snap b/tests/object_colon_bug/__snapshots__/jsfmt.spec.js.snap index 06ab37f72..aefdc358d 100644 --- a/tests/object_colon_bug/__snapshots__/jsfmt.spec.js.snap +++ b/tests/object_colon_bug/__snapshots__/jsfmt.spec.js.snap @@ -14,18 +14,3 @@ const foo = { }; " `; - -exports[`bug.js 2`] = ` -"const foo = { - bar: props.bar ? props.bar : noop, - baz: props.baz -} -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -const foo = { - bar: props.bar - ? props.bar - : noop, - baz: props.baz -}; -" -`; diff --git a/tests/object_colon_bug/jsfmt.spec.js b/tests/object_colon_bug/jsfmt.spec.js index dd7b4638b..9593c2758 100644 --- a/tests/object_colon_bug/jsfmt.spec.js +++ b/tests/object_colon_bug/jsfmt.spec.js @@ -1,2 +1 @@ -run_spec(__dirname, {printWidth: 35}); -run_spec(__dirname, {parser: 'typescript', printWidth: 35}); \ No newline at end of file +run_spec(__dirname, { printWidth: 35 }, ["typescript"]); diff --git a/tests/objects/jsfmt.spec.js b/tests/objects/jsfmt.spec.js index 939578260..f974ed6c7 100644 --- a/tests/objects/jsfmt.spec.js +++ b/tests/objects/jsfmt.spec.js @@ -1 +1 @@ -run_spec(__dirname, {parser: 'babylon'}); +run_spec(__dirname, { parser: "babylon" }); diff --git a/tests/preserve_line/__snapshots__/jsfmt.spec.js.snap b/tests/preserve_line/__snapshots__/jsfmt.spec.js.snap index 68aa4eb2a..acb62f28f 100644 --- a/tests/preserve_line/__snapshots__/jsfmt.spec.js.snap +++ b/tests/preserve_line/__snapshots__/jsfmt.spec.js.snap @@ -60,64 +60,3 @@ function a() { } " `; - -exports[`comments.js 2`] = ` -"function a() { - const a = 5; // comment - - return a; -} - -function a() { - const a = 5; /* comment */ - - return a; -} - -function a() { - const a = 5; /* comment */ /* comment */ - - return a; -} - -function a() { - const a = 5; /* comment */ /* comment */ // comment - return a; -} - -function a() { - const a = 5; /* comment */ /* comment */ // comment - - return a; -} -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -function a() { - const a = 5; // comment - - return a; -} - -function a() { - const a = 5; /* comment */ - - return a; -} - -function a() { - const a = 5; /* comment */ /* comment */ - - return a; -} - -function a() { - const a = 5; /* comment */ /* comment */ // comment - return a; -} - -function a() { - const a = 5; /* comment */ /* comment */ // comment - - return a; -} -" -`; diff --git a/tests/preserve_line/jsfmt.spec.js b/tests/preserve_line/jsfmt.spec.js index 1161d7bfb..7580dfab0 100644 --- a/tests/preserve_line/jsfmt.spec.js +++ b/tests/preserve_line/jsfmt.spec.js @@ -1,2 +1 @@ -run_spec(__dirname); -run_spec(__dirname, {parser: 'typescript'}); \ No newline at end of file +run_spec(__dirname, null, ["typescript"]); diff --git a/tests/quotes/jsfmt.spec.js b/tests/quotes/jsfmt.spec.js index 821d6e5ee..04f2867bd 100644 --- a/tests/quotes/jsfmt.spec.js +++ b/tests/quotes/jsfmt.spec.js @@ -1,3 +1,2 @@ run_spec(__dirname); - -run_spec(__dirname, { singleQuote: true }); +run_spec(__dirname, { singleQuote: true }); \ No newline at end of file diff --git a/tests/require/__snapshots__/jsfmt.spec.js.snap b/tests/require/__snapshots__/jsfmt.spec.js.snap index 2cc0c6b02..9c2bd9587 100644 --- a/tests/require/__snapshots__/jsfmt.spec.js.snap +++ b/tests/require/__snapshots__/jsfmt.spec.js.snap @@ -35,39 +35,3 @@ const { const MyReallyExtrememlyLongModuleName = require(\\"MyReallyExtrememlyLongModuleName\\"); " `; - -exports[`require.js 2`] = ` -"const { one, two, thee, four, five, six, seven, eight, nine, ten } = require('./my-utils'); -const { one, two, thee, four, five, six, seven, eight, nine, ten, eleven } = require('./my-utils'); - -const MyReallyExtrememlyLongModuleName = require('MyReallyExtrememlyLongModuleName'); -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -const { - one, - two, - thee, - four, - five, - six, - seven, - eight, - nine, - ten -} = require(\\"./my-utils\\"); -const { - one, - two, - thee, - four, - five, - six, - seven, - eight, - nine, - ten, - eleven -} = require(\\"./my-utils\\"); - -const MyReallyExtrememlyLongModuleName = require(\\"MyReallyExtrememlyLongModuleName\\"); -" -`; diff --git a/tests/require/jsfmt.spec.js b/tests/require/jsfmt.spec.js index 1161d7bfb..7580dfab0 100644 --- a/tests/require/jsfmt.spec.js +++ b/tests/require/jsfmt.spec.js @@ -1,2 +1 @@ -run_spec(__dirname); -run_spec(__dirname, {parser: 'typescript'}); \ No newline at end of file +run_spec(__dirname, null, ["typescript"]); diff --git a/tests/rest/jsfmt.spec.js b/tests/rest/jsfmt.spec.js index 11c5ee1fa..a4f98d3ff 100644 --- a/tests/rest/jsfmt.spec.js +++ b/tests/rest/jsfmt.spec.js @@ -1 +1 @@ -run_spec(__dirname, {trailingComma: "all"}); +run_spec(__dirname, { trailingComma: "all" }); diff --git a/tests/shebang/__snapshots__/jsfmt.spec.js.snap b/tests/shebang/__snapshots__/jsfmt.spec.js.snap index ee799cb7e..e6c317e7f 100644 --- a/tests/shebang/__snapshots__/jsfmt.spec.js.snap +++ b/tests/shebang/__snapshots__/jsfmt.spec.js.snap @@ -9,15 +9,6 @@ function a() {} " `; -exports[`shebang.js 2`] = ` -"#!/usr/bin/env node -function a() {} -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -#!/usr/bin/env node -function a() {} -" -`; - exports[`shebang-newline.js 1`] = ` "#!/usr/bin/env node @@ -28,14 +19,3 @@ function a() {} function a() {} " `; - -exports[`shebang-newline.js 2`] = ` -"#!/usr/bin/env node - -function a() {} -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -#!/usr/bin/env node - -function a() {} -" -`; diff --git a/tests/shebang/jsfmt.spec.js b/tests/shebang/jsfmt.spec.js index 1161d7bfb..7580dfab0 100644 --- a/tests/shebang/jsfmt.spec.js +++ b/tests/shebang/jsfmt.spec.js @@ -1,2 +1 @@ -run_spec(__dirname); -run_spec(__dirname, {parser: 'typescript'}); \ No newline at end of file +run_spec(__dirname, null, ["typescript"]); diff --git a/tests/switch/__snapshots__/jsfmt.spec.js.snap b/tests/switch/__snapshots__/jsfmt.spec.js.snap index 57d35be47..9768792e8 100644 --- a/tests/switch/__snapshots__/jsfmt.spec.js.snap +++ b/tests/switch/__snapshots__/jsfmt.spec.js.snap @@ -11,15 +11,3 @@ switch (1) { } " `; - -exports[`empty_switch.js 2`] = ` -"switch (1) { default:; } -switch (1) {} -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -switch (1) { - default: -} -switch (1) { -} -" -`; diff --git a/tests/switch/jsfmt.spec.js b/tests/switch/jsfmt.spec.js index 1161d7bfb..7580dfab0 100644 --- a/tests/switch/jsfmt.spec.js +++ b/tests/switch/jsfmt.spec.js @@ -1,2 +1 @@ -run_spec(__dirname); -run_spec(__dirname, {parser: 'typescript'}); \ No newline at end of file +run_spec(__dirname, null, ["typescript"]); diff --git a/tests/tabWith/jsfmt.spec.js b/tests/tabWith/jsfmt.spec.js index 862b4296f..8f2eb802c 100644 --- a/tests/tabWith/jsfmt.spec.js +++ b/tests/tabWith/jsfmt.spec.js @@ -1,3 +1,2 @@ run_spec(__dirname); - -run_spec(__dirname, { tabWidth: 4 }); +run_spec(__dirname, { tabWidth: 4 }); \ No newline at end of file diff --git a/tests/template/__snapshots__/jsfmt.spec.js.snap b/tests/template/__snapshots__/jsfmt.spec.js.snap index 39ac372fb..5a4933538 100644 --- a/tests/template/__snapshots__/jsfmt.spec.js.snap +++ b/tests/template/__snapshots__/jsfmt.spec.js.snap @@ -33,39 +33,6 @@ var x = { " `; -exports[`faulty-locations.js 2`] = ` -"var o = { - [\`key\`]: () => { - // Comment - } -}; - -var x = { - y: () => Relay.QL\` - query { - \${foo}, - field, - } - \` -}; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -var o = { - [\`key\`]: () => { - // Comment - } -}; - -var x = { - y: () => Relay.QL\` - query { - \${foo}, - field, - } - \` -}; -" -`; - exports[`parenthesis.js 1`] = ` "// \\"ArrowFunctionExpression\\" (() => {})\`\`; @@ -178,116 +145,3 @@ function* f() { } " `; - -exports[`parenthesis.js 2`] = ` -"// \\"ArrowFunctionExpression\\" -(() => {})\`\`; - -// \\"AssignmentExpression\\" -(b = c)\`\`; - -// \\"AwaitExpression\\" -async function f() { - (await b)\`\`; -} - -// \\"BinaryExpression\\" -(b + c)\`\`; - -// \\"CallExpression\\" -b()\`\`; - -// \\"ClassExpression\\" -(class {})\`\`; - -// \\"ConditionalExpression\\" -(b ? c : d)\`\`; - -// \\"FunctionExpression\\" -(function() {})\`\`; - -// \\"LogicalExpression\\" -(b || c)\`\`; - -// \\"MemberExpression\\" -b.c\`\`; - -// \\"NewExpression\\" -(new B())\`\`; - -// \\"ObjectExpression\\" -({})\`\`; - -// \\"SequenceExpression\\" -(b, c)\`\`; - -// \\"TaggedTemplateExpression\\" -(\`\`)\`\`; - -// \\"UnaryExpression\\" -(void b)\`\`; - -// \\"UpdateExpression\\" -(++b)\`\`; - -// \\"YieldExpression\\" -function* f() { - (yield 1)\`\`; -} -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -// \\"ArrowFunctionExpression\\" -(() => {})\`\`; - -// \\"AssignmentExpression\\" -(b = c)\`\`; - -// \\"AwaitExpression\\" -async function f() { - (await b)\`\`; -} - -// \\"BinaryExpression\\" -(b + c)\`\`; - -// \\"CallExpression\\" -b()\`\`; - -// \\"ClassExpression\\" -(class {}\`\`); - -// \\"ConditionalExpression\\" -(b ? c : d)\`\`; - -// \\"FunctionExpression\\" -(function() {})\`\`; - -// \\"LogicalExpression\\" -(b || c)\`\`; - -// \\"MemberExpression\\" -b.c\`\`; - -// \\"NewExpression\\" -new B()\`\`; - -// \\"ObjectExpression\\" -({}\`\`); - -// \\"SequenceExpression\\" -(b, c)\`\`; - -// \\"TaggedTemplateExpression\\" -\`\`\`\`; - -// \\"UnaryExpression\\" -(void b)\`\`; - -// \\"UpdateExpression\\" -(++b)\`\`; - -// \\"YieldExpression\\" -function* f() { - (yield 1)\`\`; -} -" -`; diff --git a/tests/template/jsfmt.spec.js b/tests/template/jsfmt.spec.js index 1161d7bfb..7580dfab0 100644 --- a/tests/template/jsfmt.spec.js +++ b/tests/template/jsfmt.spec.js @@ -1,2 +1 @@ -run_spec(__dirname); -run_spec(__dirname, {parser: 'typescript'}); \ No newline at end of file +run_spec(__dirname, null, ["typescript"]); diff --git a/tests/ternaries/__snapshots__/jsfmt.spec.js.snap b/tests/ternaries/__snapshots__/jsfmt.spec.js.snap index d4cdad92b..2f2e57dde 100644 --- a/tests/ternaries/__snapshots__/jsfmt.spec.js.snap +++ b/tests/ternaries/__snapshots__/jsfmt.spec.js.snap @@ -103,107 +103,3 @@ const obj5 = conditionIsTruthy }; " `; - -exports[`test.js 3`] = ` -"const obj0 = conditionIsTruthy ? shortThing : otherShortThing - -const obj1 = conditionIsTruthy ? { some: 'long', object: 'with', lots: 'of', stuff } : shortThing - -const obj2 = conditionIsTruthy ? shortThing : { some: 'long', object: 'with', lots: 'of', stuff } - -const obj3 = conditionIsTruthy ? { some: 'eeeeeeeeeeeeven looooooooooooooooooooooooooooooonger', object: 'with', lots: 'of', stuff } : shortThing - -const obj4 = conditionIsTruthy ? shortThing : { some: 'eeeeeeeeeeeeven looooooooooooooooooooooooooooooonger', object: 'with', lots: 'of', stuff } - -const obj5 = conditionIsTruthy ? { some: 'long', object: 'with', lots: 'of', stuff } : { some: 'eeeeeeeeeeeeven looooooooooooooooooooooooooooooonger', object: 'with', lots: 'of', stuff } -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -const obj0 = conditionIsTruthy ? shortThing : otherShortThing; - -const obj1 = conditionIsTruthy - ? { some: \\"long\\", object: \\"with\\", lots: \\"of\\", stuff } - : shortThing; - -const obj2 = conditionIsTruthy - ? shortThing - : { some: \\"long\\", object: \\"with\\", lots: \\"of\\", stuff }; - -const obj3 = conditionIsTruthy - ? { - some: \\"eeeeeeeeeeeeven looooooooooooooooooooooooooooooonger\\", - object: \\"with\\", - lots: \\"of\\", - stuff - } - : shortThing; - -const obj4 = conditionIsTruthy - ? shortThing - : { - some: \\"eeeeeeeeeeeeven looooooooooooooooooooooooooooooonger\\", - object: \\"with\\", - lots: \\"of\\", - stuff - }; - -const obj5 = conditionIsTruthy - ? { some: \\"long\\", object: \\"with\\", lots: \\"of\\", stuff } - : { - some: \\"eeeeeeeeeeeeven looooooooooooooooooooooooooooooonger\\", - object: \\"with\\", - lots: \\"of\\", - stuff - }; -" -`; - -exports[`test.js 4`] = ` -"const obj0 = conditionIsTruthy ? shortThing : otherShortThing - -const obj1 = conditionIsTruthy ? { some: 'long', object: 'with', lots: 'of', stuff } : shortThing - -const obj2 = conditionIsTruthy ? shortThing : { some: 'long', object: 'with', lots: 'of', stuff } - -const obj3 = conditionIsTruthy ? { some: 'eeeeeeeeeeeeven looooooooooooooooooooooooooooooonger', object: 'with', lots: 'of', stuff } : shortThing - -const obj4 = conditionIsTruthy ? shortThing : { some: 'eeeeeeeeeeeeven looooooooooooooooooooooooooooooonger', object: 'with', lots: 'of', stuff } - -const obj5 = conditionIsTruthy ? { some: 'long', object: 'with', lots: 'of', stuff } : { some: 'eeeeeeeeeeeeven looooooooooooooooooooooooooooooonger', object: 'with', lots: 'of', stuff } -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -const obj0 = conditionIsTruthy ? shortThing : otherShortThing; - -const obj1 = conditionIsTruthy - ? { some: \\"long\\", object: \\"with\\", lots: \\"of\\", stuff } - : shortThing; - -const obj2 = conditionIsTruthy - ? shortThing - : { some: \\"long\\", object: \\"with\\", lots: \\"of\\", stuff }; - -const obj3 = conditionIsTruthy - ? { - some: \\"eeeeeeeeeeeeven looooooooooooooooooooooooooooooonger\\", - object: \\"with\\", - lots: \\"of\\", - stuff - } - : shortThing; - -const obj4 = conditionIsTruthy - ? shortThing - : { - some: \\"eeeeeeeeeeeeven looooooooooooooooooooooooooooooonger\\", - object: \\"with\\", - lots: \\"of\\", - stuff - }; - -const obj5 = conditionIsTruthy - ? { some: \\"long\\", object: \\"with\\", lots: \\"of\\", stuff } - : { - some: \\"eeeeeeeeeeeeven looooooooooooooooooooooooooooooonger\\", - object: \\"with\\", - lots: \\"of\\", - stuff - }; -" -`; diff --git a/tests/ternaries/jsfmt.spec.js b/tests/ternaries/jsfmt.spec.js index 9a1c5daa6..129171846 100644 --- a/tests/ternaries/jsfmt.spec.js +++ b/tests/ternaries/jsfmt.spec.js @@ -1,5 +1,2 @@ -run_spec(__dirname); -run_spec(__dirname, { tabWidth: 4 }); - -run_spec(__dirname, {parser: 'typescript'}); -run_spec(__dirname, { parser: 'typescript', tabWidth: 4 }); \ No newline at end of file +run_spec(__dirname, null, ["typescript"]); +run_spec(__dirname, { tabWidth: 4 }, ["typescript"]); \ No newline at end of file diff --git a/tests/test_declarations/__snapshots__/jsfmt.spec.js.snap b/tests/test_declarations/__snapshots__/jsfmt.spec.js.snap index e52cda389..b838c7bab 100644 --- a/tests/test_declarations/__snapshots__/jsfmt.spec.js.snap +++ b/tests/test_declarations/__snapshots__/jsfmt.spec.js.snap @@ -152,156 +152,3 @@ it.only.only( ); " `; - -exports[`test_declarations.js 2`] = ` -"// Shouldn't break - -it(\\"does something really long and complicated so I have to write a very long name for the test\\", () => { - console.log(\\"hello!\\"); -}); - -it(\\"does something really long and complicated so I have to write a very long name for the test\\", function() { - console.log(\\"hello!\\"); -}); - -it(\`does something really long and complicated so I have to write a very long name for the test\`, function() { - console.log(\\"hello!\\"); -}); - -it(\`{foo + bar} does something really long and complicated so I have to write a very long name for the test\`, function() { - console.log(\\"hello!\\"); -}); - -it(\`handles - some - newlines - does something really long and complicated so I have to write a very long name for the test\`, () => { - console.log(\\"hello!\\"); -}) - -test(\\"does something really long and complicated so I have to write a very long name for the test\\", (done) => { - console.log(\\"hello!\\"); -}); - -test(\`does something really long and complicated so I have to write a very long name for the test\`, (done) => { - console.log(\\"hello!\\"); -}); - -describe(\\"does something really long and complicated so I have to write a very long name for the describe block\\", () => { - it(\\"an example test\\", (done) => { - console.log(\\"hello!\\"); - }); -}); - -describe(\`does something really long and complicated so I have to write a very long name for the describe block\`, () => { - it(\`an example test\`, (done) => { - console.log(\\"hello!\\"); - }); -}); - -// Should break - -it.only(\\"does something really long and complicated so I have to write a very long name for the test\\", () => { - console.log(\\"hello!\\"); -}); - -it.only(\`does something really long and complicated so I have to write a very long name for the test\`, () => { - console.log(\\"hello!\\"); -}); - -it.only(\\"does something really long and complicated so I have to write a very long name for the test\\", 10, () => { - console.log(\\"hello!\\"); -}); - -it.only.only(\\"does something really long and complicated so I have to write a very long name for the test\\", () => { - console.log(\\"hello!\\"); -}); - -it.only.only(\\"does something really long and complicated so I have to write a very long name for the test\\", (a, b, c) => { - console.log(\\"hello!\\"); -}); -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -// Shouldn't break - -it(\\"does something really long and complicated so I have to write a very long name for the test\\", () => { - console.log(\\"hello!\\"); -}); - -it(\\"does something really long and complicated so I have to write a very long name for the test\\", function() { - console.log(\\"hello!\\"); -}); - -it(\`does something really long and complicated so I have to write a very long name for the test\`, function() { - console.log(\\"hello!\\"); -}); - -it(\`{foo + bar} does something really long and complicated so I have to write a very long name for the test\`, function() { - console.log(\\"hello!\\"); -}); - -it(\`handles - some - newlines - does something really long and complicated so I have to write a very long name for the test\`, () => { - console.log(\\"hello!\\"); -}); - -test(\\"does something really long and complicated so I have to write a very long name for the test\\", done => { - console.log(\\"hello!\\"); -}); - -test(\`does something really long and complicated so I have to write a very long name for the test\`, done => { - console.log(\\"hello!\\"); -}); - -describe(\\"does something really long and complicated so I have to write a very long name for the describe block\\", () => { - it(\\"an example test\\", done => { - console.log(\\"hello!\\"); - }); -}); - -describe(\`does something really long and complicated so I have to write a very long name for the describe block\`, () => { - it(\`an example test\`, done => { - console.log(\\"hello!\\"); - }); -}); - -// Should break - -it.only( - \\"does something really long and complicated so I have to write a very long name for the test\\", - () => { - console.log(\\"hello!\\"); - } -); - -it.only( - \`does something really long and complicated so I have to write a very long name for the test\`, - () => { - console.log(\\"hello!\\"); - } -); - -it.only( - \\"does something really long and complicated so I have to write a very long name for the test\\", - 10, - () => { - console.log(\\"hello!\\"); - } -); - -it.only.only( - \\"does something really long and complicated so I have to write a very long name for the test\\", - () => { - console.log(\\"hello!\\"); - } -); - -it.only.only( - \\"does something really long and complicated so I have to write a very long name for the test\\", - (a, b, c) => { - console.log(\\"hello!\\"); - } -); -" -`; diff --git a/tests/test_declarations/jsfmt.spec.js b/tests/test_declarations/jsfmt.spec.js index 1161d7bfb..7580dfab0 100644 --- a/tests/test_declarations/jsfmt.spec.js +++ b/tests/test_declarations/jsfmt.spec.js @@ -1,2 +1 @@ -run_spec(__dirname); -run_spec(__dirname, {parser: 'typescript'}); \ No newline at end of file +run_spec(__dirname, null, ["typescript"]); diff --git a/tests/trailing_comma/__snapshots__/jsfmt.spec.js.snap b/tests/trailing_comma/__snapshots__/jsfmt.spec.js.snap index dc2d9623a..d8964afae 100644 --- a/tests/trailing_comma/__snapshots__/jsfmt.spec.js.snap +++ b/tests/trailing_comma/__snapshots__/jsfmt.spec.js.snap @@ -117,123 +117,6 @@ function send_single_email( " `; -exports[`es5.js 4`] = ` -"function send_single_email( - app, - email_id, - email_address, - subject, - html, - reply_to -) { - send_single_email_implementation( app, - email_id, - email_address, - subject, - html, - reply_to); - return \\"nothing\\"; -} -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -function send_single_email( - app, - email_id, - email_address, - subject, - html, - reply_to -) { - send_single_email_implementation( - app, - email_id, - email_address, - subject, - html, - reply_to - ); - return \\"nothing\\"; -} -" -`; - -exports[`es5.js 5`] = ` -"function send_single_email( - app, - email_id, - email_address, - subject, - html, - reply_to -) { - send_single_email_implementation( app, - email_id, - email_address, - subject, - html, - reply_to); - return \\"nothing\\"; -} -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -function send_single_email( - app, - email_id, - email_address, - subject, - html, - reply_to, -) { - send_single_email_implementation( - app, - email_id, - email_address, - subject, - html, - reply_to, - ); - return \\"nothing\\"; -} -" -`; - -exports[`es5.js 6`] = ` -"function send_single_email( - app, - email_id, - email_address, - subject, - html, - reply_to -) { - send_single_email_implementation( app, - email_id, - email_address, - subject, - html, - reply_to); - return \\"nothing\\"; -} -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -function send_single_email( - app, - email_id, - email_address, - subject, - html, - reply_to -) { - send_single_email_implementation( - app, - email_id, - email_address, - subject, - html, - reply_to - ); - return \\"nothing\\"; -} -" -`; - exports[`function-calls.js 1`] = ` "const a = (param1, param2, param3) => {} @@ -327,99 +210,6 @@ a( " `; -exports[`function-calls.js 4`] = ` -"const a = (param1, param2, param3) => {} - -a('value', 'value2', 'value3'); - -a( - 'a-long-value', - 'a-really-really-long-value', - 'a-really-really-really-long-value', -); - -a('value', 'value2', a('long-nested-value', 'long-nested-value2', 'long-nested-value3')); -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -const a = (param1, param2, param3) => {}; - -a(\\"value\\", \\"value2\\", \\"value3\\"); - -a( - \\"a-long-value\\", - \\"a-really-really-long-value\\", - \\"a-really-really-really-long-value\\" -); - -a( - \\"value\\", - \\"value2\\", - a(\\"long-nested-value\\", \\"long-nested-value2\\", \\"long-nested-value3\\") -); -" -`; - -exports[`function-calls.js 5`] = ` -"const a = (param1, param2, param3) => {} - -a('value', 'value2', 'value3'); - -a( - 'a-long-value', - 'a-really-really-long-value', - 'a-really-really-really-long-value', -); - -a('value', 'value2', a('long-nested-value', 'long-nested-value2', 'long-nested-value3')); -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -const a = (param1, param2, param3) => {}; - -a(\\"value\\", \\"value2\\", \\"value3\\"); - -a( - \\"a-long-value\\", - \\"a-really-really-long-value\\", - \\"a-really-really-really-long-value\\", -); - -a( - \\"value\\", - \\"value2\\", - a(\\"long-nested-value\\", \\"long-nested-value2\\", \\"long-nested-value3\\"), -); -" -`; - -exports[`function-calls.js 6`] = ` -"const a = (param1, param2, param3) => {} - -a('value', 'value2', 'value3'); - -a( - 'a-long-value', - 'a-really-really-long-value', - 'a-really-really-really-long-value', -); - -a('value', 'value2', a('long-nested-value', 'long-nested-value2', 'long-nested-value3')); -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -const a = (param1, param2, param3) => {}; - -a(\\"value\\", \\"value2\\", \\"value3\\"); - -a( - \\"a-long-value\\", - \\"a-really-really-long-value\\", - \\"a-really-really-really-long-value\\" -); - -a( - \\"value\\", - \\"value2\\", - a(\\"long-nested-value\\", \\"long-nested-value2\\", \\"long-nested-value3\\") -); -" -`; - exports[`object.js 1`] = ` "const a = { b: true, @@ -561,147 +351,6 @@ const aLong = { " `; -exports[`object.js 4`] = ` -"const a = { - b: true, - c: { - c1: 'hello' - }, - d: false -}; - -const aLong = { - bHasALongName: 'a-long-value', - cHasALongName: { - c1: 'a-really-long-value', - c2: 'a-really-really-long-value', - }, - dHasALongName: 'a-long-value-too' -}; - -const aLong = { - dHasALongName: 'a-long-value-too', - eHasABooleanExpression: a === a, -}; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -const a = { - b: true, - c: { - c1: \\"hello\\" - }, - d: false -}; - -const aLong = { - bHasALongName: \\"a-long-value\\", - cHasALongName: { - c1: \\"a-really-long-value\\", - c2: \\"a-really-really-long-value\\" - }, - dHasALongName: \\"a-long-value-too\\" -}; - -const aLong = { - dHasALongName: \\"a-long-value-too\\", - eHasABooleanExpression: a === a -}; -" -`; - -exports[`object.js 5`] = ` -"const a = { - b: true, - c: { - c1: 'hello' - }, - d: false -}; - -const aLong = { - bHasALongName: 'a-long-value', - cHasALongName: { - c1: 'a-really-long-value', - c2: 'a-really-really-long-value', - }, - dHasALongName: 'a-long-value-too' -}; - -const aLong = { - dHasALongName: 'a-long-value-too', - eHasABooleanExpression: a === a, -}; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -const a = { - b: true, - c: { - c1: \\"hello\\", - }, - d: false, -}; - -const aLong = { - bHasALongName: \\"a-long-value\\", - cHasALongName: { - c1: \\"a-really-long-value\\", - c2: \\"a-really-really-long-value\\", - }, - dHasALongName: \\"a-long-value-too\\", -}; - -const aLong = { - dHasALongName: \\"a-long-value-too\\", - eHasABooleanExpression: a === a, -}; -" -`; - -exports[`object.js 6`] = ` -"const a = { - b: true, - c: { - c1: 'hello' - }, - d: false -}; - -const aLong = { - bHasALongName: 'a-long-value', - cHasALongName: { - c1: 'a-really-long-value', - c2: 'a-really-really-long-value', - }, - dHasALongName: 'a-long-value-too' -}; - -const aLong = { - dHasALongName: 'a-long-value-too', - eHasABooleanExpression: a === a, -}; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -const a = { - b: true, - c: { - c1: \\"hello\\", - }, - d: false, -}; - -const aLong = { - bHasALongName: \\"a-long-value\\", - cHasALongName: { - c1: \\"a-really-long-value\\", - c2: \\"a-really-really-long-value\\", - }, - dHasALongName: \\"a-long-value-too\\", -}; - -const aLong = { - dHasALongName: \\"a-long-value-too\\", - eHasABooleanExpression: a === a, -}; -" -`; - exports[`trailing_whitespace.js 1`] = ` "let example = [ 'FOO', @@ -929,231 +578,3 @@ function supersupersupersuperLongF( } " `; - -exports[`trailing_whitespace.js 4`] = ` -"let example = [ - 'FOO', - 'BAR', - // Comment -]; - -foo({}, - // Comment -); - -o = { - state, - // Comment -}; - -o = { - state, - - // Comment -}; - -function supersupersupersuperLongF( - supersupersupersuperLongA, - supersupersupersuperLongB - // Comment -) { - a -} -function supersupersupersuperLongF( - supersupersupersuperLongA, - supersupersupersuperLongB, - // Comment -) { - a -} -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -let example = [ - \\"FOO\\", - \\"BAR\\" - // Comment -]; - -foo( - {} - // Comment -); - -o = { - state - // Comment -}; - -o = { - state - - // Comment -}; - -function supersupersupersuperLongF( - supersupersupersuperLongA, - supersupersupersuperLongB -) // Comment -{ - a; -} -function supersupersupersuperLongF( - supersupersupersuperLongA, - supersupersupersuperLongB -) // Comment -{ - a; -} -" -`; - -exports[`trailing_whitespace.js 5`] = ` -"let example = [ - 'FOO', - 'BAR', - // Comment -]; - -foo({}, - // Comment -); - -o = { - state, - // Comment -}; - -o = { - state, - - // Comment -}; - -function supersupersupersuperLongF( - supersupersupersuperLongA, - supersupersupersuperLongB - // Comment -) { - a -} -function supersupersupersuperLongF( - supersupersupersuperLongA, - supersupersupersuperLongB, - // Comment -) { - a -} -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -let example = [ - \\"FOO\\", - \\"BAR\\", - // Comment -]; - -foo( - {}, - // Comment -); - -o = { - state, - // Comment -}; - -o = { - state, - - // Comment -}; - -function supersupersupersuperLongF( - supersupersupersuperLongA, - supersupersupersuperLongB, -) // Comment -{ - a; -} -function supersupersupersuperLongF( - supersupersupersuperLongA, - supersupersupersuperLongB, -) // Comment -{ - a; -} -" -`; - -exports[`trailing_whitespace.js 6`] = ` -"let example = [ - 'FOO', - 'BAR', - // Comment -]; - -foo({}, - // Comment -); - -o = { - state, - // Comment -}; - -o = { - state, - - // Comment -}; - -function supersupersupersuperLongF( - supersupersupersuperLongA, - supersupersupersuperLongB - // Comment -) { - a -} -function supersupersupersuperLongF( - supersupersupersuperLongA, - supersupersupersuperLongB, - // Comment -) { - a -} -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -let example = [ - \\"FOO\\", - \\"BAR\\", - // Comment -]; - -foo( - {} - // Comment -); - -o = { - state, - // Comment -}; - -o = { - state, - - // Comment -}; - -function supersupersupersuperLongF( - supersupersupersuperLongA, - supersupersupersuperLongB -) // Comment -{ - a; -} -function supersupersupersuperLongF( - supersupersupersuperLongA, - supersupersupersuperLongB -) // Comment -{ - a; -} -" -`; diff --git a/tests/trailing_comma/jsfmt.spec.js b/tests/trailing_comma/jsfmt.spec.js index 340e6fc24..644003e9f 100644 --- a/tests/trailing_comma/jsfmt.spec.js +++ b/tests/trailing_comma/jsfmt.spec.js @@ -1,7 +1,3 @@ -run_spec(__dirname); -run_spec(__dirname, { trailingComma: "all" }); -run_spec(__dirname, { trailingComma: "es5" }); -// -run_spec(__dirname, {parser: 'typescript'}); -run_spec(__dirname, { parser: 'typescript', trailingComma: "all" }); -run_spec(__dirname, { parser: 'typescript', trailingComma: "es5" }); +run_spec(__dirname, null, ["typescript"]); +run_spec(__dirname, { trailingComma: "all" }, ["typescript"]); +run_spec(__dirname, { trailingComma: "es5" }, ["typescript"]); diff --git a/tests/try/__snapshots__/jsfmt.spec.js.snap b/tests/try/__snapshots__/jsfmt.spec.js.snap index 77187de16..54f365553 100644 --- a/tests/try/__snapshots__/jsfmt.spec.js.snap +++ b/tests/try/__snapshots__/jsfmt.spec.js.snap @@ -21,27 +21,6 @@ try { " `; -exports[`empty.js 2`] = ` -"try { -} catch (e) { -} -finally { -} - -try { -} catch (e) { -} -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -try { -} catch (e) { -} finally { -} - -try { -} catch (e) {} -" -`; - exports[`try.js 1`] = ` "try /* missing comment */ @@ -54,16 +33,3 @@ try { } " `; - -exports[`try.js 2`] = ` -"try -/* missing comment */ -{;} -finally {} -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -try { - /* missing comment */ -} finally { -} -" -`; diff --git a/tests/try/jsfmt.spec.js b/tests/try/jsfmt.spec.js index 1161d7bfb..7580dfab0 100644 --- a/tests/try/jsfmt.spec.js +++ b/tests/try/jsfmt.spec.js @@ -1,2 +1 @@ -run_spec(__dirname); -run_spec(__dirname, {parser: 'typescript'}); \ No newline at end of file +run_spec(__dirname, null, ["typescript"]); diff --git a/tests/typescript/conformance/types/any/jsfmt.spec.js b/tests/typescript/conformance/types/any/jsfmt.spec.js index 1982d0456..bc085c48c 100644 --- a/tests/typescript/conformance/types/any/jsfmt.spec.js +++ b/tests/typescript/conformance/types/any/jsfmt.spec.js @@ -1 +1 @@ -run_spec(__dirname, {parser: 'typescript'}); +run_spec(__dirname, { parser: "typescript" }); diff --git a/tests/typescript/conformance/types/functions/jsfmt.spec.js b/tests/typescript/conformance/types/functions/jsfmt.spec.js index 1982d0456..bc085c48c 100644 --- a/tests/typescript/conformance/types/functions/jsfmt.spec.js +++ b/tests/typescript/conformance/types/functions/jsfmt.spec.js @@ -1 +1 @@ -run_spec(__dirname, {parser: 'typescript'}); +run_spec(__dirname, { parser: "typescript" }); diff --git a/tests/typescript/conformance/types/tuple/emptyTuples/jsfmt.spec.js b/tests/typescript/conformance/types/tuple/emptyTuples/jsfmt.spec.js index 1982d0456..bc085c48c 100644 --- a/tests/typescript/conformance/types/tuple/emptyTuples/jsfmt.spec.js +++ b/tests/typescript/conformance/types/tuple/emptyTuples/jsfmt.spec.js @@ -1 +1 @@ -run_spec(__dirname, {parser: 'typescript'}); +run_spec(__dirname, { parser: "typescript" }); diff --git a/tests/typescript/conformance/types/tuple/jsfmt.spec.js b/tests/typescript/conformance/types/tuple/jsfmt.spec.js index 1982d0456..bc085c48c 100644 --- a/tests/typescript/conformance/types/tuple/jsfmt.spec.js +++ b/tests/typescript/conformance/types/tuple/jsfmt.spec.js @@ -1 +1 @@ -run_spec(__dirname, {parser: 'typescript'}); +run_spec(__dirname, { parser: "typescript" }); diff --git a/tests/typescript/conformance/types/typeParameters/typeParameterLists/jsfmt.spec.js b/tests/typescript/conformance/types/typeParameters/typeParameterLists/jsfmt.spec.js index 1982d0456..bc085c48c 100644 --- a/tests/typescript/conformance/types/typeParameters/typeParameterLists/jsfmt.spec.js +++ b/tests/typescript/conformance/types/typeParameters/typeParameterLists/jsfmt.spec.js @@ -1 +1 @@ -run_spec(__dirname, {parser: 'typescript'}); +run_spec(__dirname, { parser: "typescript" }); diff --git a/tests/typescript/conformance/types/union/jsfmt.spec.js b/tests/typescript/conformance/types/union/jsfmt.spec.js index 1982d0456..bc085c48c 100644 --- a/tests/typescript/conformance/types/union/jsfmt.spec.js +++ b/tests/typescript/conformance/types/union/jsfmt.spec.js @@ -1 +1 @@ -run_spec(__dirname, {parser: 'typescript'}); +run_spec(__dirname, { parser: "typescript" }); diff --git a/tests/unary/__snapshots__/jsfmt.spec.js.snap b/tests/unary/__snapshots__/jsfmt.spec.js.snap index 1868258ab..ff9113c2e 100644 --- a/tests/unary/__snapshots__/jsfmt.spec.js.snap +++ b/tests/unary/__snapshots__/jsfmt.spec.js.snap @@ -13,19 +13,6 @@ state = { " `; -exports[`object.js 2`] = ` -"state = { - // students - hoverColumn: -1 -}; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -state = { - // students - hoverColumn: -1 -}; -" -`; - exports[`series.js 1`] = ` "1 + ++x; 1 + x++; @@ -64,42 +51,3 @@ x-- - 1; --x - 1; " `; - -exports[`series.js 2`] = ` -"1 + ++x; -1 + x++; - -+ ++x; -+ x++; - -x++ + 1; -++x + 1; - -1 - --x; -1 - x--; - -- --x; -- x--; - -x-- - 1; ---x - 1; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -1 + ++x; -1 + x++; - -+(++x); -+x++; - -x++ + 1; -++x + 1; - -1 - --x; -1 - x--; - --(--x); --x--; - -x-- - 1; ---x - 1; -" -`; diff --git a/tests/unary/jsfmt.spec.js b/tests/unary/jsfmt.spec.js index 1161d7bfb..7580dfab0 100644 --- a/tests/unary/jsfmt.spec.js +++ b/tests/unary/jsfmt.spec.js @@ -1,2 +1 @@ -run_spec(__dirname); -run_spec(__dirname, {parser: 'typescript'}); \ No newline at end of file +run_spec(__dirname, null, ["typescript"]); diff --git a/tests/unary_expression/__snapshots__/jsfmt.spec.js.snap b/tests/unary_expression/__snapshots__/jsfmt.spec.js.snap index d23cc4c30..3fceaa163 100644 --- a/tests/unary_expression/__snapshots__/jsfmt.spec.js.snap +++ b/tests/unary_expression/__snapshots__/jsfmt.spec.js.snap @@ -20,24 +20,3 @@ x * +y; +x * y; " `; - -exports[`urnary_expression.js 2`] = ` -"!!x -x++ -x--; --+1; -x + + + + 1; -x + (+ (+ (+ 1))) -x * +y; -+x * y; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -!!x; -x++; -x--; --+1; -x + +(+(+1)); -x + +(+(+1)); -x * +y; -+x * y; -" -`; diff --git a/tests/unary_expression/jsfmt.spec.js b/tests/unary_expression/jsfmt.spec.js index 1161d7bfb..7580dfab0 100644 --- a/tests/unary_expression/jsfmt.spec.js +++ b/tests/unary_expression/jsfmt.spec.js @@ -1,2 +1 @@ -run_spec(__dirname); -run_spec(__dirname, {parser: 'typescript'}); \ No newline at end of file +run_spec(__dirname, null, ["typescript"]); diff --git a/tests/update_expression/__snapshots__/jsfmt.spec.js.snap b/tests/update_expression/__snapshots__/jsfmt.spec.js.snap index 1d0217054..ee0cc47f6 100644 --- a/tests/update_expression/__snapshots__/jsfmt.spec.js.snap +++ b/tests/update_expression/__snapshots__/jsfmt.spec.js.snap @@ -12,16 +12,3 @@ new (r++)(); const uuid = String(this._uuidCounter++); " `; - -exports[`update_expression.js 2`] = ` -"(this.x++).toString() -new (r++); -(x++)(); -const uuid = String(this._uuidCounter++); -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -(this.x++).toString(); -new (r++)(); -(x++)(); -const uuid = String(this._uuidCounter++); -" -`; diff --git a/tests/update_expression/jsfmt.spec.js b/tests/update_expression/jsfmt.spec.js index 1161d7bfb..7580dfab0 100644 --- a/tests/update_expression/jsfmt.spec.js +++ b/tests/update_expression/jsfmt.spec.js @@ -1,2 +1 @@ -run_spec(__dirname); -run_spec(__dirname, {parser: 'typescript'}); \ No newline at end of file +run_spec(__dirname, null, ["typescript"]); diff --git a/tests/while/__snapshots__/jsfmt.spec.js.snap b/tests/while/__snapshots__/jsfmt.spec.js.snap index 11d7214bb..6c6ff4bbe 100644 --- a/tests/while/__snapshots__/jsfmt.spec.js.snap +++ b/tests/while/__snapshots__/jsfmt.spec.js.snap @@ -20,24 +20,3 @@ while ( } " `; - -exports[`indent.js 2`] = ` -"if (someVeryLongStringA && someVeryLongStringB && someVeryLongStringC && someVeryLongStringD) {} -while (someVeryLongStringA && someVeryLongStringB && someVeryLongStringC && someVeryLongStringD) {} -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -if ( - someVeryLongStringA && - someVeryLongStringB && - someVeryLongStringC && - someVeryLongStringD -) { -} -while ( - someVeryLongStringA && - someVeryLongStringB && - someVeryLongStringC && - someVeryLongStringD -) { -} -" -`; diff --git a/tests/while/jsfmt.spec.js b/tests/while/jsfmt.spec.js index 1161d7bfb..7580dfab0 100644 --- a/tests/while/jsfmt.spec.js +++ b/tests/while/jsfmt.spec.js @@ -1,2 +1 @@ -run_spec(__dirname); -run_spec(__dirname, {parser: 'typescript'}); \ No newline at end of file +run_spec(__dirname, null, ["typescript"]); diff --git a/tests/windows/__snapshots__/jsfmt.spec.js.snap b/tests/windows/__snapshots__/jsfmt.spec.js.snap index 6b0016a15..5892fe8ee 100644 --- a/tests/windows/__snapshots__/jsfmt.spec.js.snap +++ b/tests/windows/__snapshots__/jsfmt.spec.js.snap @@ -14,18 +14,3 @@ line; endings; " `; - -exports[`line-ending.js 2`] = ` -"this; -has; -windows; -line; -endings; -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -this; -has; -windows; -line; -endings; -" -`; diff --git a/tests/windows/jsfmt.spec.js b/tests/windows/jsfmt.spec.js index 1161d7bfb..7580dfab0 100644 --- a/tests/windows/jsfmt.spec.js +++ b/tests/windows/jsfmt.spec.js @@ -1,2 +1 @@ -run_spec(__dirname); -run_spec(__dirname, {parser: 'typescript'}); \ No newline at end of file +run_spec(__dirname, null, ["typescript"]); diff --git a/tests/yield/__snapshots__/jsfmt.spec.js.snap b/tests/yield/__snapshots__/jsfmt.spec.js.snap index f2dee0e07..b76a92b37 100644 --- a/tests/yield/__snapshots__/jsfmt.spec.js.snap +++ b/tests/yield/__snapshots__/jsfmt.spec.js.snap @@ -42,46 +42,3 @@ async function f() { } " `; - -exports[`conditional.js 2`] = ` -"function* f() { - a = (yield) ? 1 : 1; - a = yield 1 ? 1 : 1; - a = (yield 1) ? 1 : 1; - a = 1 ? yield : yield; - a = 1 ? yield 1 : yield 1; -} - -function* f() { - a = yield* 1 ? 1 : 1; - a = (yield* 1) ? 1 : 1; - a = 1 ? yield* 1 : yield* 1; -} - -async function f() { - a = await 1 ? 1 : 1; - a = (await 1) ? 1 : 1; - a = 1 ? await 1 : await 1; -} -~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ -function* f() { - a = (yield) ? 1 : 1; - a = yield 1 ? 1 : 1; - a = (yield 1) ? 1 : 1; - a = 1 ? yield : yield; - a = 1 ? yield 1 : yield 1; -} - -function* f() { - a = yield* 1 ? 1 : 1; - a = (yield* 1) ? 1 : 1; - a = 1 ? yield* 1 : yield* 1; -} - -async function f() { - a = (await 1) ? 1 : 1; - a = (await 1) ? 1 : 1; - a = 1 ? await 1 : await 1; -} -" -`; diff --git a/tests/yield/jsfmt.spec.js b/tests/yield/jsfmt.spec.js index 551601bd1..6a6711aef 100644 --- a/tests/yield/jsfmt.spec.js +++ b/tests/yield/jsfmt.spec.js @@ -1,2 +1 @@ -run_spec(__dirname, {parser: 'babylon'}); -run_spec(__dirname, {parser: 'typescript'}); \ No newline at end of file +run_spec(__dirname, { parser: "babylon" }, ["typescript"]); diff --git a/tests_config/run_spec.js b/tests_config/run_spec.js index a8c1469de..710829e53 100644 --- a/tests_config/run_spec.js +++ b/tests_config/run_spec.js @@ -1,10 +1,14 @@ "use strict"; -const fs = require('fs'); +const fs = require("fs"); const prettier = require("../"); const types = require("ast-types"); -const parser = require('../src/parser'); +const parser = require("../src/parser"); const RUN_AST_TESTS = process.env["AST_COMPARE"]; +const VERIFY_ALL_PARSERS = process.env["VERIFY_ALL_PARSERS"] || false; +const ALL_PASERS = process.env["ALL_PASERS"] + ? JSON.parse(process.env["ALL_PASERS"]) + : ["flow", "babylon", "typescript"]; // Ignoring empty statements that are added into the output removes a // lot of noise from test failures and let's us focus on the real @@ -18,41 +22,58 @@ function removeEmptyStatements(ast) { }); } -function run_spec(dirname, options) { +function run_spec(dirname, options, additionalParsers) { fs.readdirSync(dirname).forEach(filename => { - if ((filename.endsWith('.js') || filename.endsWith('.ts')) && filename !== 'jsfmt.spec.js') { - const path = dirname + '/' + filename; + if ( + (filename.endsWith(".js") || filename.endsWith(".ts")) && + filename !== "jsfmt.spec.js" + ) { + const path = dirname + "/" + filename; if (!RUN_AST_TESTS) { - const source = read(path).replace(/\r\n/g, '\n'); - const output = prettyprint(source, path, options || {}); - test(filename, () => { - expect(source + '~'.repeat(80) + '\n' + output).toMatchSnapshot(); + const source = read(path).replace(/\r\n/g, "\n"); + const mergedOptions = mergeDefaultOptions(options || {}); + const output = prettyprint(source, path, mergedOptions); + test(`${mergedOptions.parser} - ${parser.parser}-verify`, () => { + expect(source + "~".repeat(80) + "\n" + output).toMatchSnapshot( + filename + ); + }); + + getParsersToVerify( + mergedOptions.parser, + additionalParsers || [] + ).forEach(parserName => { + test(`${filename} - ${parserName}-verify`, () => { + const verifyOptions = Object.assign(mergedOptions, { + parser: parserName + }); + const verifyOutput = prettyprint(source, path, verifyOptions); + expect(output).toEqual(verifyOutput); + }); }); } if (RUN_AST_TESTS) { - const source = read(dirname + '/' + filename); + const source = read(dirname + "/" + filename); const ast = removeEmptyStatements(parse(source)); let prettyprinted = false; let ppast; let pperr = null; try { ppast = removeEmptyStatements(parse(prettyprint(source, path))); - } - catch(e) { + } catch (e) { pperr = e.stack; } - test(path + ' parse', () => { + test(path + " parse", () => { expect(pperr).toBe(null); expect(ppast).toBeDefined(); - if(ast.errors.length === 0) { + if (ast.errors.length === 0) { expect(ast).toEqual(ppast); } }); } - } }); } @@ -62,10 +83,12 @@ function stripLocation(ast) { if (Array.isArray(ast)) { return ast.map(e => stripLocation(e)); } - if (typeof ast === 'object') { + if (typeof ast === "object") { const newObj = {}; for (var key in ast) { - if (key === 'loc' || key === 'range' || key === 'raw' || key === 'comments') { + if ( + key === "loc" || key === "range" || key === "raw" || key === "comments" + ) { continue; } newObj[key] = stripLocation(ast[key]); @@ -80,13 +103,34 @@ function parse(string) { } function prettyprint(src, filename, options) { - return prettier.format(src, Object.assign({ - filename, - parser: 'flow', - printWidth: 80, - }, options)); + return prettier.format( + src, + Object.assign( + { + filename + }, + options + ) + ); } function read(filename) { - return fs.readFileSync(filename, 'utf8'); + return fs.readFileSync(filename, "utf8"); +} + +function mergeDefaultOptions(parserConfig) { + return Object.assign( + { + parser: "flow", + printWidth: 80 + }, + parserConfig + ); +} + +function getParsersToVerify(parser, additionalParsers) { + if (VERIFY_ALL_PARSERS) { + return ALL_PASERS.splice(ALL_PASERS.indexOf(parent), 1); + } + return additionalParsers; }