add comprehensive generation tests

This commit is contained in:
Sebastian McKenzie
2014-11-14 00:51:59 +11:00
parent 1d4f79790a
commit dc131f05a8
120 changed files with 736 additions and 42 deletions

View File

@@ -1,3 +0,0 @@
var multiples = [for (num of nums) num * num];
var multiples = [for (num of nums) for (num2 of nums) num * num];
var multiples = [for (num of nums) if (num > 5) num * num];

View File

@@ -1,3 +0,0 @@
var multiples = [for (num of nums) num * num];
var multiples = [for (num of nums) for (num2 of nums) num * num];
var multiples = [for (num of nums) if (num > 5) num * num];

View File

@@ -1 +0,0 @@
var foo = [1, 2, 3];

View File

@@ -1 +0,0 @@
var foo = [1, 2, 3];

View File

@@ -1,17 +0,0 @@
var foo = `i
am a multiline string`;
var foo = `i am also
a multiline string
foobar`;
var foo = `im a single line string`;
var foo = tagit`i
am a multiline string`;
var foo = tagit`i am also
a multiline string
foobar`;
var foo = tagit`im a single line string`;

View File

@@ -1,17 +0,0 @@
var foo = `i
am a multiline string`;
var foo = `i am also
a multiline string
foobar`;
var foo = `im a single line string`;
var foo = tagit`i
am a multiline string`;
var foo = tagit`i am also
a multiline string
foobar`;
var foo = tagit`im a single line string`;

View File

@@ -0,0 +1,5 @@
[a, b, c];
[[], [b, c], []];
[a,, b,];
[a,,,, b];
[a, b,, c];

View File

@@ -0,0 +1,5 @@
[a, b, c];
[[], [b, c], []];
[a,, b];
[a,,,, b];
[a, b,, c];

View File

@@ -0,0 +1,4 @@
var foo = x => x * x;
var foo = (a, b) => a * b;
var foo = async x => x * x;
var foo = async (a, b) => a * b;

View File

@@ -0,0 +1,4 @@
var foo = x => x * x;
var foo = (a, b) => a * b;
var foo = async x => x * x;
var foo = async (a, b) => a * b;

View File

@@ -0,0 +1,3 @@
foo === bar;
foo + bar;
foo = bar;

View File

@@ -0,0 +1,3 @@
foo === bar;
foo + bar;
foo = bar;

View File

@@ -0,0 +1,7 @@
async function foo() {
await bar();
}
async function bar() {
await* foo();
}

View File

@@ -0,0 +1,7 @@
async function foo() {
await bar();
}
async function bar() {
await* foo();
}

View File

@@ -0,0 +1,5 @@
{}
{
foo();
}

View File

@@ -0,0 +1,5 @@
{}
{
foo();
}

View File

@@ -0,0 +1,7 @@
for (var i in foo) {
break;
}
foo: for (var i in foo) {
break foo;
}

View File

@@ -0,0 +1,7 @@
for (var i in foo) {
break;
}
foo: for (var i in foo) {
break foo;
}

View File

@@ -0,0 +1,5 @@
foo();
foo("foo");
foo("foo", "bar");
foo(bar());
foo(bar("test"));

View File

@@ -0,0 +1,5 @@
foo();
foo("foo");
foo("foo", "bar");
foo(bar());
foo(bar("test"));

View File

@@ -0,0 +1,13 @@
class Foo {
async foo() {}
foo() {}
["foo"]() {}
get foo() {}
set foo() {}
static async foo() {}
static foo() {}
static ["foo"]() {}
static get foo() {}
static set foo() {}
}

View File

@@ -0,0 +1,13 @@
class Foo {
async foo() {}
foo() {}
["foo"]() {}
get foo() {}
set foo() {}
static async foo() {}
static foo() {}
static ["foo"]() {}
static get foo() {}
static set foo() {}
}

View File

@@ -0,0 +1,2 @@
var foo = class Foo {};
var foo = class Foo extends Bar {};

View File

@@ -0,0 +1,2 @@
var foo = class Foo {};
var foo = class Foo extends Bar {};

View File

@@ -0,0 +1,2 @@
class Foo {}
class Foo extends Bar {}

View File

@@ -0,0 +1,2 @@
class Foo {}
class Foo extends Bar {}

View File

@@ -0,0 +1,9 @@
[for (x of nums) x * x];
[for (x of nums) if (x > 2) x * x];
[for (nums of nums2) for (x of nums) x * x];
[for (nums of nums2) for (x of nums) if (x > 2) x * x];
(for (x of nums) x * x);
(for (x of nums) if (x > 2) x * x);
(for (nums of nums2) for (x of nums) x * x);
(for (nums of nums2) for (x of nums) if (x > 2) x * x);

View File

@@ -0,0 +1,9 @@
[for (x of nums) x * x];
[for (x of nums) if (x > 2) x * x];
[for (nums of nums2) for (x of nums) x * x];
[for (nums of nums2) for (x of nums) if (x > 2) x * x];
(for (x of nums) x * x);
(for (x of nums) if (x > 2) x * x);
(for (nums of nums2) for (x of nums) x * x);
(for (nums of nums2) for (x of nums) if (x > 2) x * x);

View File

@@ -0,0 +1 @@
foo ? foo : bar;

View File

@@ -0,0 +1 @@
foo ? foo : bar;

View File

@@ -0,0 +1,7 @@
for (var i in foo) {
continue;
}
foo: for (var i in foo) {
continue foo;
}

View File

@@ -0,0 +1,7 @@
for (var i in foo) {
continue;
}
foo: for (var i in foo) {
continue foo;
}

View File

@@ -0,0 +1 @@
debugger;

View File

@@ -0,0 +1 @@
debugger;

View File

@@ -0,0 +1,5 @@
do {
test();
} while (true);
do {} while (true);

View File

@@ -0,0 +1,5 @@
do {
test();
} while (true);
do {} while (true);

View File

@@ -0,0 +1 @@
;

View File

@@ -0,0 +1 @@
;

View File

@@ -0,0 +1,27 @@
export default 42;
export default {};
export default [];
export default foo;
export default function () {};
export default class {};
export default function foo() {};
export default class Foo {};
export * from "foo";
export { foo } from "foo";
export { foo, bar } from "foo";
export { foo as bar } from "foo";
export { foo as default } from "foo";
export { foo as default, bar } from "foo";
export { foo };
export { foo, bar };
export { foo as bar };
export { foo as default };
export { foo as default, bar };
export var foo = 1;
export var foo2 = function () {};
export var foo3;
export let foo4 = 2;
export let foo5;
export const foo6 = 3;
export function foo7() {}
export class foo8 {}

View File

@@ -0,0 +1,27 @@
export default 42;
export default {};
export default [];
export default foo;
export default function () {};
export default class {};
export default function foo() {};
export default class Foo {};
export * from "foo";
export { foo } from "foo";
export { foo, bar } from "foo";
export { foo as bar } from "foo";
export { foo as default } from "foo";
export { foo as default, bar } from "foo";
export { foo };
export { foo, bar };
export { foo as bar };
export { foo as default };
export { foo as default, bar };
export var foo = 1;
export var foo2 = function () {};
export var foo3;
export let foo4 = 2;
export let foo5;
export const foo6 = 3;
export function foo7() {}
export class foo8 {}

View File

@@ -0,0 +1,5 @@
for (var i in nums) {}
for (var i in nums) {
nums[i] = nums[i] * nums[i];
}

View File

@@ -0,0 +1,5 @@
for (var i in nums) {}
for (var i in nums) {
nums[i] = nums[i] * nums[i];
}

View File

@@ -0,0 +1,5 @@
for (var x of nums) {}
for (var x of nums) {
console.log(x * x);
}

View File

@@ -0,0 +1,5 @@
for (var x of nums) {}
for (var x of nums) {
console.log(x * x);
}

View File

@@ -0,0 +1,3 @@
for (var i = 0;;) {}
for (var i = 0; i < 5;) {}
for (var i = 0; i < 5; i++) {}

View File

@@ -0,0 +1,3 @@
for (var i = 0;;) {}
for (var i = 0; i < 5;) {}
for (var i = 0; i < 5; i++) {}

View File

@@ -0,0 +1,23 @@
function foo(bar = "bar") {}
function foo(bar = "bar", ...items) {}
function foo(...items) {}
function* foo() {}
function foo() {}
async function foo() {}
var foo = function* foo() {};
var foo = function foo() {};
var foo = async function foo() {};
var foo = function* () {};
var foo = function () {};
var foo = async function () {};

View File

@@ -0,0 +1,23 @@
function foo(bar = "bar") {}
function foo(bar = "bar", ...items) {}
function foo(...items) {}
function* foo() {}
function foo() {}
async function foo() {}
var foo = function* foo() {};
var foo = function foo() {};
var foo = async function foo() {};
var foo = function* () {};
var foo = function () {};
var foo = async function () {};

View File

@@ -0,0 +1,2 @@
foo;
undefined;

View File

@@ -0,0 +1,2 @@
foo;
undefined;

View File

@@ -0,0 +1,25 @@
if (foo) foobar();
if (foo) {
foobar();
}
if (foo) {}
if (foo) {
foo();
} else bar();
if (foo) {
foo();
} else {
bar();
}
if (foo) {
foo();
} else if (bar) {
foobar();
} else {
bar();
}

View File

@@ -0,0 +1,25 @@
if (foo) foobar();
if (foo) {
foobar();
}
if (foo) {}
if (foo) {
foo();
} else bar();
if (foo) {
foo();
} else {
bar();
}
if (foo) {
foo();
} else if (bar) {
foobar();
} else {
bar();
}

View File

@@ -0,0 +1,9 @@
import "foo";
import foo from "foo";
import { default as foo } from "foo";
import * as foo from "foo";
import foo, { baz as xyz } from "foo";
import { bar } from "foo";
import { bar, baz } from "foo";
import { bar as baz } from "foo";
import { bar as baz, xyz } from "foo";

View File

@@ -0,0 +1,9 @@
import "foo";
import foo from "foo";
import { default as foo } from "foo";
import * as foo from "foo";
import foo, { baz as xyz } from "foo";
import { bar } from "foo";
import { bar, baz } from "foo";
import { bar as baz } from "foo";
import { bar as baz, xyz } from "foo";

View File

@@ -0,0 +1 @@
label: for (var i in test) {}

View File

@@ -0,0 +1 @@
label: for (var i in test) {}

View File

@@ -0,0 +1,6 @@
5;
"foobar";
/foobar/g;
null;
true;
false;

View File

@@ -0,0 +1,6 @@
5;
"foobar";
/foobar/g;
null;
true;
false;

View File

@@ -0,0 +1,8 @@
foo["bar"];
foo.bar;
foo.bar.foo;
foo.bar["foo"];
foo["foo"]["bar"];
foo[test()][bar()];

View File

@@ -0,0 +1,8 @@
foo["bar"];
foo.bar;
foo.bar.foo;
foo.bar["foo"];
foo["foo"]["bar"];
foo[test()][bar()];

View File

@@ -0,0 +1,3 @@
new Foo;
new Foo();
new Foo(bar);

View File

@@ -0,0 +1,3 @@
new Foo();
new Foo();
new Foo(bar);

View File

@@ -0,0 +1,20 @@
var foo = {};
var foo = { x, y };
var foo = { x: x, y: y };
var foo = {
x: x,
y: y
};
var foo = {
["bar"]: "foo",
["foo"]() {},
foo() {},
async foo() {},
*foo() {},
get foo() {},
set foo() {}
};

View File

@@ -0,0 +1,20 @@
var foo = {};
var foo = { x, y };
var foo = { x: x, y: y };
var foo = {
x: x,
y: y
};
var foo = {
["bar"]: "foo",
["foo"]() {},
foo() {},
async foo() {},
*foo() {},
get foo() {},
set foo() {}
};

View File

@@ -0,0 +1,2 @@
(foo());
(5 * 6);

View File

@@ -0,0 +1,2 @@
(foo());
(5 * 6);

View File

@@ -0,0 +1,7 @@
function foo() {
return;
}
function bar() {
return "foo";
}

View File

@@ -0,0 +1,7 @@
function foo() {
return;
}
function bar() {
return "foo";
}

View File

@@ -0,0 +1,4 @@
foo, bar;
foo,
bar;

View File

@@ -0,0 +1,4 @@
foo, bar;
foo,
bar;

View File

@@ -0,0 +1,3 @@
[...foo];
foo(bar, ...items);
new Foo(...foo);

View File

@@ -0,0 +1,3 @@
[...foo];
foo(bar, ...items);
new Foo(...foo);

View File

@@ -0,0 +1,39 @@
switch (foo) {}
switch (foo) {
case "foo":
}
switch (foo) {
default:
}
switch (foo) {
case "foo":
default:
}
switch (foo) {
case "foo":
case "bar":
default:
}
switch (foo) {
case "foo":
foo();
break;
case "bar":
bar();
break;
default:
yay();
}
switch (foo) {
case "foo": foo();
case "bar": bar();
default: yay();
}

View File

@@ -0,0 +1,39 @@
switch (foo) {}
switch (foo) {
case "foo":
}
switch (foo) {
default:
}
switch (foo) {
case "foo":
default:
}
switch (foo) {
case "foo":
case "bar":
default:
}
switch (foo) {
case "foo":
foo();
break;
case "bar":
bar();
break;
default:
yay();
}
switch (foo) {
case "foo": foo();
case "bar": bar();
default: yay();
}

View File

@@ -0,0 +1,12 @@
html`<b></b>`;
`multi
lines`;
`test ${ interpolation } test`;
`foob
asdf
awer
erqer`;

View File

@@ -0,0 +1,12 @@
html`<b></b>`;
`multi
lines`;
`test ${ interpolation } test`;
`foob
asdf
awer
erqer`;

View File

@@ -0,0 +1,5 @@
this;
this.foo;
this["foo"];
this.foo();
this["foo"]();

View File

@@ -0,0 +1,5 @@
this;
this.foo;
this["foo"];
this.foo();
this["foo"]();

View File

@@ -0,0 +1,3 @@
throw err;
throw Error("foobar");
throw new Error("foobar");

View File

@@ -0,0 +1,3 @@
throw err;
throw Error("foobar");
throw new Error("foobar");

View File

@@ -0,0 +1,25 @@
try {} catch (err) {}
try {
bar;
} catch (err) {}
try {
bar;
} catch (err) {
foo();
}
try {
bar;
} catch (err) {
foo();
} finally {
yay();
}
try {
bar;
} catch (err) {
foo();
} finally {}

View File

@@ -0,0 +1,25 @@
try {} catch (err) {}
try {
bar;
} catch (err) {}
try {
bar;
} catch (err) {
foo();
}
try {
bar;
} catch (err) {
foo();
} finally {
yay();
}
try {
bar;
} catch (err) {
foo();
} finally {}

View File

@@ -0,0 +1,5 @@
delete delete i;
+ +i;
!!i;
+ ++i;
- --i;

View File

@@ -0,0 +1,5 @@
delete delete i;
+ +i;
!!i;
+ ++i;
- --i;

View File

@@ -0,0 +1,2 @@
++i;
i++;

View File

@@ -0,0 +1,2 @@
++i;
i++;

View File

@@ -0,0 +1,13 @@
let foo;
var foo;
let foo = "foo";
var foo = "bar";
const foo = "foo";
let foo, bar = "bar";
var foo, bar = "bar";
let foo = "foo", bar = "bar";
var foo = "foo", bar = "bar";
const foo = "foo", bar = "bar";

View File

@@ -0,0 +1,13 @@
let foo;
var foo;
let foo = "foo";
var foo = "bar";
const foo = "foo";
let foo, bar = "bar";
var foo, bar = "bar";
let foo = "foo", bar = "bar";
var foo = "foo", bar = "bar";
const foo = "foo", bar = "bar";

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