Feature/verify against same snapshot (#1087)

* Verify parsers against same snapshot

- Reworked run_spec, now accepts 3th optional array argument for
additional parsers to verify against
- Merged duplicate run_spec configs
- Removed duplicate snapshot data

* Formatted run_spec.js with prettier

* Fixed node4 incompatibility
master
ChristianHersevoort 2017-03-25 16:10:17 +01:00 committed by Christopher Chedeau
parent 862adaf94d
commit 04c959d687
133 changed files with 154 additions and 7336 deletions

View File

@ -8,12 +8,3 @@ exports[`multiple.js 1`] = `
[...a, ...b];
"
`;
exports[`multiple.js 2`] = `
"[...a, ...b,];
[...a, ...b];
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
[...a, ...b];
[...a, ...b];
"
`;

View File

@ -1,2 +1 @@
run_spec(__dirname);
run_spec(__dirname, {parser: 'typescript'});
run_spec(__dirname, null, ["typescript"]);

View File

@ -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];
"
`;

View File

@ -1,2 +1 @@
run_spec(__dirname);
run_spec(__dirname, {parser: 'typescript'});
run_spec(__dirname, null, ["typescript"]);

View File

@ -1 +1 @@
run_spec(__dirname, {parser: 'babylon'});
run_spec(__dirname, { parser: "babylon" });

View File

@ -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
) => {};
"
`;

View File

@ -1,2 +1 @@
run_spec(__dirname);
run_spec(__dirname, {parser: 'typescript'});
run_spec(__dirname, null, ["typescript"]);

View File

@ -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\\")));
})();
"
`;

View File

@ -1,2 +1 @@
run_spec(__dirname);
run_spec(__dirname, {parser: 'typescript'});
run_spec(__dirname, null, ["typescript"]);

View File

@ -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};
"
`;

View File

@ -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"]);

View File

@ -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;
}
);
"
`;

View File

@ -1,2 +1 @@
run_spec(__dirname);
run_spec(__dirname, {parser: 'typescript'});
run_spec(__dirname, null, ["typescript"]);

View File

@ -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
}
}
"
`;

View File

@ -1,2 +1 @@
run_spec(__dirname);
run_spec(__dirname, {parser: 'typescript'});
run_spec(__dirname, null, ["typescript"]);

View File

@ -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) {};
"
`;

View File

@ -1,2 +1 @@
run_spec(__dirname);
run_spec(__dirname, {parser: 'typescript'});
run_spec(__dirname, null, ["typescript"]);

File diff suppressed because it is too large Load Diff

View File

@ -1,2 +1 @@
run_spec(__dirname);
run_spec(__dirname, {parser: 'babylon'});
run_spec(__dirname, null, ["babylon"]);

View File

@ -10,14 +10,3 @@ class c {
}
"
`;
exports[`classes.js 2`] = `
"class c {
[\\"i\\"]() {}
}
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
class c {
[\\"i\\"]() {}
}
"
`;

View File

@ -1,2 +1 @@
run_spec(__dirname);
run_spec(__dirname, {parser: 'typescript'});
run_spec(__dirname, null, ["typescript"]);

View File

@ -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
);
"
`;

View File

@ -1,2 +1 @@
run_spec(__dirname);
run_spec(__dirname, {parser: 'typescript'});
run_spec(__dirname, null, ["typescript"]);

View File

@ -1 +1 @@
run_spec(__dirname, {parser: 'babylon'});
run_spec(__dirname, { parser: "babylon" });

View File

@ -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\\";
}
"
`;

View File

@ -1,3 +1 @@
run_spec(__dirname);
run_spec(__dirname, {parser: 'typescript'});
run_spec(__dirname, {parser: 'babylon'});
run_spec(__dirname, null, ["typescript", "babylon"]);

View File

@ -1 +1 @@
run_spec(__dirname, {parser: 'babylon'});
run_spec(__dirname, { parser: "babylon" });

View File

@ -1 +1 @@
run_spec(__dirname, {parser: 'babylon'});
run_spec(__dirname, { parser: "babylon" });

View File

@ -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);
"
`;

View File

@ -1,2 +1 @@
run_spec(__dirname);
run_spec(__dirname, {parser: 'babylon'});
run_spec(__dirname, null, ["babylon"]);

View File

@ -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);
"
`;

View File

@ -1,2 +1 @@
run_spec(__dirname);
run_spec(__dirname, {parser: 'typescript'});
run_spec(__dirname, null, ["typescript"]);

View File

@ -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" });

View File

@ -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 \\".\\";
"
`;

View File

@ -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"]);

View File

@ -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);
"
`;

View File

@ -1,2 +1 @@
run_spec(__dirname);
run_spec(__dirname, {parser: 'typescript'});
run_spec(__dirname, null, ["typescript"]);

View File

@ -1 +1 @@
run_spec(__dirname, {parser: 'babylon'});
run_spec(__dirname, { parser: "babylon" });

View File

@ -1 +1 @@
run_spec(__dirname, {parser: 'babylon'});
run_spec(__dirname, { parser: "babylon" });

View File

@ -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" });

View File

@ -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<string>;
@ -169,61 +112,6 @@ async function f() {
"
`;
exports[`generator.js 2`] = `
"declare interface File {
readLine(): Promise<string>;
close(): void;
EOF: boolean;
}
declare function fileOpen(path: string): Promise<File>;
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<string>,
close(): void,
EOF: boolean
}
declare function fileOpen(path: string): Promise<File>;
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<void,string,void>;
@ -273,55 +161,6 @@ refuse_return().return(\\"string\\").then(result => {
"
`;
exports[`return.js 2`] = `
"declare var gen: AsyncGenerator<void,string,void>;
// 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<void, string, void>;
// 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
}
});
};
"
`;

View File

@ -1,2 +1 @@
run_spec(__dirname);
run_spec(__dirname, { parser: 'babylon' });
run_spec(__dirname, null, ["babylon"]);

View File

@ -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<A,B>,
v2: Variance<B,A>
) {
(v1: Variance<B,A>); // error on both targs (A ~/~> B)
(v2: Variance<A,B>); // 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<A, B>, v2: Variance<B, A>) {
(v1: Variance<B, A>); // error on both targs (A ~/~> B)
(v2: Variance<A, B>); // 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
}
"
`;

View File

@ -1,2 +1 @@
run_spec(__dirname);
run_spec(__dirname, { parser: 'babylon' });
run_spec(__dirname, null, ["babylon"]);

View File

@ -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
};
"
`;

View File

@ -1,2 +1 @@
run_spec(__dirname);
run_spec(__dirname, { parser: 'babylon' });
run_spec(__dirname, null, ["babylon"]);

View File

@ -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;
});
"
`;

View File

@ -1,2 +1 @@
run_spec(__dirname);
run_spec(__dirname, { parser: 'babylon' });
run_spec(__dirname, null, ["babylon"]);

View File

@ -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();
"
`;

View File

@ -1,2 +1 @@
run_spec(__dirname);
run_spec(__dirname, { parser: 'babylon' });
run_spec(__dirname, null, ["babylon"]);

View File

@ -11,17 +11,6 @@ module.exports = id;
"
`;
exports[`id.js 2`] = `
"declare function id<X>(_: X): X;
module.exports = id;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
declare function id<X>(_: 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\`
"
`;

View File

@ -1,2 +1 @@
run_spec(__dirname);
run_spec(__dirname, { parser: 'babylon' });
run_spec(__dirname, null, ["babylon"]);

View File

@ -45,51 +45,6 @@ declare var b: B<any>;
"
`;
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<T> = A & {
+a: () => B<T>;
+b: () => B<T>;
+c: () => B<T>;
+d: () => B<T>;
+e: () => B<T>;
+f: () => B<T>;
+g: () => B<T>;
+h: () => B<T>;
+i: () => B<T>;
};
declare var b: B<any>;
(b: B<any>);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/* 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<T> = A & {
+a: () => B<T>,
+b: () => B<T>,
+c: () => B<T>,
+d: () => B<T>,
+e: () => B<T>,
+f: () => B<T>,
+g: () => B<T>,
+h: () => B<T>,
+i: () => B<T>
};
declare var b: B<any>;
(b: B<any>);
"
`;
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<any>;
(b: B<any>);
"
`;
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<T> = A & {
+a: (x: B<T>) => void;
+b: (x: B<T>) => void;
+c: (x: B<T>) => void;
+d: (x: B<T>) => void;
+e: (x: B<T>) => void;
+f: (x: B<T>) => void;
+g: (x: B<T>) => void;
+h: (x: B<T>) => void;
+i: (x: B<T>) => void;
};
declare var b: B<any>;
(b: B<any>);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
/* 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<T> = A & {
+a: (x: B<T>) => void,
+b: (x: B<T>) => void,
+c: (x: B<T>) => void,
+d: (x: B<T>) => void,
+e: (x: B<T>) => void,
+f: (x: B<T>) => void,
+g: (x: B<T>) => void,
+h: (x: B<T>) => void,
+i: (x: B<T>) => void
};
declare var b: B<any>;
(b: B<any>);
"
`;

View File

@ -1,2 +1 @@
run_spec(__dirname);
run_spec(__dirname, { parser: 'babylon' });
run_spec(__dirname, null, ["babylon"]);

View File

@ -1,2 +1,3 @@
run_spec(__dirname);
run_spec(__dirname, {parser: 'babylon'});
// FIXME arrow.js flow != babylon output
run_spec(__dirname, { parser: "babylon" });

View File

@ -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 = {};
[];
"
`;

View File

@ -1,2 +1 @@
run_spec(__dirname);
run_spec(__dirname, {parser: 'typescript'});
run_spec(__dirname, null, ["typescript"]);

View File

@ -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() {}();
"
`;

View File

@ -1,2 +1 @@
run_spec(__dirname);
run_spec(__dirname, {parser: 'typescript'});
run_spec(__dirname, null, ["typescript"]);

View File

@ -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;
}
}
"
`;

View File

@ -1,2 +1 @@
run_spec(__dirname);
run_spec(__dirname, {parser: 'typescript'});
run_spec(__dirname, null, ["typescript"]);

View File

@ -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\\";
"
`;

View File

@ -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"]);

View File

@ -52,56 +52,3 @@ const comp4 = (
const comp5 = <div>Keep it on one line.</div>;
"
`;
exports[`test.js 2`] = `
"const comp1 = (
<div style={styles} key=\\"something\\">
Keep the wrapping parens.
</div>
);
const comp2 = <div style={styles} key=\\"something\\">
Create wrapping parens.
</div>;
comp2A = <div style={styles} key=\\"something\\">
Create wrapping parens.
</div>;
const comp3 = <div style={styles} key=\\"something\\">Bump to next line without parens</div>;
const comp4 = <div style={styles} key=\\"something\\">Create wrapping parens and indent <strong>all the things</strong>.</div>;
const comp5 = <div>Keep it on one line.</div>;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
const comp1 = (
<div style={styles} key=\\"something\\">
Keep the wrapping parens.
</div>
);
const comp2 = (
<div style={styles} key=\\"something\\">
Create wrapping parens.
</div>
);
comp2A = (
<div style={styles} key=\\"something\\">
Create wrapping parens.
</div>
);
const comp3 = (
<div style={styles} key=\\"something\\">Bump to next line without parens</div>
);
const comp4 = (
<div style={styles} key=\\"something\\">
Create wrapping parens and indent <strong>all the things</strong>.
</div>
);
const comp5 = <div>Keep it on one line.</div>;
"
`;

View File

@ -1,2 +1 @@
run_spec(__dirname);
run_spec(__dirname, {parser: 'typescript'});
run_spec(__dirname, null, ["typescript"]);

View File

@ -187,191 +187,3 @@ regression_extra_newline_2 = (
);
"
`;
exports[`test.js 2`] = `
"keep = <p>
Welcome to the <strong>Universal React Starter-kyt</strong>.
This starter kyt should serve as the base for an advanced,
server-rendered React app.
</p>
newlines_text =
<div>
hi
there
how
are you
are you fine today?
</div>
newlines_text_spaced =
<div>
space above
space below
</div>
newlines_elems_spaced =
<div>
<span>space above</span>
<span>space below</span>
</div>
newlines_mixed =
<div>
hi
<span>there</span>
how
are <strong>you</strong>
are you fine today?
</div>
newlines_elems =
<div>
<div>
<div></div>
</div>
hi
<div></div>
<span />
<Big />
</div>
regression_extra_newline = (
<div>
<span
className=\\"nuclide-console-new-messages-notification-icon icon icon-nuclicon-arrow-down\\"
/>
New Messages
</div>
);
regression_extra_newline_2 = (
<div>
(
<FormattedMessage
id=\\"some-id\\"
defaultMessage=\\"some loooooooooooooooooooooooooooong default\\"
/>
)
</div>
);
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
keep = (
<p>
Welcome to the <strong>Universal React Starter-kyt</strong>.
This starter kyt should serve as the base for an advanced,
server-rendered React app.
</p>
);
newlines_text = (
<div>
hi
there
how
are you
are you fine today?
</div>
);
newlines_text_spaced = (
<div>
space above
space below
</div>
);
newlines_elems_spaced = (
<div>
<span>space above</span>
<span>space below</span>
</div>
);
newlines_mixed = (
<div>
hi
<span>there</span>
how
are <strong>you</strong>
are you fine today?
</div>
);
newlines_elems = (
<div>
<div>
<div />
</div>
hi
<div />
<span />
<Big />
</div>
);
regression_extra_newline = (
<div>
<span className=\\"nuclide-console-new-messages-notification-icon icon icon-nuclicon-arrow-down\\" />
New Messages
</div>
);
regression_extra_newline_2 = (
<div>
(
<FormattedMessage
id=\\"some-id\\"
defaultMessage=\\"some loooooooooooooooooooooooooooong default\\"
/>
)
</div>
);
"
`;

View File

@ -1,2 +1 @@
run_spec(__dirname);
run_spec(__dirname, {parser: 'typescript'});
run_spec(__dirname, null, ["typescript"]);

View File

@ -198,202 +198,3 @@ not_broken_begin = (
);
"
`;
exports[`test.js 2`] = `
"after =
<span>
foo <span>bar</span>
</span>
before =
<span>
<span>bar</span> foo
</span>
before_break1 =
<span>
<span barbarbarbarbarbarbarbarbarbarbarbarbarbarbarbarbarbarbarbarbarbar /> foo
</span>
before_break2 =
<span>
<span barbarbarbarbarbarbarbarbarbarbarbarbarbarbarbarbarbarbarbarbarbarbarbar /> foo
</span>
after_break =
<span>
foo <span barbarbarbarbarbarbarbarbarbarbarbarbarbarbarbarbarbarbarbarbarbar />
</span>
within =
<span>
foo <span> bar </span>
</span>
break_components =
<div>
<Foo />
<Bar>
<p>foo<span>bar bar bar</span></p><h1><span><em>yep</em></span></h1>
</Bar>
<h2>nope</h2>
</div>
var x = <div>
hello <strong>hi</strong> <foo>sdkflsdfjk</foo>
</div>;
nest_plz =
<div>
<div>
<div></div>
</div>
</div>
regression_not_transformed_1 =
<span> <Icon icon=\\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\\" /></span>;
regression_not_transformed_2 =
<span><Icon icon=\\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\\" /> </span>;
similar_1 =
<span> <Icon icon=\\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\\" /></span>;
similar_2 =
<span><Icon icon=\\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\\" /> </span>;
similar_3 =
<span><Icon icon=\\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\\" /> <Icon icon=\\"\\" /></span>;
not_broken_end =
<div>
long text long text long text long text long text long text long text long text <link>url</link> long text long text
</div>
not_broken_begin =
<div>
<br /> long text long text long text long text long text long text long text long text<link>url</link> long text long text
</div>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
after = (
<span>
foo <span>bar</span>
</span>
);
before = (
<span>
<span>bar</span> foo
</span>
);
before_break1 = (
<span>
<span barbarbarbarbarbarbarbarbarbarbarbarbarbarbarbarbarbarbarbarbarbar />
{\\" \\"}
foo
</span>
);
before_break2 = (
<span>
<span
barbarbarbarbarbarbarbarbarbarbarbarbarbarbarbarbarbarbarbarbarbarbarbar
/>
{\\" \\"}
foo
</span>
);
after_break = (
<span>
foo
{\\" \\"}
<span barbarbarbarbarbarbarbarbarbarbarbarbarbarbarbarbarbarbarbarbarbar />
</span>
);
within = (
<span>
foo <span> bar </span>
</span>
);
break_components = (
<div>
<Foo />
<Bar>
<p>foo<span>bar bar bar</span></p><h1><span><em>yep</em></span></h1>
</Bar>
<h2>nope</h2>
</div>
);
var x = (
<div>
hello <strong>hi</strong> <foo>sdkflsdfjk</foo>
</div>
);
nest_plz = (
<div>
<div>
<div />
</div>
</div>
);
regression_not_transformed_1 = (
<span>
{\\" \\"}<Icon icon=\\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\\" />
</span>
);
regression_not_transformed_2 = (
<span>
<Icon icon=\\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\\" />{\\" \\"}
</span>
);
similar_1 = (
<span>
{\\" \\"}
<Icon icon=\\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\\" />
</span>
);
similar_2 = (
<span>
<Icon icon=\\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\\" />
{\\" \\"}
</span>
);
similar_3 = (
<span>
<Icon icon=\\"aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa\\" /> <Icon icon=\\"\\" />
</span>
);
not_broken_end = (
<div>
long text long text long text long text long text long text long text long text
{\\" \\"}
<link>url</link>
{\\" \\"}
long text long text
</div>
);
not_broken_begin = (
<div>
<br />
{\\" \\"}
long text long text long text long text long text long text long text long text
<link>url</link>
{\\" \\"}
long text long text
</div>
);
"
`;

View File

@ -1,2 +1 @@
run_spec(__dirname);
run_spec(__dirname, {parser: 'typescript'});
run_spec(__dirname, null, ["typescript"]);

View File

@ -212,216 +212,3 @@ long_obj = (
);
"
`;
exports[`test.js 2`] = `
"long_closed =
<BaseForm url=\\"/auth/google\\" method=\\"GET\\" colour=\\"blue\\" size=\\"large\\" submitLabel=\\"Sign in with Google\\"/>
long_open =
<BaseForm url=\\"/auth/google\\" method=\\"GET\\" colour=\\"blue\\" size=\\"large\\" submitLabel=\\"Sign in with Google\\">
hello
</BaseForm>
long_open_long_children =
<BaseForm url=\\"/auth/google\\" method=\\"GET\\" colour=\\"blue\\" size=\\"large\\" submitLabel=\\"Sign in with Google\\">
<BaseForm url=\\"/auth/google\\" method=\\"GET\\" colour=\\"blue\\" size=\\"large\\" submitLabel=\\"Sign in with Google\\">
Hello world
</BaseForm>
<div><div><div><div><div><div>hey hiya how are ya</div></div></div></div></div></div>
<div><div><div><div attr=\\"long\\" attr2=\\"also long\\" attr3=\\"gonna break\\"></div></div></div></div>
<div><div><div>
<div attr=\\"long\\" attr2=\\"also long\\" attr3=\\"gonna break\\" attr4=\\"hello please break me\\" />
</div></div></div>
<BaseForm url=\\"/auth/google\\" method=\\"GET\\" colour=\\"blue\\" size=\\"large\\" submitLabel=\\"Sign in with Google\\"><BaseForm url=\\"/auth/google\\" method=\\"GET\\" colour=\\"blue\\" size=\\"large\\" submitLabel=\\"Sign in with Google\\"></BaseForm>d</BaseForm>
<BaseForm url=\\"/auth/google\\" method=\\"GET\\" colour=\\"blue\\" size=\\"large\\" submitLabel=\\"Sign in with Google\\"><BaseForm url=\\"/auth/google\\" method=\\"GET\\" colour=\\"blue\\" size=\\"large\\" submitLabel=\\"Sign in with Google\\"></BaseForm></BaseForm>
</BaseForm>
short_closed =
<BaseForm url=\\"/auth/google\\" method=\\"GET\\"/>
short_open =
<BaseForm url=\\"/auth/google\\" method=\\"GET\\">
hello
</BaseForm>
make_self_closing =
<div>
<BaseForm url=\\"/auth/google\\" method=\\"GET\\" colour=\\"blue\\" size=\\"large\\" submitLabel=\\"Sign in with Google\\">
</BaseForm>
<BaseForm url=\\"/auth/google\\" method=\\"GET\\" colour=\\"blue\\" size=\\"large\\" submitLabel=\\"Sign in with Google\\"></BaseForm>
</div>
leave_opening =
<BaseForm url=\\"/auth/google\\" method=\\"GET\\" colour=\\"blue\\" size=\\"large\\" submitLabel=\\"Sign in with Google\\"> </BaseForm>
long_string =
<div className=\\"i use bootstrap and just put loooaads of classnames in here all the time\\">hello world</div>
long_string_with_extra_param =
<div className=\\"i use bootstrap and just put loooaads of classnames in here all the time\\" blah=\\"3\\">hello world</div>
long_obj =
<div style={{ i: 'dont', use: 'bootstrap', and: 'instead', use: 'massive', objects }}>hello world</div>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
long_closed = (
<BaseForm
url=\\"/auth/google\\"
method=\\"GET\\"
colour=\\"blue\\"
size=\\"large\\"
submitLabel=\\"Sign in with Google\\"
/>
);
long_open = (
<BaseForm
url=\\"/auth/google\\"
method=\\"GET\\"
colour=\\"blue\\"
size=\\"large\\"
submitLabel=\\"Sign in with Google\\"
>
hello
</BaseForm>
);
long_open_long_children = (
<BaseForm
url=\\"/auth/google\\"
method=\\"GET\\"
colour=\\"blue\\"
size=\\"large\\"
submitLabel=\\"Sign in with Google\\"
>
<BaseForm
url=\\"/auth/google\\"
method=\\"GET\\"
colour=\\"blue\\"
size=\\"large\\"
submitLabel=\\"Sign in with Google\\"
>
Hello world
</BaseForm>
<div>
<div><div><div><div><div>hey hiya how are ya</div></div></div></div></div>
</div>
<div>
<div>
<div><div attr=\\"long\\" attr2=\\"also long\\" attr3=\\"gonna break\\" /></div>
</div>
</div>
<div>
<div>
<div>
<div
attr=\\"long\\"
attr2=\\"also long\\"
attr3=\\"gonna break\\"
attr4=\\"hello please break me\\"
/>
</div>
</div>
</div>
<BaseForm
url=\\"/auth/google\\"
method=\\"GET\\"
colour=\\"blue\\"
size=\\"large\\"
submitLabel=\\"Sign in with Google\\"
>
<BaseForm
url=\\"/auth/google\\"
method=\\"GET\\"
colour=\\"blue\\"
size=\\"large\\"
submitLabel=\\"Sign in with Google\\"
/>
d
</BaseForm>
<BaseForm
url=\\"/auth/google\\"
method=\\"GET\\"
colour=\\"blue\\"
size=\\"large\\"
submitLabel=\\"Sign in with Google\\"
>
<BaseForm
url=\\"/auth/google\\"
method=\\"GET\\"
colour=\\"blue\\"
size=\\"large\\"
submitLabel=\\"Sign in with Google\\"
/>
</BaseForm>
</BaseForm>
);
short_closed = <BaseForm url=\\"/auth/google\\" method=\\"GET\\" />;
short_open = (
<BaseForm url=\\"/auth/google\\" method=\\"GET\\">
hello
</BaseForm>
);
make_self_closing = (
<div>
<BaseForm
url=\\"/auth/google\\"
method=\\"GET\\"
colour=\\"blue\\"
size=\\"large\\"
submitLabel=\\"Sign in with Google\\"
/>
<BaseForm
url=\\"/auth/google\\"
method=\\"GET\\"
colour=\\"blue\\"
size=\\"large\\"
submitLabel=\\"Sign in with Google\\"
/>
</div>
);
leave_opening = (
<BaseForm
url=\\"/auth/google\\"
method=\\"GET\\"
colour=\\"blue\\"
size=\\"large\\"
submitLabel=\\"Sign in with Google\\"
>
{\\" \\"}
</BaseForm>
);
long_string = (
<div className=\\"i use bootstrap and just put loooaads of classnames in here all the time\\">
hello world
</div>
);
long_string_with_extra_param = (
<div
className=\\"i use bootstrap and just put loooaads of classnames in here all the time\\"
blah=\\"3\\"
>
hello world
</div>
);
long_obj = (
<div
style={{
i: \\"dont\\",
use: \\"bootstrap\\",
and: \\"instead\\",
use: \\"massive\\",
objects
}}
>
hello world
</div>
);
"
`;

View File

@ -1,2 +1 @@
run_spec(__dirname);
run_spec(__dirname, {parser: 'typescript'});
run_spec(__dirname, null, ["typescript"]);

View File

@ -232,236 +232,3 @@ const renderTernary = props => (
);
"
`;
exports[`test.js 2`] = `
"const render1 = ({ styles }) => (
<div style={styles} key=\\"something\\">
Keep the wrapping parens. Put each key on its own line.
</div>
);
const render2 = ({ styles }) => <div style={styles} key=\\"something\\">
Create wrapping parens.
</div>;
const render3 = ({ styles }) => <div style={styles} key=\\"something\\">Bump to next line without parens</div>;
const render4 = ({ styles }) => <div style={styles} key=\\"something\\">Create wrapping parens and indent <strong>all the things</strong>.</div>;
const render5 = ({ styles }) => <div>Keep it on one line.</div>;
const render6 = ({ styles }) => (
<div attr1=\\"aaaaaaaaaaaaaaaaa\\" attr2=\\"bbbbbbbbbbb\\" attr3=\\"cccccccccccc\\">
<div attr1=\\"aaaaaaaaaaaaaaaaa\\" attr2=\\"bbbbbbbbbbb\\" attr3=\\"cccccccccccc\\" attr4>ddd d dd d d dddd dddd <strong>hello</strong></div>
<div attr1=\\"aaaaaaaaaaaaaaaaa\\" attr2=\\"bbbbbbbbbbb\\" attr3=\\"cccccccccccc\\" attr4>ddd d dd d d dddd dddd <strong>hello</strong></div>
<div attr1=\\"aaaaaaaaaaaaaaaaa\\" attr2=\\"bbbbbbbbbbb\\" attr3=\\"cccccccccccc\\" attr4>
<div attr1=\\"aaaaaaaaaaaaaaaaa\\" attr2=\\"bbbbbbbbbbb\\" attr3=\\"cccccccccccc\\" attr4>ddd d dd d d dddd dddd <strong>hello</strong></div> <strong>hello</strong></div>
</div>
)
const render7 = () =>
<div>
<span /><span>Dont break each elem onto its own line.</span> <span />
<div /> <div />
</div>
const render7A = () => (
<div>
<div /><div /><div />
</div>
)
const render7B = () => (
<div>
<span> <span/> Dont break plz</span>
<span><span/>Dont break plz</span>
<span>Dont break plz<span/></span>
</div>
)
const render8 = (props) => <div>{props.text}</div>
const render9 = (props) => <div>{props.looooooooooooooooooooooooooooooong_text}</div>
const render10 = (props) => <div>{props.even_looooooooooooooooooooooooooooooooooooooooooonger_contents}</div>
const notJSX = (aaaaaaaaaaaaaaaaa, bbbbbbbbbbb) => this.someLongCallWithParams(aaaaaa, bbbbbbb).anotherLongCallWithParams(cccccccccccc, dddddddddddddddddddddd)
React.render(
<BaseForm url=\\"/auth/google\\" method=\\"GET\\" colour=\\"blue\\" size=\\"large\\" submitLabel=\\"Sign in with Google\\" />
, document.querySelector('#react-root')
)
const renderTernary = (props) =>
<BaseForm url=\\"/auth/google\\" method=\\"GET\\" colour=\\"blue\\" size=\\"large\\" submitLabel=\\"Sign in with Google\\">
{props.showTheThing ?
<BaseForm url=\\"/auth/google\\" method=\\"GET\\" colour=\\"blue\\" size=\\"large\\" submitLabel=\\"Sign in with Google\\">Hello world</BaseForm>
: \\"hello \\" + \\"howdy! \\"}
{props.showTheThing ?
<BaseForm url=\\"/auth/google\\" method=\\"GET\\" colour=\\"blue\\" size=\\"large\\" submitLabel=\\"Sign in with Google\\">Hello world</BaseForm>
:
null
}
{props.showTheThing ? null :
<BaseForm url=\\"/auth/google\\" method=\\"GET\\" colour=\\"blue\\" size=\\"large\\" submitLabel=\\"Sign in with Google\\">Hello world</BaseForm>
}
{props.showTheOtherThing ? <div>I am here</div> : <div attr=\\"blah\\" />}
{props.showTheOtherThing ? <div>I am here!!</div> : null}
</BaseForm>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
const render1 = ({ styles }) => (
<div style={styles} key=\\"something\\">
Keep the wrapping parens. Put each key on its own line.
</div>
);
const render2 = ({ styles }) => (
<div style={styles} key=\\"something\\">
Create wrapping parens.
</div>
);
const render3 = ({ styles }) => (
<div style={styles} key=\\"something\\">Bump to next line without parens</div>
);
const render4 = ({ styles }) => (
<div style={styles} key=\\"something\\">
Create wrapping parens and indent <strong>all the things</strong>.
</div>
);
const render5 = ({ styles }) => <div>Keep it on one line.</div>;
const render6 = ({ styles }) => (
<div attr1=\\"aaaaaaaaaaaaaaaaa\\" attr2=\\"bbbbbbbbbbb\\" attr3=\\"cccccccccccc\\">
<div
attr1=\\"aaaaaaaaaaaaaaaaa\\"
attr2=\\"bbbbbbbbbbb\\"
attr3=\\"cccccccccccc\\"
attr4
>
ddd d dd d d dddd dddd <strong>hello</strong>
</div>
<div
attr1=\\"aaaaaaaaaaaaaaaaa\\"
attr2=\\"bbbbbbbbbbb\\"
attr3=\\"cccccccccccc\\"
attr4
>
ddd d dd d d dddd dddd <strong>hello</strong>
</div>
<div
attr1=\\"aaaaaaaaaaaaaaaaa\\"
attr2=\\"bbbbbbbbbbb\\"
attr3=\\"cccccccccccc\\"
attr4
>
<div
attr1=\\"aaaaaaaaaaaaaaaaa\\"
attr2=\\"bbbbbbbbbbb\\"
attr3=\\"cccccccccccc\\"
attr4
>
ddd d dd d d dddd dddd <strong>hello</strong>
</div>
{\\" \\"}
<strong>hello</strong>
</div>
</div>
);
const render7 = () => (
<div>
<span /><span>Dont break each elem onto its own line.</span> <span />
<div /> <div />
</div>
);
const render7A = () => (
<div>
<div /><div /><div />
</div>
);
const render7B = () => (
<div>
<span> <span /> Dont break plz</span>
<span><span />Dont break plz</span>
<span>Dont break plz<span /></span>
</div>
);
const render8 = props => <div>{props.text}</div>;
const render9 = props => (
<div>{props.looooooooooooooooooooooooooooooong_text}</div>
);
const render10 = props => (
<div>
{props.even_looooooooooooooooooooooooooooooooooooooooooonger_contents}
</div>
);
const notJSX = (aaaaaaaaaaaaaaaaa, bbbbbbbbbbb) =>
this.someLongCallWithParams(aaaaaa, bbbbbbb).anotherLongCallWithParams(
cccccccccccc,
dddddddddddddddddddddd
);
React.render(
<BaseForm
url=\\"/auth/google\\"
method=\\"GET\\"
colour=\\"blue\\"
size=\\"large\\"
submitLabel=\\"Sign in with Google\\"
/>,
document.querySelector(\\"#react-root\\")
);
const renderTernary = props => (
<BaseForm
url=\\"/auth/google\\"
method=\\"GET\\"
colour=\\"blue\\"
size=\\"large\\"
submitLabel=\\"Sign in with Google\\"
>
{props.showTheThing
? <BaseForm
url=\\"/auth/google\\"
method=\\"GET\\"
colour=\\"blue\\"
size=\\"large\\"
submitLabel=\\"Sign in with Google\\"
>
Hello world
</BaseForm>
: \\"hello \\" + \\"howdy! \\"}
{props.showTheThing
? <BaseForm
url=\\"/auth/google\\"
method=\\"GET\\"
colour=\\"blue\\"
size=\\"large\\"
submitLabel=\\"Sign in with Google\\"
>
Hello world
</BaseForm>
: null}
{props.showTheThing
? null
: <BaseForm
url=\\"/auth/google\\"
method=\\"GET\\"
colour=\\"blue\\"
size=\\"large\\"
submitLabel=\\"Sign in with Google\\"
>
Hello world
</BaseForm>}
{props.showTheOtherThing ? <div>I am here</div> : <div attr=\\"blah\\" />}
{props.showTheOtherThing ? <div>I am here!!</div> : null}
</BaseForm>
);
"
`;

View File

@ -1,2 +1 @@
run_spec(__dirname);
run_spec(__dirname, {parser: 'typescript'});
run_spec(__dirname, null, ["typescript"]);

View File

@ -139,145 +139,6 @@ exports[`expression.js 1`] = `
"
`;
exports[`expression.js 2`] = `
"<View
style={
{
someVeryLongStyle1: \\"true\\",
someVeryLongStyle2: \\"true\\",
someVeryLongStyle3: \\"true\\",
someVeryLongStyle4: \\"true\\"
}
}
/>;
<View
style={
[
{
someVeryLongStyle1: \\"true\\",
someVeryLongStyle2: \\"true\\",
someVeryLongStyle3: \\"true\\",
someVeryLongStyle4: \\"true\\"
}
]
}
/>;
<Something>
{() => (
<SomethingElse>
<span />
</SomethingElse>
)}
</Something>;
<Something>
{items.map(item => (
<SomethingElse>
<span />
</SomethingElse>
))}
</Something>;
<Something>
{function() {
return (
<SomethingElse>
<span />
</SomethingElse>
);
}}
</Something>;
<RadioListItem
key={option}
imageSource={this.props.veryBigItemImageSourceFunc &&
this.props.veryBigItemImageSourceFunc(option)}
imageSize={this.props.veryBigItemImageSize}
imageView={this.props.veryBigItemImageViewFunc &&
this.props.veryBigItemImageViewFunc(option)}
heading={this.props.displayTextFunc(option)}
value={option}
/>;
<ParentComponent prop={
<Child>
test
</Child>
}/>;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<View
style={{
someVeryLongStyle1: \\"true\\",
someVeryLongStyle2: \\"true\\",
someVeryLongStyle3: \\"true\\",
someVeryLongStyle4: \\"true\\"
}}
/>;
<View
style={[
{
someVeryLongStyle1: \\"true\\",
someVeryLongStyle2: \\"true\\",
someVeryLongStyle3: \\"true\\",
someVeryLongStyle4: \\"true\\"
}
]}
/>;
<Something>
{() => (
<SomethingElse>
<span />
</SomethingElse>
)}
</Something>;
<Something>
{items.map(item => (
<SomethingElse>
<span />
</SomethingElse>
))}
</Something>;
<Something>
{function() {
return (
<SomethingElse>
<span />
</SomethingElse>
);
}}
</Something>;
<RadioListItem
key={option}
imageSource={
this.props.veryBigItemImageSourceFunc &&
this.props.veryBigItemImageSourceFunc(option)
}
imageSize={this.props.veryBigItemImageSize}
imageView={
this.props.veryBigItemImageViewFunc &&
this.props.veryBigItemImageViewFunc(option)
}
heading={this.props.displayTextFunc(option)}
value={option}
/>;
<ParentComponent
prop={
<Child>
test
</Child>
}
/>;
"
`;
exports[`hug.js 1`] = `
"<div>
{__DEV__
@ -348,76 +209,6 @@ exports[`hug.js 1`] = `
"
`;
exports[`hug.js 2`] = `
"<div>
{__DEV__
? this.renderDevApp()
: <div>
{routes.map(route => (
<MatchAsync
key={\`\${route.to}-async\`}
pattern={route.to}
exactly={route.to === \\"/\\"}
getComponent={routeES6Modules[route.value]}
/>
))}
</div>}
</div>;
<div>
{__DEV__ && <div>
{routes.map(route => (
<MatchAsync
key={\`\${route.to}-async\`}
pattern={route.to}
exactly={route.to === \\"/\\"}
getComponent={routeES6Modules[route.value]}
/>
))}
</div>}
</div>;
<div>
{member.memberName.memberSomething +
(member.memberDef.memberSomething.signatures ? '()' : '')}
</div>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<div>
{__DEV__
? this.renderDevApp()
: <div>
{routes.map(route => (
<MatchAsync
key={\`\${route.to}-async\`}
pattern={route.to}
exactly={route.to === \\"/\\"}
getComponent={routeES6Modules[route.value]}
/>
))}
</div>}
</div>;
<div>
{__DEV__ &&
<div>
{routes.map(route => (
<MatchAsync
key={\`\${route.to}-async\`}
pattern={route.to}
exactly={route.to === \\"/\\"}
getComponent={routeES6Modules[route.value]}
/>
))}
</div>}
</div>;
<div>
{member.memberName.memberSomething +
(member.memberDef.memberSomething.signatures ? \\"()\\" : \\"\\")}
</div>;
"
`;
exports[`object-property.js 1`] = `
"const tabs = [
{
@ -449,37 +240,6 @@ const tabs = [
"
`;
exports[`object-property.js 2`] = `
"const tabs = [
{
title: \\"General Info\\",
content: (
<GeneralForm
long-attribute=\\"i-need-long-value-here\\"
onSave={ onSave }
onCancel={ onCancel }
countries={ countries }
/>
)
}
];
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
const tabs = [
{
title: \\"General Info\\",
content: (
<GeneralForm
long-attribute=\\"i-need-long-value-here\\"
onSave={onSave}
onCancel={onCancel}
countries={countries}
/>
)
}
];
"
`;
exports[`open-break.js 1`] = `
"<td
onClick={() => {
@ -510,36 +270,6 @@ onClick={() => {
"
`;
exports[`open-break.js 2`] = `
"<td
onClick={() => {
a
}}>{header}{showSort}</td>;
<td
onClick={() => {
a
}}>{header}<showSort attr=\\"long long long long long long long long long long long\\"/></td>;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<td
onClick={() => {
a;
}}
>
{header}{showSort}
</td>;
<td
onClick={() => {
a;
}}
>
{header}
<showSort attr=\\"long long long long long long long long long long long\\" />
</td>;
"
`;
exports[`parens.js 1`] = `
"a = [
<path
@ -569,35 +299,6 @@ a = [
"
`;
exports[`parens.js 2`] = `
"a = [
<path
key='0'
d='M13.6,10.6l,4-2.8L9.5,M13.6,10.6l,4-2.8L9.5,M13.6,10.6l,4-2.8L9.5,M13.6,10.6l,4-2.8L9.5,M13.6,10.6l,4-2.8L9.5,M13.6,10.6l,4-2.8L9.5,'
/>,
<path
key='1'
d='M13.6,10.6l,4-2.8L9.5,M13.6,10.6l,4-2.8L9.5,M13.6,10.6l,4-2.8L9.5,M13.6,10.6l,4-2.8L9.5,M13.6,10.6l,4-2.8L9.5,M13.6,10.6l,4-2.8L9.5,'
/>,
];
<div {...((foo || foo === null) ? {foo} : null)} />
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a = [
<path
key=\\"0\\"
d=\\"M13.6,10.6l,4-2.8L9.5,M13.6,10.6l,4-2.8L9.5,M13.6,10.6l,4-2.8L9.5,M13.6,10.6l,4-2.8L9.5,M13.6,10.6l,4-2.8L9.5,M13.6,10.6l,4-2.8L9.5,\\"
/>,
<path
key=\\"1\\"
d=\\"M13.6,10.6l,4-2.8L9.5,M13.6,10.6l,4-2.8L9.5,M13.6,10.6l,4-2.8L9.5,M13.6,10.6l,4-2.8L9.5,M13.6,10.6l,4-2.8L9.5,M13.6,10.6l,4-2.8L9.5,\\"
/>
];
<div {...(foo || foo === null ? { foo } : null)} />;
"
`;
exports[`quotes.js 1`] = `
"<div id=\\"&quot;'<>&amp;quot;\\" />;
<div id='\\"&#39;<>&amp;quot;' />;
@ -608,14 +309,3 @@ exports[`quotes.js 1`] = `
<div id={\\"'\\\\\\"&quot;<>&amp;quot;\\"} />;
"
`;
exports[`quotes.js 2`] = `
"<div id=\\"&quot;'<>&amp;quot;\\" />;
<div id='\\"&#39;<>&amp;quot;' />;
<div id={'\\\\'\\"&quot;<>&amp;quot;'} />;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<div id=\\"&quot;'<>&amp;quot;\\" />;
<div id=\\"&quot;'<>&amp;quot;\\" />;
<div id={\\"'\\\\\\"&quot;<>&amp;quot;\\"} />;
"
`;

View File

@ -1,2 +1 @@
run_spec(__dirname);
run_spec(__dirname, {parser: 'typescript'});
run_spec(__dirname, null, ["typescript"]);

View File

@ -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" });

View File

@ -48,52 +48,3 @@ exports[`last_line.js 2`] = `
</SomeHighlyConfiguredComponent>;
"
`;
exports[`last_line.js 3`] = `
"<SomeHighlyConfiguredComponent
onEnter={this.onEnter}
onLeave={this.onLeave}
onChange={this.onChange}
initialValue={this.state.initialValue}
ignoreStuff={true}
>
<div>and the children go here</div>
<div>and here too</div>
</SomeHighlyConfiguredComponent>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<SomeHighlyConfiguredComponent
onEnter={this.onEnter}
onLeave={this.onLeave}
onChange={this.onChange}
initialValue={this.state.initialValue}
ignoreStuff={true}>
<div>and the children go here</div>
<div>and here too</div>
</SomeHighlyConfiguredComponent>;
"
`;
exports[`last_line.js 4`] = `
"<SomeHighlyConfiguredComponent
onEnter={this.onEnter}
onLeave={this.onLeave}
onChange={this.onChange}
initialValue={this.state.initialValue}
ignoreStuff={true}
>
<div>and the children go here</div>
<div>and here too</div>
</SomeHighlyConfiguredComponent>
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
<SomeHighlyConfiguredComponent
onEnter={this.onEnter}
onLeave={this.onLeave}
onChange={this.onChange}
initialValue={this.state.initialValue}
ignoreStuff={true}
>
<div>and the children go here</div>
<div>and here too</div>
</SomeHighlyConfiguredComponent>;
"
`;

View File

@ -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"]);

View File

@ -8,12 +8,3 @@ a:;
b;
"
`;
exports[`empty_label.js 2`] = `
"a:;
b
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
a:;
b;
"
`;

View File

@ -1,2 +1 @@
run_spec(__dirname);
run_spec(__dirname, {parser: 'typescript'});
run_spec(__dirname, null, ["typescript"]);

View File

@ -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;
"
`;

View File

@ -1,2 +1 @@
run_spec(__dirname);
run_spec(__dirname, {parser: 'typescript'});
run_spec(__dirname, null, ["typescript"]);

View File

@ -50,54 +50,3 @@ ExampleStory.getFragment(\\"story\\")}
</div>;
"
`;
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')}
\`;
<div>
{ExampleStory.getFragment('story') // $FlowFixMe found when converting React.createClass to ES6
}
</div>;
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
\`\${a + a // a
}
\${/* comment*/
a}
\${/* comment */ b}
\${/* comment */ /* comment */ c}
\${/* comment*/
/*comment*/
d}
\${/* $FlowFixMe found when converting React.createClass to ES6*/
ExampleStory.getFragment(\\"story\\")}
\`;
<div>
{ExampleStory.getFragment(\\"story\\") // $FlowFixMe found when converting React.createClass to ES6
}
</div>;
"
`;

View File

@ -1,2 +1 @@
run_spec(__dirname);
run_spec(__dirname, {parser: 'babylon'});
run_spec(__dirname, null, ["babylon"]);

View File

@ -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];
"
`;

View File

@ -1,2 +1 @@
run_spec(__dirname);
run_spec(__dirname, {parser: 'typescript'});
run_spec(__dirname, null, ["typescript"]);

View File

@ -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())();
"
`;

View File

@ -1,2 +1 @@
run_spec(__dirname);
run_spec(__dirname, {parser: 'typescript'});
run_spec(__dirname, null, ["typescript"]);

View File

@ -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
});
"
`;

View File

@ -1,2 +1 @@
run_spec(__dirname);
run_spec(__dirname, {parser: 'typescript'});
run_spec(__dirname, null, ["typescript"]);

View File

@ -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
};
"
`;

View File

@ -1,2 +1 @@
run_spec(__dirname, {printWidth: 35});
run_spec(__dirname, {parser: 'typescript', printWidth: 35});
run_spec(__dirname, { printWidth: 35 }, ["typescript"]);

View File

@ -1 +1 @@
run_spec(__dirname, {parser: 'babylon'});
run_spec(__dirname, { parser: "babylon" });

View File

@ -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;
}
"
`;

View File

@ -1,2 +1 @@
run_spec(__dirname);
run_spec(__dirname, {parser: 'typescript'});
run_spec(__dirname, null, ["typescript"]);

View File

@ -1,3 +1,2 @@
run_spec(__dirname);
run_spec(__dirname, { singleQuote: true });
run_spec(__dirname, { singleQuote: true });

View File

@ -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\\");
"
`;

View File

@ -1,2 +1 @@
run_spec(__dirname);
run_spec(__dirname, {parser: 'typescript'});
run_spec(__dirname, null, ["typescript"]);

View File

@ -1 +1 @@
run_spec(__dirname, {trailingComma: "all"});
run_spec(__dirname, { trailingComma: "all" });

View File

@ -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() {}
"
`;

Some files were not shown because too many files have changed in this diff Show More