function test_syntax(postfixes, check_error, ignore_opts) { function test_reflect(code, module) { var options = undefined; if (module) {
options = {target: "module"};
} for (var postfix of postfixes) { var cur_code = code + postfix;
function test(code, opts={}) { if (ignore_opts) {
opts = {};
}
let no_strict = "no_strict" in opts && opts.no_strict;
let no_fun = "no_fun" in opts && opts.no_fun;
let no_eval = "no_eval" in opts && opts.no_eval;
let module = "module" in opts && opts.module;
test("switch ");
test("switch (");
test("switch (x ");
test("switch (x) ");
test("switch (x) { ");
test("switch (x) { case ");
test("switch (x) { case 1 ");
test("switch (x) { case 1: ");
test("switch (x) { case 1: case ");
test("switch (x) { case 1: case 2 ");
test("switch (x) { case 1: case 2: ");
test("switch (x) { case 1: case 2: x ");
test("switch (x) { case 1: case 2: x; ");
test("switch (x) { case 1: case 2: x; break ");
test("switch (x) { case 1: case 2: x; break; ");
test("switch (x) { case 1: case 2: x; break; case ");
test("switch (x) { case 1: case 2: x; break; case 3 ");
test("switch (x) { case 1: case 2: x; break; case 3: y ");
test("switch (x) { case 1: case 2: x; break; case 3: y; ");
test("switch (x) { case 1: case 2: x; break; case 3: y; default ");
test("switch (x) { case 1: case 2: x; break; case 3: y; default: ");
test("switch (x) { case 1: case 2: x; break; case 3: y; default: z ");
test("switch (x) { case 1: case 2: x; break; case 3: y; default: z; ");
test("switch (x) { case 1: case 2: x; break; case 3: y; default: z; } ");
// throw
test("throw ");
test("throw x ");
test("throw x; ");
test("var ");
test("var x ");
test("var x = ");
test("var x = 1 ");
test("var x = 1 + ");
test("var x = 1 + 2 ");
test("var x = 1 + 2, ");
test("var x = 1 + 2, y ");
test("var x = 1 + 2, y, ");
test("var x = 1 + 2, y, z ");
test("var x = 1 + 2, y, z; ");
test("var [ ");
test("var [ x ");
test("var [ x, ");
test("var [ x, ... ");
test("var { ");
test("var { x ");
test("var { x: ");
test("var { x: y ");
test("var { x: y, ");
test("var { x: y } ");
test("var { x: y } = ");
// let
test("let ");
test("let x ");
test("let x = ");
test("let x = 1 ");
test("let x = 1 + ");
test("let x = 1 + 2 ");
test("let x = 1 + 2, ");
test("let x = 1 + 2, y ");
test("let x = 1 + 2, y, ");
test("let x = 1 + 2, y, z ");
test("let x = 1 + 2, y, z; ");
test("let [ ");
test("let [ x ");
test("let [ x, ");
test("let [ x, ... ");
test("let { ");
test("let { x ");
test("let { x: ");
test("let { x: y ");
test("let { x: y, ");
test("let { x: y } ");
test("let { x: y } = ");
// const
test("const ");
test("const x ");
test("const x = ");
test("const x = 1 ");
test("const x = 1 + ");
test("const x = 1 + 2 ");
test("const x = 1 + 2, ");
test("const x = 1 + 2, y = 0");
test("const x = 1 + 2, y = 0, ");
test("const x = 1 + 2, y = 0, z = 0 ");
test("const x = 1 + 2, y = 0, z = 0; ");
test("const [ ");
test("const [ x ");
test("const [ x, ");
test("const [ x, ... ");
test("const { ");
test("const { x ");
test("const { x: ");
test("const { x: y ");
test("const { x: y, ");
test("const { x: y } ");
test("const { x: y } = ");
var opts = { no_fun: true, no_eval: true, module: true };
test("export ", opts);
test("export { ", opts);
test("export { x ", opts);
test("export { x, ", opts);
test("export { x, y ", opts);
test("export { x, y as ", opts);
test("export { x, y as z ", opts);
test("export { x, y as z } ", opts);
test("export { x, y as z } from ", opts);
test("export { x, y as z } from 'a' ", opts);
test("export { x, y as z } from 'a'; ", opts);
test("export * ", opts);
test("export * from ", opts);
test("export * from 'a' ", opts);
test("export * from 'a'; ", opts);
test("export * ", opts);
test("export * as ", opts);
test("export * as ns ", opts);
test("export * as ns from ", opts);
test("export * as ns from 'a' ", opts);
test("export * as ns from 'a'; ", opts);
test("export function ", opts);
test("export function f ", opts);
test("export function f( ", opts);
test("export function f() ", opts);
test("export function f() { ", opts);
test("export function f() {} ", opts);
test("export function f() {}; ", opts);
test("export var ", opts);
test("export var a ", opts);
test("export var a = ", opts);
test("export var a = 1 ", opts);
test("export var a = 1, ", opts);
test("export var a = 1, b ", opts);
test("export var a = 1, b = ", opts);
test("export var a = 1, b = 2 ", opts);
test("export var a = 1, b = 2; ", opts);
test("export let ", opts);
test("export let a ", opts);
test("export let a = ", opts);
test("export let a = 1 ", opts);
test("export let a = 1, ", opts);
test("export let a = 1, b ", opts);
test("export let a = 1, b = ", opts);
test("export let a = 1, b = 2 ", opts);
test("export let a = 1, b = 2; ", opts);
test("export const ", opts);
test("export const a ", opts);
test("export const a = ", opts);
test("export const a = 1 ", opts);
test("export const a = 1, ", opts);
test("export const a = 1, b ", opts);
test("export const a = 1, b = ", opts);
test("export const a = 1, b = 2 ", opts);
test("export const a = 1, b = 2; ", opts);
test("export class ", opts);
test("export class Foo ", opts);
test("export class Foo { ", opts);
test("export class Foo { constructor ", opts);
test("export class Foo { constructor( ", opts);
test("export class Foo { constructor() ", opts);
test("export class Foo { constructor() { ", opts);
test("export class Foo { constructor() {} ", opts);
test("export class Foo { constructor() {} } ", opts);
test("export class Foo { constructor() {} }; ", opts);
test("export default function foo ", opts);
test("export default function foo( ", opts);
test("export default function foo() ", opts);
test("export default function foo() { ", opts);
test("export default function foo() {} ", opts);
test("export default function foo() {}; ", opts);
test("export default class ", opts);
test("export default class { ", opts);
test("export default class { constructor ", opts);
test("export default class { constructor( ", opts);
test("export default class { constructor() ", opts);
test("export default class { constructor() { ", opts);
test("export default class { constructor() {} ", opts);
test("export default class { constructor() {} } ", opts);
test("export default class { constructor() {} }; ", opts);
test("export default class Foo ", opts);
test("export default class Foo { ", opts);
test("export default class Foo { constructor ", opts);
test("export default class Foo { constructor( ", opts);
test("export default class Foo { constructor() ", opts);
test("export default class Foo { constructor() { ", opts);
test("export default class Foo { constructor() {} ", opts);
test("export default class Foo { constructor() {} } ", opts);
test("export default class Foo { constructor() {} }; ", opts);
// import
test("import ", opts);
test("import x ", opts);
test("import x from ", opts);
test("import x from 'a' ", opts);
test("import x from 'a'; ", opts);
test("import { ", opts);
test("import { x ", opts);
test("import { x, ", opts);
test("import { x, y ", opts);
test("import { x, y } ", opts);
test("import { x, y } from ", opts);
test("import { x, y } from 'a' ", opts);
test("import { x, y } from 'a'; ", opts);
test("import { x as ", opts);
test("import { x as y ", opts);
test("import { x as y } ", opts);
test("import { x as y } from ", opts);
test("import { x as y } from 'a' ", opts);
test("import { x as y } from 'a'; ", opts);
test("import * ", opts);
test("import * as ", opts);
test("import * as a ", opts);
test("import * as a from ", opts);
test("import * as a from 'a' ", opts);
test("import * as a from 'a'; ", opts);
test("import a ", opts);
test("import a, ", opts);
test("import a, * ", opts);
test("import a, * as ", opts);
test("import a, * as b ", opts);
test("import a, * as b from ", opts);
test("import a, * as b from 'c' ", opts);
test("import a, * as b from 'c'; ", opts);
test("import a, { ", opts);
test("import a, { b ", opts);
test("import a, { b } ", opts);
test("import a, { b } from ", opts);
test("import a, { b } from 'c' ", opts);
test("import a, { b } from 'c'; ", opts);
test("({ get ");
test("({ get p ");
test("({ get p( ");
test("({ get p() ");
test("({ get p() { ");
test("({ get p() {} ");
test("({ get p() {}, ");
test("({ get p() {}, } ");
test("({ get [ ");
test("({ get [p ");
test("({ get [p] ");
test("({ get [p]( ");
test("({ get [p]() ");
// object: setter
test("({ set ");
test("({ set p ");
test("({ set p( ");
test("({ set p(v ");
test("({ set p(v) ");
test("({ set p(v) { ");
test("({ set p(v) {} ");
test("({ set [ ");
test("({ set [p ");
test("({ set [p] ");
test("({ set [p]( ");
test("({ set [p](v ");
test("({ set [p](v) ");
test("class ");
test("class a ");
test("class a { ");
test("class a { constructor ");
test("class a { constructor( ");
test("class a { constructor() ");
test("class a { constructor() { ");
test("class a { constructor() { } ");
test("class a { constructor() { } } ");
test("class a { constructor() { } static ");
test("class a { constructor() { } static m ");
test("class a { constructor() { } static m( ");
test("class a { constructor() { } static m() ");
test("class a { constructor() { } static m() { ");
test("class a { constructor() { } static m() {} ");
test("class a { constructor() { } static m() {} } ");
test("class a { constructor() { } static ( ");
test("class a { constructor() { } static () ");
test("class a { constructor() { } static () { ");
test("class a { constructor() { } static () {} ");
test("class a { constructor() { } static () {} } ");
test("class a { constructor() { } static get ");
test("class a { constructor() { } static get p ");
test("class a { constructor() { } static get p( ");
test("class a { constructor() { } static get p() ");
test("class a { constructor() { } static get p() { ");
test("class a { constructor() { } static get p() {} ");
test("class a { constructor() { } static get p() {} } ");
test("class a { constructor() { } static set ");
test("class a { constructor() { } static set p ");
test("class a { constructor() { } static set p( ");
test("class a { constructor() { } static set p(v ");
test("class a { constructor() { } static set p(v) ");
test("class a { constructor() { } static set p(v) { ");
test("class a { constructor() { } static set p(v) {} ");
test("class a { constructor() { } static set p(v) {} } ");
test("class a { constructor() { } * ");
test("class a { constructor() { } *m ");
test("class a { constructor() { } *m( ");
test("class a { constructor() { } *m() ");
test("class a { constructor() { } *m() { ");
test("class a { constructor() { } *m() {} ");
test("class a { constructor() { } *m() {} } ");
test("class a { constructor() { } static * ");
test("class a { constructor() { } static *m ");
test("class a { constructor() { } static *m( ");
test("class a { constructor() { } static *m() ");
test("class a { constructor() { } static *m() { ");
test("class a { constructor() { } static *m() {} ");
test("class a { constructor() { } static *m() {} } ");
test("class a extends ");
test("class a extends b ");
test("class a extends b { ");
test("class a extends ( ");
test("class a extends ( b ");
test("class a extends ( b ) ");
test("class a extends ( b ) { ");
// ---- Class expression ----
test("( class ");
test("( class a ");
test("( class a { ");
test("( class a { constructor ");
test("( class a { constructor( ");
test("( class a { constructor() ");
test("( class a { constructor() { ");
test("( class a { constructor() { } ");
test("( class a { constructor() { } } ");
test("( class a { constructor() { } } ) ");
test("(class a extends ");
test("(class a extends b ");
test("(class a extends b { ");
test("(class a extends ( ");
test("(class a extends ( b ");
test("(class a extends ( b ) ");
test("(class a extends ( b ) { ");
test("( class { ");
test("( class { constructor ");
test("( class { constructor( ");
test("( class { constructor() ");
test("( class { constructor() { ");
test("( class { constructor() { } ");
test("( class { constructor() { } } ");
test("( class { constructor() { } } ) ");
test("(class extends ");
test("(class extends b ");
test("(class extends b { ");
test("(class extends ( ");
test("(class extends ( b ");
test("(class extends ( b ) ");
test("(class extends ( b ) { ");
test("(function() { 'use asm'; ");
test("(function() { 'use asm'; var ");
test("(function() { 'use asm'; var a ");
test("(function() { 'use asm'; var a = ");
test("(function() { 'use asm'; var a = 1 ");
test("(function() { 'use asm'; var a = 1; ");
test("(function() { 'use asm'; var a = 1; function ");
test("(function() { 'use asm'; var a = 1; function f ");
test("(function() { 'use asm'; var a = 1; function f( ");
test("(function() { 'use asm'; var a = 1; function f() ");
test("(function() { 'use asm'; var a = 1; function f() { ");
test("(function() { 'use asm'; var a = 1; function f() { } ");
test("(function() { 'use asm'; var a = 1; function f() { } var ");
test("(function() { 'use asm'; var a = 1; function f() { } var tbl ");
test("(function() { 'use asm'; var a = 1; function f() { } var tbl = ");
test("(function() { 'use asm'; var a = 1; function f() { } var tbl = [ ");
test("(function() { 'use asm'; var a = 1; function f() { } var tbl = [f ");
test("(function() { 'use asm'; var a = 1; function f() { } var tbl = [f] ");
test("(function() { 'use asm'; var a = 1; function f() { } var tbl = [f]; ");
test("(function() { 'use asm'; var a = 1; function f() { } var tbl = [f]; return ");
test("(function() { 'use asm'; var a = 1; function f() { } var tbl = [f]; return f ");
test("(function() { 'use asm'; var a = 1; function f() { } var tbl = [f]; return f; ");
test("(function() { 'use asm'; var a = 1; function f() { } var tbl = [f]; return f; } ");
test("(function() { 'use asm'; var a = 1; function f() { } var tbl = [f]; return f; }) ");
test("(function() { 'use asm'; var a = 1; function f() { } var tbl = [f]; return f; }); ");
// ==== async/await ====
// async/await function decralation
test("async ");
test("async function ");
test("async function A ");
test("async function A( ");
test("async function A() ");
test("async function A(a ");
test("async function A(a) ");
test("async function A(a) { ");
test("async function A(a) {} ");
test("async function A(a) { await ");
test("async function A(a) { await X ");
test("async function A(a) { await X; ");
test("async function A(a) { await X; } ");
test("async function A(a) { await await ");
test("async function A(a) { await await await ");
test("async function A(a) { await await await X ");
test("async function A(a) { await await await X; ");
test("async function A(a) { await await await X; } ");
opts = { no_fun: true, no_eval: true, module: true };
test("export default async ", opts);
test("export default async function ", opts);
test("export default async function ( ", opts);
test("export default async function () ", opts);
test("export default async function (a ", opts);
test("export default async function (a) ", opts);
test("export default async function (a) { ", opts);
test("export default async function (a) {} ", opts);
test("export default async function (a) { await ", opts);
test("export default async function (a) { await X ", opts);
test("export default async function (a) { await X; ", opts);
test("export default async function (a) { await X; } ", opts);
// async/await function expression
test("(async ");
test("(async function ");
test("(async function A ");
test("(async function A( ");
test("(async function A() ");
test("(async function A(a ");
test("(async function A(a) ");
test("(async function A(a) { ");
test("(async function A(a) {} ");
test("(async function A(a) { await ");
test("(async function A(a) { await X ");
test("(async function A(a) { await X; ");
test("(async function A(a) { await X; } ");
test("(async function A(a) { await X; }) ");
test("(async function ( ");
test("(async function () ");
test("(async function (a ");
test("(async function (a) ");
test("(async function (a) { ");
test("(async function (a) {} ");
test("(async function (a) { await ");
test("(async function (a) { await X ");
test("(async function (a) { await X; ");
test("(async function (a) { await X; } ");
test("(async function (a) { await X; }) ");
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.