diff --git a/src/expression.js b/src/expression.js
index cd7da6ac71..f80a55c318 100755
--- a/src/expression.js
+++ b/src/expression.js
@@ -101,6 +101,13 @@ pp.parseMaybeAssign = function(noIn, refShorthandDefaultPos, afterLeftParse) {
node.left = this.type === tt.eq ? this.toAssignable(left) : left
refShorthandDefaultPos.start = 0; // reset because shorthand default was used correctly
this.checkLVal(left)
+ if (left.parenthesizedExpression) {
+ if (left.type === "ObjectPattern") {
+ this.raise(left.start, "You're trying to assign to a parenthesized expression, instead of `({ foo }) = {}` use `({ foo } = {})`");
+ } else {
+ this.raise(left.start, "Parenthesized left hand expressions are illegal");
+ }
+ }
this.next()
node.right = this.parseMaybeAssign(noIn)
return this.finishNode(node, "AssignmentExpression")
diff --git a/src/lval.js b/src/lval.js
index 3f5eff3532..b7c4f2707d 100755
--- a/src/lval.js
+++ b/src/lval.js
@@ -9,14 +9,6 @@ const pp = Parser.prototype
// if possible.
pp.toAssignable = function(node, isBinding) {
- if (node.parenthesizedExpression) {
- if (node.type === "ObjectExpression") {
- this.raise(node.start, "You're trying to assign to a parenthesized expression, instead of `({ foo }) = {}` use `({ foo } = {})`");
- } else {
- this.raise(node.start, "Parenthesized left hand expressions are illegal");
- }
- }
-
if (this.options.ecmaVersion >= 6 && node) {
switch (node.type) {
case "Identifier":
diff --git a/src/tokencontext.js b/src/tokencontext.js
index a3cabb58e2..f1cb36e7b8 100755
--- a/src/tokencontext.js
+++ b/src/tokencontext.js
@@ -57,6 +57,10 @@ pp.updateContext = function(prevType) {
// Token-specific context update code
tt.parenR.updateContext = tt.braceR.updateContext = function() {
+ if (this.context.length == 1) {
+ this.exprAllowed = true
+ return
+ }
let out = this.context.pop()
if (out === types.b_stat && this.curContext() === types.f_expr) {
this.context.pop()
@@ -64,7 +68,7 @@ tt.parenR.updateContext = tt.braceR.updateContext = function() {
} else if (out === types.b_tmpl) {
this.exprAllowed = true
} else {
- this.exprAllowed = !(out && out.isExpr)
+ this.exprAllowed = !out.isExpr
}
}
diff --git a/test/driver.js b/test/driver.js
deleted file mode 100755
index ed48ace821..0000000000
--- a/test/driver.js
+++ /dev/null
@@ -1,114 +0,0 @@
-(function(exports) {
- var tests = [];
-
- exports.test = function(code, ast, options) {
- tests.push({code: code, ast: ast, options: options});
- };
- exports.testFail = function(code, message, options) {
- tests.push({code: code, error: message, options: options});
- };
- exports.testAssert = function(code, assert, options) {
- tests.push({code: code, assert: assert, options: options});
- };
-
- exports.runTests = function(config, callback) {
- var parse = config.parse;
-
- for (var i = 0; i < tests.length; ++i) {
- var test = tests[i];
- if (config.filter && !config.filter(test)) continue;
- var testOpts = test.options || {locations: true};
- var expected = {};
- if (expected.onComment = testOpts.onComment)
- testOpts.onComment = []
- if (expected.onToken = testOpts.onToken)
- testOpts.onToken = [];
-
- try {
- var ast = parse(test.code, testOpts);
- } catch(e) {
- if (!(e instanceof SyntaxError)) { console.log(e.stack); throw e; }
- if (test.error) {
- if (e.message == test.error) callback("ok", test.code);
- else callback("fail", test.code,
- "Expected error message: " + test.error + "\nGot error message: " + e.message);
- } else {
- callback("error", test.code, e.message || e.toString());
- }
- continue
- }
-
- if (test.error) {
- if (config.loose) callback("ok", test.code);
- else callback("fail", test.code, "Expected error message: " + test.error + "\nBut parsing succeeded.");
- } else if (test.assert) {
- var error = test.assert(ast);
- if (error) callback("fail", test.code, "\n Assertion failed:\n " + error);
- else callback("ok", test.code);
- } else {
- var mis = misMatch(test.ast, ast);
- for (var name in expected) {
- if (mis) break;
- if (expected[name]) {
- mis = misMatch(expected[name], testOpts[name]);
- testOpts[name] = expected[name];
- }
- }
- if (mis) callback("fail", test.code, mis);
- else callback("ok", test.code);
- }
- }
- };
-
- function ppJSON(v) { return v instanceof RegExp ? v.toString() : JSON.stringify(v, null, 2); }
- function addPath(str, pt) {
- if (str.charAt(str.length-1) == ")")
- return str.slice(0, str.length-1) + "/" + pt + ")";
- return str + " (" + pt + ")";
- }
-
- var misMatch = exports.misMatch = function(exp, act) {
- if (!exp || !act || (typeof exp != "object") || (typeof act != "object")) {
- if (exp !== act && typeof exp != "function")
- return ppJSON(exp) + " !== " + ppJSON(act);
- } else if (exp instanceof RegExp || act instanceof RegExp) {
- var left = ppJSON(exp), right = ppJSON(act);
- if (left !== right) return left + " !== " + right;
- } else if (exp.splice) {
- if (!act.slice) return ppJSON(exp) + " != " + ppJSON(act);
- if (act.length != exp.length) return "array length mismatch " + exp.length + " != " + act.length;
- for (var i = 0; i < act.length; ++i) {
- var mis = misMatch(exp[i], act[i]);
- if (mis) return addPath(mis, i);
- }
- } else {
- for (var prop in exp) {
- var mis = misMatch(exp[prop], act[prop]);
- if (mis) return addPath(mis, prop);
- }
- }
- };
-
- function mangle(ast) {
- if (typeof ast != "object" || !ast) return;
- if (ast.slice) {
- for (var i = 0; i < ast.length; ++i) mangle(ast[i]);
- } else {
- var loc = ast.start && ast.end && {start: ast.start, end: ast.end};
- if (loc) { delete ast.start; delete ast.end; }
- for (var name in ast) if (ast.hasOwnProperty(name)) mangle(ast[name]);
- if (loc) ast.loc = loc;
- }
- }
-
- exports.printTests = function() {
- var out = "";
- for (var i = 0; i < tests.length; ++i) {
- if (tests[i].error) continue;
- mangle(tests[i].ast);
- out += "test(" + JSON.stringify(tests[i].code) + ", " + JSON.stringify(tests[i].ast, null, 2) + ");\n\n";
- }
- document.body.innerHTML = "";
- document.body.appendChild(document.createElement("pre")).appendChild(document.createTextNode(out));
- };
-})(typeof exports == "undefined" ? window : exports);
diff --git a/test/run.js b/test/run.js
deleted file mode 100755
index 4c4ff3c85e..0000000000
--- a/test/run.js
+++ /dev/null
@@ -1,104 +0,0 @@
-(function() {
- var driver, acorn;
-
- if (typeof require !== "undefined") {
- driver = require("./driver.js");
- require("./tests.js");
- require("./tests-harmony.js");
- require("./tests-flow.js");
- require("./tests-jsx.js");
- require("./tests-babel.js");
- require("babel/register")
- acorn = require("../src")
- } else {
- driver = window;
- acorn = window.acorn;
- }
-
- var htmlLog = typeof document === "object" && document.getElementById('log');
- var htmlGroup = htmlLog;
-
- function group(name) {
- if (htmlGroup) {
- var parentGroup = htmlGroup;
- htmlGroup = document.createElement("ul");
- var item = document.createElement("li");
- item.textContent = name;
- item.appendChild(htmlGroup);
- parentGroup.appendChild(item);
- }
- if (typeof console === "object" && console.group) {
- console.group(name);
- }
- }
-
- function groupEnd() {
- if (htmlGroup) {
- htmlGroup = htmlGroup.parentElement.parentElement;
- }
- if (typeof console === "object" && console.groupEnd) {
- console.groupEnd(name);
- }
- }
-
- function log(title, message) {
- if (htmlGroup) {
- var elem = document.createElement("li");
- elem.innerHTML = "" + title + " " + message;
- htmlGroup.appendChild(elem);
- }
- if (typeof console === "object") console.log(title, message);
- }
-
- var stats, modes = {
- Normal: {
- config: {
- parse: acorn.parse
- }
- }
- };
-
- function report(state, code, message) {
- if (state != "ok") {++stats.failed; log(code, message);}
- ++stats.testsRun;
- }
-
- group("Errors");
-
- for (var name in modes) {
- group(name);
- var mode = modes[name];
- stats = mode.stats = {testsRun: 0, failed: 0};
- var t0 = +new Date;
- driver.runTests(mode.config, report);
- mode.stats.duration = +new Date - t0;
- groupEnd();
- }
-
- groupEnd();
-
- function outputStats(name, stats) {
- log(name + ":", stats.testsRun + " tests run in " + stats.duration + "ms; " +
- (stats.failed ? stats.failed + " failures." : "all passed."));
- }
-
- var total = {testsRun: 0, failed: 0, duration: 0};
-
- group("Stats");
-
- for (var name in modes) {
- var stats = modes[name].stats;
- outputStats(name + " parser", stats);
- for (var key in stats) total[key] += stats[key];
- }
-
- outputStats("Total", total);
-
- groupEnd();
-
- if (total.failed && typeof process === "object") {
- process.stdout.write("", function() {
- process.exit(1);
- });
- }
-})();
diff --git a/test/tests-babel.js b/test/tests-babel.js
deleted file mode 100644
index c0d2a26e3e..0000000000
--- a/test/tests-babel.js
+++ /dev/null
@@ -1,2060 +0,0 @@
-var test = require("./driver.js").test;
-var testFail = require("./driver.js").testFail;
-var testAssert = require("./driver.js").testAssert;
-
-// ES7: Exponentiation Operator
-
-test('a **= 2;', {
- type: "Program",
- start: 0,
- end: 8,
- body: [{
- type: "ExpressionStatement",
- start: 0,
- end: 8,
- expression: {
- type: "AssignmentExpression",
- start: 0,
- end: 7,
- operator: "**=",
- left: {
- type: "Identifier",
- start: 0,
- end: 1,
- name: "a"
- },
- right: {
- type: "Literal",
- start: 6,
- end: 7,
- value: 2
- }
- }
- }]
-}, {
- ecmaVersion: 7
-});
-
-test('var squared = 2 ** 2;', {
- type: "Program",
- start: 0,
- end: 21,
- body: [{
- type: "VariableDeclaration",
- start: 0,
- end: 21,
- declarations: [{
- type: "VariableDeclarator",
- start: 4,
- end: 20,
- id: {
- type: "Identifier",
- start: 4,
- end: 11,
- name: "squared"
- },
- init: {
- type: "BinaryExpression",
- start: 14,
- end: 20,
- left: {
- type: "Literal",
- start: 14,
- end: 15,
- value: 2
- },
- operator: "**",
- right: {
- type: "Literal",
- start: 19,
- end: 20,
- value: 2
- }
- }
- }],
- kind: "var"
- }]
-}, {
- ecmaVersion: 7
-});
-
-test("2 ** (3 ** 2)", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "BinaryExpression",
- left: {
- type: "Literal",
- value: 2
- },
- operator: "**",
- right: {
- type: "BinaryExpression",
- left: {
- type: "Literal",
- value: 3
- },
- operator: "**",
- right: {
- type: "Literal",
- value: 2
- }
- }
- }
- }]
-}, {
- ecmaVersion: 7
-});
-
-test("2 ** 3 ** 2", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "BinaryExpression",
- left: {
- type: "Literal",
- value: 2
- },
- operator: "**",
- right: {
- type: "BinaryExpression",
- left: {
- type: "Literal",
- value: 3
- },
- operator: "**",
- right: {
- type: "Literal",
- value: 2
- }
- }
- }
- }]
-}, {
- ecmaVersion: 7
-});
-
-test("(2 ** -1) * 2", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "BinaryExpression",
- left: {
- type: "BinaryExpression",
- left: {
- type: "Literal",
- value: 2
- },
- operator: "**",
- right: {
- type: "UnaryExpression",
- operator: "-",
- prefix: true,
- argument: {
- type: "Literal",
- value: 1
- }
- }
- },
- operator: "*",
- right: {
- type: "Literal",
- value: 2
- }
- }
- }]
-}, {
- ecmaVersion: 7
-});
-
-test("2 ** -1 * 2", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "BinaryExpression",
- left: {
- type: "BinaryExpression",
- left: {
- type: "Literal",
- value: 2
- },
- operator: "**",
- right: {
- type: "UnaryExpression",
- operator: "-",
- prefix: true,
- argument: {
- type: "Literal",
- value: 1
- }
- }
- },
- operator: "*",
- right: {
- type: "Literal",
- value: 2
- }
- }
- }]
-}, {
- ecmaVersion: 7
-});
-
-// ES7: Object Rest/Spread
-
-test('let {...x} = z', {
- type: "Program",
- start: 0,
- end: 14,
- body: [{
- type: "VariableDeclaration",
- start: 0,
- end: 14,
- declarations: [
- {
- type: "VariableDeclarator",
- start: 4,
- end: 14,
- id: {
- type: "ObjectPattern",
- start: 4,
- end: 10,
- properties: [
- {
- type: "SpreadProperty",
- start: 5,
- end: 9,
- argument: {
- type: "Identifier",
- start: 8,
- end: 9,
- name: "x"
- }
- }
- ]
- },
- init: {
- type: "Identifier",
- start: 13,
- end: 14,
- name: "z"
- }
- }
- ],
- kind: "let"
- }]
-}, {
- ecmaVersion: 7,
- features: { "es7.objectRestSpread": true }
-});
-
-test('let {x, ...y} = z', {
- type: "Program",
- start: 0,
- end: 17,
- body: [{
- type: "VariableDeclaration",
- start: 0,
- end: 17,
- declarations: [
- {
- type: "VariableDeclarator",
- start: 4,
- end: 17,
- id: {
- type: "ObjectPattern",
- start: 4,
- end: 13,
- properties: [
- {
- type: "Property",
- start: 5,
- end: 6,
- method: false,
- shorthand: true,
- computed: false,
- key: {
- type: "Identifier",
- start: 5,
- end: 6,
- name: "x"
- },
- kind: "init",
- value: {
- type: "Identifier",
- start: 5,
- end: 6,
- name: "x"
- }
- },
- {
- type: "SpreadProperty",
- start: 8,
- end: 12,
- argument: {
- type: "Identifier",
- start: 11,
- end: 12,
- name: "y"
- }
- }
- ]
- },
- init: {
- type: "Identifier",
- start: 16,
- end: 17,
- name: "z"
- }
- }
- ],
- kind: "let"
- }]
-}, {
- ecmaVersion: 7,
- features: { "es7.objectRestSpread": true }
-});
-
-test('(function({x, ...y}) { })', {
- type: "Program",
- start: 0,
- end: 25,
- body: [{
- type: "ExpressionStatement",
- start: 0,
- end: 25,
- expression: {
- type: "FunctionExpression",
- start: 1,
- end: 24,
- id: null,
- params: [
- {
- type: "ObjectPattern",
- start: 10,
- end: 19,
- properties: [
- {
- type: "Property",
- start: 11,
- end: 12,
- method: false,
- shorthand: true,
- computed: false,
- key: {
- type: "Identifier",
- start: 11,
- end: 12,
- name: "x"
- },
- kind: "init",
- value: {
- type: "Identifier",
- start: 11,
- end: 12,
- name: "x"
- }
- },
- {
- type: "SpreadProperty",
- start: 14,
- end: 18,
- argument: {
- type: "Identifier",
- start: 17,
- end: 18,
- name: "y"
- }
- }
- ]
- }
- ],
- generator: false,
- body: {
- type: "BlockStatement",
- start: 21,
- end: 24,
- body: []
- },
- expression: false
- }
- }]
-}, {
- ecmaVersion: 7,
- features: { "es7.objectRestSpread": true }
-});
-
-test('let z = {...x}', {
- type: "Program",
- start: 0,
- end: 14,
- body: [{
- type: "VariableDeclaration",
- start: 0,
- end: 14,
- declarations: [
- {
- type: "VariableDeclarator",
- start: 4,
- end: 14,
- id: {
- type: "Identifier",
- start: 4,
- end: 5,
- name: "z"
- },
- init: {
- type: "ObjectExpression",
- start: 8,
- end: 14,
- properties: [
- {
- type: "SpreadProperty",
- start: 9,
- end: 13,
- argument: {
- type: "Identifier",
- start: 12,
- end: 13,
- name: "x"
- }
- }
- ]
- }
- }
- ],
- kind: "let"
- }]
-}, {
- ecmaVersion: 7,
- features: { "es7.objectRestSpread": true }
-});
-
-test('z = {x, ...y}', {
- type: "Program",
- start: 0,
- end: 13,
- body: [{
- type: "ExpressionStatement",
- start: 0,
- end: 13,
- expression: {
- type: "AssignmentExpression",
- start: 0,
- end: 13,
- operator: "=",
- left: {
- type: "Identifier",
- start: 0,
- end: 1,
- name: "z"
- },
- right: {
- type: "ObjectExpression",
- start: 4,
- end: 13,
- properties: [
- {
- type: "Property",
- start: 5,
- end: 6,
- method: false,
- shorthand: true,
- computed: false,
- key: {
- type: "Identifier",
- start: 5,
- end: 6,
- name: "x"
- },
- kind: "init",
- value: {
- type: "Identifier",
- start: 5,
- end: 6,
- name: "x"
- }
- },
- {
- type: "SpreadProperty",
- start: 8,
- end: 12,
- argument: {
- type: "Identifier",
- start: 11,
- end: 12,
- name: "y"
- }
- }
- ]
- }
- }
- }]
-}, {
- ecmaVersion: 7,
- features: { "es7.objectRestSpread": true }
-});
-
-test('({x, ...y, a, ...b, c})', {
- type: "Program",
- start: 0,
- end: 23,
- body: [{
- type: "ExpressionStatement",
- start: 0,
- end: 23,
- expression: {
- type: "ObjectExpression",
- start: 1,
- end: 22,
- properties: [
- {
- type: "Property",
- start: 2,
- end: 3,
- method: false,
- shorthand: true,
- computed: false,
- key: {
- type: "Identifier",
- start: 2,
- end: 3,
- name: "x"
- },
- kind: "init",
- value: {
- type: "Identifier",
- start: 2,
- end: 3,
- name: "x"
- }
- },
- {
- type: "SpreadProperty",
- start: 5,
- end: 9,
- argument: {
- type: "Identifier",
- start: 8,
- end: 9,
- name: "y"
- }
- },
- {
- type: "Property",
- start: 11,
- end: 12,
- method: false,
- shorthand: true,
- computed: false,
- key: {
- type: "Identifier",
- start: 11,
- end: 12,
- name: "a"
- },
- kind: "init",
- value: {
- type: "Identifier",
- start: 11,
- end: 12,
- name: "a"
- }
- },
- {
- type: "SpreadProperty",
- start: 14,
- end: 18,
- argument: {
- type: "Identifier",
- start: 17,
- end: 18,
- name: "b"
- }
- },
- {
- type: "Property",
- start: 20,
- end: 21,
- method: false,
- shorthand: true,
- computed: false,
- key: {
- type: "Identifier",
- start: 20,
- end: 21,
- name: "c"
- },
- kind: "init",
- value: {
- type: "Identifier",
- start: 20,
- end: 21,
- name: "c"
- }
- }
- ]
- }
- }]
-}, {
- ecmaVersion: 7,
- features: { "es7.objectRestSpread": true }
-});
-
-// ES7: Async Functions
-
-testFail("function foo(promise) { await promise; }", "Unexpected token (1:30)", {
- ecmaVersion: 7,
- features: { "es7.asyncFunctions": true }
-});
-
-test('async function foo(promise) { await promise; }', {
- type: "Program",
- body: [{
- type: "FunctionDeclaration",
- id: {
- type: "Identifier",
- name: "foo",
- loc: {
- start: {line: 1, column: 15},
- end: {line: 1, column: 18}
- }
- },
- params: [{
- type: "Identifier",
- name: "promise",
- loc: {
- start: {line: 1, column: 19},
- end: {line: 1, column: 26}
- }
- }],
- body: {
- type: "BlockStatement",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "AwaitExpression",
- argument: {
- type: "Identifier",
- name: "promise",
- loc: {
- start: {line: 1, column: 36},
- end: {line: 1, column: 43}
- }
- },
- loc: {
- start: {line: 1, column: 30},
- end: {line: 1, column: 43}
- }
- },
- loc: {
- start: {line: 1, column: 30},
- end: {line: 1, column: 44}
- }
- }],
- loc: {
- start: {line: 1, column: 28},
- end: {line: 1, column: 46}
- }
- },
- generator: false,
- expression: false,
- async: true,
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 46}
- }
- }]
-}, {
- ecmaVersion: 7,
- features: { "es7.asyncFunctions": true },
- locations: true
-});
-
-test('(function(x) { async function inner() { await x } })', {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "FunctionExpression",
- id: null,
- params: [
- {
- type: "Identifier",
- name: "x",
- loc: {
- start: {line: 1, column: 10},
- end: {line: 1, column: 11}
- }
- }
- ],
- body: {
- type: "BlockStatement",
- body: [
- {
- type: "FunctionDeclaration",
- id: {
- type: "Identifier",
- name: "inner",
- loc: {
- start: {line: 1, column: 30},
- end: {line: 1, column: 35}
- }
- },
- params: [],
- body: {
- type: "BlockStatement",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "AwaitExpression",
- argument: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {line: 1, column: 46},
- end: {line: 1, column: 47}
- }
- },
- loc: {
- start: {line: 1, column: 40},
- end: {line: 1, column: 47}
- }
- },
- loc: {
- start: {line: 1, column: 40},
- end: {line: 1, column: 47}
- }
- }
- ],
- loc: {
- start: {line: 1, column: 38},
- end: {line: 1, column: 49}
- }
- },
- generator: false,
- expression: false,
- async: true,
- loc: {
- start: {line: 1, column: 15},
- end: {line: 1, column: 49}
- }
- }
- ],
- loc: {
- start: {line: 1, column: 13},
- end: {line: 1, column: 51}
- }
- },
- generator: false,
- expression: false,
- loc: {
- start: {line: 1, column: 1},
- end: {line: 1, column: 51}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 52}
- }
- }]
-}, {
- ecmaVersion: 7,
- features: { "es7.asyncFunctions": true },
- locations: true
-});
-
-test('var foo = async function(promise) { await promise; }', {
- type: "Program",
- body: [{
- type: "VariableDeclaration",
- declarations: [
- {
- type: "VariableDeclarator",
- id: {
- type: "Identifier",
- name: "foo",
- loc: {
- start: {line: 1, column: 4},
- end: {line: 1, column: 7}
- }
- },
- init: {
- type: "FunctionExpression",
- id: null,
- params: [
- {
- type: "Identifier",
- name: "promise",
- loc: {
- start: {line: 1, column: 25},
- end: {line: 1, column: 32}
- }
- }
- ],
- body: {
- type: "BlockStatement",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "AwaitExpression",
- argument: {
- type: "Identifier",
- name: "promise",
- loc: {
- start: {line: 1, column: 42},
- end: {line: 1, column: 49}
- }
- },
- loc: {
- start: {line: 1, column: 36},
- end: {line: 1, column: 49}
- }
- },
- loc: {
- start: {line: 1, column: 36},
- end: {line: 1, column: 50}
- }
- }
- ],
- loc: {
- start: {line: 1, column: 34},
- end: {line: 1, column: 52}
- }
- },
- generator: false,
- expression: false,
- async: true,
- loc: {
- start: {line: 1, column: 10},
- end: {line: 1, column: 52}
- }
- },
- loc: {
- start: {line: 1, column: 4},
- end: {line: 1, column: 52}
- }
- }
- ],
- kind: "var",
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 52}
- }
- }]
-}, {
- ecmaVersion: 7,
- features: { "es7.asyncFunctions": true },
- locations: true
-});
-
-test('var o = { a: 1, async foo(promise) { await promise } }', {
- type: "Program",
- body: [{
- type: "VariableDeclaration",
- declarations: [
- {
- type: "VariableDeclarator",
- id: {
- type: "Identifier",
- name: "o",
- loc: {
- start: {line: 1, column: 4},
- end: {line: 1, column: 5}
- }
- },
- init: {
- type: "ObjectExpression",
- properties: [
- {
- type: "Property",
- key: {
- type: "Identifier",
- name: "a",
- loc: {
- start: {line: 1, column: 10},
- end: {line: 1, column: 11}
- }
- },
- value: {
- type: "Literal",
- value: 1,
- loc: {
- start: {line: 1, column: 13},
- end: {line: 1, column: 14}
- }
- },
- kind: "init",
- method: false,
- shorthand: false,
- computed: false,
- loc: {
- start: {line: 1, column: 10},
- end: {line: 1, column: 14}
- }
- },
- {
- type: "Property",
- key: {
- type: "Identifier",
- name: "foo",
- loc: {
- start: {line: 1, column: 22},
- end: {line: 1, column: 25}
- }
- },
- value: {
- type: "FunctionExpression",
- id: null,
- params: [
- {
- type: "Identifier",
- name: "promise",
- loc: {
- start: {line: 1, column: 26},
- end: {line: 1, column: 33}
- }
- }
- ],
- body: {
- type: "BlockStatement",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "AwaitExpression",
- argument: {
- type: "Identifier",
- name: "promise",
- loc: {
- start: {line: 1, column: 43},
- end: {line: 1, column: 50}
- }
- },
- loc: {
- start: {line: 1, column: 37},
- end: {line: 1, column: 50}
- }
- },
- loc: {
- start: {line: 1, column: 37},
- end: {line: 1, column: 50}
- }
- }
- ],
- loc: {
- start: {line: 1, column: 35},
- end: {line: 1, column: 52}
- }
- },
- generator: false,
- expression: false,
- async: true,
- loc: {
- start: {line: 1, column: 25},
- end: {line: 1, column: 52}
- }
- },
- kind: "init",
- method: true,
- shorthand: false,
- computed: false,
- loc: {
- start: {line: 1, column: 16},
- end: {line: 1, column: 52}
- }
- }
- ],
- loc: {
- start: {line: 1, column: 8},
- end: {line: 1, column: 54}
- }
- },
- loc: {
- start: {line: 1, column: 4},
- end: {line: 1, column: 54}
- }
- }
- ],
- kind: "var",
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 54}
- }
- }]
-}, {
- ecmaVersion: 7,
- features: { "es7.asyncFunctions": true },
- locations: true
-});
-
-test('class Foo { async bar(promise) { await promise } }', {
- type: "Program",
- body: [{
- type: "ClassDeclaration",
- id: {
- type: "Identifier",
- name: "Foo",
- loc: {
- start: {line: 1, column: 6},
- end: {line: 1, column: 9}
- }
- },
- superClass: null,
- body: {
- type: "ClassBody",
- body: [
- {
- type: "MethodDefinition",
- key: {
- type: "Identifier",
- name: "bar",
- loc: {
- start: {line: 1, column: 18},
- end: {line: 1, column: 21}
- }
- },
- value: {
- type: "FunctionExpression",
- id: null,
- params: [
- {
- type: "Identifier",
- name: "promise",
- loc: {
- start: {line: 1, column: 22},
- end: {line: 1, column: 29}
- }
- }
- ],
- body: {
- type: "BlockStatement",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "AwaitExpression",
- argument: {
- type: "Identifier",
- name: "promise",
- loc: {
- start: {line: 1, column: 39},
- end: {line: 1, column: 46}
- }
- },
- loc: {
- start: {line: 1, column: 33},
- end: {line: 1, column: 46}
- }
- },
- loc: {
- start: {line: 1, column: 33},
- end: {line: 1, column: 46}
- }
- }
- ],
- loc: {
- start: {line: 1, column: 31},
- end: {line: 1, column: 48}
- }
- },
- generator: false,
- expression: false,
- async: true,
- loc: {
- start: {line: 1, column: 21},
- end: {line: 1, column: 48}
- }
- },
- kind: "method",
- static: false,
- loc: {
- start: {line: 1, column: 12},
- end: {line: 1, column: 48}
- }
- }
- ],
- loc: {
- start: {line: 1, column: 10},
- end: {line: 1, column: 50}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 50}
- }
- }]
-}, {
- ecmaVersion: 7,
- features: { "es7.asyncFunctions": true },
- locations: true
-});
-
-test('f(a, async promise => await promise)', {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "CallExpression",
- callee: {
- type: "Identifier",
- name: "f",
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 1}
- }
- },
- arguments: [
- {
- type: "Identifier",
- name: "a",
- loc: {
- start: {line: 1, column: 2},
- end: {line: 1, column: 3}
- }
- },
- {
- type: "ArrowFunctionExpression",
- id: null,
- params: [
- {
- type: "Identifier",
- name: "promise",
- loc: {
- start: {line: 1, column: 11},
- end: {line: 1, column: 18}
- }
- }
- ],
- body: {
- type: "AwaitExpression",
- argument: {
- type: "Identifier",
- name: "promise",
- loc: {
- start: {line: 1, column: 28},
- end: {line: 1, column: 35}
- }
- },
- loc: {
- start: {line: 1, column: 22},
- end: {line: 1, column: 35}
- }
- },
- generator: false,
- expression: true,
- async: true,
- loc: {
- start: {line: 1, column: 5},
- end: {line: 1, column: 35}
- }
- }
- ],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 36}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 36}
- }
- }]
-}, {
- ecmaVersion: 7,
- features: { "es7.asyncFunctions": true },
- locations: true
-});
-
-test('f(a, async(x, y) => await [x, y], b)', {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "CallExpression",
- callee: {
- type: "Identifier",
- name: "f",
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 1}
- }
- },
- arguments: [
- {
- type: "Identifier",
- name: "a",
- loc: {
- start: {line: 1, column: 2},
- end: {line: 1, column: 3}
- }
- },
- {
- type: "ArrowFunctionExpression",
- id: null,
- params: [
- {
- type: "Identifier",
- name: "x",
- loc: {
- start: {line: 1, column: 11},
- end: {line: 1, column: 12}
- }
- },
- {
- type: "Identifier",
- name: "y",
- loc: {
- start: {line: 1, column: 14},
- end: {line: 1, column: 15}
- }
- }
- ],
- body: {
- type: "AwaitExpression",
- argument: {
- type: "ArrayExpression",
- elements: [
- {
- type: "Identifier",
- name: "x",
- loc: {
- start: {line: 1, column: 27},
- end: {line: 1, column: 28}
- }
- },
- {
- type: "Identifier",
- name: "y",
- loc: {
- start: {line: 1, column: 30},
- end: {line: 1, column: 31}
- }
- }
- ],
- loc: {
- start: {line: 1, column: 26},
- end: {line: 1, column: 32}
- }
- },
- loc: {
- start: {line: 1, column: 20},
- end: {line: 1, column: 32}
- }
- },
- generator: false,
- expression: true,
- async: true,
- loc: {
- start: {line: 1, column: 5},
- end: {line: 1, column: 32}
- }
- },
- {
- type: "Identifier",
- name: "b",
- loc: {
- start: {line: 1, column: 34},
- end: {line: 1, column: 35}
- }
- }
- ],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 36}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 36}
- }
- }]
-}, {
- ecmaVersion: 7,
- features: { "es7.asyncFunctions": true },
- locations: true
-});
-
-test('f(async function(promise) { await promise })', {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "CallExpression",
- callee: {
- type: "Identifier",
- name: "f",
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 1}
- }
- },
- arguments: [
- {
- type: "FunctionExpression",
- id: null,
- params: [
- {
- type: "Identifier",
- name: "promise",
- loc: {
- start: {line: 1, column: 17},
- end: {line: 1, column: 24}
- }
- }
- ],
- body: {
- type: "BlockStatement",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "AwaitExpression",
- argument: {
- type: "Identifier",
- name: "promise",
- loc: {
- start: {line: 1, column: 34},
- end: {line: 1, column: 41}
- }
- },
- loc: {
- start: {line: 1, column: 28},
- end: {line: 1, column: 41}
- }
- },
- loc: {
- start: {line: 1, column: 28},
- end: {line: 1, column: 41}
- }
- }
- ],
- loc: {
- start: {line: 1, column: 26},
- end: {line: 1, column: 43}
- }
- },
- generator: false,
- expression: false,
- async: true,
- loc: {
- start: {line: 1, column: 2},
- end: {line: 1, column: 43}
- }
- }
- ],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 44}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 44}
- }
- }]
-}, {
- ecmaVersion: 7,
- features: { "es7.asyncFunctions": true },
- locations: true
-});
-
-test('f(a, async(1, 2), b)', {
- type: "Program",
- body: [{
- "type": "ExpressionStatement",
- "expression": {
- "type": "CallExpression",
- "callee": {
- "type": "Identifier",
- "name": "f",
- "range": [
- 0,
- 1
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 0
- },
- "end": {
- "line": 1,
- "column": 1
- }
- }
- },
- "arguments": [
- {
- "type": "Identifier",
- "name": "a",
- "range": [
- 2,
- 3
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 2
- },
- "end": {
- "line": 1,
- "column": 3
- }
- }
- },
- {
- "type": "CallExpression",
- "callee": {
- "type": "Identifier",
- "name": "async",
- "range": [
- 5,
- 10
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 5
- },
- "end": {
- "line": 1,
- "column": 10
- }
- }
- },
- "arguments": [
- {
- "type": "Literal",
- "value": 1,
- "raw": "1",
- "range": [
- 11,
- 12
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 11
- },
- "end": {
- "line": 1,
- "column": 12
- }
- }
- },
- {
- "type": "Literal",
- "value": 2,
- "raw": "2",
- "range": [
- 14,
- 15
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 14
- },
- "end": {
- "line": 1,
- "column": 15
- }
- }
- }
- ],
- "range": [
- 5,
- 16
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 5
- },
- "end": {
- "line": 1,
- "column": 16
- }
- }
- },
- {
- "type": "Identifier",
- "name": "b",
- "range": [
- 18,
- 19
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 18
- },
- "end": {
- "line": 1,
- "column": 19
- }
- }
- }
- ],
- "range": [
- 0,
- 20
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 0
- },
- "end": {
- "line": 1,
- "column": 20
- }
- }
- },
- "range": [
- 0,
- 20
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 0
- },
- "end": {
- "line": 1,
- "column": 20
- }
- }
- }]
-}, {
- ecmaVersion: 7,
- features: { "es7.asyncFunctions": true },
- locations: true,
- ranges: true
-});
-
-test('var ok = async(x)', {
- type: "Program",
- body: [{
- "type": "VariableDeclaration",
- "declarations": [
- {
- "type": "VariableDeclarator",
- "id": {
- "type": "Identifier",
- "name": "ok",
- "range": [
- 4,
- 6
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 4
- },
- "end": {
- "line": 1,
- "column": 6
- }
- }
- },
- "init": {
- "type": "CallExpression",
- "callee": {
- "type": "Identifier",
- "name": "async",
- "range": [
- 9,
- 14
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 9
- },
- "end": {
- "line": 1,
- "column": 14
- }
- }
- },
- "arguments": [
- {
- "type": "Identifier",
- "name": "x",
- "range": [
- 15,
- 16
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 15
- },
- "end": {
- "line": 1,
- "column": 16
- }
- }
- }
- ],
- "range": [
- 9,
- 17
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 9
- },
- "end": {
- "line": 1,
- "column": 17
- }
- }
- },
- "range": [
- 4,
- 17
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 4
- },
- "end": {
- "line": 1,
- "column": 17
- }
- }
- }
- ],
- "kind": "var",
- "range": [
- 0,
- 17
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 0
- },
- "end": {
- "line": 1,
- "column": 17
- }
- }
- }]
-}, {
- ecmaVersion: 7,
- features: { "es7.asyncFunctions": true },
- locations: true,
- ranges: true
-});
-
-test('(function() { var async; async = 10 })', {
- type: "Program",
- body: [{
- "type": "ExpressionStatement",
- "expression": {
- "type": "FunctionExpression",
- "id": null,
- "params": [],
- "body": {
- "type": "BlockStatement",
- "body": [
- {
- "type": "VariableDeclaration",
- "declarations": [
- {
- "type": "VariableDeclarator",
- "id": {
- "type": "Identifier",
- "name": "async",
- "range": [
- 18,
- 23
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 18
- },
- "end": {
- "line": 1,
- "column": 23
- }
- }
- },
- "init": null,
- "range": [
- 18,
- 23
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 18
- },
- "end": {
- "line": 1,
- "column": 23
- }
- }
- }
- ],
- "kind": "var",
- "range": [
- 14,
- 24
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 14
- },
- "end": {
- "line": 1,
- "column": 24
- }
- }
- },
- {
- "type": "ExpressionStatement",
- "expression": {
- "type": "AssignmentExpression",
- "operator": "=",
- "left": {
- "type": "Identifier",
- "name": "async",
- "range": [
- 25,
- 30
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 25
- },
- "end": {
- "line": 1,
- "column": 30
- }
- }
- },
- "right": {
- "type": "Literal",
- "value": 10,
- "raw": "10",
- "range": [
- 33,
- 35
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 33
- },
- "end": {
- "line": 1,
- "column": 35
- }
- }
- },
- "range": [
- 25,
- 35
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 25
- },
- "end": {
- "line": 1,
- "column": 35
- }
- }
- },
- "range": [
- 25,
- 35
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 25
- },
- "end": {
- "line": 1,
- "column": 35
- }
- }
- }
- ],
- "range": [
- 12,
- 37
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 12
- },
- "end": {
- "line": 1,
- "column": 37
- }
- }
- },
- "generator": false,
- "expression": false,
- "range": [
- 1,
- 37
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 1
- },
- "end": {
- "line": 1,
- "column": 37
- }
- }
- },
- "range": [
- 0,
- 38
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 0
- },
- "end": {
- "line": 1,
- "column": 38
- }
- }
- }]
-}, {
- ecmaVersion: 7,
- features: { "es7.asyncFunctions": true },
- locations: true,
- ranges: true
-});
-
-test('class Test { async() {} }', {
- type: "Program",
- start: 0,
- end: 25,
- body: [{
- type: "ClassDeclaration",
- start: 0,
- end: 25,
- id: {
- type: "Identifier",
- start: 6,
- end: 10,
- name: "Test"
- },
- superClass: null,
- body: {
- type: "ClassBody",
- start: 11,
- end: 25,
- body: [{
- type: "MethodDefinition",
- start: 13,
- end: 23,
- static: false,
- key: {
- type: "Identifier",
- start: 13,
- end: 18,
- name: "async"
- },
- kind: "method",
- value: {
- type: "FunctionExpression",
- start: 18,
- end: 23,
- id: null,
- params: [],
- generator: false,
- async: false,
- body: {
- type: "BlockStatement",
- start: 21,
- end: 23,
- body: []
- },
- expression: false
- }
- }]
- }
- }]
-}, {
- ecmaVersion: 7,
- features: { "es7.asyncFunctions": true }
-});
-
-test('var obj = { async: "test" };', {
- type: "Program",
- start: 0,
- end: 28,
- body: [{
- type: "VariableDeclaration",
- start: 0,
- end: 28,
- declarations: [{
- type: "VariableDeclarator",
- start: 4,
- end: 27,
- id: {
- type: "Identifier",
- start: 4,
- end: 7,
- name: "obj"
- },
- init: {
- type: "ObjectExpression",
- start: 10,
- end: 27,
- properties: [{
- type: "Property",
- start: 12,
- end: 25,
- method: false,
- shorthand: false,
- key: {
- type: "Identifier",
- start: 12,
- end: 17,
- name: "async"
- },
- value: {
- type: "Literal",
- start: 19,
- end: 25,
- value: "test",
- raw: "\"test\""
- },
- kind: "init"
- }]
- }
- }],
- kind: "var"
- }]
-}, {
- ecmaVersion: 7,
- features: { "es7.asyncFunctions": true }
-});
-
-test('var obj = { async() {} };', {
- type: "Program",
- start: 0,
- end: 25,
- body: [{
- type: "VariableDeclaration",
- start: 0,
- end: 25,
- declarations: [{
- type: "VariableDeclarator",
- start: 4,
- end: 24,
- id: {
- type: "Identifier",
- start: 4,
- end: 7,
- name: "obj"
- },
- init: {
- type: "ObjectExpression",
- start: 10,
- end: 24,
- properties: [{
- type: "Property",
- start: 12,
- end: 22,
- method: true,
- shorthand: false,
- key: {
- type: "Identifier",
- start: 12,
- end: 17,
- name: "async"
- },
- kind: "init",
- value: {
- type: "FunctionExpression",
- start: 17,
- end: 22,
- id: null,
- params: [],
- generator: false,
- body: {
- type: "BlockStatement",
- start: 20,
- end: 22,
- body: []
- },
- expression: false
- }
- }]
- }
- }],
- kind: "var"
- }]
-}, {
- ecmaVersion: 7,
- features: { "es7.asyncFunctions": true }
-});
-
-test('export async function foo(){}', {
- "type": "Program",
- "start": 0,
- "end": 29,
- "body": [{
- "type": "ExportNamedDeclaration",
- "start": 0,
- "end": 29,
- "declaration": {
- "type": "FunctionDeclaration",
- "start": 7,
- "end": 29,
- "id": {
- "type": "Identifier",
- "start": 22,
- "end": 25,
- "name": "foo"
- },
- "params": [],
- "generator": false,
- "async": true,
- "body": {
- "type": "BlockStatement",
- "start": 27,
- "end": 29,
- "body": []
- },
- "expression": false
- },
- "specifiers": [],
- "source": null
- }]
-}, {
- ecmaVersion: 7,
- sourceType: "module",
- features: { "es7.asyncFunctions": true }
-});
-
-// ES7 decorators
diff --git a/test/tests-flow.js b/test/tests-flow.js
deleted file mode 100644
index 276ef4aa22..0000000000
--- a/test/tests-flow.js
+++ /dev/null
@@ -1,11125 +0,0 @@
-// React JSX tests
-
-var fbTestFixture = {
- 'Type Annotations': {
- 'function foo(numVal: any){}': {
- type: 'FunctionDeclaration',
- id: {
- type: 'Identifier',
- name: 'foo',
- range: [9, 12],
- loc: {
- start: { line: 1, column: 9 },
- end: { line: 1, column: 12 }
- }
- },
- params: [{
- type: 'Identifier',
- name: 'numVal',
- typeAnnotation: {
- type: 'TypeAnnotation',
- typeAnnotation: {
- type: 'AnyTypeAnnotation',
- range: [21, 24],
- loc: {
- start: { line: 1, column: 21 },
- end: { line: 1, column: 24 }
- }
- },
- range: [19, 24],
- loc: {
- start: { line: 1, column: 19 },
- end: { line: 1, column: 24 }
- }
- },
- range: [13, 24],
- loc: {
- start: { line: 1, column: 13 },
- end: { line: 1, column: 24 }
- }
- }],
- body: {
- type: 'BlockStatement',
- body: [],
- range: [25, 27],
- loc: {
- start: { line: 1, column: 25 },
- end: { line: 1, column: 27 }
- }
- },
- generator: false,
- expression: false,
- range: [0, 27],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 27 }
- }
- },
- 'function foo(numVal: number){}': {
- type: 'FunctionDeclaration',
- id: {
- type: 'Identifier',
- name: 'foo',
- range: [9, 12],
- loc: {
- start: { line: 1, column: 9 },
- end: { line: 1, column: 12 }
- }
- },
- params: [{
- type: 'Identifier',
- name: 'numVal',
- typeAnnotation: {
- type: 'TypeAnnotation',
- typeAnnotation: {
- type: 'NumberTypeAnnotation',
- range: [21, 27],
- loc: {
- start: { line: 1, column: 21 },
- end: { line: 1, column: 27 }
- }
- },
- range: [19, 27],
- loc: {
- start: { line: 1, column: 19 },
- end: { line: 1, column: 27 }
- }
- },
- range: [13, 27],
- loc: {
- start: { line: 1, column: 13 },
- end: { line: 1, column: 27 }
- }
- }],
- body: {
- type: 'BlockStatement',
- body: [],
- range: [28, 30],
- loc: {
- start: { line: 1, column: 28 },
- end: { line: 1, column: 30 }
- }
- },
- generator: false,
- expression: false,
- range: [0, 30],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 30 }
- }
- },
- 'function foo(numVal: number, strVal: string){}': {
- type: 'FunctionDeclaration',
- id: {
- type: 'Identifier',
- name: 'foo',
- range: [9, 12],
- loc: {
- start: { line: 1, column: 9 },
- end: { line: 1, column: 12 }
- }
- },
- params: [{
- type: 'Identifier',
- name: 'numVal',
- typeAnnotation: {
- type: 'TypeAnnotation',
- typeAnnotation: {
- type: 'NumberTypeAnnotation',
- range: [21, 27],
- loc: {
- start: { line: 1, column: 21 },
- end: { line: 1, column: 27 }
- }
- },
- range: [19, 27],
- loc: {
- start: { line: 1, column: 19 },
- end: { line: 1, column: 27 }
- }
- },
- range: [13, 27],
- loc: {
- start: { line: 1, column: 13 },
- end: { line: 1, column: 27 }
- }
- }, {
- type: 'Identifier',
- name: 'strVal',
- typeAnnotation: {
- type: 'TypeAnnotation',
- typeAnnotation: {
- type: 'StringTypeAnnotation',
- range: [37, 43],
- loc: {
- start: { line: 1, column: 37 },
- end: { line: 1, column: 43 }
- }
- },
- range: [35, 43],
- loc: {
- start: { line: 1, column: 35 },
- end: { line: 1, column: 43 }
- }
- },
- range: [29, 43],
- loc: {
- start: { line: 1, column: 29 },
- end: { line: 1, column: 43 }
- }
- }],
- body: {
- type: 'BlockStatement',
- body: [],
- range: [44, 46],
- loc: {
- start: { line: 1, column: 44 },
- end: { line: 1, column: 46 }
- }
- },
- generator: false,
- expression: false,
- range: [0, 46],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 46 }
- }
- },
- 'function foo(numVal: number, untypedVal){}': {
- type: 'FunctionDeclaration',
- id: {
- type: 'Identifier',
- name: 'foo',
- range: [9, 12],
- loc: {
- start: { line: 1, column: 9 },
- end: { line: 1, column: 12 }
- }
- },
- params: [{
- type: 'Identifier',
- name: 'numVal',
- typeAnnotation: {
- type: 'TypeAnnotation',
- typeAnnotation: {
- type: 'NumberTypeAnnotation',
- range: [21, 27],
- loc: {
- start: { line: 1, column: 21 },
- end: { line: 1, column: 27 }
- }
- },
- range: [19, 27],
- loc: {
- start: { line: 1, column: 19 },
- end: { line: 1, column: 27 }
- }
- },
- range: [13, 27],
- loc: {
- start: { line: 1, column: 13 },
- end: { line: 1, column: 27 }
- }
- }, {
- type: 'Identifier',
- name: 'untypedVal',
- range: [29, 39],
- loc: {
- start: { line: 1, column: 29 },
- end: { line: 1, column: 39 }
- }
- }],
- body: {
- type: 'BlockStatement',
- body: [],
- range: [40, 42],
- loc: {
- start: { line: 1, column: 40 },
- end: { line: 1, column: 42 }
- }
- },
- generator: false,
- expression: false,
- range: [0, 42],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 42 }
- }
- },
- 'function foo(untypedVal, numVal: number){}': {
- type: 'FunctionDeclaration',
- id: {
- type: 'Identifier',
- name: 'foo',
- range: [9, 12],
- loc: {
- start: { line: 1, column: 9 },
- end: { line: 1, column: 12 }
- }
- },
- params: [{
- type: 'Identifier',
- name: 'untypedVal',
- range: [13, 23],
- loc: {
- start: { line: 1, column: 13 },
- end: { line: 1, column: 23 }
- }
- }, {
- type: 'Identifier',
- name: 'numVal',
- typeAnnotation: {
- type: 'TypeAnnotation',
- typeAnnotation: {
- type: 'NumberTypeAnnotation',
- range: [33, 39],
- loc: {
- start: { line: 1, column: 33 },
- end: { line: 1, column: 39 }
- }
- },
- range: [31, 39],
- loc: {
- start: { line: 1, column: 31 },
- end: { line: 1, column: 39 }
- }
- },
- range: [25, 39],
- loc: {
- start: { line: 1, column: 25 },
- end: { line: 1, column: 39 }
- }
- }],
- body: {
- type: 'BlockStatement',
- body: [],
- range: [40, 42],
- loc: {
- start: { line: 1, column: 40 },
- end: { line: 1, column: 42 }
- }
- },
- generator: false,
- expression: false,
- range: [0, 42],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 42 }
- }
- },
- 'function foo(nullableNum: ?number){}': {
- type: 'FunctionDeclaration',
- id: {
- type: 'Identifier',
- name: 'foo',
- range: [9, 12],
- loc: {
- start: { line: 1, column: 9 },
- end: { line: 1, column: 12 }
- }
- },
- params: [{
- type: 'Identifier',
- name: 'nullableNum',
- typeAnnotation: {
- type: 'TypeAnnotation',
- typeAnnotation: {
- type: 'NullableTypeAnnotation',
- typeAnnotation: {
- type: 'NumberTypeAnnotation',
- range: [27, 33],
- loc: {
- start: { line: 1, column: 27 },
- end: { line: 1, column: 33 }
- }
- },
- range: [26, 33],
- loc: {
- start: { line: 1, column: 26 },
- end: { line: 1, column: 33 }
- }
- },
- range: [24, 33],
- loc: {
- start: { line: 1, column: 24 },
- end: { line: 1, column: 33 }
- }
- },
- range: [13, 33],
- loc: {
- start: { line: 1, column: 13 },
- end: { line: 1, column: 33 }
- }
- }],
- body: {
- type: 'BlockStatement',
- body: [],
- range: [34, 36],
- loc: {
- start: { line: 1, column: 34 },
- end: { line: 1, column: 36 }
- }
- },
- generator: false,
- expression: false,
- range: [0, 36],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 36 }
- }
- },
- 'function foo(callback: () => void){}': {
- type: 'FunctionDeclaration',
- id: {
- type: 'Identifier',
- name: 'foo',
- range: [9, 12],
- loc: {
- start: { line: 1, column: 9 },
- end: { line: 1, column: 12 }
- }
- },
- params: [{
- type: 'Identifier',
- name: 'callback',
- typeAnnotation: {
- type: 'TypeAnnotation',
- typeAnnotation: {
- type: 'FunctionTypeAnnotation',
- params: [],
- returnType: {
- type: 'VoidTypeAnnotation',
- range: [29, 33],
- loc: {
- start: { line: 1, column: 29 },
- end: { line: 1, column: 33 }
- }
- },
- typeParameters: null,
- range: [23, 33],
- loc: {
- start: { line: 1, column: 23 },
- end: { line: 1, column: 33 }
- }
- },
- range: [21, 33],
- loc: {
- start: { line: 1, column: 21 },
- end: { line: 1, column: 33 }
- }
- },
- range: [13, 33],
- loc: {
- start: { line: 1, column: 13 },
- end: { line: 1, column: 33 }
- }
- }],
- body: {
- type: 'BlockStatement',
- body: [],
- range: [34, 36],
- loc: {
- start: { line: 1, column: 34 },
- end: { line: 1, column: 36 }
- }
- },
- generator: false,
- expression: false,
- range: [0, 36],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 36 }
- }
- },
- 'function foo(callback: () => number){}': {
- type: 'FunctionDeclaration',
- id: {
- type: 'Identifier',
- name: 'foo',
- range: [9, 12],
- loc: {
- start: { line: 1, column: 9 },
- end: { line: 1, column: 12 }
- }
- },
- params: [{
- type: 'Identifier',
- name: 'callback',
- typeAnnotation: {
- type: 'TypeAnnotation',
- typeAnnotation: {
- type: 'FunctionTypeAnnotation',
- params: [],
- returnType: {
- type: 'NumberTypeAnnotation',
- range: [29, 35],
- loc: {
- start: { line: 1, column: 29 },
- end: { line: 1, column: 35 }
- }
- },
- typeParameters: null,
- range: [23, 35],
- loc: {
- start: { line: 1, column: 23 },
- end: { line: 1, column: 35 }
- }
- },
- range: [21, 35],
- loc: {
- start: { line: 1, column: 21 },
- end: { line: 1, column: 35 }
- }
- },
- range: [13, 35],
- loc: {
- start: { line: 1, column: 13 },
- end: { line: 1, column: 35 }
- }
- }],
- body: {
- type: 'BlockStatement',
- body: [],
- range: [36, 38],
- loc: {
- start: { line: 1, column: 36 },
- end: { line: 1, column: 38 }
- }
- },
- generator: false,
- expression: false,
- range: [0, 38],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 38 }
- }
- },
- 'function foo(callback: (_:bool) => number){}': {
- type: 'FunctionDeclaration',
- id: {
- type: 'Identifier',
- name: 'foo',
- range: [9, 12],
- loc: {
- start: { line: 1, column: 9 },
- end: { line: 1, column: 12 }
- }
- },
- params: [{
- type: 'Identifier',
- name: 'callback',
- typeAnnotation: {
- type: 'TypeAnnotation',
- typeAnnotation: {
- type: 'FunctionTypeAnnotation',
- params: [{
- type: 'FunctionTypeParam',
- name: {
- type: 'Identifier',
- name: '_',
- range: [24, 25],
- loc: {
- start: { line: 1, column: 24 },
- end: { line: 1, column: 25 }
- }
- },
- typeAnnotation: {
- type: 'BooleanTypeAnnotation',
- range: [26, 30],
- loc: {
- start: { line: 1, column: 26 },
- end: { line: 1, column: 30 }
- }
- },
- optional: false,
- range: [24, 30],
- loc: {
- start: { line: 1, column: 24 },
- end: { line: 1, column: 30 }
- }
- }],
- returnType: {
- type: 'NumberTypeAnnotation',
- range: [35, 41],
- loc: {
- start: { line: 1, column: 35 },
- end: { line: 1, column: 41 }
- }
- },
- typeParameters: null,
- range: [23, 41],
- loc: {
- start: { line: 1, column: 23 },
- end: { line: 1, column: 41 }
- }
- },
- range: [21, 41],
- loc: {
- start: { line: 1, column: 21 },
- end: { line: 1, column: 41 }
- }
- },
- range: [13, 41],
- loc: {
- start: { line: 1, column: 13 },
- end: { line: 1, column: 41 }
- }
- }],
- body: {
- type: 'BlockStatement',
- body: [],
- range: [42, 44],
- loc: {
- start: { line: 1, column: 42 },
- end: { line: 1, column: 44 }
- }
- },
- generator: false,
- expression: false,
- range: [0, 44],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 44 }
- }
- },
- 'function foo(callback: (_1:bool, _2:string) => number){}': {
- type: 'FunctionDeclaration',
- id: {
- type: 'Identifier',
- name: 'foo',
- range: [9, 12],
- loc: {
- start: { line: 1, column: 9 },
- end: { line: 1, column: 12 }
- }
- },
- params: [{
- type: 'Identifier',
- name: 'callback',
- typeAnnotation: {
- type: 'TypeAnnotation',
- typeAnnotation: {
- type: 'FunctionTypeAnnotation',
- params: [{
- type: 'FunctionTypeParam',
- name: {
- type: 'Identifier',
- name: '_1',
- range: [24, 26],
- loc: {
- start: { line: 1, column: 24 },
- end: { line: 1, column: 26 }
- }
- },
- typeAnnotation: {
- type: 'BooleanTypeAnnotation',
- range: [27, 31],
- loc: {
- start: { line: 1, column: 27 },
- end: { line: 1, column: 31 }
- }
- },
- optional: false,
- range: [24, 31],
- loc: {
- start: { line: 1, column: 24 },
- end: { line: 1, column: 31 }
- }
- }, {
- type: 'FunctionTypeParam',
- name: {
- type: 'Identifier',
- name: '_2',
- range: [33, 35],
- loc: {
- start: { line: 1, column: 33 },
- end: { line: 1, column: 35 }
- }
- },
- typeAnnotation: {
- type: 'StringTypeAnnotation',
- range: [36, 42],
- loc: {
- start: { line: 1, column: 36 },
- end: { line: 1, column: 42 }
- }
- },
- optional: false,
- range: [33, 42],
- loc: {
- start: { line: 1, column: 33 },
- end: { line: 1, column: 42 }
- }
- }],
- returnType: {
- type: 'NumberTypeAnnotation',
- range: [47, 53],
- loc: {
- start: { line: 1, column: 47 },
- end: { line: 1, column: 53 }
- }
- },
- typeParameters: null,
- range: [23, 53],
- loc: {
- start: { line: 1, column: 23 },
- end: { line: 1, column: 53 }
- }
- },
- range: [21, 53],
- loc: {
- start: { line: 1, column: 21 },
- end: { line: 1, column: 53 }
- }
- },
- range: [13, 53],
- loc: {
- start: { line: 1, column: 13 },
- end: { line: 1, column: 53 }
- }
- }],
- body: {
- type: 'BlockStatement',
- body: [],
- range: [54, 56],
- loc: {
- start: { line: 1, column: 54 },
- end: { line: 1, column: 56 }
- }
- },
- generator: false,
- expression: false,
- range: [0, 56],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 56 }
- }
- },
- 'function foo(callback: (_1:bool, ...foo:Array) => number){}': {
- type: 'FunctionDeclaration',
- id: {
- type: 'Identifier',
- name: 'foo',
- range: [9, 12],
- loc: {
- start: { line: 1, column: 9 },
- end: { line: 1, column: 12 }
- }
- },
- params: [{
- type: 'Identifier',
- name: 'callback',
- typeAnnotation: {
- type: 'TypeAnnotation',
- typeAnnotation: {
- type: 'FunctionTypeAnnotation',
- params: [{
- type: 'FunctionTypeParam',
- name: {
- type: 'Identifier',
- name: '_1',
- range: [24, 26],
- loc: {
- start: { line: 1, column: 24 },
- end: { line: 1, column: 26 }
- }
- },
- typeAnnotation: {
- type: 'BooleanTypeAnnotation',
- range: [27, 31],
- loc: {
- start: { line: 1, column: 27 },
- end: { line: 1, column: 31 }
- }
- },
- optional: false,
- range: [24, 31],
- loc: {
- start: { line: 1, column: 24 },
- end: { line: 1, column: 31 }
- }
- }],
- returnType: {
- type: 'NumberTypeAnnotation',
- range: [58, 64],
- loc: {
- start: { line: 1, column: 58 },
- end: { line: 1, column: 64 }
- }
- },
- rest: {
- type: 'FunctionTypeParam',
- name: {
- type: 'Identifier',
- name: 'foo',
- range: [36, 39],
- loc: {
- start: { line: 1, column: 36 },
- end: { line: 1, column: 39 }
- }
- },
- typeAnnotation: {
- type: 'GenericTypeAnnotation',
- id: {
- type: 'Identifier',
- name: 'Array',
- range: [40, 45],
- loc: {
- start: { line: 1, column: 40 },
- end: { line: 1, column: 45 }
- }
- },
- typeParameters: {
- type: 'TypeParameterInstantiation',
- params: [{
- type: 'NumberTypeAnnotation',
- range: [46, 52],
- loc: {
- start: { line: 1, column: 46 },
- end: { line: 1, column: 52 }
- }
- }],
- range: [45, 53],
- loc: {
- start: { line: 1, column: 45 },
- end: { line: 1, column: 53 }
- }
- },
- range: [40, 53],
- loc: {
- start: { line: 1, column: 40 },
- end: { line: 1, column: 53 }
- }
- },
- optional: false,
- range: [36, 53],
- loc: {
- start: { line: 1, column: 36 },
- end: { line: 1, column: 53 }
- }
- },
- typeParameters: null,
- range: [23, 64],
- loc: {
- start: { line: 1, column: 23 },
- end: { line: 1, column: 64 }
- }
- },
- range: [21, 64],
- loc: {
- start: { line: 1, column: 21 },
- end: { line: 1, column: 64 }
- }
- },
- range: [13, 64],
- loc: {
- start: { line: 1, column: 13 },
- end: { line: 1, column: 64 }
- }
- }],
- body: {
- type: 'BlockStatement',
- body: [],
- range: [65, 67],
- loc: {
- start: { line: 1, column: 65 },
- end: { line: 1, column: 67 }
- }
- },
- generator: false,
- expression: false,
- range: [0, 67],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 67 }
- }
- },
- 'function foo():number{}': {
- type: 'FunctionDeclaration',
- id: {
- type: 'Identifier',
- name: 'foo',
- range: [9, 12],
- loc: {
- start: { line: 1, column: 9 },
- end: { line: 1, column: 12 }
- }
- },
- params: [],
- body: {
- type: 'BlockStatement',
- body: [],
- range: [21, 23],
- loc: {
- start: { line: 1, column: 21 },
- end: { line: 1, column: 23 }
- }
- },
- generator: false,
- expression: false,
- returnType: {
- type: 'TypeAnnotation',
- typeAnnotation: {
- type: 'NumberTypeAnnotation',
- range: [15, 21],
- loc: {
- start: { line: 1, column: 15 },
- end: { line: 1, column: 21 }
- }
- },
- range: [14, 21],
- loc: {
- start: { line: 1, column: 14 },
- end: { line: 1, column: 21 }
- }
- },
- range: [0, 23],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 23 }
- }
- },
- 'function foo():() => void{}': {
- type: 'FunctionDeclaration',
- id: {
- type: 'Identifier',
- name: 'foo',
- range: [9, 12],
- loc: {
- start: { line: 1, column: 9 },
- end: { line: 1, column: 12 }
- }
- },
- params: [],
- body: {
- type: 'BlockStatement',
- body: [],
- range: [25, 27],
- loc: {
- start: { line: 1, column: 25 },
- end: { line: 1, column: 27 }
- }
- },
- generator: false,
- expression: false,
- returnType: {
- type: 'TypeAnnotation',
- typeAnnotation: {
- type: 'FunctionTypeAnnotation',
- params: [],
- returnType: {
- type: 'VoidTypeAnnotation',
- range: [21, 25],
- loc: {
- start: { line: 1, column: 21 },
- end: { line: 1, column: 25 }
- }
- },
- typeParameters: null,
- range: [15, 25],
- loc: {
- start: { line: 1, column: 15 },
- end: { line: 1, column: 25 }
- }
- },
- range: [14, 25],
- loc: {
- start: { line: 1, column: 14 },
- end: { line: 1, column: 25 }
- }
- },
- range: [0, 27],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 27 }
- }
- },
- 'function foo():(_:bool) => number{}': {
- type: 'FunctionDeclaration',
- id: {
- type: 'Identifier',
- name: 'foo',
- range: [9, 12],
- loc: {
- start: { line: 1, column: 9 },
- end: { line: 1, column: 12 }
- }
- },
- params: [],
- body: {
- type: 'BlockStatement',
- body: [],
- range: [33, 35],
- loc: {
- start: { line: 1, column: 33 },
- end: { line: 1, column: 35 }
- }
- },
- generator: false,
- expression: false,
- returnType: {
- type: 'TypeAnnotation',
- typeAnnotation: {
- type: 'FunctionTypeAnnotation',
- params: [{
- type: 'FunctionTypeParam',
- name: {
- type: 'Identifier',
- name: '_',
- range: [16, 17],
- loc: {
- start: { line: 1, column: 16 },
- end: { line: 1, column: 17 }
- }
- },
- typeAnnotation: {
- type: 'BooleanTypeAnnotation',
- range: [18, 22],
- loc: {
- start: { line: 1, column: 18 },
- end: { line: 1, column: 22 }
- }
- },
- optional: false,
- range: [16, 22],
- loc: {
- start: { line: 1, column: 16 },
- end: { line: 1, column: 22 }
- }
- }],
- returnType: {
- type: 'NumberTypeAnnotation',
- range: [27, 33],
- loc: {
- start: { line: 1, column: 27 },
- end: { line: 1, column: 33 }
- }
- },
- typeParameters: null,
- range: [15, 33],
- loc: {
- start: { line: 1, column: 15 },
- end: { line: 1, column: 33 }
- }
- },
- range: [14, 33],
- loc: {
- start: { line: 1, column: 14 },
- end: { line: 1, column: 33 }
- }
- },
- range: [0, 35],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 35 }
- }
- },
- 'function foo():(_?:bool) => number{}': {
- type: 'FunctionDeclaration',
- id: {
- type: 'Identifier',
- name: 'foo',
- range: [9, 12],
- loc: {
- start: { line: 1, column: 9 },
- end: { line: 1, column: 12 }
- }
- },
- params: [],
- body: {
- type: 'BlockStatement',
- body: [],
- range: [34, 36],
- loc: {
- start: { line: 1, column: 34 },
- end: { line: 1, column: 36 }
- }
- },
- generator: false,
- expression: false,
- returnType: {
- type: 'TypeAnnotation',
- typeAnnotation: {
- type: 'FunctionTypeAnnotation',
- params: [{
- type: 'FunctionTypeParam',
- name: {
- type: 'Identifier',
- name: '_',
- range: [16, 17],
- loc: {
- start: { line: 1, column: 16 },
- end: { line: 1, column: 17 }
- }
- },
- typeAnnotation: {
- type: 'BooleanTypeAnnotation',
- range: [19, 23],
- loc: {
- start: { line: 1, column: 19 },
- end: { line: 1, column: 23 }
- }
- },
- optional: true,
- range: [16, 23],
- loc: {
- start: { line: 1, column: 16 },
- end: { line: 1, column: 23 }
- }
- }],
- returnType: {
- type: 'NumberTypeAnnotation',
- range: [28, 34],
- loc: {
- start: { line: 1, column: 28 },
- end: { line: 1, column: 34 }
- }
- },
- typeParameters: null,
- range: [15, 34],
- loc: {
- start: { line: 1, column: 15 },
- end: { line: 1, column: 34 }
- }
- },
- range: [14, 34],
- loc: {
- start: { line: 1, column: 14 },
- end: { line: 1, column: 34 }
- }
- },
- range: [0, 36],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 36 }
- }
- },
- 'function foo(): {} {}': {
- type: 'FunctionDeclaration',
- id: {
- type: 'Identifier',
- name: 'foo',
- range: [9, 12],
- loc: {
- start: { line: 1, column: 9 },
- end: { line: 1, column: 12 }
- }
- },
- params: [],
- body: {
- type: 'BlockStatement',
- body: [],
- range: [19, 21],
- loc: {
- start: { line: 1, column: 19 },
- end: { line: 1, column: 21 }
- }
- },
- generator: false,
- expression: false,
- returnType: {
- type: 'TypeAnnotation',
- typeAnnotation: {
- type: 'ObjectTypeAnnotation',
- properties: [],
- indexers: [],
- callProperties: [],
- range: [16, 18],
- loc: {
- start: { line: 1, column: 16 },
- end: { line: 1, column: 18 }
- }
- },
- range: [14, 18],
- loc: {
- start: { line: 1, column: 14 },
- end: { line: 1, column: 18 }
- }
- },
- range: [0, 21],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 21 }
- }
- },
- 'function foo() {}': {
- type: 'FunctionDeclaration',
- id: {
- type: 'Identifier',
- name: 'foo',
- range: [9, 12],
- loc: {
- start: { line: 1, column: 9 },
- end: { line: 1, column: 12 }
- }
- },
- params: [],
- body: {
- type: 'BlockStatement',
- body: [],
- range: [18, 20],
- loc: {
- start: { line: 1, column: 18 },
- end: { line: 1, column: 20 }
- }
- },
- generator: false,
- expression: false,
- typeParameters: {
- type: 'TypeParameterDeclaration',
- params: [{
- type: 'Identifier',
- name: 'T',
- range: [13, 14],
- loc: {
- start: { line: 1, column: 13 },
- end: { line: 1, column: 14 }
- }
- }],
- range: [12, 15],
- loc: {
- start: { line: 1, column: 12 },
- end: { line: 1, column: 15 }
- }
- },
- range: [0, 20],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 20 }
- }
- },
- 'function foo() {}': {
- type: 'FunctionDeclaration',
- id: {
- type: 'Identifier',
- name: 'foo',
- range: [9, 12],
- loc: {
- start: { line: 1, column: 9 },
- end: { line: 1, column: 12 }
- }
- },
- params: [],
- body: {
- type: 'BlockStatement',
- body: [],
- range: [20, 22],
- loc: {
- start: { line: 1, column: 20 },
- end: { line: 1, column: 22 }
- }
- },
- generator: false,
- expression: false,
- typeParameters: {
- type: 'TypeParameterDeclaration',
- params: [{
- type: 'Identifier',
- name: 'T',
- range: [13, 14],
- loc: {
- start: { line: 1, column: 13 },
- end: { line: 1, column: 14 }
- }
- }, {
- type: 'Identifier',
- name: 'S',
- range: [15, 16],
- loc: {
- start: { line: 1, column: 15 },
- end: { line: 1, column: 16 }
- }
- }],
- range: [12, 17],
- loc: {
- start: { line: 1, column: 12 },
- end: { line: 1, column: 17 }
- }
- },
- range: [0, 22],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 22 }
- }
- },
- 'a=function() {}': {
- type: 'ExpressionStatement',
- expression: {
- type: 'AssignmentExpression',
- operator: '=',
- left: {
- type: 'Identifier',
- name: 'a',
- range: [0, 1],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 1 }
- }
- },
- right: {
- type: 'FunctionExpression',
- id: null,
- params: [],
- body: {
- type: 'BlockStatement',
- body: [],
- range: [18, 20],
- loc: {
- start: { line: 1, column: 18 },
- end: { line: 1, column: 20 }
- }
- },
- generator: false,
- expression: false,
- typeParameters: {
- type: 'TypeParameterDeclaration',
- params: [{
- type: 'Identifier',
- name: 'T',
- range: [11, 12],
- loc: {
- start: { line: 1, column: 11 },
- end: { line: 1, column: 12 }
- }
- }, {
- type: 'Identifier',
- name: 'S',
- range: [13, 14],
- loc: {
- start: { line: 1, column: 13 },
- end: { line: 1, column: 14 }
- }
- }],
- range: [10, 15],
- loc: {
- start: { line: 1, column: 10 },
- end: { line: 1, column: 15 }
- }
- },
- range: [2, 20],
- loc: {
- start: { line: 1, column: 2 },
- end: { line: 1, column: 20 }
- }
- },
- range: [0, 20],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 20 }
- }
- },
- range: [0, 20],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 20 }
- }
- },
- "a={set fooProp(value:number){}}": {
- type: "ExpressionStatement",
- expression: {
- type: "AssignmentExpression",
- operator: "=",
- left: {
- type: "Identifier",
- name: "a",
- range: [0, 1],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 1 }
- }
- },
- right: {
- type: "ObjectExpression",
- properties: [{
- type: "Property",
- key: {
- type: "Identifier",
- name: "fooProp",
- range: [7, 14],
- loc: {
- start: { line: 1, column: 7 },
- end: { line: 1, column: 14 }
- }
- },
- value: {
- type: "FunctionExpression",
- id: null,
- params: [{
- type: "Identifier",
- name: "value",
- typeAnnotation: {
- type: "TypeAnnotation",
- typeAnnotation: {
- type: "NumberTypeAnnotation",
- range: [21, 27],
- loc: {
- start: { line: 1, column: 21 },
- end: { line: 1, column: 27 }
- }
- },
- range: [20, 27],
- loc: {
- start: { line: 1, column: 20 },
- end: { line: 1, column: 27 }
- }
- },
- range: [15, 27],
- loc: {
- start: { line: 1, column: 15 },
- end: { line: 1, column: 27 }
- }
- }],
- body: {
- type: "BlockStatement",
- body: [],
- range: [28, 30],
- loc: {
- start: { line: 1, column: 28 },
- end: { line: 1, column: 30 }
- }
- },
- generator: false,
- expression: false,
- //range: [28, 30],
- //loc: {
- // start: { line: 1, column: 28 },
- // end: { line: 1, column: 30 }
- //}
- },
- kind: "set",
- method: false,
- shorthand: false,
- computed: false,
- range: [3, 30],
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 30 }
- }
- }],
- range: [2, 31],
- loc: {
- start: { line: 1, column: 2 },
- end: { line: 1, column: 31 }
- }
- },
- range: [0, 31],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 31 }
- }
- },
- range: [0, 31],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 31 }
- }
- },
- "a={set fooProp(value:number):void{}}": {
- type: "ExpressionStatement",
- expression: {
- type: "AssignmentExpression",
- operator: "=",
- left: {
- type: "Identifier",
- name: "a",
- range: [0, 1],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 1 }
- }
- },
- right: {
- type: "ObjectExpression",
- properties: [{
- type: "Property",
- key: {
- type: "Identifier",
- name: "fooProp",
- range: [7, 14],
- loc: {
- start: { line: 1, column: 7 },
- end: { line: 1, column: 14 }
- }
- },
- value: {
- type: "FunctionExpression",
- id: null,
- params: [{
- type: "Identifier",
- name: "value",
- typeAnnotation: {
- type: "TypeAnnotation",
- typeAnnotation: {
- type: "NumberTypeAnnotation",
- range: [21, 27],
- loc: {
- start: { line: 1, column: 21 },
- end: { line: 1, column: 27 }
- }
- },
- range: [20, 27],
- loc: {
- start: { line: 1, column: 20 },
- end: { line: 1, column: 27 }
- }
- },
- range: [15, 27],
- loc: {
- start: { line: 1, column: 15 },
- end: { line: 1, column: 27 }
- }
- }],
- body: {
- type: "BlockStatement",
- body: [],
- range: [33, 35],
- loc: {
- start: { line: 1, column: 33 },
- end: { line: 1, column: 35 }
- }
- },
- generator: false,
- expression: false,
- returnType: {
- type: "TypeAnnotation",
- typeAnnotation: {
- type: "VoidTypeAnnotation",
- range: [29, 33],
- loc: {
- start: { line: 1, column: 29 },
- end: { line: 1, column: 33 }
- }
- },
- range: [28, 33],
- loc: {
- start: { line: 1, column: 28 },
- end: { line: 1, column: 33 }
- }
- },
- //range: [33, 35],
- //loc: {
- // start: { line: 1, column: 33 },
- // end: { line: 1, column: 35 }
- //}
- },
- kind: "set",
- method: false,
- shorthand: false,
- computed: false,
- range: [3, 35],
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 35 }
- }
- }],
- range: [2, 36],
- loc: {
- start: { line: 1, column: 2 },
- end: { line: 1, column: 36 }
- }
- },
- range: [0, 36],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 36 }
- }
- },
- range: [0, 36],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 36 }
- }
- },
- "a={get fooProp():number{}}": {
- type: "ExpressionStatement",
- expression: {
- type: "AssignmentExpression",
- operator: "=",
- left: {
- type: "Identifier",
- name: "a",
- range: [0, 1],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 1 }
- }
- },
- right: {
- type: "ObjectExpression",
- properties: [{
- type: "Property",
- key: {
- type: "Identifier",
- name: "fooProp",
- range: [7, 14],
- loc: {
- start: { line: 1, column: 7 },
- end: { line: 1, column: 14 }
- }
- },
- value: {
- type: "FunctionExpression",
- id: null,
- params: [],
- body: {
- type: "BlockStatement",
- body: [],
- range: [23, 25],
- loc: {
- start: { line: 1, column: 23 },
- end: { line: 1, column: 25 }
- }
- },
- generator: false,
- expression: false,
- returnType: {
- type: "TypeAnnotation",
- typeAnnotation: {
- type: "NumberTypeAnnotation",
- range: [17, 23],
- loc: {
- start: { line: 1, column: 17 },
- end: { line: 1, column: 23 }
- }
- },
- range: [16, 23],
- loc: {
- start: { line: 1, column: 16 },
- end: { line: 1, column: 23 }
- }
- },
- //range: [23, 25],
- //loc: {
- // start: { line: 1, column: 23 },
- // end: { line: 1, column: 25 }
- //}
- },
- kind: "get",
- method: false,
- shorthand: false,
- computed: false,
- range: [3, 25],
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 25 }
- }
- }],
- range: [2, 26],
- loc: {
- start: { line: 1, column: 2 },
- end: { line: 1, column: 26 }
- }
- },
- range: [0, 26],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 26 }
- }
- },
- range: [0, 26],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 26 }
- }
- },
- 'a={id(x: T): T {}}': {
- type: "ExpressionStatement",
- expression: {
- type: "AssignmentExpression",
- operator: "=",
- left: {
- type: "Identifier",
- name: "a",
- range: [0, 1],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 1 }
- }
- },
- right: {
- type: "ObjectExpression",
- properties: [{
- type: "Property",
- key: {
- type: "Identifier",
- name: "id",
- range: [3, 5],
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 5 }
- }
- },
- value: {
- type: "FunctionExpression",
- //id: null,
- params: [{
- type: "Identifier",
- name: "x",
- typeAnnotation: {
- type: "TypeAnnotation",
- typeAnnotation: {
- type: "GenericTypeAnnotation",
- id: {
- type: "Identifier",
- name: "T",
- range: [12, 13],
- loc: {
- start: { line: 1, column: 12 },
- end: { line: 1, column: 13 }
- }
- },
- typeParameters: null,
- range: [12, 13],
- loc: {
- start: { line: 1, column: 12 },
- end: { line: 1, column: 13 }
- }
- },
- range: [10, 13],
- loc: {
- start: { line: 1, column: 10 },
- end: { line: 1, column: 13 }
- }
- },
- range: [9, 13],
- loc: {
- start: { line: 1, column: 9 },
- end: { line: 1, column: 13 }
- }
- }],
- body: {
- type: "BlockStatement",
- body: [],
- range: [18, 20],
- loc: {
- start: { line: 1, column: 18 },
- end: { line: 1, column: 20 }
- }
- },
- generator: false,
- expression: false,
- returnType: {
- type: "TypeAnnotation",
- typeAnnotation: {
- type: "GenericTypeAnnotation",
- id: {
- type: "Identifier",
- name: "T",
- range: [16, 17],
- loc: {
- start: { line: 1, column: 16 },
- end: { line: 1, column: 17 }
- }
- },
- typeParameters: null,
- range: [16, 17],
- loc: {
- start: { line: 1, column: 16 },
- end: { line: 1, column: 17 }
- }
- },
- range: [14, 17],
- loc: {
- start: { line: 1, column: 14 },
- end: { line: 1, column: 17 }
- }
- },
- typeParameters: {
- type: "TypeParameterDeclaration",
- params: [{
- type: "Identifier",
- name: "T",
- range: [6, 7],
- loc: {
- start: { line: 1, column: 6 },
- end: { line: 1, column: 7 }
- }
- }],
- range: [5, 8],
- loc: {
- start: { line: 1, column: 5 },
- end: { line: 1, column: 8 }
- }
- },
- //range: [18, 20],
- //loc: {
- // start: { line: 1, column: 18 },
- // end: { line: 1, column: 20 }
- //}
- },
- kind: "init",
- method: true,
- shorthand: false,
- computed: false,
- range: [3, 20],
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 20 }
- }
- }],
- range: [2, 21],
- loc: {
- start: { line: 1, column: 2 },
- end: { line: 1, column: 21 }
- }
- },
- range: [0, 21],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 21 }
- }
- },
- range: [0, 21],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 21 }
- }
- },
- 'a={*id(x: T): T {}}': {
- type: "ExpressionStatement",
- expression: {
- type: "AssignmentExpression",
- operator: "=",
- left: {
- type: "Identifier",
- name: "a",
- range: [0, 1],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 1 }
- }
- },
- right: {
- type: "ObjectExpression",
- properties: [{
- type: "Property",
- key: {
- type: "Identifier",
- name: "id",
- range: [4, 6],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 6 }
- }
- },
- value: {
- type: "FunctionExpression",
- id: null,
- params: [{
- type: "Identifier",
- name: "x",
- typeAnnotation: {
- type: "TypeAnnotation",
- typeAnnotation: {
- type: "GenericTypeAnnotation",
- id: {
- type: "Identifier",
- name: "T",
- range: [13, 14],
- loc: {
- start: { line: 1, column: 13 },
- end: { line: 1, column: 14 }
- }
- },
- typeParameters: null,
- range: [13, 14],
- loc: {
- start: { line: 1, column: 13 },
- end: { line: 1, column: 14 }
- }
- },
- range: [11, 14],
- loc: {
- start: { line: 1, column: 11 },
- end: { line: 1, column: 14 }
- }
- },
- range: [10, 14],
- loc: {
- start: { line: 1, column: 10 },
- end: { line: 1, column: 14 }
- }
- }],
- body: {
- type: "BlockStatement",
- body: [],
- range: [19, 21],
- loc: {
- start: { line: 1, column: 19 },
- end: { line: 1, column: 21 }
- }
- },
- generator: true,
- expression: false,
- returnType: {
- type: "TypeAnnotation",
- typeAnnotation: {
- type: "GenericTypeAnnotation",
- id: {
- type: "Identifier",
- name: "T",
- range: [17, 18],
- loc: {
- start: { line: 1, column: 17 },
- end: { line: 1, column: 18 }
- }
- },
- typeParameters: null,
- range: [17, 18],
- loc: {
- start: { line: 1, column: 17 },
- end: { line: 1, column: 18 }
- }
- },
- range: [15, 18],
- loc: {
- start: { line: 1, column: 15 },
- end: { line: 1, column: 18 }
- }
- },
- typeParameters: {
- type: "TypeParameterDeclaration",
- params: [{
- type: "Identifier",
- name: "T",
- range: [7, 8],
- loc: {
- start: { line: 1, column: 7 },
- end: { line: 1, column: 8 }
- }
- }],
- range: [6, 9],
- loc: {
- start: { line: 1, column: 6 },
- end: { line: 1, column: 9 }
- }
- },
- //range: [19, 21],
- //loc: {
- // start: { line: 1, column: 19 },
- // end: { line: 1, column: 21 }
- //}
- },
- kind: "init",
- method: true,
- shorthand: false,
- computed: false,
- //range: [3, 21],
- //loc: {
- // start: { line: 1, column: 3 },
- // end: { line: 1, column: 21 }
- //}
- }],
- range: [2, 22],
- loc: {
- start: { line: 1, column: 2 },
- end: { line: 1, column: 22 }
- }
- },
- range: [0, 22],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 22 }
- }
- },
- range: [0, 22],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 22 }
- }
- },
- 'a={async id(x: T): T {}}': {
- type: 'ExpressionStatement',
- expression: {
- type: 'AssignmentExpression',
- operator: '=',
- left: {
- type: 'Identifier',
- name: 'a',
- range: [0, 1],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 1 }
- }
- },
- right: {
- type: 'ObjectExpression',
- properties: [{
- type: 'Property',
- key: {
- type: 'Identifier',
- name: 'id',
- range: [9, 11],
- loc: {
- start: { line: 1, column: 9 },
- end: { line: 1, column: 11 }
- }
- },
- value: {
- type: 'FunctionExpression',
- id: null,
- params: [{
- type: 'Identifier',
- name: 'x',
- typeAnnotation: {
- type: 'TypeAnnotation',
- typeAnnotation: {
- type: 'GenericTypeAnnotation',
- id: {
- type: 'Identifier',
- name: 'T',
- range: [18, 19],
- loc: {
- start: { line: 1, column: 18 },
- end: { line: 1, column: 19 }
- }
- },
- typeParameters: null,
- range: [18, 19],
- loc: {
- start: { line: 1, column: 18 },
- end: { line: 1, column: 19 }
- }
- },
- range: [16, 19],
- loc: {
- start: { line: 1, column: 16 },
- end: { line: 1, column: 19 }
- }
- },
- range: [15, 19],
- loc: {
- start: { line: 1, column: 15 },
- end: { line: 1, column: 19 }
- }
- }],
- body: {
- type: 'BlockStatement',
- body: [],
- range: [24, 26],
- loc: {
- start: { line: 1, column: 24 },
- end: { line: 1, column: 26 }
- }
- },
- generator: false,
- expression: false,
- returnType: {
- type: 'TypeAnnotation',
- typeAnnotation: {
- type: 'GenericTypeAnnotation',
- id: {
- type: 'Identifier',
- name: 'T',
- range: [22, 23],
- loc: {
- start: { line: 1, column: 22 },
- end: { line: 1, column: 23 }
- }
- },
- typeParameters: null,
- range: [22, 23],
- loc: {
- start: { line: 1, column: 22 },
- end: { line: 1, column: 23 }
- }
- },
- range: [20, 23],
- loc: {
- start: { line: 1, column: 20 },
- end: { line: 1, column: 23 }
- }
- },
- typeParameters: {
- type: 'TypeParameterDeclaration',
- params: [{
- type: 'Identifier',
- name: 'T',
- range: [12, 13],
- loc: {
- start: { line: 1, column: 12 },
- end: { line: 1, column: 13 }
- }
- }],
- range: [11, 14],
- loc: {
- start: { line: 1, column: 11 },
- end: { line: 1, column: 14 }
- }
- },
- async: true,
- //range: [24, 26],
- //loc: {
- // start: { line: 1, column: 24 },
- // end: { line: 1, column: 26 }
- //}
- },
- kind: 'init',
- method: true,
- shorthand: false,
- computed: false,
- range: [3, 26],
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 26 }
- }
- }],
- range: [2, 27],
- loc: {
- start: { line: 1, column: 2 },
- end: { line: 1, column: 27 }
- }
- },
- range: [0, 27],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 27 }
- }
- },
- range: [0, 27],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 27 }
- }
- },
- 'a={123(x: T): T {}}': {
- type: "ExpressionStatement",
- expression: {
- type: "AssignmentExpression",
- operator: "=",
- left: {
- type: "Identifier",
- name: "a",
- range: [0, 1],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 1 }
- }
- },
- right: {
- type: "ObjectExpression",
- properties: [{
- type: "Property",
- key: {
- type: "Literal",
- value: 123,
- raw: "123",
- range: [3, 6],
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 6 }
- }
- },
- value: {
- type: "FunctionExpression",
- id: null,
- params: [{
- type: "Identifier",
- name: "x",
- typeAnnotation: {
- type: "TypeAnnotation",
- typeAnnotation: {
- type: "GenericTypeAnnotation",
- id: {
- type: "Identifier",
- name: "T",
- range: [13, 14],
- loc: {
- start: { line: 1, column: 13 },
- end: { line: 1, column: 14 }
- }
- },
- typeParameters: null,
- range: [13, 14],
- loc: {
- start: { line: 1, column: 13 },
- end: { line: 1, column: 14 }
- }
- },
- range: [11, 14],
- loc: {
- start: { line: 1, column: 11 },
- end: { line: 1, column: 14 }
- }
- },
- range: [10, 14],
- loc: {
- start: { line: 1, column: 10 },
- end: { line: 1, column: 14 }
- }
- }],
- body: {
- type: "BlockStatement",
- body: [],
- range: [19, 21],
- loc: {
- start: { line: 1, column: 19 },
- end: { line: 1, column: 21 }
- }
- },
- generator: false,
- expression: false,
- returnType: {
- type: "TypeAnnotation",
- typeAnnotation: {
- type: "GenericTypeAnnotation",
- id: {
- type: "Identifier",
- name: "T",
- range: [17, 18],
- loc: {
- start: { line: 1, column: 17 },
- end: { line: 1, column: 18 }
- }
- },
- typeParameters: null,
- range: [17, 18],
- loc: {
- start: { line: 1, column: 17 },
- end: { line: 1, column: 18 }
- }
- },
- range: [15, 18],
- loc: {
- start: { line: 1, column: 15 },
- end: { line: 1, column: 18 }
- }
- },
- typeParameters: {
- type: "TypeParameterDeclaration",
- params: [{
- type: "Identifier",
- name: "T",
- range: [7, 8],
- loc: {
- start: { line: 1, column: 7 },
- end: { line: 1, column: 8 }
- }
- }],
- range: [6, 9],
- loc: {
- start: { line: 1, column: 6 },
- end: { line: 1, column: 9 }
- }
- },
- //range: [19, 21],
- //loc: {
- // start: { line: 1, column: 19 },
- // end: { line: 1, column: 21 }
- //}
- },
- kind: "init",
- method: true,
- shorthand: false,
- computed: false,
- range: [3, 21],
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 21 }
- }
- }],
- range: [2, 22],
- loc: {
- start: { line: 1, column: 2 },
- end: { line: 1, column: 22 }
- }
- },
- range: [0, 22],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 22 }
- }
- },
- range: [0, 22],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 22 }
- }
- },
- "class Foo {set fooProp(value:number){}}": {
- type: "ClassDeclaration",
- id: {
- type: "Identifier",
- name: "Foo",
- range: [6, 9],
- loc: {
- start: { line: 1, column: 6 },
- end: { line: 1, column: 9 }
- }
- },
- superClass: null,
- body: {
- type: "ClassBody",
- body: [{
- type: "MethodDefinition",
- key: {
- type: "Identifier",
- name: "fooProp",
- range: [15, 22],
- loc: {
- start: { line: 1, column: 15 },
- end: { line: 1, column: 22 }
- }
- },
- value: {
- type: "FunctionExpression",
- id: null,
- params: [{
- type: "Identifier",
- name: "value",
- typeAnnotation: {
- type: "TypeAnnotation",
- typeAnnotation: {
- type: "NumberTypeAnnotation",
- range: [29, 35],
- loc: {
- start: { line: 1, column: 29 },
- end: { line: 1, column: 35 }
- }
- },
- range: [28, 35],
- loc: {
- start: { line: 1, column: 28 },
- end: { line: 1, column: 35 }
- }
- },
- range: [23, 35],
- loc: {
- start: { line: 1, column: 23 },
- end: { line: 1, column: 35 }
- }
- }],
- body: {
- type: "BlockStatement",
- body: [],
- range: [36, 38],
- loc: {
- start: { line: 1, column: 36 },
- end: { line: 1, column: 38 }
- }
- },
- generator: false,
- expression: false,
- //range: [36, 38],
- //loc: {
- // start: { line: 1, column: 36 },
- // end: { line: 1, column: 38 }
- //}
- },
- kind: "set",
- "static": false,
- computed: false,
- range: [11, 38],
- loc: {
- start: { line: 1, column: 11 },
- end: { line: 1, column: 38 }
- }
- }],
- range: [10, 39],
- loc: {
- start: { line: 1, column: 10 },
- end: { line: 1, column: 39 }
- }
- },
- range: [0, 39],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 39 }
- }
- },
- 'class Foo {set fooProp(value:number):void{}}': {
- type: "ClassDeclaration",
- id: {
- type: "Identifier",
- name: "Foo",
- range: [6, 9],
- loc: {
- start: { line: 1, column: 6 },
- end: { line: 1, column: 9 }
- }
- },
- superClass: null,
- body: {
- type: "ClassBody",
- body: [{
- type: "MethodDefinition",
- key: {
- type: "Identifier",
- name: "fooProp",
- range: [15, 22],
- loc: {
- start: { line: 1, column: 15 },
- end: { line: 1, column: 22 }
- }
- },
- value: {
- type: "FunctionExpression",
- id: null,
- params: [{
- type: "Identifier",
- name: "value",
- typeAnnotation: {
- type: "TypeAnnotation",
- typeAnnotation: {
- type: "NumberTypeAnnotation",
- range: [29, 35],
- loc: {
- start: { line: 1, column: 29 },
- end: { line: 1, column: 35 }
- }
- },
- range: [28, 35],
- loc: {
- start: { line: 1, column: 28 },
- end: { line: 1, column: 35 }
- }
- },
- range: [23, 35],
- loc: {
- start: { line: 1, column: 23 },
- end: { line: 1, column: 35 }
- }
- }],
- body: {
- type: "BlockStatement",
- body: [],
- range: [41, 43],
- loc: {
- start: { line: 1, column: 41 },
- end: { line: 1, column: 43 }
- }
- },
- generator: false,
- expression: false,
- returnType: {
- type: "TypeAnnotation",
- typeAnnotation: {
- type: "VoidTypeAnnotation",
- range: [37, 41],
- loc: {
- start: { line: 1, column: 37 },
- end: { line: 1, column: 41 }
- }
- },
- range: [36, 41],
- loc: {
- start: { line: 1, column: 36 },
- end: { line: 1, column: 41 }
- }
- },
- //range: [41, 43],
- //loc: {
- // start: { line: 1, column: 41 },
- // end: { line: 1, column: 43 }
- //}
- },
- kind: "set",
- "static": false,
- computed: false,
- range: [11, 43],
- loc: {
- start: { line: 1, column: 11 },
- end: { line: 1, column: 43 }
- }
- }],
- range: [10, 44],
- loc: {
- start: { line: 1, column: 10 },
- end: { line: 1, column: 44 }
- }
- },
- range: [0, 44],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 44 }
- }
- },
- 'class Foo {get fooProp():number{}}': {
- type: "ClassDeclaration",
- id: {
- type: "Identifier",
- name: "Foo",
- range: [6, 9],
- loc: {
- start: { line: 1, column: 6 },
- end: { line: 1, column: 9 }
- }
- },
- superClass: null,
- body: {
- type: "ClassBody",
- body: [{
- type: "MethodDefinition",
- key: {
- type: "Identifier",
- name: "fooProp",
- range: [15, 22],
- loc: {
- start: { line: 1, column: 15 },
- end: { line: 1, column: 22 }
- }
- },
- value: {
- type: "FunctionExpression",
- id: null,
- params: [],
- body: {
- type: "BlockStatement",
- body: [],
- range: [31, 33],
- loc: {
- start: { line: 1, column: 31 },
- end: { line: 1, column: 33 }
- }
- },
- generator: false,
- expression: false,
- returnType: {
- type: "TypeAnnotation",
- typeAnnotation: {
- type: "NumberTypeAnnotation",
- range: [25, 31],
- loc: {
- start: { line: 1, column: 25 },
- end: { line: 1, column: 31 }
- }
- },
- range: [24, 31],
- loc: {
- start: { line: 1, column: 24 },
- end: { line: 1, column: 31 }
- }
- },
- //range: [31, 33],
- //loc: {
- // start: { line: 1, column: 31 },
- // end: { line: 1, column: 33 }
- //}
- },
- kind: "get",
- "static": false,
- computed: false,
- range: [11, 33],
- loc: {
- start: { line: 1, column: 11 },
- end: { line: 1, column: 33 }
- }
- }],
- range: [10, 34],
- loc: {
- start: { line: 1, column: 10 },
- end: { line: 1, column: 34 }
- }
- },
- range: [0, 34],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 34 }
- }
- },
- 'var numVal:number;': {
- type: 'VariableDeclaration',
- declarations: [{
- type: 'VariableDeclarator',
- id: {
- type: 'Identifier',
- name: 'numVal',
- typeAnnotation: {
- type: 'TypeAnnotation',
- typeAnnotation: {
- type: 'NumberTypeAnnotation',
- range: [11, 17],
- loc: {
- start: { line: 1, column: 11 },
- end: { line: 1, column: 17 }
- }
- },
- range: [10, 17],
- loc: {
- start: { line: 1, column: 10 },
- end: { line: 1, column: 17 }
- }
- },
- range: [4, 17],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 17 }
- }
- },
- init: null,
- range: [4, 17],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 17 }
- }
- }],
- kind: 'var',
- range: [0, 18],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 18 }
- }
- },
- 'var numVal:number = otherNumVal;': {
- type: 'VariableDeclaration',
- declarations: [{
- type: 'VariableDeclarator',
- id: {
- type: 'Identifier',
- name: 'numVal',
- typeAnnotation: {
- type: 'TypeAnnotation',
- typeAnnotation: {
- type: 'NumberTypeAnnotation',
- range: [11, 17],
- loc: {
- start: { line: 1, column: 11 },
- end: { line: 1, column: 17 }
- }
- },
- range: [10, 17],
- loc: {
- start: { line: 1, column: 10 },
- end: { line: 1, column: 17 }
- }
- },
- range: [4, 17],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 17 }
- }
- },
- init: {
- type: 'Identifier',
- name: 'otherNumVal',
- range: [20, 31],
- loc: {
- start: { line: 1, column: 20 },
- end: { line: 1, column: 31 }
- }
- },
- range: [4, 31],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 31 }
- }
- }],
- kind: 'var',
- range: [0, 32],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 32 }
- }
- },
- 'var a: {numVal: number};': {
- type: 'VariableDeclaration',
- declarations: [{
- type: 'VariableDeclarator',
- id: {
- type: 'Identifier',
- name: 'a',
- typeAnnotation: {
- type: 'TypeAnnotation',
- typeAnnotation: {
- type: 'ObjectTypeAnnotation',
- properties: [{
- type: 'ObjectTypeProperty',
- key: {
- type: 'Identifier',
- name: 'numVal',
- range: [8, 14],
- loc: {
- start: { line: 1, column: 8 },
- end: { line: 1, column: 14 }
- }
- },
- value: {
- type: 'NumberTypeAnnotation',
- range: [16, 22],
- loc: {
- start: { line: 1, column: 16 },
- end: { line: 1, column: 22 }
- }
- },
- optional: false,
- range: [8, 22],
- loc: {
- start: { line: 1, column: 8 },
- end: { line: 1, column: 22 }
- }
- }],
- indexers: [],
- callProperties: [],
- range: [7, 23],
- loc: {
- start: { line: 1, column: 7 },
- end: { line: 1, column: 23 }
- }
- },
- range: [5, 23],
- loc: {
- start: { line: 1, column: 5 },
- end: { line: 1, column: 23 }
- }
- },
- range: [4, 23],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 23 }
- }
- },
- init: null,
- range: [4, 23],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 23 }
- }
- }],
- kind: 'var',
- range: [0, 24],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 24 }
- }
- },
- 'var a: {numVal: number;};': {
- type: 'VariableDeclaration',
- declarations: [{
- type: 'VariableDeclarator',
- id: {
- type: 'Identifier',
- name: 'a',
- typeAnnotation: {
- type: 'TypeAnnotation',
- typeAnnotation: {
- type: 'ObjectTypeAnnotation',
- properties: [{
- type: 'ObjectTypeProperty',
- key: {
- type: 'Identifier',
- name: 'numVal',
- range: [8, 14],
- loc: {
- start: { line: 1, column: 8 },
- end: { line: 1, column: 14 }
- }
- },
- value: {
- type: 'NumberTypeAnnotation',
- range: [16, 22],
- loc: {
- start: { line: 1, column: 16 },
- end: { line: 1, column: 22 }
- }
- },
- optional: false,
- range: [8, 22],
- loc: {
- start: { line: 1, column: 8 },
- end: { line: 1, column: 22 }
- }
- }],
- indexers: [],
- callProperties: [],
- range: [7, 24],
- loc: {
- start: { line: 1, column: 7 },
- end: { line: 1, column: 24 }
- }
- },
- range: [5, 24],
- loc: {
- start: { line: 1, column: 5 },
- end: { line: 1, column: 24 }
- }
- },
- range: [4, 24],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 24 }
- }
- },
- init: null,
- range: [4, 24],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 24 }
- }
- }],
- kind: 'var',
- range: [0, 25],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 25 }
- }
- },
- 'var a: {numVal: number; [indexer: string]: number};': {
- type: 'VariableDeclaration',
- declarations: [{
- type: 'VariableDeclarator',
- id: {
- type: 'Identifier',
- name: 'a',
- typeAnnotation: {
- type: 'TypeAnnotation',
- typeAnnotation: {
- type: 'ObjectTypeAnnotation',
- properties: [{
- type: 'ObjectTypeProperty',
- key: {
- type: 'Identifier',
- name: 'numVal',
- range: [8, 14],
- loc: {
- start: { line: 1, column: 8 },
- end: { line: 1, column: 14 }
- }
- },
- value: {
- type: 'NumberTypeAnnotation',
- range: [16, 22],
- loc: {
- start: { line: 1, column: 16 },
- end: { line: 1, column: 22 }
- }
- },
- optional: false,
- range: [8, 22],
- loc: {
- start: { line: 1, column: 8 },
- end: { line: 1, column: 22 }
- }
- }],
- indexers: [{
- type: 'ObjectTypeIndexer',
- id: {
- type: 'Identifier',
- name: 'indexer',
- range: [25, 32],
- loc: {
- start: { line: 1, column: 25 },
- end: { line: 1, column: 32 }
- }
- },
- key: {
- type: 'StringTypeAnnotation',
- range: [34, 40],
- loc: {
- start: { line: 1, column: 34 },
- end: { line: 1, column: 40 }
- }
- },
- value: {
- type: 'NumberTypeAnnotation',
- range: [43, 49],
- loc: {
- start: { line: 1, column: 43 },
- end: { line: 1, column: 49 }
- }
- },
- range: [24, 49],
- loc: {
- start: { line: 1, column: 24 },
- end: { line: 1, column: 49 }
- }
- }],
- callProperties: [],
- range: [7, 50],
- loc: {
- start: { line: 1, column: 7 },
- end: { line: 1, column: 50 }
- }
- },
- range: [5, 50],
- loc: {
- start: { line: 1, column: 5 },
- end: { line: 1, column: 50 }
- }
- },
- range: [4, 50],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 50 }
- }
- },
- init: null,
- range: [4, 50],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 50 }
- }
- }],
- kind: 'var',
- range: [0, 51],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 51 }
- }
- },
- 'var a: ?{numVal: number};': {
- type: 'VariableDeclaration',
- declarations: [{
- type: 'VariableDeclarator',
- id: {
- type: 'Identifier',
- name: 'a',
- typeAnnotation: {
- type: 'TypeAnnotation',
- typeAnnotation: {
- type: 'NullableTypeAnnotation',
- typeAnnotation: {
- type: 'ObjectTypeAnnotation',
- properties: [{
- type: 'ObjectTypeProperty',
- key: {
- type: 'Identifier',
- name: 'numVal',
- range: [9, 15],
- loc: {
- start: { line: 1, column: 9 },
- end: { line: 1, column: 15 }
- }
- },
- value: {
- type: 'NumberTypeAnnotation',
- range: [17, 23],
- loc: {
- start: { line: 1, column: 17 },
- end: { line: 1, column: 23 }
- }
- },
- optional: false,
- range: [9, 23],
- loc: {
- start: { line: 1, column: 9 },
- end: { line: 1, column: 23 }
- }
- }],
- indexers: [],
- callProperties: [],
- range: [8, 24],
- loc: {
- start: { line: 1, column: 8 },
- end: { line: 1, column: 24 }
- }
- },
- range: [7, 24],
- loc: {
- start: { line: 1, column: 7 },
- end: { line: 1, column: 24 }
- }
- },
- range: [5, 24],
- loc: {
- start: { line: 1, column: 5 },
- end: { line: 1, column: 24 }
- }
- },
- range: [4, 24],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 24 }
- }
- },
- init: null,
- range: [4, 24],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 24 }
- }
- }],
- kind: 'var',
- range: [0, 25],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 25 }
- }
- },
- 'var a: {numVal: number; strVal: string}': {
- type: 'VariableDeclaration',
- declarations: [{
- type: 'VariableDeclarator',
- id: {
- type: 'Identifier',
- name: 'a',
- typeAnnotation: {
- type: 'TypeAnnotation',
- typeAnnotation: {
- type: 'ObjectTypeAnnotation',
- properties: [{
- type: 'ObjectTypeProperty',
- key: {
- type: 'Identifier',
- name: 'numVal',
- range: [8, 14],
- loc: {
- start: { line: 1, column: 8 },
- end: { line: 1, column: 14 }
- }
- },
- value: {
- type: 'NumberTypeAnnotation',
- range: [16, 22],
- loc: {
- start: { line: 1, column: 16 },
- end: { line: 1, column: 22 }
- }
- },
- optional: false,
- range: [8, 22],
- loc: {
- start: { line: 1, column: 8 },
- end: { line: 1, column: 22 }
- }
- }, {
- type: 'ObjectTypeProperty',
- key: {
- type: 'Identifier',
- name: 'strVal',
- range: [24, 30],
- loc: {
- start: { line: 1, column: 24 },
- end: { line: 1, column: 30 }
- }
- },
- value: {
- type: 'StringTypeAnnotation',
- range: [32, 38],
- loc: {
- start: { line: 1, column: 32 },
- end: { line: 1, column: 38 }
- }
- },
- optional: false,
- range: [24, 38],
- loc: {
- start: { line: 1, column: 24 },
- end: { line: 1, column: 38 }
- }
- }],
- indexers: [],
- callProperties: [],
- range: [7, 39],
- loc: {
- start: { line: 1, column: 7 },
- end: { line: 1, column: 39 }
- }
- },
- range: [5, 39],
- loc: {
- start: { line: 1, column: 5 },
- end: { line: 1, column: 39 }
- }
- },
- range: [4, 39],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 39 }
- }
- },
- init: null,
- range: [4, 39],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 39 }
- }
- }],
- kind: 'var',
- range: [0, 39],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 39 }
- }
- },
- 'var a: {subObj: {strVal: string}}': {
- type: 'VariableDeclaration',
- declarations: [{
- type: 'VariableDeclarator',
- id: {
- type: 'Identifier',
- name: 'a',
- typeAnnotation: {
- type: 'TypeAnnotation',
- typeAnnotation: {
- type: 'ObjectTypeAnnotation',
- properties: [{
- type: 'ObjectTypeProperty',
- key: {
- type: 'Identifier',
- name: 'subObj',
- range: [8, 14],
- loc: {
- start: { line: 1, column: 8 },
- end: { line: 1, column: 14 }
- }
- },
- value: {
- type: 'ObjectTypeAnnotation',
- properties: [{
- type: 'ObjectTypeProperty',
- key: {
- type: 'Identifier',
- name: 'strVal',
- range: [17, 23],
- loc: {
- start: { line: 1, column: 17 },
- end: { line: 1, column: 23 }
- }
- },
- value: {
- type: 'StringTypeAnnotation',
- range: [25, 31],
- loc: {
- start: { line: 1, column: 25 },
- end: { line: 1, column: 31 }
- }
- },
- optional: false,
- range: [17, 31],
- loc: {
- start: { line: 1, column: 17 },
- end: { line: 1, column: 31 }
- }
- }],
- indexers: [],
- callProperties: [],
- range: [16, 32],
- loc: {
- start: { line: 1, column: 16 },
- end: { line: 1, column: 32 }
- }
- },
- optional: false,
- range: [8, 32],
- loc: {
- start: { line: 1, column: 8 },
- end: { line: 1, column: 32 }
- }
- }],
- indexers: [],
- callProperties: [],
- range: [7, 33],
- loc: {
- start: { line: 1, column: 7 },
- end: { line: 1, column: 33 }
- }
- },
- range: [5, 33],
- loc: {
- start: { line: 1, column: 5 },
- end: { line: 1, column: 33 }
- }
- },
- range: [4, 33],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 33 }
- }
- },
- init: null,
- range: [4, 33],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 33 }
- }
- }],
- kind: 'var',
- range: [0, 33],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 33 }
- }
- },
- 'var a: {subObj: ?{strVal: string}}': {
- type: 'VariableDeclaration',
- declarations: [{
- type: 'VariableDeclarator',
- id: {
- type: 'Identifier',
- name: 'a',
- typeAnnotation: {
- type: 'TypeAnnotation',
- typeAnnotation: {
- type: 'ObjectTypeAnnotation',
- properties: [{
- type: 'ObjectTypeProperty',
- key: {
- type: 'Identifier',
- name: 'subObj',
- range: [8, 14],
- loc: {
- start: { line: 1, column: 8 },
- end: { line: 1, column: 14 }
- }
- },
- value: {
- type: 'NullableTypeAnnotation',
- typeAnnotation: {
- type: 'ObjectTypeAnnotation',
- properties: [{
- type: 'ObjectTypeProperty',
- key: {
- type: 'Identifier',
- name: 'strVal',
- range: [18, 24],
- loc: {
- start: { line: 1, column: 18 },
- end: { line: 1, column: 24 }
- }
- },
- value: {
- type: 'StringTypeAnnotation',
- range: [26, 32],
- loc: {
- start: { line: 1, column: 26 },
- end: { line: 1, column: 32 }
- }
- },
- optional: false,
- range: [18, 32],
- loc: {
- start: { line: 1, column: 18 },
- end: { line: 1, column: 32 }
- }
- }],
- indexers: [],
- callProperties: [],
- range: [17, 33],
- loc: {
- start: { line: 1, column: 17 },
- end: { line: 1, column: 33 }
- }
- },
- range: [16, 33],
- loc: {
- start: { line: 1, column: 16 },
- end: { line: 1, column: 33 }
- }
- },
- optional: false,
- range: [8, 33],
- loc: {
- start: { line: 1, column: 8 },
- end: { line: 1, column: 33 }
- }
- }],
- indexers: [],
- callProperties: [],
- range: [7, 34],
- loc: {
- start: { line: 1, column: 7 },
- end: { line: 1, column: 34 }
- }
- },
- range: [5, 34],
- loc: {
- start: { line: 1, column: 5 },
- end: { line: 1, column: 34 }
- }
- },
- range: [4, 34],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 34 }
- }
- },
- init: null,
- range: [4, 34],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 34 }
- }
- }],
- kind: 'var',
- range: [0, 34],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 34 }
- }
- },
- 'var a: {param1: number; param2: string}': {
- type: 'VariableDeclaration',
- declarations: [{
- type: 'VariableDeclarator',
- id: {
- type: 'Identifier',
- name: 'a',
- typeAnnotation: {
- type: 'TypeAnnotation',
- typeAnnotation: {
- type: 'ObjectTypeAnnotation',
- properties: [{
- type: 'ObjectTypeProperty',
- key: {
- type: 'Identifier',
- name: 'param1',
- range: [8, 14],
- loc: {
- start: { line: 1, column: 8 },
- end: { line: 1, column: 14 }
- }
- },
- value: {
- type: 'NumberTypeAnnotation',
- range: [16, 22],
- loc: {
- start: { line: 1, column: 16 },
- end: { line: 1, column: 22 }
- }
- },
- optional: false,
- range: [8, 22],
- loc: {
- start: { line: 1, column: 8 },
- end: { line: 1, column: 22 }
- }
- }, {
- type: 'ObjectTypeProperty',
- key: {
- type: 'Identifier',
- name: 'param2',
- range: [24, 30],
- loc: {
- start: { line: 1, column: 24 },
- end: { line: 1, column: 30 }
- }
- },
- value: {
- type: 'StringTypeAnnotation',
- range: [32, 38],
- loc: {
- start: { line: 1, column: 32 },
- end: { line: 1, column: 38 }
- }
- },
- optional: false,
- range: [24, 38],
- loc: {
- start: { line: 1, column: 24 },
- end: { line: 1, column: 38 }
- }
- }],
- indexers: [],
- callProperties: [],
- range: [7, 39],
- loc: {
- start: { line: 1, column: 7 },
- end: { line: 1, column: 39 }
- }
- },
- range: [5, 39],
- loc: {
- start: { line: 1, column: 5 },
- end: { line: 1, column: 39 }
- }
- },
- range: [4, 39],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 39 }
- }
- },
- init: null,
- range: [4, 39],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 39 }
- }
- }],
- kind: 'var',
- range: [0, 39],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 39 }
- }
- },
- 'var a: {param1: number; param2?: string}': {
- type: 'VariableDeclaration',
- declarations: [{
- type: 'VariableDeclarator',
- id: {
- type: 'Identifier',
- name: 'a',
- typeAnnotation: {
- type: 'TypeAnnotation',
- typeAnnotation: {
- type: 'ObjectTypeAnnotation',
- properties: [{
- type: 'ObjectTypeProperty',
- key: {
- type: 'Identifier',
- name: 'param1',
- range: [8, 14],
- loc: {
- start: { line: 1, column: 8 },
- end: { line: 1, column: 14 }
- }
- },
- value: {
- type: 'NumberTypeAnnotation',
- range: [16, 22],
- loc: {
- start: { line: 1, column: 16 },
- end: { line: 1, column: 22 }
- }
- },
- optional: false,
- range: [8, 22],
- loc: {
- start: { line: 1, column: 8 },
- end: { line: 1, column: 22 }
- }
- }, {
- type: 'ObjectTypeProperty',
- key: {
- type: 'Identifier',
- name: 'param2',
- range: [24, 30],
- loc: {
- start: { line: 1, column: 24 },
- end: { line: 1, column: 30 }
- }
- },
- value: {
- type: 'StringTypeAnnotation',
- range: [33, 39],
- loc: {
- start: { line: 1, column: 33 },
- end: { line: 1, column: 39 }
- }
- },
- optional: true,
- range: [24, 39],
- loc: {
- start: { line: 1, column: 24 },
- end: { line: 1, column: 39 }
- }
- }],
- indexers: [],
- callProperties: [],
- range: [7, 40],
- loc: {
- start: { line: 1, column: 7 },
- end: { line: 1, column: 40 }
- }
- },
- range: [5, 40],
- loc: {
- start: { line: 1, column: 5 },
- end: { line: 1, column: 40 }
- }
- },
- range: [4, 40],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 40 }
- }
- },
- init: null,
- range: [4, 40],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 40 }
- }
- }],
- kind: 'var',
- range: [0, 40],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 40 }
- }
- },
- 'var a: { [a: number]: string; [b: number]: string; };': {
- type: 'VariableDeclaration',
- declarations: [{
- type: 'VariableDeclarator',
- id: {
- type: 'Identifier',
- name: 'a',
- typeAnnotation: {
- type: 'TypeAnnotation',
- typeAnnotation: {
- type: 'ObjectTypeAnnotation',
- properties: [],
- indexers: [{
- type: 'ObjectTypeIndexer',
- id: {
- type: 'Identifier',
- name: 'a',
- range: [10, 11],
- loc: {
- start: { line: 1, column: 10 },
- end: { line: 1, column: 11 }
- }
- },
- key: {
- type: 'NumberTypeAnnotation',
- range: [13, 19],
- loc: {
- start: { line: 1, column: 13 },
- end: { line: 1, column: 19 }
- }
- },
- value: {
- type: 'StringTypeAnnotation',
- range: [22, 28],
- loc: {
- start: { line: 1, column: 22 },
- end: { line: 1, column: 28 }
- }
- },
- range: [9, 28],
- loc: {
- start: { line: 1, column: 9 },
- end: { line: 1, column: 28 }
- }
- }, {
- type: 'ObjectTypeIndexer',
- id: {
- type: 'Identifier',
- name: 'b',
- range: [31, 32],
- loc: {
- start: { line: 1, column: 31 },
- end: { line: 1, column: 32 }
- }
- },
- key: {
- type: 'NumberTypeAnnotation',
- range: [34, 40],
- loc: {
- start: { line: 1, column: 34 },
- end: { line: 1, column: 40 }
- }
- },
- value: {
- type: 'StringTypeAnnotation',
- range: [43, 49],
- loc: {
- start: { line: 1, column: 43 },
- end: { line: 1, column: 49 }
- }
- },
- range: [30, 49],
- loc: {
- start: { line: 1, column: 30 },
- end: { line: 1, column: 49 }
- }
- }],
- callProperties: [],
- range: [7, 52],
- loc: {
- start: { line: 1, column: 7 },
- end: { line: 1, column: 52 }
- }
- },
- range: [5, 52],
- loc: {
- start: { line: 1, column: 5 },
- end: { line: 1, column: 52 }
- }
- },
- range: [4, 52],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 52 }
- }
- },
- init: null,
- range: [4, 52],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 52 }
- }
- }],
- kind: 'var',
- range: [0, 53],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 53 }
- }
- },
- 'var a: {add(x:number, ...y:Array): void}': {
- type: 'VariableDeclaration',
- declarations: [{
- type: 'VariableDeclarator',
- id: {
- type: 'Identifier',
- name: 'a',
- typeAnnotation: {
- type: 'TypeAnnotation',
- typeAnnotation: {
- type: 'ObjectTypeAnnotation',
- properties: [{
- type: 'ObjectTypeProperty',
- key: {
- type: 'Identifier',
- name: 'add',
- range: [8, 11],
- loc: {
- start: { line: 1, column: 8 },
- end: { line: 1, column: 11 }
- }
- },
- value: {
- type: 'FunctionTypeAnnotation',
- params: [{
- type: 'FunctionTypeParam',
- name: {
- type: 'Identifier',
- name: 'x',
- range: [12, 13],
- loc: {
- start: { line: 1, column: 12 },
- end: { line: 1, column: 13 }
- }
- },
- typeAnnotation: {
- type: 'NumberTypeAnnotation',
- range: [14, 20],
- loc: {
- start: { line: 1, column: 14 },
- end: { line: 1, column: 20 }
- }
- },
- optional: false,
- range: [12, 20],
- loc: {
- start: { line: 1, column: 12 },
- end: { line: 1, column: 20 }
- }
- }],
- returnType: {
- type: 'VoidTypeAnnotation',
- range: [43, 47],
- loc: {
- start: { line: 1, column: 43 },
- end: { line: 1, column: 47 }
- }
- },
- rest: {
- type: 'FunctionTypeParam',
- name: {
- type: 'Identifier',
- name: 'y',
- range: [25, 26],
- loc: {
- start: { line: 1, column: 25 },
- end: { line: 1, column: 26 }
- }
- },
- typeAnnotation: {
- type: 'GenericTypeAnnotation',
- id: {
- type: 'Identifier',
- name: 'Array',
- range: [27, 32],
- loc: {
- start: { line: 1, column: 27 },
- end: { line: 1, column: 32 }
- }
- },
- typeParameters: {
- type: 'TypeParameterInstantiation',
- params: [{
- type: 'StringTypeAnnotation',
- range: [33, 39],
- loc: {
- start: { line: 1, column: 33 },
- end: { line: 1, column: 39 }
- }
- }],
- range: [32, 40],
- loc: {
- start: { line: 1, column: 32 },
- end: { line: 1, column: 40 }
- }
- },
- range: [27, 40],
- loc: {
- start: { line: 1, column: 27 },
- end: { line: 1, column: 40 }
- }
- },
- optional: false,
- range: [25, 40],
- loc: {
- start: { line: 1, column: 25 },
- end: { line: 1, column: 40 }
- }
- },
- typeParameters: null,
- range: [8, 47],
- loc: {
- start: { line: 1, column: 8 },
- end: { line: 1, column: 47 }
- }
- },
- optional: false,
- range: [8, 47],
- loc: {
- start: { line: 1, column: 8 },
- end: { line: 1, column: 47 }
- }
- }],
- indexers: [],
- callProperties: [],
- range: [7, 48],
- loc: {
- start: { line: 1, column: 7 },
- end: { line: 1, column: 48 }
- }
- },
- range: [5, 48],
- loc: {
- start: { line: 1, column: 5 },
- end: { line: 1, column: 48 }
- }
- },
- range: [4, 48],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 48 }
- }
- },
- init: null,
- range: [4, 48],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 48 }
- }
- }],
- kind: 'var',
- range: [0, 48],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 48 }
- }
- },
- 'var a: { id(x: T): T; }': {
- type: 'VariableDeclaration',
- declarations: [{
- type: 'VariableDeclarator',
- id: {
- type: 'Identifier',
- name: 'a',
- typeAnnotation: {
- type: 'TypeAnnotation',
- typeAnnotation: {
- type: 'ObjectTypeAnnotation',
- properties: [{
- type: 'ObjectTypeProperty',
- key: {
- type: 'Identifier',
- name: 'id',
- range: [9, 11],
- loc: {
- start: { line: 1, column: 9 },
- end: { line: 1, column: 11 }
- }
- },
- value: {
- type: 'FunctionTypeAnnotation',
- params: [{
- type: 'FunctionTypeParam',
- name: {
- type: 'Identifier',
- name: 'x',
- range: [15, 16],
- loc: {
- start: { line: 1, column: 15 },
- end: { line: 1, column: 16 }
- }
- },
- typeAnnotation: {
- type: 'GenericTypeAnnotation',
- id: {
- type: 'Identifier',
- name: 'T',
- range: [18, 19],
- loc: {
- start: { line: 1, column: 18 },
- end: { line: 1, column: 19 }
- }
- },
- typeParameters: null,
- range: [18, 19],
- loc: {
- start: { line: 1, column: 18 },
- end: { line: 1, column: 19 }
- }
- },
- optional: false,
- range: [15, 19],
- loc: {
- start: { line: 1, column: 15 },
- end: { line: 1, column: 19 }
- }
- }],
- returnType: {
- type: 'GenericTypeAnnotation',
- id: {
- type: 'Identifier',
- name: 'T',
- range: [22, 23],
- loc: {
- start: { line: 1, column: 22 },
- end: { line: 1, column: 23 }
- }
- },
- typeParameters: null,
- range: [22, 23],
- loc: {
- start: { line: 1, column: 22 },
- end: { line: 1, column: 23 }
- }
- },
- typeParameters: {
- type: 'TypeParameterDeclaration',
- params: [{
- type: 'Identifier',
- name: 'T',
- range: [12, 13],
- loc: {
- start: { line: 1, column: 12 },
- end: { line: 1, column: 13 }
- }
- }],
- range: [11, 14],
- loc: {
- start: { line: 1, column: 11 },
- end: { line: 1, column: 14 }
- }
- },
- range: [9, 23],
- loc: {
- start: { line: 1, column: 9 },
- end: { line: 1, column: 23 }
- }
- },
- optional: false,
- range: [9, 23],
- loc: {
- start: { line: 1, column: 9 },
- end: { line: 1, column: 23 }
- }
- }],
- indexers: [],
- callProperties: [],
- range: [7, 26],
- loc: {
- start: { line: 1, column: 7 },
- end: { line: 1, column: 26 }
- }
- },
- range: [5, 26],
- loc: {
- start: { line: 1, column: 5 },
- end: { line: 1, column: 26 }
- }
- },
- range: [4, 26],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 26 }
- }
- },
- init: null,
- range: [4, 26],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 26 }
- }
- }],
- kind: 'var',
- range: [0, 26],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 26 }
- }
- },
- 'var a:Array = [1, 2, 3]': {
- type: 'VariableDeclaration',
- declarations: [{
- type: 'VariableDeclarator',
- id: {
- type: 'Identifier',
- name: 'a',
- typeAnnotation: {
- type: 'TypeAnnotation',
- typeAnnotation: {
- type: 'GenericTypeAnnotation',
- id: {
- type: 'Identifier',
- name: 'Array',
- range: [6, 11],
- loc: {
- start: { line: 1, column: 6 },
- end: { line: 1, column: 11 }
- }
- },
- typeParameters: {
- type: 'TypeParameterInstantiation',
- params: [{
- type: 'NumberTypeAnnotation',
- range: [12, 18],
- loc: {
- start: { line: 1, column: 12 },
- end: { line: 1, column: 18 }
- }
- }],
- range: [11, 19],
- loc: {
- start: { line: 1, column: 11 },
- end: { line: 1, column: 19 }
- }
- },
- range: [6, 19],
- loc: {
- start: { line: 1, column: 6 },
- end: { line: 1, column: 19 }
- }
- },
- range: [5, 19],
- loc: {
- start: { line: 1, column: 5 },
- end: { line: 1, column: 19 }
- }
- },
- range: [4, 19],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 19 }
- }
- },
- init: {
- type: 'ArrayExpression',
- elements: [{
- type: 'Literal',
- value: 1,
- raw: '1',
- range: [23, 24],
- loc: {
- start: { line: 1, column: 23 },
- end: { line: 1, column: 24 }
- }
- }, {
- type: 'Literal',
- value: 2,
- raw: '2',
- range: [26, 27],
- loc: {
- start: { line: 1, column: 26 },
- end: { line: 1, column: 27 }
- }
- }, {
- type: 'Literal',
- value: 3,
- raw: '3',
- range: [29, 30],
- loc: {
- start: { line: 1, column: 29 },
- end: { line: 1, column: 30 }
- }
- }],
- range: [22, 31],
- loc: {
- start: { line: 1, column: 22 },
- end: { line: 1, column: 31 }
- }
- },
- range: [4, 31],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 31 }
- }
- }],
- kind: 'var',
- range: [0, 31],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 31 }
- }
- },
- 'a = class Foo { }': {
- type: 'ExpressionStatement',
- expression: {
- type: 'AssignmentExpression',
- operator: '=',
- left: {
- type: 'Identifier',
- name: 'a',
- range: [0, 1],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 1 }
- }
- },
- right: {
- type: 'ClassExpression',
- id: {
- type: 'Identifier',
- name: 'Foo',
- range: [10, 13],
- loc: {
- start: { line: 1, column: 10 },
- end: { line: 1, column: 13 }
- }
- },
- superClass: null,
- body: {
- type: 'ClassBody',
- body: [],
- range: [17, 20],
- loc: {
- start: { line: 1, column: 17 },
- end: { line: 1, column: 20 }
- }
- },
- typeParameters: {
- type: 'TypeParameterDeclaration',
- params: [{
- type: 'Identifier',
- name: 'T',
- range: [14, 15],
- loc: {
- start: { line: 1, column: 14 },
- end: { line: 1, column: 15 }
- }
- }],
- range: [13, 16],
- loc: {
- start: { line: 1, column: 13 },
- end: { line: 1, column: 16 }
- }
- },
- range: [4, 20],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 20 }
- }
- },
- range: [0, 20],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 20 }
- }
- },
- range: [0, 20],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 20 }
- }
- },
- 'a = class Foo extends Bar { }': {
- type: 'ExpressionStatement',
- expression: {
- type: 'AssignmentExpression',
- operator: '=',
- left: {
- type: 'Identifier',
- name: 'a',
- range: [0, 1],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 1 }
- }
- },
- right: {
- type: 'ClassExpression',
- id: {
- type: 'Identifier',
- name: 'Foo',
- range: [10, 13],
- loc: {
- start: { line: 1, column: 10 },
- end: { line: 1, column: 13 }
- }
- },
- superClass: {
- type: 'Identifier',
- name: 'Bar',
- range: [25, 28],
- loc: {
- start: { line: 1, column: 25 },
- end: { line: 1, column: 28 }
- }
- },
- body: {
- type: 'ClassBody',
- body: [],
- range: [32, 35],
- loc: {
- start: { line: 1, column: 32 },
- end: { line: 1, column: 35 }
- }
- },
- typeParameters: {
- type: 'TypeParameterDeclaration',
- params: [{
- type: 'Identifier',
- name: 'T',
- range: [14, 15],
- loc: {
- start: { line: 1, column: 14 },
- end: { line: 1, column: 15 }
- }
- }],
- range: [13, 16],
- loc: {
- start: { line: 1, column: 13 },
- end: { line: 1, column: 16 }
- }
- },
- superTypeParameters: {
- type: 'TypeParameterInstantiation',
- params: [{
- type: 'GenericTypeAnnotation',
- id: {
- type: 'Identifier',
- name: 'T',
- range: [29, 30],
- loc: {
- start: { line: 1, column: 29 },
- end: { line: 1, column: 30 }
- }
- },
- typeParameters: null,
- range: [29, 30],
- loc: {
- start: { line: 1, column: 29 },
- end: { line: 1, column: 30 }
- }
- }],
- range: [28, 31],
- loc: {
- start: { line: 1, column: 28 },
- end: { line: 1, column: 31 }
- }
- },
- range: [4, 35],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 35 }
- }
- },
- range: [0, 35],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 35 }
- }
- },
- range: [0, 35],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 35 }
- }
- },
- 'class Foo {}': {
- type: 'ClassDeclaration',
- id: {
- type: 'Identifier',
- name: 'Foo',
- range: [6, 9],
- loc: {
- start: { line: 1, column: 6 },
- end: { line: 1, column: 9 }
- }
- },
- superClass: null,
- body: {
- type: 'ClassBody',
- body: [],
- range: [13, 15],
- loc: {
- start: { line: 1, column: 13 },
- end: { line: 1, column: 15 }
- }
- },
- typeParameters: {
- type: 'TypeParameterDeclaration',
- params: [{
- type: 'Identifier',
- name: 'T',
- range: [10, 11],
- loc: {
- start: { line: 1, column: 10 },
- end: { line: 1, column: 11 }
- }
- }],
- range: [9, 12],
- loc: {
- start: { line: 1, column: 9 },
- end: { line: 1, column: 12 }
- }
- },
- range: [0, 15],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 15 }
- }
- },
- 'class Foo extends Bar { }': {
- type: 'ClassDeclaration',
- id: {
- type: 'Identifier',
- name: 'Foo',
- range: [6, 9],
- loc: {
- start: { line: 1, column: 6 },
- end: { line: 1, column: 9 }
- }
- },
- superClass: {
- type: 'Identifier',
- name: 'Bar',
- range: [21, 24],
- loc: {
- start: { line: 1, column: 21 },
- end: { line: 1, column: 24 }
- }
- },
- body: {
- type: 'ClassBody',
- body: [],
- range: [28, 31],
- loc: {
- start: { line: 1, column: 28 },
- end: { line: 1, column: 31 }
- }
- },
- typeParameters: {
- type: 'TypeParameterDeclaration',
- params: [{
- type: 'Identifier',
- name: 'T',
- range: [10, 11],
- loc: {
- start: { line: 1, column: 10 },
- end: { line: 1, column: 11 }
- }
- }],
- range: [9, 12],
- loc: {
- start: { line: 1, column: 9 },
- end: { line: 1, column: 12 }
- }
- },
- superTypeParameters: {
- type: 'TypeParameterInstantiation',
- params: [{
- type: 'GenericTypeAnnotation',
- id: {
- type: 'Identifier',
- name: 'T',
- range: [25, 26],
- loc: {
- start: { line: 1, column: 25 },
- end: { line: 1, column: 26 }
- }
- },
- typeParameters: null,
- range: [25, 26],
- loc: {
- start: { line: 1, column: 25 },
- end: { line: 1, column: 26 }
- }
- }],
- range: [24, 27],
- loc: {
- start: { line: 1, column: 24 },
- end: { line: 1, column: 27 }
- }
- },
- range: [0, 31],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 31 }
- }
- },
- 'class Foo extends mixin(Bar) { }': {
- type: 'ClassDeclaration',
- id: {
- type: 'Identifier',
- name: 'Foo',
- range: [6, 9],
- loc: {
- start: { line: 1, column: 6 },
- end: { line: 1, column: 9 }
- }
- },
- superClass: {
- type: 'CallExpression',
- callee: {
- type: 'Identifier',
- name: 'mixin',
- range: [21, 26],
- loc: {
- start: { line: 1, column: 21 },
- end: { line: 1, column: 26 }
- }
- },
- 'arguments': [{
- type: 'Identifier',
- name: 'Bar',
- range: [27, 30],
- loc: {
- start: { line: 1, column: 27 },
- end: { line: 1, column: 30 }
- }
- }],
- range: [21, 31],
- loc: {
- start: { line: 1, column: 21 },
- end: { line: 1, column: 31 }
- }
- },
- body: {
- type: 'ClassBody',
- body: [],
- range: [32, 35],
- loc: {
- start: { line: 1, column: 32 },
- end: { line: 1, column: 35 }
- }
- },
- typeParameters: {
- type: 'TypeParameterDeclaration',
- params: [{
- type: 'Identifier',
- name: 'T',
- range: [10, 11],
- loc: {
- start: { line: 1, column: 10 },
- end: { line: 1, column: 11 }
- }
- }],
- range: [9, 12],
- loc: {
- start: { line: 1, column: 9 },
- end: { line: 1, column: 12 }
- }
- },
- range: [0, 35],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 35 }
- }
- },
- 'class Foo { bar():number { return 42; }}': {
- type: "ClassDeclaration",
- id: {
- type: "Identifier",
- name: "Foo",
- range: [6, 9],
- loc: {
- start: { line: 1, column: 6 },
- end: { line: 1, column: 9 }
- }
- },
- superClass: null,
- body: {
- type: "ClassBody",
- body: [{
- type: "MethodDefinition",
- key: {
- type: "Identifier",
- name: "bar",
- range: [15, 18],
- loc: {
- start: { line: 1, column: 15 },
- end: { line: 1, column: 18 }
- }
- },
- value: {
- type: "FunctionExpression",
- id: null,
- params: [],
- body: {
- type: "BlockStatement",
- body: [{
- type: "ReturnStatement",
- argument: {
- type: "Literal",
- value: 42,
- raw: "42",
- range: [40, 42],
- loc: {
- start: { line: 1, column: 40 },
- end: { line: 1, column: 42 }
- }
- },
- range: [33, 43],
- loc: {
- start: { line: 1, column: 33 },
- end: { line: 1, column: 43 }
- }
- }],
- range: [31, 45],
- loc: {
- start: { line: 1, column: 31 },
- end: { line: 1, column: 45 }
- }
- },
- generator: false,
- expression: false,
- returnType: {
- type: "TypeAnnotation",
- typeAnnotation: {
- type: "NumberTypeAnnotation",
- range: [24, 30],
- loc: {
- start: { line: 1, column: 24 },
- end: { line: 1, column: 30 }
- }
- },
- range: [23, 30],
- loc: {
- start: { line: 1, column: 23 },
- end: { line: 1, column: 30 }
- }
- },
- typeParameters: {
- type: "TypeParameterDeclaration",
- params: [{
- type: "Identifier",
- name: "U",
- range: [19, 20],
- loc: {
- start: { line: 1, column: 19 },
- end: { line: 1, column: 20 }
- }
- }],
- range: [18, 21],
- loc: {
- start: { line: 1, column: 18 },
- end: { line: 1, column: 21 }
- }
- },
- //range: [31, 45],
- //loc: {
- // start: { line: 1, column: 31 },
- // end: { line: 1, column: 45 }
- //}
- },
- kind: "method",
- "static": false,
- computed: false,
- range: [15, 45],
- loc: {
- start: { line: 1, column: 15 },
- end: { line: 1, column: 45 }
- }
- }],
- range: [13, 46],
- loc: {
- start: { line: 1, column: 13 },
- end: { line: 1, column: 46 }
- }
- },
- typeParameters: {
- type: "TypeParameterDeclaration",
- params: [{
- type: "Identifier",
- name: "T",
- range: [10, 11],
- loc: {
- start: { line: 1, column: 10 },
- end: { line: 1, column: 11 }
- }
- }],
- range: [9, 12],
- loc: {
- start: { line: 1, column: 9 },
- end: { line: 1, column: 12 }
- }
- },
- range: [0, 46],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 46 }
- }
- },
- 'class Foo { "bar"() { } }': {
- type: "ClassDeclaration",
- id: {
- type: "Identifier",
- name: "Foo",
- range: [6, 9],
- loc: {
- start: { line: 1, column: 6 },
- end: { line: 1, column: 9 }
- }
- },
- superClass: null,
- body: {
- type: "ClassBody",
- body: [{
- type: "MethodDefinition",
- key: {
- type: "Literal",
- value: "bar",
- raw: '"bar"',
- range: [12, 17],
- loc: {
- start: { line: 1, column: 12 },
- end: { line: 1, column: 17 }
- }
- },
- value: {
- type: "FunctionExpression",
- id: null,
- params: [],
- body: {
- type: "BlockStatement",
- body: [],
- range: [23, 26],
- loc: {
- start: { line: 1, column: 23 },
- end: { line: 1, column: 26 }
- }
- },
- generator: false,
- expression: false,
- typeParameters: {
- type: "TypeParameterDeclaration",
- params: [{
- type: "Identifier",
- name: "T",
- range: [18, 19],
- loc: {
- start: { line: 1, column: 18 },
- end: { line: 1, column: 19 }
- }
- }],
- range: [17, 20],
- loc: {
- start: { line: 1, column: 17 },
- end: { line: 1, column: 20 }
- }
- },
- //range: [23, 26],
- //loc: {
- // start: { line: 1, column: 23 },
- // end: { line: 1, column: 26 }
- //}
- },
- kind: "method",
- "static": false,
- computed: false,
- range: [12, 26],
- loc: {
- start: { line: 1, column: 12 },
- end: { line: 1, column: 26 }
- }
- }],
- range: [10, 28],
- loc: {
- start: { line: 1, column: 10 },
- end: { line: 1, column: 28 }
- }
- },
- range: [0, 28],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 28 }
- }
- },
- 'function foo(requiredParam, optParam?) {}': {
- type: 'FunctionDeclaration',
- id: {
- type: 'Identifier',
- name: 'foo',
- range: [9, 12],
- loc: {
- start: { line: 1, column: 9 },
- end: { line: 1, column: 12 }
- }
- },
- params: [{
- type: 'Identifier',
- name: 'requiredParam',
- range: [13, 26],
- loc: {
- start: { line: 1, column: 13 },
- end: { line: 1, column: 26 }
- }
- }, {
- type: 'Identifier',
- name: 'optParam',
- optional: true,
- range: [28, 37],
- loc: {
- start: { line: 1, column: 28 },
- end: { line: 1, column: 37 }
- }
- }],
- body: {
- type: 'BlockStatement',
- body: [],
- range: [39, 41],
- loc: {
- start: { line: 1, column: 39 },
- end: { line: 1, column: 41 }
- }
- },
- generator: false,
- expression: false,
- range: [0, 41],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 41 }
- }
- },
- 'class Foo { prop1:string; prop2:number; }': {
- type: 'ClassDeclaration',
- id: {
- type: 'Identifier',
- name: 'Foo',
- range: [6, 9],
- loc: {
- start: { line: 1, column: 6 },
- end: { line: 1, column: 9 }
- }
- },
- superClass: null,
- body: {
- type: 'ClassBody',
- body: [{
- type: 'ClassProperty',
- key: {
- type: 'Identifier',
- name: 'prop1',
- range: [12, 17],
- loc: {
- start: { line: 1, column: 12 },
- end: { line: 1, column: 17 }
- }
- },
- typeAnnotation: {
- type: 'TypeAnnotation',
- typeAnnotation: {
- type: 'StringTypeAnnotation',
- range: [18, 24],
- loc: {
- start: { line: 1, column: 18 },
- end: { line: 1, column: 24 }
- }
- },
- range: [17, 24],
- loc: {
- start: { line: 1, column: 17 },
- end: { line: 1, column: 24 }
- }
- },
- computed: false,
- 'static': false,
- range: [12, 25],
- loc: {
- start: { line: 1, column: 12 },
- end: { line: 1, column: 25 }
- }
- }, {
- type: 'ClassProperty',
- key: {
- type: 'Identifier',
- name: 'prop2',
- range: [26, 31],
- loc: {
- start: { line: 1, column: 26 },
- end: { line: 1, column: 31 }
- }
- },
- typeAnnotation: {
- type: 'TypeAnnotation',
- typeAnnotation: {
- type: 'NumberTypeAnnotation',
- range: [32, 38],
- loc: {
- start: { line: 1, column: 32 },
- end: { line: 1, column: 38 }
- }
- },
- range: [31, 38],
- loc: {
- start: { line: 1, column: 31 },
- end: { line: 1, column: 38 }
- }
- },
- computed: false,
- 'static': false,
- range: [26, 39],
- loc: {
- start: { line: 1, column: 26 },
- end: { line: 1, column: 39 }
- }
- }],
- range: [10, 41],
- loc: {
- start: { line: 1, column: 10 },
- end: { line: 1, column: 41 }
- }
- },
- range: [0, 41],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 41 }
- }
- },
- 'class Foo { static prop1:string; prop2:number; }': {
- type: 'ClassDeclaration',
- id: {
- type: 'Identifier',
- name: 'Foo',
- range: [6, 9],
- loc: {
- start: { line: 1, column: 6 },
- end: { line: 1, column: 9 }
- }
- },
- superClass: null,
- body: {
- type: 'ClassBody',
- body: [{
- type: 'ClassProperty',
- key: {
- type: 'Identifier',
- name: 'prop1',
- range: [19, 24],
- loc: {
- start: { line: 1, column: 19 },
- end: { line: 1, column: 24 }
- }
- },
- typeAnnotation: {
- type: 'TypeAnnotation',
- typeAnnotation: {
- type: 'StringTypeAnnotation',
- range: [25, 31],
- loc: {
- start: { line: 1, column: 25 },
- end: { line: 1, column: 31 }
- }
- },
- range: [24, 31],
- loc: {
- start: { line: 1, column: 24 },
- end: { line: 1, column: 31 }
- }
- },
- computed: false,
- 'static': true,
- range: [12, 32],
- loc: {
- start: { line: 1, column: 12 },
- end: { line: 1, column: 32 }
- }
- }, {
- type: 'ClassProperty',
- key: {
- type: 'Identifier',
- name: 'prop2',
- range: [33, 38],
- loc: {
- start: { line: 1, column: 33 },
- end: { line: 1, column: 38 }
- }
- },
- typeAnnotation: {
- type: 'TypeAnnotation',
- typeAnnotation: {
- type: 'NumberTypeAnnotation',
- range: [39, 45],
- loc: {
- start: { line: 1, column: 39 },
- end: { line: 1, column: 45 }
- }
- },
- range: [38, 45],
- loc: {
- start: { line: 1, column: 38 },
- end: { line: 1, column: 45 }
- }
- },
- computed: false,
- 'static': false,
- range: [33, 46],
- loc: {
- start: { line: 1, column: 33 },
- end: { line: 1, column: 46 }
- }
- }],
- range: [10, 48],
- loc: {
- start: { line: 1, column: 10 },
- end: { line: 1, column: 48 }
- }
- },
- range: [0, 48],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 48 }
- }
- },
- 'var x : number | string = 4;': {
- type: 'VariableDeclaration',
- declarations: [{
- type: 'VariableDeclarator',
- id: {
- type: 'Identifier',
- name: 'x',
- typeAnnotation: {
- type: 'TypeAnnotation',
- typeAnnotation: {
- type: 'UnionTypeAnnotation',
- types: [{
- type: 'NumberTypeAnnotation',
- range: [8, 14],
- loc: {
- start: { line: 1, column: 8 },
- end: { line: 1, column: 14 }
- }
- }, {
- type: 'StringTypeAnnotation',
- range: [17, 23],
- loc: {
- start: { line: 1, column: 17 },
- end: { line: 1, column: 23 }
- }
- }],
- range: [8, 23],
- loc: {
- start: { line: 1, column: 8 },
- end: { line: 1, column: 23 }
- }
- },
- range: [6, 23],
- loc: {
- start: { line: 1, column: 6 },
- end: { line: 1, column: 23 }
- }
- },
- range: [4, 23],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 23 }
- }
- },
- init: {
- type: 'Literal',
- value: 4,
- raw: '4',
- range: [26, 27],
- loc: {
- start: { line: 1, column: 26 },
- end: { line: 1, column: 27 }
- }
- },
- range: [4, 27],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 27 }
- }
- }],
- kind: 'var',
- range: [0, 28],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 28 }
- }
- },
- "class Array { concat(items:number | string) {}; }": {
- type: "ClassDeclaration",
- id: {
- type: "Identifier",
- name: "Array",
- range: [6, 11],
- loc: {
- start: { line: 1, column: 6 },
- end: { line: 1, column: 11 }
- }
- },
- superClass: null,
- body: {
- type: "ClassBody",
- body: [{
- type: "MethodDefinition",
- key: {
- type: "Identifier",
- name: "concat",
- range: [14, 20],
- loc: {
- start: { line: 1, column: 14 },
- end: { line: 1, column: 20 }
- }
- },
- value: {
- type: "FunctionExpression",
- id: null,
- params: [{
- type: "Identifier",
- name: "items",
- typeAnnotation: {
- type: "TypeAnnotation",
- typeAnnotation: {
- type: "UnionTypeAnnotation",
- types: [{
- type: "NumberTypeAnnotation",
- range: [27, 33],
- loc: {
- start: { line: 1, column: 27 },
- end: { line: 1, column: 33 }
- }
- }, {
- type: "StringTypeAnnotation",
- range: [36, 42],
- loc: {
- start: { line: 1, column: 36 },
- end: { line: 1, column: 42 }
- }
- }],
- range: [27, 42],
- loc: {
- start: { line: 1, column: 27 },
- end: { line: 1, column: 42 }
- }
- },
- range: [26, 42],
- loc: {
- start: { line: 1, column: 26 },
- end: { line: 1, column: 42 }
- }
- },
- range: [21, 42],
- loc: {
- start: { line: 1, column: 21 },
- end: { line: 1, column: 42 }
- }
- }],
- body: {
- type: "BlockStatement",
- body: [],
- range: [44, 46],
- loc: {
- start: { line: 1, column: 44 },
- end: { line: 1, column: 46 }
- }
- },
- generator: false,
- expression: false,
- //range: [44, 46],
- //loc: {
- // start: { line: 1, column: 44 },
- // end: { line: 1, column: 46 }
- //}
- },
- kind: "method",
- "static": false,
- computed: false,
- range: [14, 46],
- loc: {
- start: { line: 1, column: 14 },
- end: { line: 1, column: 46 }
- }
- }],
- range: [12, 49],
- loc: {
- start: { line: 1, column: 12 },
- end: { line: 1, column: 49 }
- }
- },
- range: [0, 49],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 49 }
- }
- },
- 'var x : () => number | () => string = fn;': {
- type: 'VariableDeclaration',
- declarations: [{
- type: 'VariableDeclarator',
- id: {
- type: 'Identifier',
- name: 'x',
- typeAnnotation: {
- type: 'TypeAnnotation',
- typeAnnotation: {
- type: 'FunctionTypeAnnotation',
- params: [],
- returnType: {
- type: 'UnionTypeAnnotation',
- types: [{
- type: 'NumberTypeAnnotation',
- range: [14, 20],
- loc: {
- start: { line: 1, column: 14 },
- end: { line: 1, column: 20 }
- }
- }, {
- type: 'FunctionTypeAnnotation',
- params: [],
- returnType: {
- type: 'StringTypeAnnotation',
- range: [29, 35],
- loc: {
- start: { line: 1, column: 29 },
- end: { line: 1, column: 35 }
- }
- },
- typeParameters: null,
- range: [23, 35],
- loc: {
- start: { line: 1, column: 23 },
- end: { line: 1, column: 35 }
- }
- }],
- range: [14, 35],
- loc: {
- start: { line: 1, column: 14 },
- end: { line: 1, column: 35 }
- }
- },
- typeParameters: null,
- range: [8, 35],
- loc: {
- start: { line: 1, column: 8 },
- end: { line: 1, column: 35 }
- }
- },
- range: [6, 35],
- loc: {
- start: { line: 1, column: 6 },
- end: { line: 1, column: 35 }
- }
- },
- range: [4, 35],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 35 }
- }
- },
- init: {
- type: 'Identifier',
- name: 'fn',
- range: [38, 40],
- loc: {
- start: { line: 1, column: 38 },
- end: { line: 1, column: 40 }
- }
- },
- range: [4, 40],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 40 }
- }
- }],
- kind: 'var',
- range: [0, 41],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 41 }
- }
- },
- 'var x: typeof Y = Y;': {
- type: 'VariableDeclaration',
- declarations: [{
- type: 'VariableDeclarator',
- id: {
- type: 'Identifier',
- name: 'x',
- typeAnnotation: {
- type: 'TypeAnnotation',
- typeAnnotation: {
- type: 'TypeofTypeAnnotation',
- argument: {
- type: 'GenericTypeAnnotation',
- id: {
- type: 'Identifier',
- name: 'Y',
- range: [14, 15],
- loc: {
- start: { line: 1, column: 14 },
- end: { line: 1, column: 15 }
- }
- },
- typeParameters: null,
- range: [14, 15],
- loc: {
- start: { line: 1, column: 14 },
- end: { line: 1, column: 15 }
- }
- },
- range: [7, 15],
- loc: {
- start: { line: 1, column: 7 },
- end: { line: 1, column: 15 }
- }
- },
- range: [5, 15],
- loc: {
- start: { line: 1, column: 5 },
- end: { line: 1, column: 15 }
- }
- },
- range: [4, 15],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 15 }
- }
- },
- init: {
- type: 'Identifier',
- name: 'Y',
- range: [18, 19],
- loc: {
- start: { line: 1, column: 18 },
- end: { line: 1, column: 19 }
- }
- },
- range: [4, 19],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 19 }
- }
- }],
- kind: 'var',
- range: [0, 20],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 20 }
- }
- },
- 'var x: typeof Y | number = Y;': {
- type: 'VariableDeclaration',
- declarations: [{
- type: 'VariableDeclarator',
- id: {
- type: 'Identifier',
- name: 'x',
- typeAnnotation: {
- type: 'TypeAnnotation',
- typeAnnotation: {
- type: 'UnionTypeAnnotation',
- types: [{
- type: 'TypeofTypeAnnotation',
- argument: {
- type: 'GenericTypeAnnotation',
- id: {
- type: 'Identifier',
- name: 'Y',
- range: [14, 15],
- loc: {
- start: { line: 1, column: 14 },
- end: { line: 1, column: 15 }
- }
- },
- typeParameters: null,
- range: [14, 15],
- loc: {
- start: { line: 1, column: 14 },
- end: { line: 1, column: 15 }
- }
- },
- range: [7, 15],
- loc: {
- start: { line: 1, column: 7 },
- end: { line: 1, column: 15 }
- }
- }, {
- type: 'NumberTypeAnnotation',
- range: [18, 24],
- loc: {
- start: { line: 1, column: 18 },
- end: { line: 1, column: 24 }
- }
- }],
- range: [7, 24],
- loc: {
- start: { line: 1, column: 7 },
- end: { line: 1, column: 24 }
- }
- },
- range: [5, 24],
- loc: {
- start: { line: 1, column: 5 },
- end: { line: 1, column: 24 }
- }
- },
- range: [4, 24],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 24 }
- }
- },
- init: {
- type: 'Identifier',
- name: 'Y',
- range: [27, 28],
- loc: {
- start: { line: 1, column: 27 },
- end: { line: 1, column: 28 }
- }
- },
- range: [4, 28],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 28 }
- }
- }],
- kind: 'var',
- range: [0, 29],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 29 }
- }
- },
- 'var {x}: {x: string; } = { x: "hello" };': {
- type: 'VariableDeclaration',
- declarations: [{
- type: 'VariableDeclarator',
- id: {
- type: 'ObjectPattern',
- properties: [{
- type: 'Property',
- key: {
- type: 'Identifier',
- name: 'x',
- range: [5, 6],
- loc: {
- start: { line: 1, column: 5 },
- end: { line: 1, column: 6 }
- }
- },
- value: {
- type: 'Identifier',
- name: 'x',
- range: [5, 6],
- loc: {
- start: { line: 1, column: 5 },
- end: { line: 1, column: 6 }
- }
- },
- kind: 'init',
- method: false,
- shorthand: true,
- computed: false,
- range: [5, 6],
- loc: {
- start: { line: 1, column: 5 },
- end: { line: 1, column: 6 }
- }
- }],
- range: [4, 22],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 22 }
- },
- typeAnnotation: {
- type: 'TypeAnnotation',
- typeAnnotation: {
- type: 'ObjectTypeAnnotation',
- properties: [{
- type: 'ObjectTypeProperty',
- key: {
- type: 'Identifier',
- name: 'x',
- range: [10, 11],
- loc: {
- start: { line: 1, column: 10 },
- end: { line: 1, column: 11 }
- }
- },
- value: {
- type: 'StringTypeAnnotation',
- range: [13, 19],
- loc: {
- start: { line: 1, column: 13 },
- end: { line: 1, column: 19 }
- }
- },
- optional: false,
- range: [10, 19],
- loc: {
- start: { line: 1, column: 10 },
- end: { line: 1, column: 19 }
- }
- }],
- indexers: [],
- callProperties: [],
- range: [9, 22],
- loc: {
- start: { line: 1, column: 9 },
- end: { line: 1, column: 22 }
- }
- },
- range: [7, 22],
- loc: {
- start: { line: 1, column: 7 },
- end: { line: 1, column: 22 }
- }
- }
- },
- init: {
- type: 'ObjectExpression',
- properties: [{
- type: 'Property',
- key: {
- type: 'Identifier',
- name: 'x',
- range: [27, 28],
- loc: {
- start: { line: 1, column: 27 },
- end: { line: 1, column: 28 }
- }
- },
- value: {
- type: 'Literal',
- value: 'hello',
- raw: '"hello"',
- range: [30, 37],
- loc: {
- start: { line: 1, column: 30 },
- end: { line: 1, column: 37 }
- }
- },
- kind: 'init',
- method: false,
- shorthand: false,
- computed: false,
- range: [27, 37],
- loc: {
- start: { line: 1, column: 27 },
- end: { line: 1, column: 37 }
- }
- }],
- range: [25, 39],
- loc: {
- start: { line: 1, column: 25 },
- end: { line: 1, column: 39 }
- }
- },
- range: [4, 39],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 39 }
- }
- }],
- kind: 'var',
- range: [0, 40],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 40 }
- }
- },
- 'var {x}: {x: string } = { x: "hello" };': {
- type: 'VariableDeclaration',
- declarations: [{
- type: 'VariableDeclarator',
- id: {
- type: 'ObjectPattern',
- properties: [{
- type: 'Property',
- key: {
- type: 'Identifier',
- name: 'x',
- range: [5, 6],
- loc: {
- start: { line: 1, column: 5 },
- end: { line: 1, column: 6 }
- }
- },
- value: {
- type: 'Identifier',
- name: 'x',
- range: [5, 6],
- loc: {
- start: { line: 1, column: 5 },
- end: { line: 1, column: 6 }
- }
- },
- kind: 'init',
- method: false,
- shorthand: true,
- computed: false,
- range: [5, 6],
- loc: {
- start: { line: 1, column: 5 },
- end: { line: 1, column: 6 }
- }
- }],
- range: [4, 21],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 21 }
- },
- typeAnnotation: {
- type: 'TypeAnnotation',
- typeAnnotation: {
- type: 'ObjectTypeAnnotation',
- properties: [{
- type: 'ObjectTypeProperty',
- key: {
- type: 'Identifier',
- name: 'x',
- range: [10, 11],
- loc: {
- start: { line: 1, column: 10 },
- end: { line: 1, column: 11 }
- }
- },
- value: {
- type: 'StringTypeAnnotation',
- range: [13, 19],
- loc: {
- start: { line: 1, column: 13 },
- end: { line: 1, column: 19 }
- }
- },
- optional: false,
- range: [10, 19],
- loc: {
- start: { line: 1, column: 10 },
- end: { line: 1, column: 19 }
- }
- }],
- indexers: [],
- callProperties: [],
- range: [9, 21],
- loc: {
- start: { line: 1, column: 9 },
- end: { line: 1, column: 21 }
- }
- },
- range: [7, 21],
- loc: {
- start: { line: 1, column: 7 },
- end: { line: 1, column: 21 }
- }
- }
- },
- init: {
- type: 'ObjectExpression',
- properties: [{
- type: 'Property',
- key: {
- type: 'Identifier',
- name: 'x',
- range: [26, 27],
- loc: {
- start: { line: 1, column: 26 },
- end: { line: 1, column: 27 }
- }
- },
- value: {
- type: 'Literal',
- value: 'hello',
- raw: '"hello"',
- range: [29, 36],
- loc: {
- start: { line: 1, column: 29 },
- end: { line: 1, column: 36 }
- }
- },
- kind: 'init',
- method: false,
- shorthand: false,
- computed: false,
- range: [26, 36],
- loc: {
- start: { line: 1, column: 26 },
- end: { line: 1, column: 36 }
- }
- }],
- range: [24, 38],
- loc: {
- start: { line: 1, column: 24 },
- end: { line: 1, column: 38 }
- }
- },
- range: [4, 38],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 38 }
- }
- }],
- kind: 'var',
- range: [0, 39],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 39 }
- }
- },
- 'var [x]: Array = [ "hello" ];': {
- type: 'VariableDeclaration',
- declarations: [{
- type: 'VariableDeclarator',
- id: {
- type: 'ArrayPattern',
- elements: [{
- type: 'Identifier',
- name: 'x',
- range: [5, 6],
- loc: {
- start: { line: 1, column: 5 },
- end: { line: 1, column: 6 }
- }
- }],
- range: [4, 22],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 22 }
- },
- typeAnnotation: {
- type: 'TypeAnnotation',
- typeAnnotation: {
- type: 'GenericTypeAnnotation',
- id: {
- type: 'Identifier',
- name: 'Array',
- range: [9, 14],
- loc: {
- start: { line: 1, column: 9 },
- end: { line: 1, column: 14 }
- }
- },
- typeParameters: {
- type: 'TypeParameterInstantiation',
- params: [{
- type: 'StringTypeAnnotation',
- range: [15, 21],
- loc: {
- start: { line: 1, column: 15 },
- end: { line: 1, column: 21 }
- }
- }],
- range: [14, 22],
- loc: {
- start: { line: 1, column: 14 },
- end: { line: 1, column: 22 }
- }
- },
- range: [9, 22],
- loc: {
- start: { line: 1, column: 9 },
- end: { line: 1, column: 22 }
- }
- },
- range: [7, 22],
- loc: {
- start: { line: 1, column: 7 },
- end: { line: 1, column: 22 }
- }
- }
- },
- init: {
- type: 'ArrayExpression',
- elements: [{
- type: 'Literal',
- value: 'hello',
- raw: '"hello"',
- range: [27, 34],
- loc: {
- start: { line: 1, column: 27 },
- end: { line: 1, column: 34 }
- }
- }],
- range: [25, 36],
- loc: {
- start: { line: 1, column: 25 },
- end: { line: 1, column: 36 }
- }
- },
- range: [4, 36],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 36 }
- }
- }],
- kind: 'var',
- range: [0, 37],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 37 }
- }
- },
- 'function foo({x}: { x: string; }) {}': {
- type: 'FunctionDeclaration',
- id: {
- type: 'Identifier',
- name: 'foo',
- range: [9, 12],
- loc: {
- start: { line: 1, column: 9 },
- end: { line: 1, column: 12 }
- }
- },
- params: [{
- type: 'ObjectPattern',
- properties: [{
- type: 'Property',
- key: {
- type: 'Identifier',
- name: 'x',
- range: [14, 15],
- loc: {
- start: { line: 1, column: 14 },
- end: { line: 1, column: 15 }
- }
- },
- value: {
- type: 'Identifier',
- name: 'x',
- range: [14, 15],
- loc: {
- start: { line: 1, column: 14 },
- end: { line: 1, column: 15 }
- }
- },
- kind: 'init',
- method: false,
- shorthand: true,
- computed: false,
- range: [14, 15],
- loc: {
- start: { line: 1, column: 14 },
- end: { line: 1, column: 15 }
- }
- }],
- range: [13, 32],
- loc: {
- start: { line: 1, column: 13 },
- end: { line: 1, column: 32 }
- },
- typeAnnotation: {
- type: 'TypeAnnotation',
- typeAnnotation: {
- type: 'ObjectTypeAnnotation',
- properties: [{
- type: 'ObjectTypeProperty',
- key: {
- type: 'Identifier',
- name: 'x',
- range: [20, 21],
- loc: {
- start: { line: 1, column: 20 },
- end: { line: 1, column: 21 }
- }
- },
- value: {
- type: 'StringTypeAnnotation',
- range: [23, 29],
- loc: {
- start: { line: 1, column: 23 },
- end: { line: 1, column: 29 }
- }
- },
- optional: false,
- range: [20, 29],
- loc: {
- start: { line: 1, column: 20 },
- end: { line: 1, column: 29 }
- }
- }],
- indexers: [],
- callProperties: [],
- range: [18, 32],
- loc: {
- start: { line: 1, column: 18 },
- end: { line: 1, column: 32 }
- }
- },
- range: [16, 32],
- loc: {
- start: { line: 1, column: 16 },
- end: { line: 1, column: 32 }
- }
- }
- }],
- body: {
- type: 'BlockStatement',
- body: [],
- range: [34, 36],
- loc: {
- start: { line: 1, column: 34 },
- end: { line: 1, column: 36 }
- }
- },
- generator: false,
- expression: false,
- range: [0, 36],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 36 }
- }
- },
- 'function foo([x]: Array) {}': {
- type: 'FunctionDeclaration',
- id: {
- type: 'Identifier',
- name: 'foo',
- range: [9, 12],
- loc: {
- start: { line: 1, column: 9 },
- end: { line: 1, column: 12 }
- }
- },
- params: [{
- type: 'ArrayPattern',
- elements: [{
- type: 'Identifier',
- name: 'x',
- range: [14, 15],
- loc: {
- start: { line: 1, column: 14 },
- end: { line: 1, column: 15 }
- }
- }],
- range: [13, 31],
- loc: {
- start: { line: 1, column: 13 },
- end: { line: 1, column: 31 }
- },
- typeAnnotation: {
- type: 'TypeAnnotation',
- typeAnnotation: {
- type: 'GenericTypeAnnotation',
- id: {
- type: 'Identifier',
- name: 'Array',
- range: [18, 23],
- loc: {
- start: { line: 1, column: 18 },
- end: { line: 1, column: 23 }
- }
- },
- typeParameters: {
- type: 'TypeParameterInstantiation',
- params: [{
- type: 'StringTypeAnnotation',
- range: [24, 30],
- loc: {
- start: { line: 1, column: 24 },
- end: { line: 1, column: 30 }
- }
- }],
- range: [23, 31],
- loc: {
- start: { line: 1, column: 23 },
- end: { line: 1, column: 31 }
- }
- },
- range: [18, 31],
- loc: {
- start: { line: 1, column: 18 },
- end: { line: 1, column: 31 }
- }
- },
- range: [16, 31],
- loc: {
- start: { line: 1, column: 16 },
- end: { line: 1, column: 31 }
- }
- }
- }],
- body: {
- type: 'BlockStatement',
- body: [],
- range: [33, 35],
- loc: {
- start: { line: 1, column: 33 },
- end: { line: 1, column: 35 }
- }
- },
- generator: false,
- expression: false,
- range: [0, 35],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 35 }
- }
- },
- "function foo(...rest: Array) {}": {
- type: "FunctionDeclaration",
- start: 0,
- end: 39,
- id: {
- type: "Identifier",
- start: 9,
- end: 12,
- name: "foo"
- },
- generator: false,
- expression: false,
- params: [{
- type: "RestElement",
- start: 13,
- end: 35,
- argument: {
- type: "Identifier",
- start: 16,
- end: 20,
- name: "rest"
- },
- typeAnnotation: {
- type: "TypeAnnotation",
- start: 20,
- end: 35,
- typeAnnotation: {
- type: "GenericTypeAnnotation",
- start: 22,
- end: 35,
- typeParameters: {
- type: "TypeParameterInstantiation",
- start: 27,
- end: 35,
- params: [
- {
- type: "NumberTypeAnnotation",
- start: 28,
- end: 34
- }
- ]
- },
- id: {
- type: "Identifier",
- start: 22,
- end: 27,
- name: "Array"
- }
- }
- }
- }],
- body: {
- type: "BlockStatement",
- start: 37,
- end: 39,
- body: []
- }
- },
- "(function (...rest: Array) {})": {
- type: "ExpressionStatement",
- start: 0,
- end: 38,
- expression: {
- type: "FunctionExpression",
- start: 1,
- end: 37,
- id: null,
- generator: false,
- expression: false,
- params: [{
- type: "RestElement",
- start: 11,
- end: 33,
- argument: {
- type: "Identifier",
- start: 14,
- end: 18,
- name: "rest"
- },
- typeAnnotation: {
- type: "TypeAnnotation",
- start: 18,
- end: 33,
- typeAnnotation: {
- type: "GenericTypeAnnotation",
- start: 20,
- end: 33,
- typeParameters: {
- type: "TypeParameterInstantiation",
- start: 25,
- end: 33,
- params: [
- {
- type: "NumberTypeAnnotation",
- start: 26,
- end: 32
- }
- ]
- },
- id: {
- type: "Identifier",
- start: 20,
- end: 25,
- name: "Array"
- }
- }
- }
- }],
- body: {
- type: "BlockStatement",
- start: 35,
- end: 37,
- body: []
- }
- }
- },
- "((...rest: Array) => rest)": {
- type: "ExpressionStatement",
- start: 0,
- end: 34,
- expression: {
- type: "ArrowFunctionExpression",
- start: 1,
- end: 33,
- id: null,
- generator: false,
- expression: true,
- params: [{
- type: "RestElement",
- start: 2,
- end: 9,
- argument: {
- type: "Identifier",
- start: 5,
- end: 9,
- name: "rest"
- },
- typeAnnotation: {
- type: "TypeAnnotation",
- start: 9,
- end: 24,
- typeAnnotation: {
- type: "GenericTypeAnnotation",
- start: 11,
- end: 24,
- typeParameters: {
- type: "TypeParameterInstantiation",
- start: 16,
- end: 24,
- params: [
- {
- type: "NumberTypeAnnotation",
- start: 17,
- end: 23
- }
- ]
- },
- id: {
- type: "Identifier",
- start: 11,
- end: 16,
- name: "Array"
- }
- }
- }
- }],
- body: {
- type: "Identifier",
- start: 29,
- end: 33,
- name: "rest"
- }
- }
- },
- 'var a: Map >': {
- type: 'VariableDeclaration',
- declarations: [{
- type: 'VariableDeclarator',
- id: {
- type: 'Identifier',
- name: 'a',
- typeAnnotation: {
- type: 'TypeAnnotation',
- typeAnnotation: {
- type: 'GenericTypeAnnotation',
- id: {
- type: 'Identifier',
- name: 'Map',
- range: [7, 10],
- loc: {
- start: { line: 1, column: 7 },
- end: { line: 1, column: 10 }
- }
- },
- typeParameters: {
- type: 'TypeParameterInstantiation',
- params: [{
- type: 'StringTypeAnnotation',
- range: [11, 17],
- loc: {
- start: { line: 1, column: 11 },
- end: { line: 1, column: 17 }
- }
- }, {
- type: 'GenericTypeAnnotation',
- id: {
- type: 'Identifier',
- name: 'Array',
- range: [19, 24],
- loc: {
- start: { line: 1, column: 19 },
- end: { line: 1, column: 24 }
- }
- },
- typeParameters: {
- type: 'TypeParameterInstantiation',
- params: [{
- type: 'StringTypeAnnotation',
- range: [25, 31],
- loc: {
- start: { line: 1, column: 25 },
- end: { line: 1, column: 31 }
- }
- }],
- range: [24, 32],
- loc: {
- start: { line: 1, column: 24 },
- end: { line: 1, column: 32 }
- }
- },
- range: [19, 32],
- loc: {
- start: { line: 1, column: 19 },
- end: { line: 1, column: 32 }
- }
- }],
- range: [10, 34],
- loc: {
- start: { line: 1, column: 10 },
- end: { line: 1, column: 34 }
- }
- },
- range: [7, 34],
- loc: {
- start: { line: 1, column: 7 },
- end: { line: 1, column: 34 }
- }
- },
- range: [5, 34],
- loc: {
- start: { line: 1, column: 5 },
- end: { line: 1, column: 34 }
- }
- },
- range: [4, 34],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 34 }
- }
- },
- init: null,
- range: [4, 34],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 34 }
- }
- }],
- kind: 'var',
- range: [0, 34],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 34 }
- }
- },
- 'var a: Map>': {
- type: 'VariableDeclaration',
- declarations: [{
- type: 'VariableDeclarator',
- id: {
- type: 'Identifier',
- name: 'a',
- typeAnnotation: {
- type: 'TypeAnnotation',
- typeAnnotation: {
- type: 'GenericTypeAnnotation',
- id: {
- type: 'Identifier',
- name: 'Map',
- range: [7, 10],
- loc: {
- start: { line: 1, column: 7 },
- end: { line: 1, column: 10 }
- }
- },
- typeParameters: {
- type: 'TypeParameterInstantiation',
- params: [{
- type: 'StringTypeAnnotation',
- range: [11, 17],
- loc: {
- start: { line: 1, column: 11 },
- end: { line: 1, column: 17 }
- }
- }, {
- type: 'GenericTypeAnnotation',
- id: {
- type: 'Identifier',
- name: 'Array',
- range: [19, 24],
- loc: {
- start: { line: 1, column: 19 },
- end: { line: 1, column: 24 }
- }
- },
- typeParameters: {
- type: 'TypeParameterInstantiation',
- params: [{
- type: 'StringTypeAnnotation',
- range: [25, 31],
- loc: {
- start: { line: 1, column: 25 },
- end: { line: 1, column: 31 }
- }
- }],
- range: [24, 32],
- loc: {
- start: { line: 1, column: 24 },
- end: { line: 1, column: 32 }
- }
- },
- range: [19, 32],
- loc: {
- start: { line: 1, column: 19 },
- end: { line: 1, column: 32 }
- }
- }],
- range: [10, 33],
- loc: {
- start: { line: 1, column: 10 },
- end: { line: 1, column: 33 }
- }
- },
- range: [7, 33],
- loc: {
- start: { line: 1, column: 7 },
- end: { line: 1, column: 33 }
- }
- },
- range: [5, 33],
- loc: {
- start: { line: 1, column: 5 },
- end: { line: 1, column: 33 }
- }
- },
- range: [4, 33],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 33 }
- }
- },
- init: null,
- range: [4, 33],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 33 }
- }
- }],
- kind: 'var',
- range: [0, 33],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 33 }
- }
- },
- 'var a: number[]': {
- type: 'VariableDeclaration',
- declarations: [{
- type: 'VariableDeclarator',
- id: {
- type: 'Identifier',
- name: 'a',
- typeAnnotation: {
- type: 'TypeAnnotation',
- typeAnnotation: {
- type: 'ArrayTypeAnnotation',
- elementType: {
- type: 'NumberTypeAnnotation',
- range: [7, 13],
- loc: {
- start: { line: 1, column: 7 },
- end: { line: 1, column: 13 }
- }
- },
- range: [7, 15],
- loc: {
- start: { line: 1, column: 7 },
- end: { line: 1, column: 15 }
- }
- },
- range: [5, 15],
- loc: {
- start: { line: 1, column: 5 },
- end: { line: 1, column: 15 }
- }
- },
- range: [4, 15],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 15 }
- }
- },
- init: null,
- range: [4, 15],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 15 }
- }
- }],
- kind: 'var',
- range: [0, 15],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 15 }
- }
- },
- 'var a: ?string[]': {
- type: 'VariableDeclaration',
- declarations: [{
- type: 'VariableDeclarator',
- id: {
- type: 'Identifier',
- name: 'a',
- typeAnnotation: {
- type: 'TypeAnnotation',
- typeAnnotation: {
- type: 'NullableTypeAnnotation',
- typeAnnotation: {
- type: 'ArrayTypeAnnotation',
- elementType: {
- type: 'StringTypeAnnotation',
- range: [8, 14],
- loc: {
- start: { line: 1, column: 8 },
- end: { line: 1, column: 14 }
- }
- },
- range: [8, 16],
- loc: {
- start: { line: 1, column: 8 },
- end: { line: 1, column: 16 }
- }
- },
- range: [7, 16],
- loc: {
- start: { line: 1, column: 7 },
- end: { line: 1, column: 16 }
- }
- },
- range: [5, 16],
- loc: {
- start: { line: 1, column: 5 },
- end: { line: 1, column: 16 }
- }
- },
- range: [4, 16],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 16 }
- }
- },
- init: null,
- range: [4, 16],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 16 }
- }
- }],
- kind: 'var',
- range: [0, 16],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 16 }
- }
- },
- 'var a: Promise[]': {
- type: 'VariableDeclaration',
- declarations: [{
- type: 'VariableDeclarator',
- id: {
- type: 'Identifier',
- name: 'a',
- typeAnnotation: {
- type: 'TypeAnnotation',
- typeAnnotation: {
- type: 'ArrayTypeAnnotation',
- elementType: {
- type: 'GenericTypeAnnotation',
- id: {
- type: 'Identifier',
- name: 'Promise',
- range: [7, 14],
- loc: {
- start: { line: 1, column: 7 },
- end: { line: 1, column: 14 }
- }
- },
- typeParameters: {
- type: 'TypeParameterInstantiation',
- params: [{
- type: 'BooleanTypeAnnotation',
- range: [15, 19],
- loc: {
- start: { line: 1, column: 15 },
- end: { line: 1, column: 19 }
- }
- }],
- range: [14, 20],
- loc: {
- start: { line: 1, column: 14 },
- end: { line: 1, column: 20 }
- }
- },
- range: [7, 20],
- loc: {
- start: { line: 1, column: 7 },
- end: { line: 1, column: 20 }
- }
- },
- range: [7, 22],
- loc: {
- start: { line: 1, column: 7 },
- end: { line: 1, column: 22 }
- }
- },
- range: [5, 22],
- loc: {
- start: { line: 1, column: 5 },
- end: { line: 1, column: 22 }
- }
- },
- range: [4, 22],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 22 }
- }
- },
- init: null,
- range: [4, 22],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 22 }
- }
- }],
- kind: 'var',
- range: [0, 22],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 22 }
- }
- },
- 'var a:(...rest:Array) => number': {
- type: 'VariableDeclaration',
- declarations: [{
- type: 'VariableDeclarator',
- id: {
- type: 'Identifier',
- name: 'a',
- typeAnnotation: {
- type: 'TypeAnnotation',
- typeAnnotation: {
- type: 'FunctionTypeAnnotation',
- params: [],
- returnType: {
- type: 'NumberTypeAnnotation',
- range: [33, 39],
- loc: {
- start: { line: 1, column: 33 },
- end: { line: 1, column: 39 }
- }
- },
- rest: {
- type: 'FunctionTypeParam',
- name: {
- type: 'Identifier',
- name: 'rest',
- range: [10, 14],
- loc: {
- start: { line: 1, column: 10 },
- end: { line: 1, column: 14 }
- }
- },
- typeAnnotation: {
- type: 'GenericTypeAnnotation',
- id: {
- type: 'Identifier',
- name: 'Array',
- range: [15, 20],
- loc: {
- start: { line: 1, column: 15 },
- end: { line: 1, column: 20 }
- }
- },
- typeParameters: {
- type: 'TypeParameterInstantiation',
- params: [{
- type: 'NumberTypeAnnotation',
- range: [21, 27],
- loc: {
- start: { line: 1, column: 21 },
- end: { line: 1, column: 27 }
- }
- }],
- range: [20, 28],
- loc: {
- start: { line: 1, column: 20 },
- end: { line: 1, column: 28 }
- }
- },
- range: [15, 28],
- loc: {
- start: { line: 1, column: 15 },
- end: { line: 1, column: 28 }
- }
- },
- optional: false,
- range: [10, 28],
- loc: {
- start: { line: 1, column: 10 },
- end: { line: 1, column: 28 }
- }
- },
- typeParameters: null,
- range: [6, 39],
- loc: {
- start: { line: 1, column: 6 },
- end: { line: 1, column: 39 }
- }
- },
- range: [5, 39],
- loc: {
- start: { line: 1, column: 5 },
- end: { line: 1, column: 39 }
- }
- },
- range: [4, 39],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 39 }
- }
- },
- init: null,
- range: [4, 39],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 39 }
- }
- }],
- kind: 'var',
- range: [0, 39],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 39 }
- }
- },
- 'var identity: (x: T) => T': {
- type: 'VariableDeclaration',
- declarations: [{
- type: 'VariableDeclarator',
- id: {
- type: 'Identifier',
- name: 'identity',
- typeAnnotation: {
- type: 'TypeAnnotation',
- typeAnnotation: {
- type: 'FunctionTypeAnnotation',
- params: [{
- type: 'FunctionTypeParam',
- name: {
- type: 'Identifier',
- name: 'x',
- range: [18, 19],
- loc: {
- start: { line: 1, column: 18 },
- end: { line: 1, column: 19 }
- }
- },
- typeAnnotation: {
- type: 'GenericTypeAnnotation',
- id: {
- type: 'Identifier',
- name: 'T',
- range: [21, 22],
- loc: {
- start: { line: 1, column: 21 },
- end: { line: 1, column: 22 }
- }
- },
- typeParameters: null,
- range: [21, 22],
- loc: {
- start: { line: 1, column: 21 },
- end: { line: 1, column: 22 }
- }
- },
- optional: false,
- range: [18, 22],
- loc: {
- start: { line: 1, column: 18 },
- end: { line: 1, column: 22 }
- }
- }],
- returnType: {
- type: 'GenericTypeAnnotation',
- id: {
- type: 'Identifier',
- name: 'T',
- range: [27, 28],
- loc: {
- start: { line: 1, column: 27 },
- end: { line: 1, column: 28 }
- }
- },
- typeParameters: null,
- range: [27, 28],
- loc: {
- start: { line: 1, column: 27 },
- end: { line: 1, column: 28 }
- }
- },
- typeParameters: {
- type: 'TypeParameterDeclaration',
- params: [{
- type: 'Identifier',
- name: 'T',
- range: [15, 16],
- loc: {
- start: { line: 1, column: 15 },
- end: { line: 1, column: 16 }
- }
- }],
- range: [14, 17],
- loc: {
- start: { line: 1, column: 14 },
- end: { line: 1, column: 17 }
- }
- },
- range: [14, 28],
- loc: {
- start: { line: 1, column: 14 },
- end: { line: 1, column: 28 }
- }
- },
- range: [12, 28],
- loc: {
- start: { line: 1, column: 12 },
- end: { line: 1, column: 28 }
- }
- },
- range: [4, 28],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 28 }
- }
- },
- init: null,
- range: [4, 28],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 28 }
- }
- }],
- kind: 'var',
- range: [0, 28],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 28 }
- }
- },
- 'var identity: (x: T, ...y:T[]) => T': {
- type: 'VariableDeclaration',
- declarations: [{
- type: 'VariableDeclarator',
- id: {
- type: 'Identifier',
- name: 'identity',
- typeAnnotation: {
- type: 'TypeAnnotation',
- typeAnnotation: {
- type: 'FunctionTypeAnnotation',
- params: [{
- type: 'FunctionTypeParam',
- name: {
- type: 'Identifier',
- name: 'x',
- range: [18, 19],
- loc: {
- start: { line: 1, column: 18 },
- end: { line: 1, column: 19 }
- }
- },
- typeAnnotation: {
- type: 'GenericTypeAnnotation',
- id: {
- type: 'Identifier',
- name: 'T',
- range: [21, 22],
- loc: {
- start: { line: 1, column: 21 },
- end: { line: 1, column: 22 }
- }
- },
- typeParameters: null,
- range: [21, 22],
- loc: {
- start: { line: 1, column: 21 },
- end: { line: 1, column: 22 }
- }
- },
- optional: false,
- range: [18, 22],
- loc: {
- start: { line: 1, column: 18 },
- end: { line: 1, column: 22 }
- }
- }],
- returnType: {
- type: 'GenericTypeAnnotation',
- id: {
- type: 'Identifier',
- name: 'T',
- range: [37, 38],
- loc: {
- start: { line: 1, column: 37 },
- end: { line: 1, column: 38 }
- }
- },
- typeParameters: null,
- range: [37, 38],
- loc: {
- start: { line: 1, column: 37 },
- end: { line: 1, column: 38 }
- }
- },
- rest: {
- type: 'FunctionTypeParam',
- name: {
- type: 'Identifier',
- name: 'y',
- range: [27, 28],
- loc: {
- start: { line: 1, column: 27 },
- end: { line: 1, column: 28 }
- }
- },
- typeAnnotation: {
- type: 'ArrayTypeAnnotation',
- elementType: {
- type: 'GenericTypeAnnotation',
- id: {
- type: 'Identifier',
- name: 'T',
- range: [29, 30],
- loc: {
- start: { line: 1, column: 29 },
- end: { line: 1, column: 30 }
- }
- },
- typeParameters: null,
- range: [29, 30],
- loc: {
- start: { line: 1, column: 29 },
- end: { line: 1, column: 30 }
- }
- },
- range: [29, 32],
- loc: {
- start: { line: 1, column: 29 },
- end: { line: 1, column: 32 }
- }
- },
- optional: false,
- range: [27, 32],
- loc: {
- start: { line: 1, column: 27 },
- end: { line: 1, column: 32 }
- }
- },
- typeParameters: {
- type: 'TypeParameterDeclaration',
- params: [{
- type: 'Identifier',
- name: 'T',
- range: [15, 16],
- loc: {
- start: { line: 1, column: 15 },
- end: { line: 1, column: 16 }
- }
- }],
- range: [14, 17],
- loc: {
- start: { line: 1, column: 14 },
- end: { line: 1, column: 17 }
- }
- },
- range: [14, 38],
- loc: {
- start: { line: 1, column: 14 },
- end: { line: 1, column: 38 }
- }
- },
- range: [12, 38],
- loc: {
- start: { line: 1, column: 12 },
- end: { line: 1, column: 38 }
- }
- },
- range: [4, 38],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 38 }
- }
- },
- init: null,
- range: [4, 38],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 38 }
- }
- }],
- kind: 'var',
- range: [0, 38],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 38 }
- }
- },
- 'import type foo from "bar";': {
- type: 'ImportDeclaration',
- specifiers: [{
- type: 'ImportDefaultSpecifier',
- local: {
- type: 'Identifier',
- name: 'foo',
- range: [12, 15],
- loc: {
- start: { line: 1, column: 12 },
- end: { line: 1, column: 15 }
- }
- },
- range: [12, 15],
- loc: {
- start: { line: 1, column: 12 },
- end: { line: 1, column: 15 }
- }
- }],
- source: {
- type: 'Literal',
- value: 'bar',
- raw: '"bar"',
- range: [21, 26],
- loc: {
- start: { line: 1, column: 21 },
- end: { line: 1, column: 26 }
- }
- },
- isType: true,
- range: [0, 27],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 27 }
- }
- },
- 'import type {foo, bar} from "baz";': {
- type: 'ImportDeclaration',
- specifiers: [{
- type: 'ImportSpecifier',
- local: {
- type: 'Identifier',
- name: 'foo',
- range: [13, 16],
- loc: {
- start: { line: 1, column: 13 },
- end: { line: 1, column: 16 }
- }
- },
- imported: {
- type: 'Identifier',
- name: 'foo',
- range: [13, 16],
- loc: {
- start: { line: 1, column: 13 },
- end: { line: 1, column: 16 }
- }
- },
- range: [13, 16],
- loc: {
- start: { line: 1, column: 13 },
- end: { line: 1, column: 16 }
- }
- }, {
- type: 'ImportSpecifier',
- local: {
- type: 'Identifier',
- name: 'bar',
- range: [18, 21],
- loc: {
- start: { line: 1, column: 18 },
- end: { line: 1, column: 21 }
- }
- },
- imported: {
- type: 'Identifier',
- name: 'bar',
- range: [18, 21],
- loc: {
- start: { line: 1, column: 18 },
- end: { line: 1, column: 21 }
- }
- },
- range: [18, 21],
- loc: {
- start: { line: 1, column: 18 },
- end: { line: 1, column: 21 }
- }
- }],
- source: {
- type: 'Literal',
- value: 'baz',
- raw: '"baz"',
- range: [28, 33],
- loc: {
- start: { line: 1, column: 28 },
- end: { line: 1, column: 33 }
- }
- },
- isType: true,
- range: [0, 34],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 34 }
- }
- },
- 'import type {foo as bar} from "baz";': {
- type: 'ImportDeclaration',
- specifiers: [{
- type: 'ImportSpecifier',
- imported: {
- type: 'Identifier',
- name: 'foo',
- range: [13, 16],
- loc: {
- start: { line: 1, column: 13 },
- end: { line: 1, column: 16 }
- }
- },
- local: {
- type: 'Identifier',
- name: 'bar',
- range: [20, 23],
- loc: {
- start: { line: 1, column: 20 },
- end: { line: 1, column: 23 }
- }
- },
- range: [13, 23],
- loc: {
- start: { line: 1, column: 13 },
- end: { line: 1, column: 23 }
- }
- }],
- source: {
- type: 'Literal',
- value: 'baz',
- raw: '"baz"',
- range: [30, 35],
- loc: {
- start: { line: 1, column: 30 },
- end: { line: 1, column: 35 }
- }
- },
- isType: true,
- range: [0, 36],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 36 }
- }
- },
- 'import type from "foo";': {
- type: 'ImportDeclaration',
- specifiers: [{
- type: 'ImportDefaultSpecifier',
- local: {
- type: 'Identifier',
- name: 'type',
- range: [7, 11],
- loc: {
- start: { line: 1, column: 7 },
- end: { line: 1, column: 11 }
- }
- },
- range: [7, 11],
- loc: {
- start: { line: 1, column: 7 },
- end: { line: 1, column: 11 }
- }
- }],
- source: {
- type: 'Literal',
- value: 'foo',
- raw: '"foo"',
- range: [17, 22],
- loc: {
- start: { line: 1, column: 17 },
- end: { line: 1, column: 22 }
- }
- },
- isType: false,
- range: [0, 23],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 23 }
- }
- },
- 'import type, {foo} from "bar";': {
- type: 'ImportDeclaration',
- specifiers: [{
- type: 'ImportDefaultSpecifier',
- local: {
- type: 'Identifier',
- name: 'type',
- range: [7, 11],
- loc: {
- start: { line: 1, column: 7 },
- end: { line: 1, column: 11 }
- }
- },
- range: [7, 11],
- loc: {
- start: { line: 1, column: 7 },
- end: { line: 1, column: 11 }
- }
- }, {
- type: 'ImportSpecifier',
- local: {
- type: 'Identifier',
- name: 'foo',
- range: [14, 17],
- loc: {
- start: { line: 1, column: 14 },
- end: { line: 1, column: 17 }
- }
- },
- imported: {
- type: 'Identifier',
- name: 'foo',
- range: [14, 17],
- loc: {
- start: { line: 1, column: 14 },
- end: { line: 1, column: 17 }
- }
- },
- range: [14, 17],
- loc: {
- start: { line: 1, column: 14 },
- end: { line: 1, column: 17 }
- }
- }],
- source: {
- type: 'Literal',
- value: 'bar',
- raw: '"bar"',
- range: [24, 29],
- loc: {
- start: { line: 1, column: 24 },
- end: { line: 1, column: 29 }
- }
- },
- isType: false,
- range: [0, 30],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 30 }
- }
- },
- 'import type * as namespace from "bar";': {
- type: 'ImportDeclaration',
- specifiers: [{
- type: 'ImportNamespaceSpecifier',
- local: {
- type: 'Identifier',
- name: 'namespace',
- range: [17, 26],
- loc: {
- start: { line: 1, column: 17 },
- end: { line: 1, column: 26 }
- }
- },
- range: [12, 26],
- loc: {
- start: { line: 1, column: 12 },
- end: { line: 1, column: 26 }
- }
- }],
- source: {
- type: 'Literal',
- value: 'bar',
- raw: '"bar"',
- range: [32, 37],
- loc: {
- start: { line: 1, column: 32 },
- end: { line: 1, column: 37 }
- }
- },
- isType: true,
- range: [0, 38],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 38 }
- }
- },
- },
- 'Array Types': {
- 'var a: number[]': {
- type: 'VariableDeclaration',
- declarations: [{
- type: 'VariableDeclarator',
- id: {
- type: 'Identifier',
- name: 'a',
- typeAnnotation: {
- type: 'TypeAnnotation',
- typeAnnotation: {
- type: 'ArrayTypeAnnotation',
- elementType: {
- type: 'NumberTypeAnnotation',
- range: [7, 13],
- loc: {
- start: { line: 1, column: 7 },
- end: { line: 1, column: 13 }
- }
- },
- range: [7, 15],
- loc: {
- start: { line: 1, column: 7 },
- end: { line: 1, column: 15 }
- }
- },
- range: [5, 15],
- loc: {
- start: { line: 1, column: 5 },
- end: { line: 1, column: 15 }
- }
- },
- range: [4, 15],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 15 }
- }
- },
- init: null,
- range: [4, 15],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 15 }
- }
- }],
- kind: 'var',
- range: [0, 15],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 15 }
- }
- },
- 'var a: ?number[]': {
- type: 'VariableDeclaration',
- declarations: [{
- type: 'VariableDeclarator',
- id: {
- type: 'Identifier',
- name: 'a',
- typeAnnotation: {
- type: 'TypeAnnotation',
- typeAnnotation: {
- type: 'NullableTypeAnnotation',
- typeAnnotation: {
- type: 'ArrayTypeAnnotation',
- elementType: {
- type: 'NumberTypeAnnotation',
- range: [8, 14],
- loc: {
- start: { line: 1, column: 8 },
- end: { line: 1, column: 14 }
- }
- },
- range: [8, 16],
- loc: {
- start: { line: 1, column: 8 },
- end: { line: 1, column: 16 }
- }
- },
- range: [7, 16],
- loc: {
- start: { line: 1, column: 7 },
- end: { line: 1, column: 16 }
- }
- },
- range: [5, 16],
- loc: {
- start: { line: 1, column: 5 },
- end: { line: 1, column: 16 }
- }
- },
- range: [4, 16],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 16 }
- }
- },
- init: null,
- range: [4, 16],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 16 }
- }
- }],
- kind: 'var',
- range: [0, 16],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 16 }
- }
- },
- 'var a: (?number)[]': {
- type: 'VariableDeclaration',
- declarations: [{
- type: 'VariableDeclarator',
- id: {
- type: 'Identifier',
- name: 'a',
- typeAnnotation: {
- type: 'TypeAnnotation',
- typeAnnotation: {
- type: 'ArrayTypeAnnotation',
- elementType: {
- type: 'NullableTypeAnnotation',
- typeAnnotation: {
- type: 'NumberTypeAnnotation',
- range: [9, 15],
- loc: {
- start: { line: 1, column: 9 },
- end: { line: 1, column: 15 }
- }
- },
- range: [8, 15],
- loc: {
- start: { line: 1, column: 8 },
- end: { line: 1, column: 15 }
- }
- },
- range: [7, 18],
- loc: {
- start: { line: 1, column: 7 },
- end: { line: 1, column: 18 }
- }
- },
- range: [5, 18],
- loc: {
- start: { line: 1, column: 5 },
- end: { line: 1, column: 18 }
- }
- },
- range: [4, 18],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 18 }
- }
- },
- init: null,
- range: [4, 18],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 18 }
- }
- }],
- kind: 'var',
- range: [0, 18],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 18 }
- }
- },
- 'var a: () => number[]': {
- type: 'VariableDeclaration',
- declarations: [{
- type: 'VariableDeclarator',
- id: {
- type: 'Identifier',
- name: 'a',
- typeAnnotation: {
- type: 'TypeAnnotation',
- typeAnnotation: {
- type: 'FunctionTypeAnnotation',
- params: [],
- returnType: {
- type: 'ArrayTypeAnnotation',
- elementType: {
- type: 'NumberTypeAnnotation',
- range: [13, 19],
- loc: {
- start: { line: 1, column: 13 },
- end: { line: 1, column: 19 }
- }
- },
- range: [13, 21],
- loc: {
- start: { line: 1, column: 13 },
- end: { line: 1, column: 21 }
- }
- },
- typeParameters: null,
- range: [7, 21],
- loc: {
- start: { line: 1, column: 7 },
- end: { line: 1, column: 21 }
- }
- },
- range: [5, 21],
- loc: {
- start: { line: 1, column: 5 },
- end: { line: 1, column: 21 }
- }
- },
- range: [4, 21],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 21 }
- }
- },
- init: null,
- range: [4, 21],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 21 }
- }
- }],
- kind: 'var',
- range: [0, 21],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 21 }
- }
- },
- 'var a: (() => number)[]': {
- type: 'VariableDeclaration',
- declarations: [{
- type: 'VariableDeclarator',
- id: {
- type: 'Identifier',
- name: 'a',
- typeAnnotation: {
- type: 'TypeAnnotation',
- typeAnnotation: {
- type: 'ArrayTypeAnnotation',
- elementType: {
- type: 'FunctionTypeAnnotation',
- params: [],
- returnType: {
- type: 'NumberTypeAnnotation',
- range: [14, 20],
- loc: {
- start: { line: 1, column: 14 },
- end: { line: 1, column: 20 }
- }
- },
- typeParameters: null,
- range: [8, 20],
- loc: {
- start: { line: 1, column: 8 },
- end: { line: 1, column: 20 }
- }
- },
- range: [7, 23],
- loc: {
- start: { line: 1, column: 7 },
- end: { line: 1, column: 23 }
- }
- },
- range: [5, 23],
- loc: {
- start: { line: 1, column: 5 },
- end: { line: 1, column: 23 }
- }
- },
- range: [4, 23],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 23 }
- }
- },
- init: null,
- range: [4, 23],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 23 }
- }
- }],
- kind: 'var',
- range: [0, 23],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 23 }
- }
- },
- 'var a: typeof A[]': {
- type: 'VariableDeclaration',
- declarations: [{
- type: 'VariableDeclarator',
- id: {
- type: 'Identifier',
- name: 'a',
- typeAnnotation: {
- type: 'TypeAnnotation',
- typeAnnotation: {
- type: 'ArrayTypeAnnotation',
- elementType: {
- type: 'TypeofTypeAnnotation',
- argument: {
- type: 'GenericTypeAnnotation',
- id: {
- type: 'Identifier',
- name: 'A',
- range: [14, 15],
- loc: {
- start: { line: 1, column: 14 },
- end: { line: 1, column: 15 }
- }
- },
- typeParameters: null,
- range: [14, 15],
- loc: {
- start: { line: 1, column: 14 },
- end: { line: 1, column: 15 }
- }
- },
- range: [7, 15],
- loc: {
- start: { line: 1, column: 7 },
- end: { line: 1, column: 15 }
- }
- },
- range: [7, 17],
- loc: {
- start: { line: 1, column: 7 },
- end: { line: 1, column: 17 }
- }
- },
- range: [5, 17],
- loc: {
- start: { line: 1, column: 5 },
- end: { line: 1, column: 17 }
- }
- },
- range: [4, 17],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 17 }
- }
- },
- init: null,
- range: [4, 17],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 17 }
- }
- }],
- kind: 'var',
- range: [0, 17],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 17 }
- }
- },
- },
- 'Tuples': {
- 'var a : [] = [];': {
- type: 'VariableDeclaration',
- declarations: [{
- type: 'VariableDeclarator',
- id: {
- type: 'Identifier',
- name: 'a',
- typeAnnotation: {
- type: 'TypeAnnotation',
- typeAnnotation: {
- type: 'TupleTypeAnnotation',
- types: [],
- range: [8, 10],
- loc: {
- start: { line: 1, column: 8 },
- end: { line: 1, column: 10 }
- }
- },
- range: [6, 10],
- loc: {
- start: { line: 1, column: 6 },
- end: { line: 1, column: 10 }
- }
- },
- range: [4, 10],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 10 }
- }
- },
- init: {
- type: 'ArrayExpression',
- elements: [],
- range: [13, 15],
- loc: {
- start: { line: 1, column: 13 },
- end: { line: 1, column: 15 }
- }
- },
- range: [4, 15],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 15 }
- }
- }],
- kind: 'var',
- range: [0, 16],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 16 }
- }
- },
- 'var a : [Foo] = [foo];': {
- type: 'VariableDeclaration',
- declarations: [{
- type: 'VariableDeclarator',
- id: {
- type: 'Identifier',
- name: 'a',
- typeAnnotation: {
- type: 'TypeAnnotation',
- typeAnnotation: {
- type: 'TupleTypeAnnotation',
- types: [{
- type: 'GenericTypeAnnotation',
- id: {
- type: 'Identifier',
- name: 'Foo',
- range: [9, 12],
- loc: {
- start: { line: 1, column: 9 },
- end: { line: 1, column: 12 }
- }
- },
- typeParameters: {
- type: 'TypeParameterInstantiation',
- params: [{
- type: 'GenericTypeAnnotation',
- id: {
- type: 'Identifier',
- name: 'T',
- range: [13, 14],
- loc: {
- start: { line: 1, column: 13 },
- end: { line: 1, column: 14 }
- }
- },
- typeParameters: null,
- range: [13, 14],
- loc: {
- start: { line: 1, column: 13 },
- end: { line: 1, column: 14 }
- }
- }],
- range: [12, 15],
- loc: {
- start: { line: 1, column: 12 },
- end: { line: 1, column: 15 }
- }
- },
- range: [9, 15],
- loc: {
- start: { line: 1, column: 9 },
- end: { line: 1, column: 15 }
- }
- }],
- range: [8, 16],
- loc: {
- start: { line: 1, column: 8 },
- end: { line: 1, column: 16 }
- }
- },
- range: [6, 16],
- loc: {
- start: { line: 1, column: 6 },
- end: { line: 1, column: 16 }
- }
- },
- range: [4, 16],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 16 }
- }
- },
- init: {
- type: 'ArrayExpression',
- elements: [{
- type: 'Identifier',
- name: 'foo',
- range: [20, 23],
- loc: {
- start: { line: 1, column: 20 },
- end: { line: 1, column: 23 }
- }
- }],
- range: [19, 24],
- loc: {
- start: { line: 1, column: 19 },
- end: { line: 1, column: 24 }
- }
- },
- range: [4, 24],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 24 }
- }
- }],
- kind: 'var',
- range: [0, 25],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 25 }
- }
- },
- 'var a : [number,] = [123,];': {
- type: 'VariableDeclaration',
- declarations: [{
- type: 'VariableDeclarator',
- id: {
- type: 'Identifier',
- name: 'a',
- typeAnnotation: {
- type: 'TypeAnnotation',
- typeAnnotation: {
- type: 'TupleTypeAnnotation',
- types: [{
- type: 'NumberTypeAnnotation',
- range: [9, 15],
- loc: {
- start: { line: 1, column: 9 },
- end: { line: 1, column: 15 }
- }
- }],
- range: [8, 17],
- loc: {
- start: { line: 1, column: 8 },
- end: { line: 1, column: 17 }
- }
- },
- range: [6, 17],
- loc: {
- start: { line: 1, column: 6 },
- end: { line: 1, column: 17 }
- }
- },
- range: [4, 17],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 17 }
- }
- },
- init: {
- type: 'ArrayExpression',
- elements: [{
- type: 'Literal',
- value: 123,
- raw: '123',
- range: [21, 24],
- loc: {
- start: { line: 1, column: 21 },
- end: { line: 1, column: 24 }
- }
- }],
- range: [20, 26],
- loc: {
- start: { line: 1, column: 20 },
- end: { line: 1, column: 26 }
- }
- },
- range: [4, 26],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 26 }
- }
- }],
- kind: 'var',
- range: [0, 27],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 27 }
- }
- },
- 'var a : [number, string] = [123, "duck"];': {
- type: 'VariableDeclaration',
- declarations: [{
- type: 'VariableDeclarator',
- id: {
- type: 'Identifier',
- name: 'a',
- typeAnnotation: {
- type: 'TypeAnnotation',
- typeAnnotation: {
- type: 'TupleTypeAnnotation',
- types: [{
- type: 'NumberTypeAnnotation',
- range: [9, 15],
- loc: {
- start: { line: 1, column: 9 },
- end: { line: 1, column: 15 }
- }
- }, {
- type: 'StringTypeAnnotation',
- range: [17, 23],
- loc: {
- start: { line: 1, column: 17 },
- end: { line: 1, column: 23 }
- }
- }],
- range: [8, 24],
- loc: {
- start: { line: 1, column: 8 },
- end: { line: 1, column: 24 }
- }
- },
- range: [6, 24],
- loc: {
- start: { line: 1, column: 6 },
- end: { line: 1, column: 24 }
- }
- },
- range: [4, 24],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 24 }
- }
- },
- init: {
- type: 'ArrayExpression',
- elements: [{
- type: 'Literal',
- value: 123,
- raw: '123',
- range: [28, 31],
- loc: {
- start: { line: 1, column: 28 },
- end: { line: 1, column: 31 }
- }
- }, {
- type: 'Literal',
- value: 'duck',
- raw: '"duck"',
- range: [33, 39],
- loc: {
- start: { line: 1, column: 33 },
- end: { line: 1, column: 39 }
- }
- }],
- range: [27, 40],
- loc: {
- start: { line: 1, column: 27 },
- end: { line: 1, column: 40 }
- }
- },
- range: [4, 40],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 40 }
- }
- }],
- kind: 'var',
- range: [0, 41],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 41 }
- }
- },
- },
- 'Type Alias': {
- 'type FBID = number;': {
- type: 'TypeAlias',
- id: {
- type: 'Identifier',
- name: 'FBID',
- range: [5, 9],
- loc: {
- start: { line: 1, column: 5 },
- end: { line: 1, column: 9 }
- }
- },
- typeParameters: null,
- right: {
- type: 'NumberTypeAnnotation',
- range: [12, 18],
- loc: {
- start: { line: 1, column: 12 },
- end: { line: 1, column: 18 }
- }
- },
- range: [0, 19],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 19 }
- }
- },
- 'type Foo = Bar': {
- type: 'TypeAlias',
- id: {
- type: 'Identifier',
- name: 'Foo',
- range: [5, 8],
- loc: {
- start: { line: 1, column: 5 },
- end: { line: 1, column: 8 }
- }
- },
- typeParameters: {
- type: 'TypeParameterDeclaration',
- params: [{
- type: 'Identifier',
- name: 'T',
- range: [9, 10],
- loc: {
- start: { line: 1, column: 9 },
- end: { line: 1, column: 10 }
- }
- }],
- range: [8, 11],
- loc: {
- start: { line: 1, column: 8 },
- end: { line: 1, column: 11 }
- }
- },
- right: {
- type: 'GenericTypeAnnotation',
- id: {
- type: 'Identifier',
- name: 'Bar',
- range: [14, 17],
- loc: {
- start: { line: 1, column: 14 },
- end: { line: 1, column: 17 }
- }
- },
- typeParameters: {
- type: 'TypeParameterInstantiation',
- params: [{
- type: 'GenericTypeAnnotation',
- id: {
- type: 'Identifier',
- name: 'T',
- range: [18, 19],
- loc: {
- start: { line: 1, column: 18 },
- end: { line: 1, column: 19 }
- }
- },
- typeParameters: null,
- range: [18, 19],
- loc: {
- start: { line: 1, column: 18 },
- end: { line: 1, column: 19 }
- }
- }],
- range: [17, 20],
- loc: {
- start: { line: 1, column: 17 },
- end: { line: 1, column: 20 }
- }
- },
- range: [14, 20],
- loc: {
- start: { line: 1, column: 14 },
- end: { line: 1, column: 20 }
- }
- },
- range: [0, 20],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 20 }
- }
- },
- 'export type Foo = number;': {
- type: 'ExportNamedDeclaration',
- declaration: {
- type: 'TypeAlias',
- id: {
- type: 'Identifier',
- name: 'Foo',
- range: [12, 15],
- loc: {
- start: { line: 1, column: 12 },
- end: { line: 1, column: 15 }
- }
- },
- typeParameters: null,
- right: {
- type: 'NumberTypeAnnotation',
- range: [18, 24],
- loc: {
- start: { line: 1, column: 18 },
- end: { line: 1, column: 24 }
- }
- },
- range: [7, 25],
- loc: {
- start: { line: 1, column: 7 },
- end: { line: 1, column: 25 }
- }
- },
- specifiers: [],
- source: null,
- range: [0, 25],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 25 }
- }
- },
- },
- 'Interfaces (module and script)': {
- 'interface A {}': {
- type: 'InterfaceDeclaration',
- id: {
- type: 'Identifier',
- name: 'A',
- range: [10, 11],
- loc: {
- start: { line: 1, column: 10 },
- end: { line: 1, column: 11 }
- }
- },
- typeParameters: null,
- body: {
- type: 'ObjectTypeAnnotation',
- properties: [],
- indexers: [],
- callProperties: [],
- range: [12, 14],
- loc: {
- start: { line: 1, column: 12 },
- end: { line: 1, column: 14 }
- }
- },
- 'extends': [],
- range: [0, 14],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 14 }
- }
- },
- 'interface A extends B {}': {
- type: 'InterfaceDeclaration',
- id: {
- type: 'Identifier',
- name: 'A',
- range: [10, 11],
- loc: {
- start: { line: 1, column: 10 },
- end: { line: 1, column: 11 }
- }
- },
- typeParameters: null,
- body: {
- type: 'ObjectTypeAnnotation',
- properties: [],
- indexers: [],
- callProperties: [],
- range: [22, 24],
- loc: {
- start: { line: 1, column: 22 },
- end: { line: 1, column: 24 }
- }
- },
- 'extends': [{
- type: 'InterfaceExtends',
- id: {
- type: 'Identifier',
- name: 'B',
- range: [20, 21],
- loc: {
- start: { line: 1, column: 20 },
- end: { line: 1, column: 21 }
- }
- },
- typeParameters: null,
- range: [20, 21],
- loc: {
- start: { line: 1, column: 20 },
- end: { line: 1, column: 21 }
- }
- }],
- range: [0, 24],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 24 }
- }
- },
- 'interface A extends B, C {}': {
- type: 'InterfaceDeclaration',
- id: {
- type: 'Identifier',
- name: 'A',
- range: [10, 11],
- loc: {
- start: { line: 1, column: 10 },
- end: { line: 1, column: 11 }
- }
- },
- typeParameters: {
- type: 'TypeParameterDeclaration',
- params: [{
- type: 'Identifier',
- name: 'T',
- range: [12, 13],
- loc: {
- start: { line: 1, column: 12 },
- end: { line: 1, column: 13 }
- }
- }],
- range: [11, 14],
- loc: {
- start: { line: 1, column: 11 },
- end: { line: 1, column: 14 }
- }
- },
- body: {
- type: 'ObjectTypeAnnotation',
- properties: [],
- indexers: [],
- callProperties: [],
- range: [34, 36],
- loc: {
- start: { line: 1, column: 34 },
- end: { line: 1, column: 36 }
- }
- },
- 'extends': [{
- type: 'InterfaceExtends',
- id: {
- type: 'Identifier',
- name: 'B',
- range: [23, 24],
- loc: {
- start: { line: 1, column: 23 },
- end: { line: 1, column: 24 }
- }
- },
- typeParameters: {
- type: 'TypeParameterInstantiation',
- params: [{
- type: 'GenericTypeAnnotation',
- id: {
- type: 'Identifier',
- name: 'T',
- range: [25, 26],
- loc: {
- start: { line: 1, column: 25 },
- end: { line: 1, column: 26 }
- }
- },
- typeParameters: null,
- range: [25, 26],
- loc: {
- start: { line: 1, column: 25 },
- end: { line: 1, column: 26 }
- }
- }],
- range: [24, 27],
- loc: {
- start: { line: 1, column: 24 },
- end: { line: 1, column: 27 }
- }
- },
- range: [23, 27],
- loc: {
- start: { line: 1, column: 23 },
- end: { line: 1, column: 27 }
- }
- }, {
- type: 'InterfaceExtends',
- id: {
- type: 'Identifier',
- name: 'C',
- range: [29, 30],
- loc: {
- start: { line: 1, column: 29 },
- end: { line: 1, column: 30 }
- }
- },
- typeParameters: {
- type: 'TypeParameterInstantiation',
- params: [{
- type: 'GenericTypeAnnotation',
- id: {
- type: 'Identifier',
- name: 'T',
- range: [31, 32],
- loc: {
- start: { line: 1, column: 31 },
- end: { line: 1, column: 32 }
- }
- },
- typeParameters: null,
- range: [31, 32],
- loc: {
- start: { line: 1, column: 31 },
- end: { line: 1, column: 32 }
- }
- }],
- range: [30, 33],
- loc: {
- start: { line: 1, column: 30 },
- end: { line: 1, column: 33 }
- }
- },
- range: [29, 33],
- loc: {
- start: { line: 1, column: 29 },
- end: { line: 1, column: 33 }
- }
- }],
- range: [0, 36],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 36 }
- }
- },
- 'interface A { foo: () => number; }': {
- type: 'InterfaceDeclaration',
- id: {
- type: 'Identifier',
- name: 'A',
- range: [10, 11],
- loc: {
- start: { line: 1, column: 10 },
- end: { line: 1, column: 11 }
- }
- },
- typeParameters: null,
- body: {
- type: 'ObjectTypeAnnotation',
- properties: [{
- type: 'ObjectTypeProperty',
- key: {
- type: 'Identifier',
- name: 'foo',
- range: [14, 17],
- loc: {
- start: { line: 1, column: 14 },
- end: { line: 1, column: 17 }
- }
- },
- value: {
- type: 'FunctionTypeAnnotation',
- params: [],
- returnType: {
- type: 'NumberTypeAnnotation',
- range: [25, 31],
- loc: {
- start: { line: 1, column: 25 },
- end: { line: 1, column: 31 }
- }
- },
- typeParameters: null,
- range: [19, 31],
- loc: {
- start: { line: 1, column: 19 },
- end: { line: 1, column: 31 }
- }
- },
- optional: false,
- range: [14, 31],
- loc: {
- start: { line: 1, column: 14 },
- end: { line: 1, column: 31 }
- }
- }],
- indexers: [],
- callProperties: [],
- range: [12, 34],
- loc: {
- start: { line: 1, column: 12 },
- end: { line: 1, column: 34 }
- }
- },
- 'extends': [],
- range: [0, 34],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 34 }
- }
- },
- 'interface Dictionary { [index: string]: string; length: number; }': {
- type: 'InterfaceDeclaration',
- id: {
- type: 'Identifier',
- name: 'Dictionary',
- range: [10, 20],
- loc: {
- start: { line: 1, column: 10 },
- end: { line: 1, column: 20 }
- }
- },
- typeParameters: null,
- body: {
- type: 'ObjectTypeAnnotation',
- properties: [{
- type: 'ObjectTypeProperty',
- key: {
- type: 'Identifier',
- name: 'length',
- range: [48, 54],
- loc: {
- start: { line: 1, column: 48 },
- end: { line: 1, column: 54 }
- }
- },
- value: {
- type: 'NumberTypeAnnotation',
- range: [56, 62],
- loc: {
- start: { line: 1, column: 56 },
- end: { line: 1, column: 62 }
- }
- },
- optional: false,
- range: [48, 62],
- loc: {
- start: { line: 1, column: 48 },
- end: { line: 1, column: 62 }
- }
- }],
- indexers: [{
- type: 'ObjectTypeIndexer',
- id: {
- type: 'Identifier',
- name: 'index',
- range: [24, 29],
- loc: {
- start: { line: 1, column: 24 },
- end: { line: 1, column: 29 }
- }
- },
- key: {
- type: 'StringTypeAnnotation',
- range: [31, 37],
- loc: {
- start: { line: 1, column: 31 },
- end: { line: 1, column: 37 }
- }
- },
- value: {
- type: 'StringTypeAnnotation',
- range: [40, 46],
- loc: {
- start: { line: 1, column: 40 },
- end: { line: 1, column: 46 }
- }
- },
- range: [23, 46],
- loc: {
- start: { line: 1, column: 23 },
- end: { line: 1, column: 46 }
- }
- }],
- callProperties: [],
- range: [21, 65],
- loc: {
- start: { line: 1, column: 21 },
- end: { line: 1, column: 65 }
- }
- },
- 'extends': [],
- range: [0, 65],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 65 }
- }
- },
- 'class Foo implements Bar {}': {
- type: 'ClassDeclaration',
- id: {
- type: 'Identifier',
- name: 'Foo',
- range: [6, 9],
- loc: {
- start: { line: 1, column: 6 },
- end: { line: 1, column: 9 }
- }
- },
- superClass: null,
- body: {
- type: 'ClassBody',
- body: [],
- range: [25, 27],
- loc: {
- start: { line: 1, column: 25 },
- end: { line: 1, column: 27 }
- }
- },
- 'implements': [{
- type: 'ClassImplements',
- id: {
- type: 'Identifier',
- name: 'Bar',
- range: [21, 24],
- loc: {
- start: { line: 1, column: 21 },
- end: { line: 1, column: 24 }
- }
- },
- typeParameters: null,
- range: [21, 24],
- loc: {
- start: { line: 1, column: 21 },
- end: { line: 1, column: 24 }
- }
- }],
- range: [0, 27],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 27 }
- }
- },
- 'class Foo extends Bar implements Bat, Man {}': {
- type: 'ClassDeclaration',
- id: {
- type: 'Identifier',
- name: 'Foo',
- range: [6, 9],
- loc: {
- start: { line: 1, column: 6 },
- end: { line: 1, column: 9 }
- }
- },
- superClass: {
- type: 'Identifier',
- name: 'Bar',
- range: [18, 21],
- loc: {
- start: { line: 1, column: 18 },
- end: { line: 1, column: 21 }
- }
- },
- body: {
- type: 'ClassBody',
- body: [],
- range: [50, 52],
- loc: {
- start: { line: 1, column: 50 },
- end: { line: 1, column: 52 }
- }
- },
- 'implements': [{
- type: 'ClassImplements',
- id: {
- type: 'Identifier',
- name: 'Bat',
- range: [33, 36],
- loc: {
- start: { line: 1, column: 33 },
- end: { line: 1, column: 36 }
- }
- },
- typeParameters: null,
- range: [33, 36],
- loc: {
- start: { line: 1, column: 33 },
- end: { line: 1, column: 36 }
- }
- }, {
- type: 'ClassImplements',
- id: {
- type: 'Identifier',
- name: 'Man',
- range: [38, 41],
- loc: {
- start: { line: 1, column: 38 },
- end: { line: 1, column: 41 }
- }
- },
- typeParameters: {
- type: 'TypeParameterInstantiation',
- params: [{
- type: 'NumberTypeAnnotation',
- range: [42, 48],
- loc: {
- start: { line: 1, column: 42 },
- end: { line: 1, column: 48 }
- }
- }],
- range: [41, 49],
- loc: {
- start: { line: 1, column: 41 },
- end: { line: 1, column: 49 }
- }
- },
- range: [38, 49],
- loc: {
- start: { line: 1, column: 38 },
- end: { line: 1, column: 49 }
- }
- }],
- range: [0, 52],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 52 }
- }
- },
- 'class Foo extends class Bar implements Bat {} {}': {
- type: 'ClassDeclaration',
- id: {
- type: 'Identifier',
- name: 'Foo',
- range: [6, 9],
- loc: {
- start: { line: 1, column: 6 },
- end: { line: 1, column: 9 }
- }
- },
- superClass: {
- type: 'ClassExpression',
- id: {
- type: 'Identifier',
- name: 'Bar',
- range: [24, 27],
- loc: {
- start: { line: 1, column: 24 },
- end: { line: 1, column: 27 }
- }
- },
- superClass: null,
- body: {
- type: 'ClassBody',
- body: [],
- range: [43, 45],
- loc: {
- start: { line: 1, column: 43 },
- end: { line: 1, column: 45 }
- }
- },
- 'implements': [{
- type: 'ClassImplements',
- id: {
- type: 'Identifier',
- name: 'Bat',
- range: [39, 42],
- loc: {
- start: { line: 1, column: 39 },
- end: { line: 1, column: 42 }
- }
- },
- typeParameters: null,
- range: [39, 42],
- loc: {
- start: { line: 1, column: 39 },
- end: { line: 1, column: 42 }
- }
- }],
- range: [18, 45],
- loc: {
- start: { line: 1, column: 18 },
- end: { line: 1, column: 45 }
- }
- },
- body: {
- type: 'ClassBody',
- body: [],
- range: [46, 48],
- loc: {
- start: { line: 1, column: 46 },
- end: { line: 1, column: 48 }
- }
- },
- range: [0, 48],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 48 }
- }
- },
- 'class Foo extends class Bar implements Bat {} implements Man {}': {
- type: 'ClassDeclaration',
- id: {
- type: 'Identifier',
- name: 'Foo',
- range: [6, 9],
- loc: {
- start: { line: 1, column: 6 },
- end: { line: 1, column: 9 }
- }
- },
- superClass: {
- type: 'ClassExpression',
- id: {
- type: 'Identifier',
- name: 'Bar',
- range: [24, 27],
- loc: {
- start: { line: 1, column: 24 },
- end: { line: 1, column: 27 }
- }
- },
- superClass: null,
- body: {
- type: 'ClassBody',
- body: [],
- range: [43, 45],
- loc: {
- start: { line: 1, column: 43 },
- end: { line: 1, column: 45 }
- }
- },
- 'implements': [{
- type: 'ClassImplements',
- id: {
- type: 'Identifier',
- name: 'Bat',
- range: [39, 42],
- loc: {
- start: { line: 1, column: 39 },
- end: { line: 1, column: 42 }
- }
- },
- typeParameters: null,
- range: [39, 42],
- loc: {
- start: { line: 1, column: 39 },
- end: { line: 1, column: 42 }
- }
- }],
- range: [18, 45],
- loc: {
- start: { line: 1, column: 18 },
- end: { line: 1, column: 45 }
- }
- },
- body: {
- type: 'ClassBody',
- body: [],
- range: [61, 63],
- loc: {
- start: { line: 1, column: 61 },
- end: { line: 1, column: 63 }
- }
- },
- 'implements': [{
- type: 'ClassImplements',
- id: {
- type: 'Identifier',
- name: 'Man',
- range: [57, 60],
- loc: {
- start: { line: 1, column: 57 },
- end: { line: 1, column: 60 }
- }
- },
- typeParameters: null,
- range: [57, 60],
- loc: {
- start: { line: 1, column: 57 },
- end: { line: 1, column: 60 }
- }
- }],
- range: [0, 63],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 63 }
- }
- },
- },
- 'Type Grouping': {
- 'var a: (number)': {
- type: 'VariableDeclaration',
- declarations: [{
- type: 'VariableDeclarator',
- id: {
- type: 'Identifier',
- name: 'a',
- typeAnnotation: {
- type: 'TypeAnnotation',
- typeAnnotation: {
- type: 'NumberTypeAnnotation',
- range: [8, 14],
- loc: {
- start: { line: 1, column: 8 },
- end: { line: 1, column: 14 }
- }
- },
- range: [5, 15],
- loc: {
- start: { line: 1, column: 5 },
- end: { line: 1, column: 15 }
- }
- },
- range: [4, 15],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 15 }
- }
- },
- init: null,
- range: [4, 15],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 15 }
- }
- }],
- kind: 'var',
- range: [0, 15],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 15 }
- }
- },
- 'var a: (() => number) | () => string': {
- type: 'VariableDeclaration',
- declarations: [{
- type: 'VariableDeclarator',
- id: {
- type: 'Identifier',
- name: 'a',
- typeAnnotation: {
- type: 'TypeAnnotation',
- typeAnnotation: {
- type: 'UnionTypeAnnotation',
- types: [{
- type: 'FunctionTypeAnnotation',
- params: [],
- returnType: {
- type: 'NumberTypeAnnotation',
- range: [14, 20],
- loc: {
- start: { line: 1, column: 14 },
- end: { line: 1, column: 20 }
- }
- },
- typeParameters: null,
- range: [8, 20],
- loc: {
- start: { line: 1, column: 8 },
- end: { line: 1, column: 20 }
- }
- }, {
- type: 'FunctionTypeAnnotation',
- params: [],
- returnType: {
- type: 'StringTypeAnnotation',
- range: [30, 36],
- loc: {
- start: { line: 1, column: 30 },
- end: { line: 1, column: 36 }
- }
- },
- typeParameters: null,
- range: [24, 36],
- loc: {
- start: { line: 1, column: 24 },
- end: { line: 1, column: 36 }
- }
- }],
- range: [7, 36],
- loc: {
- start: { line: 1, column: 7 },
- end: { line: 1, column: 36 }
- }
- },
- range: [5, 36],
- loc: {
- start: { line: 1, column: 5 },
- end: { line: 1, column: 36 }
- }
- },
- range: [4, 36],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 36 }
- }
- },
- init: null,
- range: [4, 36],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 36 }
- }
- }],
- kind: 'var',
- range: [0, 36],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 36 }
- }
- },
- 'var a: number & (string | bool)': {
- type: 'VariableDeclaration',
- declarations: [{
- type: 'VariableDeclarator',
- id: {
- type: 'Identifier',
- name: 'a',
- typeAnnotation: {
- type: 'TypeAnnotation',
- typeAnnotation: {
- type: 'IntersectionTypeAnnotation',
- types: [{
- type: 'NumberTypeAnnotation',
- range: [7, 13],
- loc: {
- start: { line: 1, column: 7 },
- end: { line: 1, column: 13 }
- }
- }, {
- type: 'UnionTypeAnnotation',
- types: [{
- type: 'StringTypeAnnotation',
- range: [17, 23],
- loc: {
- start: { line: 1, column: 17 },
- end: { line: 1, column: 23 }
- }
- }, {
- type: 'BooleanTypeAnnotation',
- range: [26, 30],
- loc: {
- start: { line: 1, column: 26 },
- end: { line: 1, column: 30 }
- }
- }],
- range: [17, 30],
- loc: {
- start: { line: 1, column: 17 },
- end: { line: 1, column: 30 }
- }
- }],
- range: [7, 31],
- loc: {
- start: { line: 1, column: 7 },
- end: { line: 1, column: 31 }
- }
- },
- range: [5, 31],
- loc: {
- start: { line: 1, column: 5 },
- end: { line: 1, column: 31 }
- }
- },
- range: [4, 31],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 31 }
- }
- },
- init: null,
- range: [4, 31],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 31 }
- }
- }],
- kind: 'var',
- range: [0, 31],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 31 }
- }
- },
- 'var a: (typeof A)': {
- type: 'VariableDeclaration',
- declarations: [{
- type: 'VariableDeclarator',
- id: {
- type: 'Identifier',
- name: 'a',
- typeAnnotation: {
- type: 'TypeAnnotation',
- typeAnnotation: {
- type: 'TypeofTypeAnnotation',
- argument: {
- type: 'GenericTypeAnnotation',
- id: {
- type: 'Identifier',
- name: 'A',
- range: [15, 16],
- loc: {
- start: { line: 1, column: 15 },
- end: { line: 1, column: 16 }
- }
- },
- typeParameters: null,
- range: [15, 16],
- loc: {
- start: { line: 1, column: 15 },
- end: { line: 1, column: 16 }
- }
- },
- range: [8, 16],
- loc: {
- start: { line: 1, column: 8 },
- end: { line: 1, column: 16 }
- }
- },
- range: [5, 17],
- loc: {
- start: { line: 1, column: 5 },
- end: { line: 1, column: 17 }
- }
- },
- range: [4, 17],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 17 }
- }
- },
- init: null,
- range: [4, 17],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 17 }
- }
- }],
- kind: 'var',
- range: [0, 17],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 17 }
- }
- },
- },
- 'Call Properties': {
- 'var a : { (): number }': {
- type: 'VariableDeclaration',
- declarations: [{
- type: 'VariableDeclarator',
- id: {
- type: 'Identifier',
- name: 'a',
- typeAnnotation: {
- type: 'TypeAnnotation',
- typeAnnotation: {
- type: 'ObjectTypeAnnotation',
- properties: [],
- indexers: [],
- callProperties: [{
- type: 'ObjectTypeCallProperty',
- value: {
- type: 'FunctionTypeAnnotation',
- params: [],
- returnType: {
- type: 'NumberTypeAnnotation',
- range: [14, 20],
- loc: {
- start: { line: 1, column: 14 },
- end: { line: 1, column: 20 }
- }
- },
- typeParameters: null,
- range: [10, 20],
- loc: {
- start: { line: 1, column: 10 },
- end: { line: 1, column: 20 }
- }
- },
- range: [10, 20],
- loc: {
- start: { line: 1, column: 10 },
- end: { line: 1, column: 20 }
- }
- }],
- range: [8, 22],
- loc: {
- start: { line: 1, column: 8 },
- end: { line: 1, column: 22 }
- }
- },
- range: [6, 22],
- loc: {
- start: { line: 1, column: 6 },
- end: { line: 1, column: 22 }
- }
- },
- range: [4, 22],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 22 }
- }
- },
- init: null,
- range: [4, 22],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 22 }
- }
- }],
- kind: 'var',
- range: [0, 22],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 22 }
- }
- },
- 'var a : { (): number; }': {
- type: 'VariableDeclaration',
- declarations: [{
- type: 'VariableDeclarator',
- id: {
- type: 'Identifier',
- name: 'a',
- typeAnnotation: {
- type: 'TypeAnnotation',
- typeAnnotation: {
- type: 'ObjectTypeAnnotation',
- properties: [],
- indexers: [],
- callProperties: [{
- type: 'ObjectTypeCallProperty',
- value: {
- type: 'FunctionTypeAnnotation',
- params: [],
- returnType: {
- type: 'NumberTypeAnnotation',
- range: [14, 20],
- loc: {
- start: { line: 1, column: 14 },
- end: { line: 1, column: 20 }
- }
- },
- typeParameters: null,
- range: [10, 20],
- loc: {
- start: { line: 1, column: 10 },
- end: { line: 1, column: 20 }
- }
- },
- range: [10, 20],
- loc: {
- start: { line: 1, column: 10 },
- end: { line: 1, column: 20 }
- }
- }],
- range: [8, 23],
- loc: {
- start: { line: 1, column: 8 },
- end: { line: 1, column: 23 }
- }
- },
- range: [6, 23],
- loc: {
- start: { line: 1, column: 6 },
- end: { line: 1, column: 23 }
- }
- },
- range: [4, 23],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 23 }
- }
- },
- init: null,
- range: [4, 23],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 23 }
- }
- }],
- kind: 'var',
- range: [0, 23],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 23 }
- }
- },
- 'var a : { (): number; y: string; (x: string): string }': {
- type: 'VariableDeclaration',
- declarations: [{
- type: 'VariableDeclarator',
- id: {
- type: 'Identifier',
- name: 'a',
- typeAnnotation: {
- type: 'TypeAnnotation',
- typeAnnotation: {
- type: 'ObjectTypeAnnotation',
- properties: [{
- type: 'ObjectTypeProperty',
- key: {
- type: 'Identifier',
- name: 'y',
- range: [22, 23],
- loc: {
- start: { line: 1, column: 22 },
- end: { line: 1, column: 23 }
- }
- },
- value: {
- type: 'StringTypeAnnotation',
- range: [25, 31],
- loc: {
- start: { line: 1, column: 25 },
- end: { line: 1, column: 31 }
- }
- },
- optional: false,
- range: [22, 31],
- loc: {
- start: { line: 1, column: 22 },
- end: { line: 1, column: 31 }
- }
- }],
- indexers: [],
- callProperties: [{
- type: 'ObjectTypeCallProperty',
- value: {
- type: 'FunctionTypeAnnotation',
- params: [],
- returnType: {
- type: 'NumberTypeAnnotation',
- range: [14, 20],
- loc: {
- start: { line: 1, column: 14 },
- end: { line: 1, column: 20 }
- }
- },
- typeParameters: null,
- range: [10, 20],
- loc: {
- start: { line: 1, column: 10 },
- end: { line: 1, column: 20 }
- }
- },
- range: [10, 20],
- loc: {
- start: { line: 1, column: 10 },
- end: { line: 1, column: 20 }
- }
- }, {
- type: 'ObjectTypeCallProperty',
- value: {
- type: 'FunctionTypeAnnotation',
- params: [{
- type: 'FunctionTypeParam',
- name: {
- type: 'Identifier',
- name: 'x',
- range: [34, 35],
- loc: {
- start: { line: 1, column: 34 },
- end: { line: 1, column: 35 }
- }
- },
- typeAnnotation: {
- type: 'StringTypeAnnotation',
- range: [37, 43],
- loc: {
- start: { line: 1, column: 37 },
- end: { line: 1, column: 43 }
- }
- },
- optional: false,
- range: [34, 43],
- loc: {
- start: { line: 1, column: 34 },
- end: { line: 1, column: 43 }
- }
- }],
- returnType: {
- type: 'StringTypeAnnotation',
- range: [46, 52],
- loc: {
- start: { line: 1, column: 46 },
- end: { line: 1, column: 52 }
- }
- },
- typeParameters: null,
- range: [33, 52],
- loc: {
- start: { line: 1, column: 33 },
- end: { line: 1, column: 52 }
- }
- },
- range: [33, 52],
- loc: {
- start: { line: 1, column: 33 },
- end: { line: 1, column: 52 }
- }
- }],
- range: [8, 54],
- loc: {
- start: { line: 1, column: 8 },
- end: { line: 1, column: 54 }
- }
- },
- range: [6, 54],
- loc: {
- start: { line: 1, column: 6 },
- end: { line: 1, column: 54 }
- }
- },
- range: [4, 54],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 54 }
- }
- },
- init: null,
- range: [4, 54],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 54 }
- }
- }],
- kind: 'var',
- range: [0, 54],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 54 }
- }
- },
- 'var a : { (x: T): number; }': {
- type: 'VariableDeclaration',
- declarations: [{
- type: 'VariableDeclarator',
- id: {
- type: 'Identifier',
- name: 'a',
- typeAnnotation: {
- type: 'TypeAnnotation',
- typeAnnotation: {
- type: 'ObjectTypeAnnotation',
- properties: [],
- indexers: [],
- callProperties: [{
- type: 'ObjectTypeCallProperty',
- value: {
- type: 'FunctionTypeAnnotation',
- params: [{
- type: 'FunctionTypeParam',
- name: {
- type: 'Identifier',
- name: 'x',
- range: [14, 15],
- loc: {
- start: { line: 1, column: 14 },
- end: { line: 1, column: 15 }
- }
- },
- typeAnnotation: {
- type: 'GenericTypeAnnotation',
- id: {
- type: 'Identifier',
- name: 'T',
- range: [17, 18],
- loc: {
- start: { line: 1, column: 17 },
- end: { line: 1, column: 18 }
- }
- },
- typeParameters: null,
- range: [17, 18],
- loc: {
- start: { line: 1, column: 17 },
- end: { line: 1, column: 18 }
- }
- },
- optional: false,
- range: [14, 18],
- loc: {
- start: { line: 1, column: 14 },
- end: { line: 1, column: 18 }
- }
- }],
- returnType: {
- type: 'NumberTypeAnnotation',
- range: [21, 27],
- loc: {
- start: { line: 1, column: 21 },
- end: { line: 1, column: 27 }
- }
- },
- typeParameters: {
- type: 'TypeParameterDeclaration',
- params: [{
- type: 'Identifier',
- name: 'T',
- range: [11, 12],
- loc: {
- start: { line: 1, column: 11 },
- end: { line: 1, column: 12 }
- }
- }],
- range: [10, 13],
- loc: {
- start: { line: 1, column: 10 },
- end: { line: 1, column: 13 }
- }
- },
- range: [10, 27],
- loc: {
- start: { line: 1, column: 10 },
- end: { line: 1, column: 27 }
- }
- },
- range: [10, 27],
- loc: {
- start: { line: 1, column: 10 },
- end: { line: 1, column: 27 }
- }
- }],
- range: [8, 30],
- loc: {
- start: { line: 1, column: 8 },
- end: { line: 1, column: 30 }
- }
- },
- range: [6, 30],
- loc: {
- start: { line: 1, column: 6 },
- end: { line: 1, column: 30 }
- }
- },
- range: [4, 30],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 30 }
- }
- },
- init: null,
- range: [4, 30],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 30 }
- }
- }],
- kind: 'var',
- range: [0, 30],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 30 }
- }
- },
- 'interface A { (): number; }': {
- type: 'InterfaceDeclaration',
- id: {
- type: 'Identifier',
- name: 'A',
- range: [10, 11],
- loc: {
- start: { line: 1, column: 10 },
- end: { line: 1, column: 11 }
- }
- },
- typeParameters: null,
- body: {
- type: 'ObjectTypeAnnotation',
- properties: [],
- indexers: [],
- callProperties: [{
- type: 'ObjectTypeCallProperty',
- value: {
- type: 'FunctionTypeAnnotation',
- params: [],
- returnType: {
- type: 'NumberTypeAnnotation',
- range: [18, 24],
- loc: {
- start: { line: 1, column: 18 },
- end: { line: 1, column: 24 }
- }
- },
- typeParameters: null,
- range: [14, 24],
- loc: {
- start: { line: 1, column: 14 },
- end: { line: 1, column: 24 }
- }
- },
- 'static': false,
- range: [14, 24],
- loc: {
- start: { line: 1, column: 14 },
- end: { line: 1, column: 24 }
- }
- }],
- range: [12, 27],
- loc: {
- start: { line: 1, column: 12 },
- end: { line: 1, column: 27 }
- }
- },
- 'extends': [],
- range: [0, 27],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 27 }
- }
- },
- },
- 'String Literal Types': {
- 'function createElement(tagName: "div"): HTMLDivElement {}': {
- type: 'FunctionDeclaration',
- id: {
- type: 'Identifier',
- name: 'createElement',
- range: [9, 22],
- loc: {
- start: { line: 1, column: 9 },
- end: { line: 1, column: 22 }
- }
- },
- params: [{
- type: 'Identifier',
- name: 'tagName',
- typeAnnotation: {
- type: 'TypeAnnotation',
- typeAnnotation: {
- type: 'StringLiteralTypeAnnotation',
- value: 'div',
- raw: '"div"',
- range: [32, 37],
- loc: {
- start: { line: 1, column: 32 },
- end: { line: 1, column: 37 }
- }
- },
- range: [30, 37],
- loc: {
- start: { line: 1, column: 30 },
- end: { line: 1, column: 37 }
- }
- },
- range: [23, 37],
- loc: {
- start: { line: 1, column: 23 },
- end: { line: 1, column: 37 }
- }
- }],
- body: {
- type: 'BlockStatement',
- body: [],
- range: [55, 57],
- loc: {
- start: { line: 1, column: 55 },
- end: { line: 1, column: 57 }
- }
- },
- generator: false,
- expression: false,
- returnType: {
- type: 'TypeAnnotation',
- typeAnnotation: {
- type: 'GenericTypeAnnotation',
- id: {
- type: 'Identifier',
- name: 'HTMLDivElement',
- range: [40, 54],
- loc: {
- start: { line: 1, column: 40 },
- end: { line: 1, column: 54 }
- }
- },
- typeParameters: null,
- range: [40, 54],
- loc: {
- start: { line: 1, column: 40 },
- end: { line: 1, column: 54 }
- }
- },
- range: [38, 54],
- loc: {
- start: { line: 1, column: 38 },
- end: { line: 1, column: 54 }
- }
- },
- range: [0, 57],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 57 }
- }
- },
- 'function createElement(tagName: \'div\'): HTMLDivElement {}': {
- type: 'FunctionDeclaration',
- id: {
- type: 'Identifier',
- name: 'createElement',
- range: [9, 22],
- loc: {
- start: { line: 1, column: 9 },
- end: { line: 1, column: 22 }
- }
- },
- params: [{
- type: 'Identifier',
- name: 'tagName',
- typeAnnotation: {
- type: 'TypeAnnotation',
- typeAnnotation: {
- type: 'StringLiteralTypeAnnotation',
- value: 'div',
- raw: '\'div\'',
- range: [32, 37],
- loc: {
- start: { line: 1, column: 32 },
- end: { line: 1, column: 37 }
- }
- },
- range: [30, 37],
- loc: {
- start: { line: 1, column: 30 },
- end: { line: 1, column: 37 }
- }
- },
- range: [23, 37],
- loc: {
- start: { line: 1, column: 23 },
- end: { line: 1, column: 37 }
- }
- }],
- body: {
- type: 'BlockStatement',
- body: [],
- range: [55, 57],
- loc: {
- start: { line: 1, column: 55 },
- end: { line: 1, column: 57 }
- }
- },
- generator: false,
- expression: false,
- returnType: {
- type: 'TypeAnnotation',
- typeAnnotation: {
- type: 'GenericTypeAnnotation',
- id: {
- type: 'Identifier',
- name: 'HTMLDivElement',
- range: [40, 54],
- loc: {
- start: { line: 1, column: 40 },
- end: { line: 1, column: 54 }
- }
- },
- typeParameters: null,
- range: [40, 54],
- loc: {
- start: { line: 1, column: 40 },
- end: { line: 1, column: 54 }
- }
- },
- range: [38, 54],
- loc: {
- start: { line: 1, column: 38 },
- end: { line: 1, column: 54 }
- }
- },
- range: [0, 57],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 57 }
- }
- },
- },
- 'Qualified Generic Type': {
- 'var a : A.B': {
- type: 'VariableDeclaration',
- declarations: [{
- type: 'VariableDeclarator',
- id: {
- type: 'Identifier',
- name: 'a',
- typeAnnotation: {
- type: 'TypeAnnotation',
- typeAnnotation: {
- type: 'GenericTypeAnnotation',
- id: {
- type: 'QualifiedTypeIdentifier',
- qualification: {
- type: 'Identifier',
- name: 'A',
- range: [8, 9],
- loc: {
- start: { line: 1, column: 8 },
- end: { line: 1, column: 9 }
- }
- },
- id: {
- type: 'Identifier',
- name: 'B',
- range: [10, 11],
- loc: {
- start: { line: 1, column: 10 },
- end: { line: 1, column: 11 }
- }
- },
- range: [8, 11],
- loc: {
- start: { line: 1, column: 8 },
- end: { line: 1, column: 11 }
- }
- },
- typeParameters: null,
- range: [8, 11],
- loc: {
- start: { line: 1, column: 8 },
- end: { line: 1, column: 11 }
- }
- },
- range: [6, 11],
- loc: {
- start: { line: 1, column: 6 },
- end: { line: 1, column: 11 }
- }
- },
- range: [4, 11],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 11 }
- }
- },
- init: null,
- range: [4, 11],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 11 }
- }
- }],
- kind: 'var',
- range: [0, 11],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 11 }
- }
- },
- 'var a : A.B.C': {
- type: 'VariableDeclaration',
- declarations: [{
- type: 'VariableDeclarator',
- id: {
- type: 'Identifier',
- name: 'a',
- typeAnnotation: {
- type: 'TypeAnnotation',
- typeAnnotation: {
- type: 'GenericTypeAnnotation',
- id: {
- type: 'QualifiedTypeIdentifier',
- qualification: {
- type: 'QualifiedTypeIdentifier',
- qualification: {
- type: 'Identifier',
- name: 'A',
- range: [8, 9],
- loc: {
- start: { line: 1, column: 8 },
- end: { line: 1, column: 9 }
- }
- },
- id: {
- type: 'Identifier',
- name: 'B',
- range: [10, 11],
- loc: {
- start: { line: 1, column: 10 },
- end: { line: 1, column: 11 }
- }
- },
- range: [8, 11],
- loc: {
- start: { line: 1, column: 8 },
- end: { line: 1, column: 11 }
- }
- },
- id: {
- type: 'Identifier',
- name: 'C',
- range: [12, 13],
- loc: {
- start: { line: 1, column: 12 },
- end: { line: 1, column: 13 }
- }
- },
- range: [8, 13],
- loc: {
- start: { line: 1, column: 8 },
- end: { line: 1, column: 13 }
- }
- },
- typeParameters: null,
- range: [8, 13],
- loc: {
- start: { line: 1, column: 8 },
- end: { line: 1, column: 13 }
- }
- },
- range: [6, 13],
- loc: {
- start: { line: 1, column: 6 },
- end: { line: 1, column: 13 }
- }
- },
- range: [4, 13],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 13 }
- }
- },
- init: null,
- range: [4, 13],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 13 }
- }
- }],
- kind: 'var',
- range: [0, 13],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 13 }
- }
- },
- 'var a : A.B': {
- type: 'VariableDeclaration',
- declarations: [{
- type: 'VariableDeclarator',
- id: {
- type: 'Identifier',
- name: 'a',
- typeAnnotation: {
- type: 'TypeAnnotation',
- typeAnnotation: {
- type: 'GenericTypeAnnotation',
- id: {
- type: 'QualifiedTypeIdentifier',
- qualification: {
- type: 'Identifier',
- name: 'A',
- range: [8, 9],
- loc: {
- start: { line: 1, column: 8 },
- end: { line: 1, column: 9 }
- }
- },
- id: {
- type: 'Identifier',
- name: 'B',
- range: [10, 11],
- loc: {
- start: { line: 1, column: 10 },
- end: { line: 1, column: 11 }
- }
- },
- range: [8, 11],
- loc: {
- start: { line: 1, column: 8 },
- end: { line: 1, column: 11 }
- }
- },
- typeParameters: {
- type: 'TypeParameterInstantiation',
- params: [{
- type: 'GenericTypeAnnotation',
- id: {
- type: 'Identifier',
- name: 'T',
- range: [12, 13],
- loc: {
- start: { line: 1, column: 12 },
- end: { line: 1, column: 13 }
- }
- },
- typeParameters: null,
- range: [12, 13],
- loc: {
- start: { line: 1, column: 12 },
- end: { line: 1, column: 13 }
- }
- }],
- range: [11, 14],
- loc: {
- start: { line: 1, column: 11 },
- end: { line: 1, column: 14 }
- }
- },
- range: [8, 14],
- loc: {
- start: { line: 1, column: 8 },
- end: { line: 1, column: 14 }
- }
- },
- range: [6, 14],
- loc: {
- start: { line: 1, column: 6 },
- end: { line: 1, column: 14 }
- }
- },
- range: [4, 14],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 14 }
- }
- },
- init: null,
- range: [4, 14],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 14 }
- }
- }],
- kind: 'var',
- range: [0, 14],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 14 }
- }
- },
- 'var a : typeof A.B': {
- type: 'VariableDeclaration',
- declarations: [{
- type: 'VariableDeclarator',
- id: {
- type: 'Identifier',
- name: 'a',
- typeAnnotation: {
- type: 'TypeAnnotation',
- typeAnnotation: {
- type: 'TypeofTypeAnnotation',
- argument: {
- type: 'GenericTypeAnnotation',
- id: {
- type: 'QualifiedTypeIdentifier',
- qualification: {
- type: 'Identifier',
- name: 'A',
- range: [15, 16],
- loc: {
- start: { line: 1, column: 15 },
- end: { line: 1, column: 16 }
- }
- },
- id: {
- type: 'Identifier',
- name: 'B',
- range: [17, 18],
- loc: {
- start: { line: 1, column: 17 },
- end: { line: 1, column: 18 }
- }
- },
- range: [15, 18],
- loc: {
- start: { line: 1, column: 15 },
- end: { line: 1, column: 18 }
- }
- },
- typeParameters: {
- type: 'TypeParameterInstantiation',
- params: [{
- type: 'GenericTypeAnnotation',
- id: {
- type: 'Identifier',
- name: 'T',
- range: [19, 20],
- loc: {
- start: { line: 1, column: 19 },
- end: { line: 1, column: 20 }
- }
- },
- typeParameters: null,
- range: [19, 20],
- loc: {
- start: { line: 1, column: 19 },
- end: { line: 1, column: 20 }
- }
- }],
- range: [18, 21],
- loc: {
- start: { line: 1, column: 18 },
- end: { line: 1, column: 21 }
- }
- },
- range: [15, 21],
- loc: {
- start: { line: 1, column: 15 },
- end: { line: 1, column: 21 }
- }
- },
- range: [8, 21],
- loc: {
- start: { line: 1, column: 8 },
- end: { line: 1, column: 21 }
- }
- },
- range: [6, 21],
- loc: {
- start: { line: 1, column: 6 },
- end: { line: 1, column: 21 }
- }
- },
- range: [4, 21],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 21 }
- }
- },
- init: null,
- range: [4, 21],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 21 }
- }
- }],
- kind: 'var',
- range: [0, 21],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 21 }
- }
- },
- },
- 'Declare Statements': {
- 'declare var foo': {
- type: 'DeclareVariable',
- id: {
- type: 'Identifier',
- name: 'foo',
- range: [12, 15],
- loc: {
- start: { line: 1, column: 12 },
- end: { line: 1, column: 15 }
- }
- },
- range: [0, 15],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 15 }
- }
- },
- 'declare var foo;': {
- type: 'DeclareVariable',
- id: {
- type: 'Identifier',
- name: 'foo',
- range: [12, 15],
- loc: {
- start: { line: 1, column: 12 },
- end: { line: 1, column: 15 }
- }
- },
- range: [0, 16],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 16 }
- }
- },
- 'declare function foo(): void': {
- type: 'DeclareFunction',
- id: {
- type: 'Identifier',
- name: 'foo',
- typeAnnotation: {
- type: 'TypeAnnotation',
- typeAnnotation: {
- type: 'FunctionTypeAnnotation',
- params: [],
- returnType: {
- type: 'VoidTypeAnnotation',
- range: [24, 28],
- loc: {
- start: { line: 1, column: 24 },
- end: { line: 1, column: 28 }
- }
- },
- typeParameters: null,
- range: [20, 28],
- loc: {
- start: { line: 1, column: 20 },
- end: { line: 1, column: 28 }
- }
- },
- range: [20, 28],
- loc: {
- start: { line: 1, column: 20 },
- end: { line: 1, column: 28 }
- }
- },
- range: [17, 28],
- loc: {
- start: { line: 1, column: 17 },
- end: { line: 1, column: 28 }
- }
- },
- range: [0, 28],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 28 }
- }
- },
- 'declare function foo(): void;': {
- type: 'DeclareFunction',
- id: {
- type: 'Identifier',
- name: 'foo',
- typeAnnotation: {
- type: 'TypeAnnotation',
- typeAnnotation: {
- type: 'FunctionTypeAnnotation',
- params: [],
- returnType: {
- type: 'VoidTypeAnnotation',
- range: [24, 28],
- loc: {
- start: { line: 1, column: 24 },
- end: { line: 1, column: 28 }
- }
- },
- typeParameters: null,
- range: [20, 28],
- loc: {
- start: { line: 1, column: 20 },
- end: { line: 1, column: 28 }
- }
- },
- range: [20, 28],
- loc: {
- start: { line: 1, column: 20 },
- end: { line: 1, column: 28 }
- }
- },
- range: [17, 28],
- loc: {
- start: { line: 1, column: 17 },
- end: { line: 1, column: 28 }
- }
- },
- range: [0, 29],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 29 }
- }
- },
- 'declare function foo(): void;': {
- type: 'DeclareFunction',
- id: {
- type: 'Identifier',
- name: 'foo',
- typeAnnotation: {
- type: 'TypeAnnotation',
- typeAnnotation: {
- type: 'FunctionTypeAnnotation',
- params: [],
- returnType: {
- type: 'VoidTypeAnnotation',
- range: [27, 31],
- loc: {
- start: { line: 1, column: 27 },
- end: { line: 1, column: 31 }
- }
- },
- typeParameters: {
- type: 'TypeParameterDeclaration',
- params: [{
- type: 'Identifier',
- name: 'T',
- range: [21, 22],
- loc: {
- start: { line: 1, column: 21 },
- end: { line: 1, column: 22 }
- }
- }],
- range: [20, 23],
- loc: {
- start: { line: 1, column: 20 },
- end: { line: 1, column: 23 }
- }
- },
- range: [20, 31],
- loc: {
- start: { line: 1, column: 20 },
- end: { line: 1, column: 31 }
- }
- },
- range: [20, 31],
- loc: {
- start: { line: 1, column: 20 },
- end: { line: 1, column: 31 }
- }
- },
- range: [17, 31],
- loc: {
- start: { line: 1, column: 17 },
- end: { line: 1, column: 31 }
- }
- },
- range: [0, 32],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 32 }
- }
- },
- 'declare function foo(x: number, y: string): void;': {
- type: 'DeclareFunction',
- id: {
- type: 'Identifier',
- name: 'foo',
- typeAnnotation: {
- type: 'TypeAnnotation',
- typeAnnotation: {
- type: 'FunctionTypeAnnotation',
- params: [{
- type: 'FunctionTypeParam',
- name: {
- type: 'Identifier',
- name: 'x',
- range: [21, 22],
- loc: {
- start: { line: 1, column: 21 },
- end: { line: 1, column: 22 }
- }
- },
- typeAnnotation: {
- type: 'NumberTypeAnnotation',
- range: [24, 30],
- loc: {
- start: { line: 1, column: 24 },
- end: { line: 1, column: 30 }
- }
- },
- optional: false,
- range: [21, 30],
- loc: {
- start: { line: 1, column: 21 },
- end: { line: 1, column: 30 }
- }
- }, {
- type: 'FunctionTypeParam',
- name: {
- type: 'Identifier',
- name: 'y',
- range: [32, 33],
- loc: {
- start: { line: 1, column: 32 },
- end: { line: 1, column: 33 }
- }
- },
- typeAnnotation: {
- type: 'StringTypeAnnotation',
- range: [35, 41],
- loc: {
- start: { line: 1, column: 35 },
- end: { line: 1, column: 41 }
- }
- },
- optional: false,
- range: [32, 41],
- loc: {
- start: { line: 1, column: 32 },
- end: { line: 1, column: 41 }
- }
- }],
- returnType: {
- type: 'VoidTypeAnnotation',
- range: [44, 48],
- loc: {
- start: { line: 1, column: 44 },
- end: { line: 1, column: 48 }
- }
- },
- typeParameters: null,
- range: [20, 48],
- loc: {
- start: { line: 1, column: 20 },
- end: { line: 1, column: 48 }
- }
- },
- range: [20, 48],
- loc: {
- start: { line: 1, column: 20 },
- end: { line: 1, column: 48 }
- }
- },
- range: [17, 48],
- loc: {
- start: { line: 1, column: 17 },
- end: { line: 1, column: 48 }
- }
- },
- range: [0, 49],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 49 }
- }
- },
- 'declare class A {}': {
- type: 'DeclareClass',
- id: {
- type: 'Identifier',
- name: 'A',
- range: [14, 15],
- loc: {
- start: { line: 1, column: 14 },
- end: { line: 1, column: 15 }
- }
- },
- typeParameters: null,
- body: {
- type: 'ObjectTypeAnnotation',
- properties: [],
- indexers: [],
- callProperties: [],
- range: [16, 18],
- loc: {
- start: { line: 1, column: 16 },
- end: { line: 1, column: 18 }
- }
- },
- 'extends': [],
- range: [0, 18],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 18 }
- }
- },
- 'declare class A extends B { x: number }': {
- type: 'DeclareClass',
- id: {
- type: 'Identifier',
- name: 'A',
- range: [14, 15],
- loc: {
- start: { line: 1, column: 14 },
- end: { line: 1, column: 15 }
- }
- },
- typeParameters: {
- type: 'TypeParameterDeclaration',
- params: [{
- type: 'Identifier',
- name: 'T',
- range: [16, 17],
- loc: {
- start: { line: 1, column: 16 },
- end: { line: 1, column: 17 }
- }
- }],
- range: [15, 18],
- loc: {
- start: { line: 1, column: 15 },
- end: { line: 1, column: 18 }
- }
- },
- body: {
- type: 'ObjectTypeAnnotation',
- properties: [{
- type: 'ObjectTypeProperty',
- key: {
- type: 'Identifier',
- name: 'x',
- range: [34, 35],
- loc: {
- start: { line: 1, column: 34 },
- end: { line: 1, column: 35 }
- }
- },
- value: {
- type: 'NumberTypeAnnotation',
- range: [37, 43],
- loc: {
- start: { line: 1, column: 37 },
- end: { line: 1, column: 43 }
- }
- },
- optional: false,
- range: [34, 43],
- loc: {
- start: { line: 1, column: 34 },
- end: { line: 1, column: 43 }
- }
- }],
- indexers: [],
- callProperties: [],
- range: [32, 45],
- loc: {
- start: { line: 1, column: 32 },
- end: { line: 1, column: 45 }
- }
- },
- 'extends': [{
- type: 'InterfaceExtends',
- id: {
- type: 'Identifier',
- name: 'B',
- range: [27, 28],
- loc: {
- start: { line: 1, column: 27 },
- end: { line: 1, column: 28 }
- }
- },
- typeParameters: {
- type: 'TypeParameterInstantiation',
- params: [{
- type: 'GenericTypeAnnotation',
- id: {
- type: 'Identifier',
- name: 'T',
- range: [29, 30],
- loc: {
- start: { line: 1, column: 29 },
- end: { line: 1, column: 30 }
- }
- },
- typeParameters: null,
- range: [29, 30],
- loc: {
- start: { line: 1, column: 29 },
- end: { line: 1, column: 30 }
- }
- }],
- range: [28, 31],
- loc: {
- start: { line: 1, column: 28 },
- end: { line: 1, column: 31 }
- }
- },
- range: [27, 31],
- loc: {
- start: { line: 1, column: 27 },
- end: { line: 1, column: 31 }
- }
- }],
- range: [0, 45],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 45 }
- }
- },
- 'declare class A { static foo(): number; static x : string }': {
- type: 'DeclareClass',
- id: {
- type: 'Identifier',
- name: 'A',
- range: [14, 15],
- loc: {
- start: { line: 1, column: 14 },
- end: { line: 1, column: 15 }
- }
- },
- typeParameters: null,
- body: {
- type: 'ObjectTypeAnnotation',
- properties: [{
- type: 'ObjectTypeProperty',
- key: {
- type: 'Identifier',
- name: 'foo',
- range: [25, 28],
- loc: {
- start: { line: 1, column: 25 },
- end: { line: 1, column: 28 }
- }
- },
- value: {
- type: 'FunctionTypeAnnotation',
- params: [],
- returnType: {
- type: 'NumberTypeAnnotation',
- range: [32, 38],
- loc: {
- start: { line: 1, column: 32 },
- end: { line: 1, column: 38 }
- }
- },
- typeParameters: null,
- range: [18, 38],
- loc: {
- start: { line: 1, column: 18 },
- end: { line: 1, column: 38 }
- }
- },
- optional: false,
- 'static': true,
- range: [18, 38],
- loc: {
- start: { line: 1, column: 18 },
- end: { line: 1, column: 38 }
- }
- }, {
- type: 'ObjectTypeProperty',
- key: {
- type: 'Identifier',
- name: 'x',
- range: [47, 48],
- loc: {
- start: { line: 1, column: 47 },
- end: { line: 1, column: 48 }
- }
- },
- value: {
- type: 'StringTypeAnnotation',
- range: [51, 57],
- loc: {
- start: { line: 1, column: 51 },
- end: { line: 1, column: 57 }
- }
- },
- optional: false,
- 'static': true,
- range: [40, 57],
- loc: {
- start: { line: 1, column: 40 },
- end: { line: 1, column: 57 }
- }
- }],
- indexers: [],
- callProperties: [],
- range: [16, 59],
- loc: {
- start: { line: 1, column: 16 },
- end: { line: 1, column: 59 }
- }
- },
- 'extends': [],
- range: [0, 59],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 59 }
- }
- },
- 'declare class A { static [ indexer: number]: string }': {
- type: 'DeclareClass',
- id: {
- type: 'Identifier',
- name: 'A',
- range: [14, 15],
- loc: {
- start: { line: 1, column: 14 },
- end: { line: 1, column: 15 }
- }
- },
- typeParameters: null,
- body: {
- type: 'ObjectTypeAnnotation',
- properties: [],
- indexers: [{
- type: 'ObjectTypeIndexer',
- id: {
- type: 'Identifier',
- name: 'indexer',
- range: [27, 34],
- loc: {
- start: { line: 1, column: 27 },
- end: { line: 1, column: 34 }
- }
- },
- key: {
- type: 'NumberTypeAnnotation',
- range: [36, 42],
- loc: {
- start: { line: 1, column: 36 },
- end: { line: 1, column: 42 }
- }
- },
- value: {
- type: 'StringTypeAnnotation',
- range: [45, 51],
- loc: {
- start: { line: 1, column: 45 },
- end: { line: 1, column: 51 }
- }
- },
- 'static': true,
- range: [18, 51],
- loc: {
- start: { line: 1, column: 18 },
- end: { line: 1, column: 51 }
- }
- }],
- callProperties: [],
- range: [16, 53],
- loc: {
- start: { line: 1, column: 16 },
- end: { line: 1, column: 53 }
- }
- },
- 'extends': [],
- range: [0, 53],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 53 }
- }
- },
- 'declare class A { static () : number }': {
- type: 'DeclareClass',
- id: {
- type: 'Identifier',
- name: 'A',
- range: [14, 15],
- loc: {
- start: { line: 1, column: 14 },
- end: { line: 1, column: 15 }
- }
- },
- typeParameters: null,
- body: {
- type: 'ObjectTypeAnnotation',
- properties: [],
- indexers: [],
- callProperties: [{
- type: 'ObjectTypeCallProperty',
- value: {
- type: 'FunctionTypeAnnotation',
- params: [],
- returnType: {
- type: 'NumberTypeAnnotation',
- range: [30, 36],
- loc: {
- start: { line: 1, column: 30 },
- end: { line: 1, column: 36 }
- }
- },
- typeParameters: null,
- range: [25, 36],
- loc: {
- start: { line: 1, column: 25 },
- end: { line: 1, column: 36 }
- }
- },
- 'static': true,
- range: [18, 36],
- loc: {
- start: { line: 1, column: 18 },
- end: { line: 1, column: 36 }
- }
- }],
- range: [16, 38],
- loc: {
- start: { line: 1, column: 16 },
- end: { line: 1, column: 38 }
- }
- },
- 'extends': [],
- range: [0, 38],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 38 }
- }
- },
- },
- 'Declare Module': {
- 'declare module A {}': {
- type: 'DeclareModule',
- id: {
- type: 'Identifier',
- name: 'A',
- range: [15, 16],
- loc: {
- start: { line: 1, column: 15 },
- end: { line: 1, column: 16 }
- }
- },
- body: {
- type: 'BlockStatement',
- body: [],
- range: [17, 19],
- loc: {
- start: { line: 1, column: 17 },
- end: { line: 1, column: 19 }
- }
- },
- range: [0, 19],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 19 }
- }
- },
- 'declare module "./a/b.js" {}': {
- type: 'DeclareModule',
- id: {
- type: 'Literal',
- value: './a/b.js',
- raw: '"./a/b.js"',
- range: [15, 25],
- loc: {
- start: { line: 1, column: 15 },
- end: { line: 1, column: 25 }
- }
- },
- body: {
- type: 'BlockStatement',
- body: [],
- range: [26, 28],
- loc: {
- start: { line: 1, column: 26 },
- end: { line: 1, column: 28 }
- }
- },
- range: [0, 28],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 28 }
- }
- },
- 'declare module A { declare var x: number; }': {
- type: 'DeclareModule',
- id: {
- type: 'Identifier',
- name: 'A',
- range: [15, 16],
- loc: {
- start: { line: 1, column: 15 },
- end: { line: 1, column: 16 }
- }
- },
- body: {
- type: 'BlockStatement',
- body: [{
- type: 'DeclareVariable',
- id: {
- type: 'Identifier',
- name: 'x',
- typeAnnotation: {
- type: 'TypeAnnotation',
- typeAnnotation: {
- type: 'NumberTypeAnnotation',
- range: [34, 40],
- loc: {
- start: { line: 1, column: 34 },
- end: { line: 1, column: 40 }
- }
- },
- range: [32, 40],
- loc: {
- start: { line: 1, column: 32 },
- end: { line: 1, column: 40 }
- }
- },
- range: [31, 40],
- loc: {
- start: { line: 1, column: 31 },
- end: { line: 1, column: 40 }
- }
- },
- range: [19, 41],
- loc: {
- start: { line: 1, column: 19 },
- end: { line: 1, column: 41 }
- }
- }],
- range: [17, 43],
- loc: {
- start: { line: 1, column: 17 },
- end: { line: 1, column: 43 }
- }
- },
- range: [0, 43],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 43 }
- }
- },
- 'declare module A { declare function foo(): number; }': {
- type: 'DeclareModule',
- id: {
- type: 'Identifier',
- name: 'A',
- range: [15, 16],
- loc: {
- start: { line: 1, column: 15 },
- end: { line: 1, column: 16 }
- }
- },
- body: {
- type: 'BlockStatement',
- body: [{
- type: 'DeclareFunction',
- id: {
- type: 'Identifier',
- name: 'foo',
- typeAnnotation: {
- type: 'TypeAnnotation',
- typeAnnotation: {
- type: 'FunctionTypeAnnotation',
- params: [],
- returnType: {
- type: 'NumberTypeAnnotation',
- range: [43, 49],
- loc: {
- start: { line: 1, column: 43 },
- end: { line: 1, column: 49 }
- }
- },
- typeParameters: null,
- range: [39, 49],
- loc: {
- start: { line: 1, column: 39 },
- end: { line: 1, column: 49 }
- }
- },
- range: [39, 49],
- loc: {
- start: { line: 1, column: 39 },
- end: { line: 1, column: 49 }
- }
- },
- range: [36, 49],
- loc: {
- start: { line: 1, column: 36 },
- end: { line: 1, column: 49 }
- }
- },
- range: [19, 50],
- loc: {
- start: { line: 1, column: 19 },
- end: { line: 1, column: 50 }
- }
- }],
- range: [17, 52],
- loc: {
- start: { line: 1, column: 17 },
- end: { line: 1, column: 52 }
- }
- },
- range: [0, 52],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 52 }
- }
- },
- 'declare module A { declare class B { foo(): number; } }': {
- type: 'DeclareModule',
- id: {
- type: 'Identifier',
- name: 'A',
- range: [15, 16],
- loc: {
- start: { line: 1, column: 15 },
- end: { line: 1, column: 16 }
- }
- },
- body: {
- type: 'BlockStatement',
- body: [{
- type: 'DeclareClass',
- id: {
- type: 'Identifier',
- name: 'B',
- range: [33, 34],
- loc: {
- start: { line: 1, column: 33 },
- end: { line: 1, column: 34 }
- }
- },
- typeParameters: null,
- body: {
- type: 'ObjectTypeAnnotation',
- properties: [{
- type: 'ObjectTypeProperty',
- key: {
- type: 'Identifier',
- name: 'foo',
- range: [37, 40],
- loc: {
- start: { line: 1, column: 37 },
- end: { line: 1, column: 40 }
- }
- },
- value: {
- type: 'FunctionTypeAnnotation',
- params: [],
- returnType: {
- type: 'NumberTypeAnnotation',
- range: [44, 50],
- loc: {
- start: { line: 1, column: 44 },
- end: { line: 1, column: 50 }
- }
- },
- typeParameters: null,
- range: [37, 50],
- loc: {
- start: { line: 1, column: 37 },
- end: { line: 1, column: 50 }
- }
- },
- optional: false,
- range: [37, 50],
- loc: {
- start: { line: 1, column: 37 },
- end: { line: 1, column: 50 }
- }
- }],
- indexers: [],
- callProperties: [],
- range: [35, 53],
- loc: {
- start: { line: 1, column: 35 },
- end: { line: 1, column: 53 }
- }
- },
- 'extends': [],
- range: [19, 53],
- loc: {
- start: { line: 1, column: 19 },
- end: { line: 1, column: 53 }
- }
- }],
- range: [17, 55],
- loc: {
- start: { line: 1, column: 17 },
- end: { line: 1, column: 55 }
- }
- },
- range: [0, 55],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 55 }
- }
- },
- },
- 'Typecasts': {
- '(xxx: number)': {
- type: 'ExpressionStatement',
- expression: {
- type: 'TypeCastExpression',
- expression: {
- type: 'Identifier',
- name: 'xxx',
- range: [1, 4],
- loc: {
- start: { line: 1, column: 1 },
- end: { line: 1, column: 4 }
- }
- },
- typeAnnotation: {
- type: 'TypeAnnotation',
- typeAnnotation: {
- type: 'NumberTypeAnnotation',
- range: [6, 12],
- loc: {
- start: { line: 1, column: 6 },
- end: { line: 1, column: 12 }
- }
- },
- range: [4, 12],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 12 }
- }
- },
- range: [1, 12],
- loc: {
- start: { line: 1, column: 1 },
- end: { line: 1, column: 12 }
- }
- },
- range: [0, 13],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 13 }
- }
- },
- '({xxx: 0, yyy: "hey"}: {xxx: number; yyy: string})': {
- type: 'ExpressionStatement',
- expression: {
- type: 'TypeCastExpression',
- expression: {
- type: 'ObjectExpression',
- properties: [{
- type: 'Property',
- key: {
- type: 'Identifier',
- name: 'xxx',
- range: [2, 5],
- loc: {
- start: { line: 1, column: 2 },
- end: { line: 1, column: 5 }
- }
- },
- value: {
- type: 'Literal',
- value: 0,
- raw: '0',
- range: [7, 8],
- loc: {
- start: { line: 1, column: 7 },
- end: { line: 1, column: 8 }
- }
- },
- kind: 'init',
- method: false,
- shorthand: false,
- computed: false,
- range: [2, 8],
- loc: {
- start: { line: 1, column: 2 },
- end: { line: 1, column: 8 }
- }
- }, {
- type: 'Property',
- key: {
- type: 'Identifier',
- name: 'yyy',
- range: [10, 13],
- loc: {
- start: { line: 1, column: 10 },
- end: { line: 1, column: 13 }
- }
- },
- value: {
- type: 'Literal',
- value: 'hey',
- raw: '"hey"',
- range: [15, 20],
- loc: {
- start: { line: 1, column: 15 },
- end: { line: 1, column: 20 }
- }
- },
- kind: 'init',
- method: false,
- shorthand: false,
- computed: false,
- range: [10, 20],
- loc: {
- start: { line: 1, column: 10 },
- end: { line: 1, column: 20 }
- }
- }],
- range: [1, 21],
- loc: {
- start: { line: 1, column: 1 },
- end: { line: 1, column: 21 }
- }
- },
- typeAnnotation: {
- type: 'TypeAnnotation',
- typeAnnotation: {
- type: 'ObjectTypeAnnotation',
- properties: [{
- type: 'ObjectTypeProperty',
- key: {
- type: 'Identifier',
- name: 'xxx',
- range: [24, 27],
- loc: {
- start: { line: 1, column: 24 },
- end: { line: 1, column: 27 }
- }
- },
- value: {
- type: 'NumberTypeAnnotation',
- range: [29, 35],
- loc: {
- start: { line: 1, column: 29 },
- end: { line: 1, column: 35 }
- }
- },
- optional: false,
- range: [24, 35],
- loc: {
- start: { line: 1, column: 24 },
- end: { line: 1, column: 35 }
- }
- }, {
- type: 'ObjectTypeProperty',
- key: {
- type: 'Identifier',
- name: 'yyy',
- range: [37, 40],
- loc: {
- start: { line: 1, column: 37 },
- end: { line: 1, column: 40 }
- }
- },
- value: {
- type: 'StringTypeAnnotation',
- range: [42, 48],
- loc: {
- start: { line: 1, column: 42 },
- end: { line: 1, column: 48 }
- }
- },
- optional: false,
- range: [37, 48],
- loc: {
- start: { line: 1, column: 37 },
- end: { line: 1, column: 48 }
- }
- }],
- indexers: [],
- callProperties: [],
- range: [23, 49],
- loc: {
- start: { line: 1, column: 23 },
- end: { line: 1, column: 49 }
- }
- },
- range: [21, 49],
- loc: {
- start: { line: 1, column: 21 },
- end: { line: 1, column: 49 }
- }
- },
- range: [1, 49],
- loc: {
- start: { line: 1, column: 1 },
- end: { line: 1, column: 49 }
- }
- },
- range: [0, 50],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 50 }
- }
- },
- '((xxx) => xxx + 1: (xxx: number) => number)': {
- type: 'ExpressionStatement',
- expression: {
- type: 'TypeCastExpression',
- expression: {
- type: 'ArrowFunctionExpression',
- id: null,
- params: [{
- type: 'Identifier',
- name: 'xxx',
- range: [2, 5],
- loc: {
- start: { line: 1, column: 2 },
- end: { line: 1, column: 5 }
- }
- }],
- body: {
- type: 'BinaryExpression',
- operator: '+',
- left: {
- type: 'Identifier',
- name: 'xxx',
- range: [10, 13],
- loc: {
- start: { line: 1, column: 10 },
- end: { line: 1, column: 13 }
- }
- },
- right: {
- type: 'Literal',
- value: 1,
- raw: '1',
- range: [16, 17],
- loc: {
- start: { line: 1, column: 16 },
- end: { line: 1, column: 17 }
- }
- },
- range: [10, 17],
- loc: {
- start: { line: 1, column: 10 },
- end: { line: 1, column: 17 }
- }
- },
- generator: false,
- expression: true,
- range: [1, 17],
- loc: {
- start: { line: 1, column: 1 },
- end: { line: 1, column: 17 }
- }
- },
- typeAnnotation: {
- type: 'TypeAnnotation',
- typeAnnotation: {
- type: 'FunctionTypeAnnotation',
- params: [{
- type: 'FunctionTypeParam',
- name: {
- type: 'Identifier',
- name: 'xxx',
- range: [20, 23],
- loc: {
- start: { line: 1, column: 20 },
- end: { line: 1, column: 23 }
- }
- },
- typeAnnotation: {
- type: 'NumberTypeAnnotation',
- range: [25, 31],
- loc: {
- start: { line: 1, column: 25 },
- end: { line: 1, column: 31 }
- }
- },
- optional: false,
- range: [20, 31],
- loc: {
- start: { line: 1, column: 20 },
- end: { line: 1, column: 31 }
- }
- }],
- returnType: {
- type: 'NumberTypeAnnotation',
- range: [36, 42],
- loc: {
- start: { line: 1, column: 36 },
- end: { line: 1, column: 42 }
- }
- },
- typeParameters: null,
- range: [19, 42],
- loc: {
- start: { line: 1, column: 19 },
- end: { line: 1, column: 42 }
- }
- },
- range: [17, 42],
- loc: {
- start: { line: 1, column: 17 },
- end: { line: 1, column: 42 }
- }
- },
- range: [1, 42],
- loc: {
- start: { line: 1, column: 1 },
- end: { line: 1, column: 42 }
- }
- },
- range: [0, 43],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 43 }
- }
- },
- '((xxx: number), (yyy: string))': {
- type: 'ExpressionStatement',
- expression: {
- type: 'SequenceExpression',
- expressions: [{
- type: 'TypeCastExpression',
- expression: {
- type: 'Identifier',
- name: 'xxx',
- range: [2, 5],
- loc: {
- start: { line: 1, column: 2 },
- end: { line: 1, column: 5 }
- }
- },
- typeAnnotation: {
- type: 'TypeAnnotation',
- typeAnnotation: {
- type: 'NumberTypeAnnotation',
- range: [7, 13],
- loc: {
- start: { line: 1, column: 7 },
- end: { line: 1, column: 13 }
- }
- },
- range: [5, 13],
- loc: {
- start: { line: 1, column: 5 },
- end: { line: 1, column: 13 }
- }
- },
- range: [2, 13],
- loc: {
- start: { line: 1, column: 2 },
- end: { line: 1, column: 13 }
- }
- }, {
- type: 'TypeCastExpression',
- expression: {
- type: 'Identifier',
- name: 'yyy',
- range: [17, 20],
- loc: {
- start: { line: 1, column: 17 },
- end: { line: 1, column: 20 }
- }
- },
- typeAnnotation: {
- type: 'TypeAnnotation',
- typeAnnotation: {
- type: 'StringTypeAnnotation',
- range: [22, 28],
- loc: {
- start: { line: 1, column: 22 },
- end: { line: 1, column: 28 }
- }
- },
- range: [20, 28],
- loc: {
- start: { line: 1, column: 20 },
- end: { line: 1, column: 28 }
- }
- },
- range: [17, 28],
- loc: {
- start: { line: 1, column: 17 },
- end: { line: 1, column: 28 }
- }
- }],
- range: [1, 29],
- loc: {
- start: { line: 1, column: 1 },
- end: { line: 1, column: 29 }
- }
- },
- range: [0, 30],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 30 }
- }
- },
- },
- 'Bounded Polymorphism': {
- 'class A {}': {
- type: 'ClassDeclaration',
- id: {
- type: 'Identifier',
- name: 'A',
- range: [6, 7],
- loc: {
- start: { line: 1, column: 6 },
- end: { line: 1, column: 7 }
- }
- },
- superClass: null,
- body: {
- type: 'ClassBody',
- body: [],
- range: [16, 18],
- loc: {
- start: { line: 1, column: 16 },
- end: { line: 1, column: 18 }
- }
- },
- typeParameters: {
- type: 'TypeParameterDeclaration',
- params: [{
- type: 'Identifier',
- name: 'T',
- typeAnnotation: {
- type: 'TypeAnnotation',
- typeAnnotation: {
- type: 'GenericTypeAnnotation',
- id: {
- type: 'Identifier',
- name: 'Foo',
- range: [11, 14],
- loc: {
- start: { line: 1, column: 11 },
- end: { line: 1, column: 14 }
- }
- },
- typeParameters: null,
- range: [11, 14],
- loc: {
- start: { line: 1, column: 11 },
- end: { line: 1, column: 14 }
- }
- },
- range: [9, 14],
- loc: {
- start: { line: 1, column: 9 },
- end: { line: 1, column: 14 }
- }
- },
- range: [8, 14],
- loc: {
- start: { line: 1, column: 8 },
- end: { line: 1, column: 14 }
- }
- }],
- range: [7, 15],
- loc: {
- start: { line: 1, column: 7 },
- end: { line: 1, column: 15 }
- }
- },
- range: [0, 18],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 18 }
- }
- },
- 'function bar() {}': {
- type: 'FunctionDeclaration',
- id: {
- type: 'Identifier',
- name: 'bar',
- range: [9, 12],
- loc: {
- start: { line: 1, column: 9 },
- end: { line: 1, column: 12 }
- }
- },
- params: [],
- body: {
- type: 'BlockStatement',
- body: [],
- range: [27, 29],
- loc: {
- start: { line: 1, column: 27 },
- end: { line: 1, column: 29 }
- }
- },
- generator: false,
- expression: false,
- typeParameters: {
- type: 'TypeParameterDeclaration',
- params: [{
- type: 'Identifier',
- name: 'T',
- typeAnnotation: {
- type: 'TypeAnnotation',
- typeAnnotation: {
- type: 'NullableTypeAnnotation',
- typeAnnotation: {
- type: 'NumberTypeAnnotation',
- range: [17, 23],
- loc: {
- start: { line: 1, column: 17 },
- end: { line: 1, column: 23 }
- }
- },
- range: [16, 23],
- loc: {
- start: { line: 1, column: 16 },
- end: { line: 1, column: 23 }
- }
- },
- range: [14, 23],
- loc: {
- start: { line: 1, column: 14 },
- end: { line: 1, column: 23 }
- }
- },
- range: [13, 23],
- loc: {
- start: { line: 1, column: 13 },
- end: { line: 1, column: 23 }
- }
- }],
- range: [12, 24],
- loc: {
- start: { line: 1, column: 12 },
- end: { line: 1, column: 24 }
- }
- },
- range: [0, 29],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 29 }
- }
- },
- },
-};
-
-if (typeof exports !== "undefined") {
- var test = require("./driver.js").test;
-}
-
-for (var ns in fbTestFixture) {
- ns = fbTestFixture[ns];
- for (var code in ns) {
- test(code, {
- type: "Program",
- body: [ns[code]]
- }, {
- ecmaVersion: 7,
- sourceType: "module",
- plugins: { jsx: true, flow: true },
- features: { "es7.asyncFunctions": true },
- locations: true,
- ranges: true
- });
- }
-}
diff --git a/test/tests-harmony.js b/test/tests-harmony.js
deleted file mode 100755
index 71b9be9c08..0000000000
--- a/test/tests-harmony.js
+++ /dev/null
@@ -1,15598 +0,0 @@
-/*
- Copyright (C) 2012 Ariya Hidayat
- Copyright (C) 2012 Joost-Wim Boekesteijn
- Copyright (C) 2012 Yusuke Suzuki
- Copyright (C) 2012 Arpad Borsos
- Copyright (C) 2011 Ariya Hidayat
- Copyright (C) 2011 Yusuke Suzuki
- Copyright (C) 2011 Arpad Borsos
- Copyright (C) 2014 Ingvar Stepanyan
-
- Redistribution and use in source and binary forms, with or without
- modification, are permitted provided that the following conditions are met:
-
- * Redistributions of source code must retain the above copyright
- notice, this list of conditions and the following disclaimer.
- * Redistributions in binary form must reproduce the above copyright
- notice, this list of conditions and the following disclaimer in the
- documentation and/or other materials provided with the distribution.
-
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
- ARE DISCLAIMED. IN NO EVENT SHALL BE LIABLE FOR ANY
- DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
- THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
-*/
-
-if (typeof exports != "undefined") {
- var test = require("./driver.js").test;
- var testFail = require("./driver.js").testFail;
- var testAssert = require("./driver.js").testAssert;
-}
-
-/*
- Tests below were automatically converted from https://github.com/ariya/esprima/blob/2bb17ef9a45c88e82d72c2c61b7b7af93caef028/test/harmonytest.js.
-
- Manually fixed locations for:
- - parenthesized expressions (include brackets into expression's location)
- - expression statements (excluded spaces after statement's semicolon)
- - arrow and method functions (included arguments into function's location)
- - template elements (excluded '`', '${' and '}' from element's location)
-*/
-
-// ES6 Unicode Code Point Escape Sequence
-
-test("\"\\u{714E}\\u{8336}\"", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "Literal",
- value: "煎茶",
- raw: "\"\\u{714E}\\u{8336}\"",
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 18}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 18}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 18}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("\"\\u{20BB7}\\u{91CE}\\u{5BB6}\"", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "Literal",
- value: "𠮷野家",
- raw: "\"\\u{20BB7}\\u{91CE}\\u{5BB6}\"",
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 27}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 27}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 27}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-// ES6: Numeric Literal
-
-test("00", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "Literal",
- value: 0,
- raw: "00",
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 2}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 2}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 2}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("0o0", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "Literal",
- value: 0,
- raw: "0o0",
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 3}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 3}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 3}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("function test() {'use strict'; 0o0; }", {
- type: "Program",
- body: [{
- type: "FunctionDeclaration",
- id: {
- type: "Identifier",
- name: "test",
- loc: {
- start: {line: 1, column: 9},
- end: {line: 1, column: 13}
- }
- },
- params: [],
- body: {
- type: "BlockStatement",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "Literal",
- value: "use strict",
- raw: "'use strict'",
- loc: {
- start: {line: 1, column: 17},
- end: {line: 1, column: 29}
- }
- },
- loc: {
- start: {line: 1, column: 17},
- end: {line: 1, column: 30}
- }
- },
- {
- type: "ExpressionStatement",
- expression: {
- type: "Literal",
- value: 0,
- raw: "0o0",
- loc: {
- start: {line: 1, column: 31},
- end: {line: 1, column: 34}
- }
- },
- loc: {
- start: {line: 1, column: 31},
- end: {line: 1, column: 35}
- }
- }
- ],
- loc: {
- start: {line: 1, column: 16},
- end: {line: 1, column: 37}
- }
- },
- generator: false,
- expression: false,
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 37}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 37}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("0o2", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "Literal",
- value: 2,
- raw: "0o2",
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 3}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 3}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 3}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("0o12", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "Literal",
- value: 10,
- raw: "0o12",
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 4}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 4}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 4}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("0O0", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "Literal",
- value: 0,
- raw: "0O0",
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 3}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 3}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 3}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("function test() {'use strict'; 0O0; }", {
- type: "Program",
- body: [{
- type: "FunctionDeclaration",
- id: {
- type: "Identifier",
- name: "test",
- loc: {
- start: {line: 1, column: 9},
- end: {line: 1, column: 13}
- }
- },
- params: [],
- body: {
- type: "BlockStatement",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "Literal",
- value: "use strict",
- raw: "'use strict'",
- loc: {
- start: {line: 1, column: 17},
- end: {line: 1, column: 29}
- }
- },
- loc: {
- start: {line: 1, column: 17},
- end: {line: 1, column: 30}
- }
- },
- {
- type: "ExpressionStatement",
- expression: {
- type: "Literal",
- value: 0,
- raw: "0O0",
- loc: {
- start: {line: 1, column: 31},
- end: {line: 1, column: 34}
- }
- },
- loc: {
- start: {line: 1, column: 31},
- end: {line: 1, column: 35}
- }
- }
- ],
- loc: {
- start: {line: 1, column: 16},
- end: {line: 1, column: 37}
- }
- },
- generator: false,
- expression: false,
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 37}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 37}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("0O2", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "Literal",
- value: 2,
- raw: "0O2",
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 3}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 3}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 3}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("0O12", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "Literal",
- value: 10,
- raw: "0O12",
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 4}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 4}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 4}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("0b0", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "Literal",
- value: 0,
- raw: "0b0",
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 3}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 3}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 3}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("0b1", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "Literal",
- value: 1,
- raw: "0b1",
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 3}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 3}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 3}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("0b10", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "Literal",
- value: 2,
- raw: "0b10",
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 4}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 4}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 4}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("0B0", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "Literal",
- value: 0,
- raw: "0B0",
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 3}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 3}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 3}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("0B1", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "Literal",
- value: 1,
- raw: "0B1",
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 3}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 3}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 3}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("0B10", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "Literal",
- value: 2,
- raw: "0B10",
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 4}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 4}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 4}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-// ES6 Template Strings
-
-test("`42`", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "TemplateLiteral",
- quasis: [{
- type: "TemplateElement",
- value: {raw: "42", cooked: "42"},
- tail: true,
- loc: {
- start: {line: 1, column: 1},
- end: {line: 1, column: 3}
- }
- }],
- expressions: [],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 4}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 4}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 4}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("raw`42`", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "TaggedTemplateExpression",
- tag: {
- type: "Identifier",
- name: "raw",
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 3}
- }
- },
- quasi: {
- type: "TemplateLiteral",
- quasis: [{
- type: "TemplateElement",
- value: {raw: "42", cooked: "42"},
- tail: true,
- loc: {
- start: {line: 1, column: 4},
- end: {line: 1, column: 6}
- }
- }],
- expressions: [],
- loc: {
- start: {line: 1, column: 3},
- end: {line: 1, column: 7}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 7}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 7}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 7}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("raw`hello ${name}`", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "TaggedTemplateExpression",
- tag: {
- type: "Identifier",
- name: "raw",
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 3}
- }
- },
- quasi: {
- type: "TemplateLiteral",
- quasis: [
- {
- type: "TemplateElement",
- value: {raw: "hello ", cooked: "hello "},
- tail: false,
- loc: {
- start: {line: 1, column: 4},
- end: {line: 1, column: 10}
- }
- },
- {
- type: "TemplateElement",
- value: {raw: "", cooked: ""},
- tail: true,
- loc: {
- start: {line: 1, column: 17},
- end: {line: 1, column: 17}
- }
- }
- ],
- expressions: [{
- type: "Identifier",
- name: "name",
- loc: {
- start: {line: 1, column: 12},
- end: {line: 1, column: 16}
- }
- }],
- loc: {
- start: {line: 1, column: 3},
- end: {line: 1, column: 18}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 18}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 18}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 18}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("`$`", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "TemplateLiteral",
- quasis: [{
- type: "TemplateElement",
- value: {raw: "$", cooked: "$"},
- tail: true,
- loc: {
- start: {line: 1, column: 1},
- end: {line: 1, column: 2}
- }
- }],
- expressions: [],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 3}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 3}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 3}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("`\\n\\r\\b\\v\\t\\f\\\n\\\r\n`", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "TemplateLiteral",
- quasis: [{
- type: "TemplateElement",
- value: {raw: "\\n\\r\\b\\v\\t\\f\\\n\\\r\n", cooked: "\n\r\b\u000b\t\f"},
- tail: true,
- loc: {
- start: {line: 1, column: 1},
- end: {line: 3, column: 0}
- }
- }],
- expressions: [],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 3, column: 1}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 3, column: 1}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 3, column: 1}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("`\n\r\n`", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "TemplateLiteral",
- quasis: [{
- type: "TemplateElement",
- value: {raw: "\n\r\n", cooked: "\n\n"},
- tail: true,
- loc: {
- start: {line: 1, column: 1},
- end: {line: 3, column: 0}
- }
- }],
- expressions: [],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 3, column: 1}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 3, column: 1}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 3, column: 1}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("`\\u{000042}\\u0042\\x42u0\\102\\A`", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "TemplateLiteral",
- quasis: [{
- type: "TemplateElement",
- value: {raw: "\\u{000042}\\u0042\\x42u0\\102\\A", cooked: "BBBu0BA"},
- tail: true,
- loc: {
- start: {line: 1, column: 1},
- end: {line: 1, column: 29}
- }
- }],
- expressions: [],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 30}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 30}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 30}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("new raw`42`", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "NewExpression",
- callee: {
- type: "TaggedTemplateExpression",
- tag: {
- type: "Identifier",
- name: "raw",
- loc: {
- start: {line: 1, column: 4},
- end: {line: 1, column: 7}
- }
- },
- quasi: {
- type: "TemplateLiteral",
- quasis: [{
- type: "TemplateElement",
- value: {raw: "42", cooked: "42"},
- tail: true,
- loc: {
- start: {line: 1, column: 8},
- end: {line: 1, column: 10}
- }
- }],
- expressions: [],
- loc: {
- start: {line: 1, column: 7},
- end: {line: 1, column: 11}
- }
- },
- loc: {
- start: {line: 1, column: 4},
- end: {line: 1, column: 11}
- }
- },
- arguments: [],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 11}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 11}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 11}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("`outer${{x: {y: 10}}}bar${`nested${function(){return 1;}}endnest`}end`",{
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "TemplateLiteral",
- expressions: [
- {
- type: "ObjectExpression",
- properties: [
- {
- type: "Property",
- method: false,
- shorthand: false,
- computed: false,
- key: {
- type: "Identifier",
- name: "x"
- },
- value: {
- type: "ObjectExpression",
- properties: [
- {
- type: "Property",
- method: false,
- shorthand: false,
- computed: false,
- key: {
- type: "Identifier",
- name: "y"
- },
- value: {
- type: "Literal",
- value: 10,
- raw: "10"
- },
- kind: "init"
- }
- ]
- },
- kind: "init"
- }
- ]
- },
- {
- type: "TemplateLiteral",
- expressions: [
- {
- type: "FunctionExpression",
- id: null,
- params: [],
- generator: false,
- body: {
- type: "BlockStatement",
- body: [
- {
- type: "ReturnStatement",
- argument: {
- type: "Literal",
- value: 1,
- raw: "1"
- }
- }
- ]
- },
- expression: false
- }
- ],
- quasis: [
- {
- type: "TemplateElement",
- value: {
- cooked: "nested",
- raw: "nested"
- },
- tail: false
- },
- {
- type: "TemplateElement",
- value: {
- cooked: "endnest",
- raw: "endnest"
- },
- tail: true
- }
- ]
- }
- ],
- quasis: [
- {
- type: "TemplateElement",
- value: {
- cooked: "outer",
- raw: "outer"
- },
- tail: false
- },
- {
- type: "TemplateElement",
- value: {
- cooked: "bar",
- raw: "bar"
- },
- tail: false
- },
- {
- type: "TemplateElement",
- value: {
- cooked: "end",
- raw: "end"
- },
- tail: true
- }
- ]
- }
- }
- ]
-}, {
- ecmaVersion: 6
-});
-
-
-// ES6: Switch Case Declaration
-
-test("switch (answer) { case 42: let t = 42; break; }", {
- type: "Program",
- body: [{
- type: "SwitchStatement",
- discriminant: {
- type: "Identifier",
- name: "answer",
- loc: {
- start: {line: 1, column: 8},
- end: {line: 1, column: 14}
- }
- },
- cases: [{
- type: "SwitchCase",
- test: {
- type: "Literal",
- value: 42,
- raw: "42",
- loc: {
- start: {line: 1, column: 23},
- end: {line: 1, column: 25}
- }
- },
- consequent: [
- {
- type: "VariableDeclaration",
- declarations: [{
- type: "VariableDeclarator",
- id: {
- type: "Identifier",
- name: "t",
- loc: {
- start: {line: 1, column: 31},
- end: {line: 1, column: 32}
- }
- },
- init: {
- type: "Literal",
- value: 42,
- raw: "42",
- loc: {
- start: {line: 1, column: 35},
- end: {line: 1, column: 37}
- }
- },
- loc: {
- start: {line: 1, column: 31},
- end: {line: 1, column: 37}
- }
- }],
- kind: "let",
- loc: {
- start: {line: 1, column: 27},
- end: {line: 1, column: 38}
- }
- },
- {
- type: "BreakStatement",
- label: null,
- loc: {
- start: {line: 1, column: 39},
- end: {line: 1, column: 45}
- }
- }
- ],
- loc: {
- start: {line: 1, column: 18},
- end: {line: 1, column: 45}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 47}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 47}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-// ES6: Arrow Function
-
-test("() => \"test\"", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "ArrowFunctionExpression",
- id: null,
- params: [],
- body: {
- type: "Literal",
- value: "test",
- raw: "\"test\"",
- loc: {
- start: {line: 1, column: 6},
- end: {line: 1, column: 12}
- }
- },
- generator: false,
- expression: true,
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 12}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 12}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 12}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("e => \"test\"", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "ArrowFunctionExpression",
- id: null,
- params: [{
- type: "Identifier",
- name: "e",
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 1}
- }
- }],
- body: {
- type: "Literal",
- value: "test",
- raw: "\"test\"",
- loc: {
- start: {line: 1, column: 5},
- end: {line: 1, column: 11}
- }
- },
- generator: false,
- expression: true,
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 11}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 11}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 11}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("(e) => \"test\"", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "ArrowFunctionExpression",
- id: null,
- params: [{
- type: "Identifier",
- name: "e",
- loc: {
- start: {line: 1, column: 1},
- end: {line: 1, column: 2}
- }
- }],
- body: {
- type: "Literal",
- value: "test",
- raw: "\"test\"",
- loc: {
- start: {line: 1, column: 7},
- end: {line: 1, column: 13}
- }
- },
- generator: false,
- expression: true,
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 13}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 13}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 13}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("(a, b) => \"test\"", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "ArrowFunctionExpression",
- id: null,
- params: [
- {
- type: "Identifier",
- name: "a",
- loc: {
- start: {line: 1, column: 1},
- end: {line: 1, column: 2}
- }
- },
- {
- type: "Identifier",
- name: "b",
- loc: {
- start: {line: 1, column: 4},
- end: {line: 1, column: 5}
- }
- }
- ],
- body: {
- type: "Literal",
- value: "test",
- raw: "\"test\"",
- loc: {
- start: {line: 1, column: 10},
- end: {line: 1, column: 16}
- }
- },
- generator: false,
- expression: true,
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 16}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 16}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 16}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("e => { 42; }", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "ArrowFunctionExpression",
- id: null,
- params: [{
- type: "Identifier",
- name: "e",
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 1}
- }
- }],
- body: {
- type: "BlockStatement",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "Literal",
- value: 42,
- raw: "42",
- loc: {
- start: {line: 1, column: 7},
- end: {line: 1, column: 9}
- }
- },
- loc: {
- start: {line: 1, column: 7},
- end: {line: 1, column: 10}
- }
- }],
- loc: {
- start: {line: 1, column: 5},
- end: {line: 1, column: 12}
- }
- },
- generator: false,
- expression: false,
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 12}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 12}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 12}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("e => ({ property: 42 })", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "ArrowFunctionExpression",
- id: null,
- params: [{
- type: "Identifier",
- name: "e",
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 1}
- }
- }],
- body: {
- type: "ObjectExpression",
- properties: [{
- type: "Property",
- key: {
- type: "Identifier",
- name: "property",
- loc: {
- start: {line: 1, column: 8},
- end: {line: 1, column: 16}
- }
- },
- value: {
- type: "Literal",
- value: 42,
- raw: "42",
- loc: {
- start: {line: 1, column: 18},
- end: {line: 1, column: 20}
- }
- },
- kind: "init",
- method: false,
- shorthand: false,
- computed: false,
- loc: {
- start: {line: 1, column: 8},
- end: {line: 1, column: 20}
- }
- }],
- loc: {
- start: {line: 1, column: 6},
- end: {line: 1, column: 22}
- }
- },
- generator: false,
- expression: true,
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 23}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 23}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 23}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("e => { label: 42 }", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "ArrowFunctionExpression",
- id: null,
- params: [{
- type: "Identifier",
- name: "e",
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 1}
- }
- }],
- body: {
- type: "BlockStatement",
- body: [{
- type: "LabeledStatement",
- label: {
- type: "Identifier",
- name: "label",
- loc: {
- start: {line: 1, column: 7},
- end: {line: 1, column: 12}
- }
- },
- body: {
- type: "ExpressionStatement",
- expression: {
- type: "Literal",
- value: 42,
- raw: "42",
- loc: {
- start: {line: 1, column: 14},
- end: {line: 1, column: 16}
- }
- },
- loc: {
- start: {line: 1, column: 14},
- end: {line: 1, column: 16}
- }
- },
- loc: {
- start: {line: 1, column: 7},
- end: {line: 1, column: 16}
- }
- }],
- loc: {
- start: {line: 1, column: 5},
- end: {line: 1, column: 18}
- }
- },
- generator: false,
- expression: false,
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 18}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 18}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 18}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("(a, b) => { 42; }", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "ArrowFunctionExpression",
- id: null,
- params: [
- {
- type: "Identifier",
- name: "a",
- loc: {
- start: {line: 1, column: 1},
- end: {line: 1, column: 2}
- }
- },
- {
- type: "Identifier",
- name: "b",
- loc: {
- start: {line: 1, column: 4},
- end: {line: 1, column: 5}
- }
- }
- ],
- body: {
- type: "BlockStatement",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "Literal",
- value: 42,
- raw: "42",
- loc: {
- start: {line: 1, column: 12},
- end: {line: 1, column: 14}
- }
- },
- loc: {
- start: {line: 1, column: 12},
- end: {line: 1, column: 15}
- }
- }],
- loc: {
- start: {line: 1, column: 10},
- end: {line: 1, column: 17}
- }
- },
- generator: false,
- expression: false,
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 17}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 17}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 17}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("([a, , b]) => 42", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "ArrowFunctionExpression",
- id: null,
- params: [{
- type: "ArrayPattern",
- elements: [
- {
- type: "Identifier",
- name: "a",
- loc: {
- start: {line: 1, column: 2},
- end: {line: 1, column: 3}
- }
- },
- null,
- {
- type: "Identifier",
- name: "b",
- loc: {
- start: {line: 1, column: 7},
- end: {line: 1, column: 8}
- }
- }
- ],
- loc: {
- start: {line: 1, column: 1},
- end: {line: 1, column: 9}
- }
- }],
- body: {
- type: "Literal",
- value: 42,
- raw: "42",
- loc: {
- start: {line: 1, column: 14},
- end: {line: 1, column: 16}
- }
- },
- generator: false,
- expression: true,
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 16}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 16}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 16}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-testFail("([a.a]) => 42", "Assigning to rvalue (1:2)", {ecmaVersion: 6});
-
-test("(x=1) => x * x", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "ArrowFunctionExpression",
- id: null,
- params: [{
- type: "AssignmentPattern",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {line: 1, column: 1},
- end: {line: 1, column: 2}
- }
- },
- right: {
- type: "Literal",
- value: 1,
- raw: "1",
- loc: {
- start: {line: 1, column: 3},
- end: {line: 1, column: 4}
- }
- },
- loc: {
- start: {line: 1, column: 1},
- end: {line: 1, column: 4}
- }
- }],
- body: {
- type: "BinaryExpression",
- operator: "*",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {line: 1, column: 9},
- end: {line: 1, column: 10}
- }
- },
- right: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {line: 1, column: 13},
- end: {line: 1, column: 14}
- }
- },
- loc: {
- start: {line: 1, column: 9},
- end: {line: 1, column: 14}
- }
- },
- generator: false,
- expression: true,
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 14}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 14}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 14}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("eval => 42", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "ArrowFunctionExpression",
- id: null,
- params: [{
- type: "Identifier",
- name: "eval",
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 4}
- }
- }],
- body: {
- type: "Literal",
- value: 42,
- raw: "42",
- loc: {
- start: {line: 1, column: 8},
- end: {line: 1, column: 10}
- }
- },
- generator: false,
- expression: true,
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 10}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 10}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 10}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("arguments => 42", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "ArrowFunctionExpression",
- id: null,
- params: [{
- type: "Identifier",
- name: "arguments",
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 9}
- }
- }],
- body: {
- type: "Literal",
- value: 42,
- raw: "42",
- loc: {
- start: {line: 1, column: 13},
- end: {line: 1, column: 15}
- }
- },
- generator: false,
- expression: true,
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 15}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 15}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 15}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("(a) => 00", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "ArrowFunctionExpression",
- id: null,
- params: [{
- type: "Identifier",
- name: "a",
- loc: {
- start: {line: 1, column: 1},
- end: {line: 1, column: 2}
- }
- }],
- body: {
- type: "Literal",
- value: 0,
- raw: "00",
- loc: {
- start: {line: 1, column: 7},
- end: {line: 1, column: 9}
- }
- },
- generator: false,
- expression: true,
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 9}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 9}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 9}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("(eval, a) => 42", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "ArrowFunctionExpression",
- id: null,
- params: [
- {
- type: "Identifier",
- name: "eval",
- loc: {
- start: {line: 1, column: 1},
- end: {line: 1, column: 5}
- }
- },
- {
- type: "Identifier",
- name: "a",
- loc: {
- start: {line: 1, column: 7},
- end: {line: 1, column: 8}
- }
- }
- ],
- body: {
- type: "Literal",
- value: 42,
- raw: "42",
- loc: {
- start: {line: 1, column: 13},
- end: {line: 1, column: 15}
- }
- },
- generator: false,
- expression: true,
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 15}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 15}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 15}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("(eval = 10) => 42", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "ArrowFunctionExpression",
- id: null,
- params: [{
- type: "AssignmentPattern",
- left: {
- type: "Identifier",
- name: "eval",
- loc: {
- start: {line: 1, column: 1},
- end: {line: 1, column: 5}
- }
- },
- right: {
- type: "Literal",
- value: 10,
- raw: "10",
- loc: {
- start: {line: 1, column: 8},
- end: {line: 1, column: 10}
- }
- },
- loc: {
- start: {line: 1, column: 1},
- end: {line: 1, column: 10}
- }
- }],
- body: {
- type: "Literal",
- value: 42,
- raw: "42",
- loc: {
- start: {line: 1, column: 15},
- end: {line: 1, column: 17}
- }
- },
- generator: false,
- expression: true,
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 17}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 17}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 17}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("(eval, a = 10) => 42", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "ArrowFunctionExpression",
- id: null,
- params: [
- {
- type: "Identifier",
- name: "eval",
- loc: {
- start: {line: 1, column: 1},
- end: {line: 1, column: 5}
- }
- },
- {
- type: "AssignmentPattern",
- left: {
- type: "Identifier",
- name: "a",
- loc: {
- start: {line: 1, column: 7},
- end: {line: 1, column: 8}
- }
- },
- right: {
- type: "Literal",
- value: 10,
- raw: "10",
- loc: {
- start: {line: 1, column: 11},
- end: {line: 1, column: 13}
- }
- },
- loc: {
- start: {line: 1, column: 7},
- end: {line: 1, column: 13}
- }
- }
- ],
- body: {
- type: "Literal",
- value: 42,
- raw: "42",
- loc: {
- start: {line: 1, column: 18},
- end: {line: 1, column: 20}
- }
- },
- generator: false,
- expression: true,
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 20}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 20}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 20}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("(x => x)", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "ArrowFunctionExpression",
- id: null,
- params: [{
- type: "Identifier",
- name: "x",
- loc: {
- start: {line: 1, column: 1},
- end: {line: 1, column: 2}
- }
- }],
- body: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {line: 1, column: 6},
- end: {line: 1, column: 7}
- }
- },
- generator: false,
- expression: true,
- loc: {
- start: {line: 1, column: 1},
- end: {line: 1, column: 7}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 8}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 8}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("x => y => 42", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "ArrowFunctionExpression",
- id: null,
- params: [{
- type: "Identifier",
- name: "x",
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 1}
- }
- }],
- body: {
- type: "ArrowFunctionExpression",
- id: null,
- params: [{
- type: "Identifier",
- name: "y",
- loc: {
- start: {line: 1, column: 5},
- end: {line: 1, column: 6}
- }
- }],
- body: {
- type: "Literal",
- value: 42,
- raw: "42",
- loc: {
- start: {line: 1, column: 10},
- end: {line: 1, column: 12}
- }
- },
- generator: false,
- expression: true,
- loc: {
- start: {line: 1, column: 5},
- end: {line: 1, column: 12}
- }
- },
- generator: false,
- expression: true,
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 12}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 12}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 12}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("(x) => ((y, z) => (x, y, z))", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "ArrowFunctionExpression",
- id: null,
- params: [{
- type: "Identifier",
- name: "x",
- loc: {
- start: {line: 1, column: 1},
- end: {line: 1, column: 2}
- }
- }],
- body: {
- type: "ArrowFunctionExpression",
- id: null,
- params: [
- {
- type: "Identifier",
- name: "y",
- loc: {
- start: {line: 1, column: 9},
- end: {line: 1, column: 10}
- }
- },
- {
- type: "Identifier",
- name: "z",
- loc: {
- start: {line: 1, column: 12},
- end: {line: 1, column: 13}
- }
- }
- ],
- body: {
- type: "SequenceExpression",
- expressions: [
- {
- type: "Identifier",
- name: "x",
- loc: {
- start: {line: 1, column: 19},
- end: {line: 1, column: 20}
- }
- },
- {
- type: "Identifier",
- name: "y",
- loc: {
- start: {line: 1, column: 22},
- end: {line: 1, column: 23}
- }
- },
- {
- type: "Identifier",
- name: "z",
- loc: {
- start: {line: 1, column: 25},
- end: {line: 1, column: 26}
- }
- }
- ],
- loc: {
- start: {line: 1, column: 19},
- end: {line: 1, column: 26}
- }
- },
- generator: false,
- expression: true,
- loc: {
- start: {line: 1, column: 8},
- end: {line: 1, column: 27}
- }
- },
- generator: false,
- expression: true,
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 28}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 28}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 28}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("foo(() => {})", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "CallExpression",
- callee: {
- type: "Identifier",
- name: "foo",
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 3}
- }
- },
- arguments: [{
- type: "ArrowFunctionExpression",
- id: null,
- params: [],
- body: {
- type: "BlockStatement",
- body: [],
- loc: {
- start: {line: 1, column: 10},
- end: {line: 1, column: 12}
- }
- },
- generator: false,
- expression: false,
- loc: {
- start: {line: 1, column: 4},
- end: {line: 1, column: 12}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 13}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 13}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 13}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("foo((x, y) => {})", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "CallExpression",
- callee: {
- type: "Identifier",
- name: "foo",
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 3}
- }
- },
- arguments: [{
- type: "ArrowFunctionExpression",
- id: null,
- params: [
- {
- type: "Identifier",
- name: "x",
- loc: {
- start: {line: 1, column: 5},
- end: {line: 1, column: 6}
- }
- },
- {
- type: "Identifier",
- name: "y",
- loc: {
- start: {line: 1, column: 8},
- end: {line: 1, column: 9}
- }
- }
- ],
- body: {
- type: "BlockStatement",
- body: [],
- loc: {
- start: {line: 1, column: 14},
- end: {line: 1, column: 16}
- }
- },
- generator: false,
- expression: false,
- loc: {
- start: {line: 1, column: 4},
- end: {line: 1, column: 16}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 17}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 17}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 17}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("(a, a) => 42", {
- type: "Program",
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 12}
- },
- body: [{
- type: "ExpressionStatement",
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 12}
- },
- expression: {
- type: "ArrowFunctionExpression",
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 12}
- },
- id: null,
- params: [
- {
- type: "Identifier",
- loc: {
- start: {line: 1, column: 1},
- end: {line: 1, column: 2}
- },
- name: "a"
- },
- {
- type: "Identifier",
- loc: {
- start: {line: 1, column: 4},
- end: {line: 1, column: 5}
- },
- name: "a"
- }
- ],
- generator: false,
- body: {
- type: "Literal",
- loc: {
- start: {line: 1, column: 10},
- end: {line: 1, column: 12}
- },
- value: 42,
- raw: "42"
- },
- expression: true
- }
- }]
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-// ES6: Method Definition
-
-test("x = { method() { } }", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "AssignmentExpression",
- operator: "=",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 1}
- }
- },
- right: {
- type: "ObjectExpression",
- properties: [{
- type: "Property",
- key: {
- type: "Identifier",
- name: "method",
- loc: {
- start: {line: 1, column: 6},
- end: {line: 1, column: 12}
- }
- },
- value: {
- type: "FunctionExpression",
- id: null,
- params: [],
- body: {
- type: "BlockStatement",
- body: [],
- loc: {
- start: {line: 1, column: 15},
- end: {line: 1, column: 18}
- }
- },
- generator: false,
- expression: false,
- loc: {
- start: {line: 1, column: 12},
- end: {line: 1, column: 18}
- }
- },
- kind: "init",
- method: true,
- shorthand: false,
- computed: false,
- loc: {
- start: {line: 1, column: 6},
- end: {line: 1, column: 18}
- }
- }],
- loc: {
- start: {line: 1, column: 4},
- end: {line: 1, column: 20}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 20}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 20}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 20}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("x = { method(test) { } }", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "AssignmentExpression",
- operator: "=",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 1}
- }
- },
- right: {
- type: "ObjectExpression",
- properties: [{
- type: "Property",
- key: {
- type: "Identifier",
- name: "method",
- loc: {
- start: {line: 1, column: 6},
- end: {line: 1, column: 12}
- }
- },
- value: {
- type: "FunctionExpression",
- id: null,
- params: [{
- type: "Identifier",
- name: "test",
- loc: {
- start: {line: 1, column: 13},
- end: {line: 1, column: 17}
- }
- }],
- body: {
- type: "BlockStatement",
- body: [],
- loc: {
- start: {line: 1, column: 19},
- end: {line: 1, column: 22}
- }
- },
- generator: false,
- expression: false,
- loc: {
- start: {line: 1, column: 12},
- end: {line: 1, column: 22}
- }
- },
- kind: "init",
- method: true,
- shorthand: false,
- computed: false,
- loc: {
- start: {line: 1, column: 6},
- end: {line: 1, column: 22}
- }
- }],
- loc: {
- start: {line: 1, column: 4},
- end: {line: 1, column: 24}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 24}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 24}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 24}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("x = { 'method'() { } }", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "AssignmentExpression",
- operator: "=",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 1}
- }
- },
- right: {
- type: "ObjectExpression",
- properties: [{
- type: "Property",
- key: {
- type: "Literal",
- value: "method",
- raw: "'method'",
- loc: {
- start: {line: 1, column: 6},
- end: {line: 1, column: 14}
- }
- },
- value: {
- type: "FunctionExpression",
- id: null,
- params: [],
- body: {
- type: "BlockStatement",
- body: [],
- loc: {
- start: {line: 1, column: 17},
- end: {line: 1, column: 20}
- }
- },
- generator: false,
- expression: false,
- loc: {
- start: {line: 1, column: 14},
- end: {line: 1, column: 20}
- }
- },
- kind: "init",
- method: true,
- shorthand: false,
- computed: false,
- loc: {
- start: {line: 1, column: 6},
- end: {line: 1, column: 20}
- }
- }],
- loc: {
- start: {line: 1, column: 4},
- end: {line: 1, column: 22}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 22}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 22}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 22}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("x = { get() { } }", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "AssignmentExpression",
- operator: "=",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 1}
- }
- },
- right: {
- type: "ObjectExpression",
- properties: [{
- type: "Property",
- key: {
- type: "Identifier",
- name: "get",
- loc: {
- start: {line: 1, column: 6},
- end: {line: 1, column: 9}
- }
- },
- value: {
- type: "FunctionExpression",
- id: null,
- params: [],
- body: {
- type: "BlockStatement",
- body: [],
- loc: {
- start: {line: 1, column: 12},
- end: {line: 1, column: 15}
- }
- },
- generator: false,
- expression: false,
- loc: {
- start: {line: 1, column: 9},
- end: {line: 1, column: 15}
- }
- },
- kind: "init",
- method: true,
- shorthand: false,
- computed: false,
- loc: {
- start: {line: 1, column: 6},
- end: {line: 1, column: 15}
- }
- }],
- loc: {
- start: {line: 1, column: 4},
- end: {line: 1, column: 17}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 17}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 17}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 17}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("x = { set() { } }", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "AssignmentExpression",
- operator: "=",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 1}
- }
- },
- right: {
- type: "ObjectExpression",
- properties: [{
- type: "Property",
- key: {
- type: "Identifier",
- name: "set",
- loc: {
- start: {line: 1, column: 6},
- end: {line: 1, column: 9}
- }
- },
- value: {
- type: "FunctionExpression",
- id: null,
- params: [],
- body: {
- type: "BlockStatement",
- body: [],
- loc: {
- start: {line: 1, column: 12},
- end: {line: 1, column: 15}
- }
- },
- generator: false,
- expression: false,
- loc: {
- start: {line: 1, column: 9},
- end: {line: 1, column: 15}
- }
- },
- kind: "init",
- method: true,
- shorthand: false,
- computed: false,
- loc: {
- start: {line: 1, column: 6},
- end: {line: 1, column: 15}
- }
- }],
- loc: {
- start: {line: 1, column: 4},
- end: {line: 1, column: 17}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 17}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 17}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 17}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("x = { method() 42 }", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "AssignmentExpression",
- operator: "=",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 1}
- }
- },
- right: {
- type: "ObjectExpression",
- properties: [{
- type: "Property",
- key: {
- type: "Identifier",
- name: "method",
- loc: {
- start: {line: 1, column: 6},
- end: {line: 1, column: 12}
- }
- },
- value: {
- type: "FunctionExpression",
- id: null,
- params: [],
- body: {
- type: "Literal",
- value: 42,
- raw: "42",
- loc: {
- start: {line: 1, column: 15},
- end: {line: 1, column: 17}
- }
- },
- generator: false,
- expression: true,
- loc: {
- start: {line: 1, column: 12},
- end: {line: 1, column: 17}
- }
- },
- kind: "init",
- method: true,
- shorthand: false,
- computed: false,
- loc: {
- start: {line: 1, column: 6},
- end: {line: 1, column: 17}
- }
- }],
- loc: {
- start: {line: 1, column: 4},
- end: {line: 1, column: 19}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 19}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 19}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 19}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("x = { get method() 42 }", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "AssignmentExpression",
- operator: "=",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 1}
- }
- },
- right: {
- type: "ObjectExpression",
- properties: [{
- type: "Property",
- key: {
- type: "Identifier",
- name: "method",
- loc: {
- start: {line: 1, column: 10},
- end: {line: 1, column: 16}
- }
- },
- value: {
- type: "FunctionExpression",
- id: null,
- params: [],
- body: {
- type: "Literal",
- value: 42,
- raw: "42",
- loc: {
- start: {line: 1, column: 19},
- end: {line: 1, column: 21}
- }
- },
- generator: false,
- expression: true,
- loc: {
- start: {line: 1, column: 16},
- end: {line: 1, column: 21}
- }
- },
- kind: "get",
- method: false,
- shorthand: false,
- computed: false,
- loc: {
- start: {line: 1, column: 6},
- end: {line: 1, column: 21}
- }
- }],
- loc: {
- start: {line: 1, column: 4},
- end: {line: 1, column: 23}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 23}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 23}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 23}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("x = { set method(val) v = val }", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "AssignmentExpression",
- operator: "=",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 1}
- }
- },
- right: {
- type: "ObjectExpression",
- properties: [{
- type: "Property",
- key: {
- type: "Identifier",
- name: "method",
- loc: {
- start: {line: 1, column: 10},
- end: {line: 1, column: 16}
- }
- },
- value: {
- type: "FunctionExpression",
- id: null,
- params: [{
- type: "Identifier",
- name: "val",
- loc: {
- start: {line: 1, column: 17},
- end: {line: 1, column: 20}
- }
- }],
- body: {
- type: "AssignmentExpression",
- operator: "=",
- left: {
- type: "Identifier",
- name: "v",
- loc: {
- start: {line: 1, column: 22},
- end: {line: 1, column: 23}
- }
- },
- right: {
- type: "Identifier",
- name: "val",
- loc: {
- start: {line: 1, column: 26},
- end: {line: 1, column: 29}
- }
- },
- loc: {
- start: {line: 1, column: 22},
- end: {line: 1, column: 29}
- }
- },
- generator: false,
- expression: true,
- loc: {
- start: {line: 1, column: 16},
- end: {line: 1, column: 29}
- }
- },
- kind: "set",
- method: false,
- shorthand: false,
- computed: false,
- loc: {
- start: {line: 1, column: 6},
- end: {line: 1, column: 29}
- }
- }],
- loc: {
- start: {line: 1, column: 4},
- end: {line: 1, column: 31}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 31}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 31}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 31}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-// Array and Generator Comprehension
-
-test("[for (x of array) x]", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "ComprehensionExpression",
- filter: null,
- blocks: [{
- type: "ComprehensionBlock",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {line: 1, column: 6},
- end: {line: 1, column: 7}
- }
- },
- right: {
- type: "Identifier",
- name: "array",
- loc: {
- start: {line: 1, column: 11},
- end: {line: 1, column: 16}
- }
- },
- loc: {
- start: {line: 1, column: 1},
- end: {line: 1, column: 17}
- }
- }],
- body: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {line: 1, column: 18},
- end: {line: 1, column: 19}
- }
- },
- generator: false,
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 20}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 20}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 20}
- }
-}, {
- ecmaVersion: 7,
- ranges: true,
- locations: true
-});
-
-test("[for (x of array) for (y of array2) if (x === test) x]", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "ComprehensionExpression",
- filter: {
- type: "BinaryExpression",
- operator: "===",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {line: 1, column: 40},
- end: {line: 1, column: 41}
- }
- },
- right: {
- type: "Identifier",
- name: "test",
- loc: {
- start: {line: 1, column: 46},
- end: {line: 1, column: 50}
- }
- },
- loc: {
- start: {line: 1, column: 40},
- end: {line: 1, column: 50}
- }
- },
- blocks: [
- {
- type: "ComprehensionBlock",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {line: 1, column: 6},
- end: {line: 1, column: 7}
- }
- },
- right: {
- type: "Identifier",
- name: "array",
- loc: {
- start: {line: 1, column: 11},
- end: {line: 1, column: 16}
- }
- },
- loc: {
- start: {line: 1, column: 1},
- end: {line: 1, column: 17}
- }
- },
- {
- type: "ComprehensionBlock",
- left: {
- type: "Identifier",
- name: "y",
- loc: {
- start: {line: 1, column: 23},
- end: {line: 1, column: 24}
- }
- },
- right: {
- type: "Identifier",
- name: "array2",
- loc: {
- start: {line: 1, column: 28},
- end: {line: 1, column: 34}
- }
- },
- loc: {
- start: {line: 1, column: 18},
- end: {line: 1, column: 35}
- }
- }
- ],
- body: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {line: 1, column: 52},
- end: {line: 1, column: 53}
- }
- },
- generator: false,
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 54}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 54}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 54}
- }
-}, {
- ecmaVersion: 7,
- ranges: true,
- locations: true
-});
-
-test("(for (x of array) for (y of array2) if (x === test) x)", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "ComprehensionExpression",
- filter: {
- type: "BinaryExpression",
- operator: "===",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {line: 1, column: 40},
- end: {line: 1, column: 41}
- }
- },
- right: {
- type: "Identifier",
- name: "test",
- loc: {
- start: {line: 1, column: 46},
- end: {line: 1, column: 50}
- }
- },
- loc: {
- start: {line: 1, column: 40},
- end: {line: 1, column: 50}
- }
- },
- blocks: [
- {
- type: "ComprehensionBlock",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {line: 1, column: 6},
- end: {line: 1, column: 7}
- }
- },
- right: {
- type: "Identifier",
- name: "array",
- loc: {
- start: {line: 1, column: 11},
- end: {line: 1, column: 16}
- }
- },
- loc: {
- start: {line: 1, column: 1},
- end: {line: 1, column: 17}
- }
- },
- {
- type: "ComprehensionBlock",
- left: {
- type: "Identifier",
- name: "y",
- loc: {
- start: {line: 1, column: 23},
- end: {line: 1, column: 24}
- }
- },
- right: {
- type: "Identifier",
- name: "array2",
- loc: {
- start: {line: 1, column: 28},
- end: {line: 1, column: 34}
- }
- },
- loc: {
- start: {line: 1, column: 18},
- end: {line: 1, column: 35}
- }
- }
- ],
- body: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {line: 1, column: 52},
- end: {line: 1, column: 53}
- }
- },
- generator: true,
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 54}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 54}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 54}
- }
-}, {
- ecmaVersion: 7,
- ranges: true,
- locations: true
-});
-
-test("[for ([,x] of array) for ({[start.x]: x, [start.y]: y} of array2) x]", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "ComprehensionExpression",
- filter: null,
- blocks: [
- {
- type: "ComprehensionBlock",
- left: {
- type: "ArrayPattern",
- elements: [
- null,
- {
- type: "Identifier",
- name: "x",
- loc: {
- start: {line: 1, column: 8},
- end: {line: 1, column: 9}
- }
- }
- ],
- loc: {
- start: {line: 1, column: 6},
- end: {line: 1, column: 10}
- }
- },
- right: {
- type: "Identifier",
- name: "array",
- loc: {
- start: {line: 1, column: 14},
- end: {line: 1, column: 19}
- }
- },
- loc: {
- start: {line: 1, column: 1},
- end: {line: 1, column: 20}
- }
- },
- {
- type: "ComprehensionBlock",
- left: {
- type: "ObjectPattern",
- properties: [
- {
- type: "Property",
- key: {
- type: "MemberExpression",
- computed: false,
- object: {
- type: "Identifier",
- name: "start",
- loc: {
- start: {line: 1, column: 28},
- end: {line: 1, column: 33}
- }
- },
- property: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {line: 1, column: 34},
- end: {line: 1, column: 35}
- }
- },
- loc: {
- start: {line: 1, column: 28},
- end: {line: 1, column: 35}
- }
- },
- value: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {line: 1, column: 38},
- end: {line: 1, column: 39}
- }
- },
- kind: "init",
- method: false,
- shorthand: false,
- computed: true,
- loc: {
- start: {line: 1, column: 27},
- end: {line: 1, column: 39}
- }
- },
- {
- type: "Property",
- key: {
- type: "MemberExpression",
- computed: false,
- object: {
- type: "Identifier",
- name: "start",
- loc: {
- start: {line: 1, column: 42},
- end: {line: 1, column: 47}
- }
- },
- property: {
- type: "Identifier",
- name: "y",
- loc: {
- start: {line: 1, column: 48},
- end: {line: 1, column: 49}
- }
- },
- loc: {
- start: {line: 1, column: 42},
- end: {line: 1, column: 49}
- }
- },
- value: {
- type: "Identifier",
- name: "y",
- loc: {
- start: {line: 1, column: 52},
- end: {line: 1, column: 53}
- }
- },
- kind: "init",
- method: false,
- shorthand: false,
- computed: true,
- loc: {
- start: {line: 1, column: 41},
- end: {line: 1, column: 53}
- }
- }
- ],
- loc: {
- start: {line: 1, column: 26},
- end: {line: 1, column: 54}
- }
- },
- right: {
- type: "Identifier",
- name: "array2",
- loc: {
- start: {line: 1, column: 58},
- end: {line: 1, column: 64}
- }
- },
- loc: {
- start: {line: 1, column: 21},
- end: {line: 1, column: 65}
- }
- }
- ],
- body: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {line: 1, column: 66},
- end: {line: 1, column: 67}
- }
- },
- generator: false,
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 68}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 68}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 68}
- }
-}, {
- ecmaVersion: 7,
- ranges: true,
- locations: true
-});
-
-// Harmony: Object Literal Property Value Shorthand
-
-test("x = { y, z }", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "AssignmentExpression",
- operator: "=",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 1}
- }
- },
- right: {
- type: "ObjectExpression",
- properties: [
- {
- type: "Property",
- key: {
- type: "Identifier",
- name: "y",
- loc: {
- start: {line: 1, column: 6},
- end: {line: 1, column: 7}
- }
- },
- value: {
- type: "Identifier",
- name: "y",
- loc: {
- start: {line: 1, column: 6},
- end: {line: 1, column: 7}
- }
- },
- kind: "init",
- method: false,
- shorthand: true,
- computed: false,
- loc: {
- start: {line: 1, column: 6},
- end: {line: 1, column: 7}
- }
- },
- {
- type: "Property",
- key: {
- type: "Identifier",
- name: "z",
- loc: {
- start: {line: 1, column: 9},
- end: {line: 1, column: 10}
- }
- },
- value: {
- type: "Identifier",
- name: "z",
- loc: {
- start: {line: 1, column: 9},
- end: {line: 1, column: 10}
- }
- },
- kind: "init",
- method: false,
- shorthand: true,
- computed: false,
- loc: {
- start: {line: 1, column: 9},
- end: {line: 1, column: 10}
- }
- }
- ],
- loc: {
- start: {line: 1, column: 4},
- end: {line: 1, column: 12}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 12}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 12}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 12}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-// Harmony: Destructuring
-
-test("[a, b] = [b, a]", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "AssignmentExpression",
- operator: "=",
- left: {
- type: "ArrayPattern",
- elements: [
- {
- type: "Identifier",
- name: "a",
- loc: {
- start: {line: 1, column: 1},
- end: {line: 1, column: 2}
- }
- },
- {
- type: "Identifier",
- name: "b",
- loc: {
- start: {line: 1, column: 4},
- end: {line: 1, column: 5}
- }
- }
- ],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 6}
- }
- },
- right: {
- type: "ArrayExpression",
- elements: [
- {
- type: "Identifier",
- name: "b",
- loc: {
- start: {line: 1, column: 10},
- end: {line: 1, column: 11}
- }
- },
- {
- type: "Identifier",
- name: "a",
- loc: {
- start: {line: 1, column: 13},
- end: {line: 1, column: 14}
- }
- }
- ],
- loc: {
- start: {line: 1, column: 9},
- end: {line: 1, column: 15}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 15}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 15}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 15}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("({ responseText: text }) = res", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "AssignmentExpression",
- operator: "=",
- left: {
- type: "ObjectPattern",
- properties: [{
- type: "Property",
- key: {
- type: "Identifier",
- name: "responseText",
- loc: {
- start: {line: 1, column: 3},
- end: {line: 1, column: 15}
- }
- },
- value: {
- type: "Identifier",
- name: "text",
- loc: {
- start: {line: 1, column: 17},
- end: {line: 1, column: 21}
- }
- },
- kind: "init",
- method: false,
- shorthand: false,
- computed: false,
- loc: {
- start: {line: 1, column: 3},
- end: {line: 1, column: 21}
- }
- }],
- loc: {
- start: {line: 1, column: 1},
- end: {line: 1, column: 23}
- }
- },
- right: {
- type: "Identifier",
- name: "res",
- loc: {
- start: {line: 1, column: 27},
- end: {line: 1, column: 30}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 30}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 30}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 30}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("const {a} = {}", {
- type: "Program",
- body: [{
- type: "VariableDeclaration",
- declarations: [{
- type: "VariableDeclarator",
- id: {
- type: "ObjectPattern",
- properties: [{
- type: "Property",
- key: {
- type: "Identifier",
- name: "a",
- loc: {
- start: {line: 1, column: 7},
- end: {line: 1, column: 8}
- }
- },
- value: {
- type: "Identifier",
- name: "a",
- loc: {
- start: {line: 1, column: 7},
- end: {line: 1, column: 8}
- }
- },
- kind: "init",
- method: false,
- shorthand: true,
- computed: false,
- loc: {
- start: {line: 1, column: 7},
- end: {line: 1, column: 8}
- }
- }],
- loc: {
- start: {line: 1, column: 6},
- end: {line: 1, column: 9}
- }
- },
- init: {
- type: "ObjectExpression",
- properties: [],
- loc: {
- start: {line: 1, column: 12},
- end: {line: 1, column: 14}
- }
- },
- loc: {
- start: {line: 1, column: 6},
- end: {line: 1, column: 14}
- }
- }],
- kind: "const",
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 14}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 14}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("const [a] = []", {
- type: "Program",
- body: [{
- type: "VariableDeclaration",
- declarations: [{
- type: "VariableDeclarator",
- id: {
- type: "ArrayPattern",
- elements: [{
- type: "Identifier",
- name: "a",
- loc: {
- start: {line: 1, column: 7},
- end: {line: 1, column: 8}
- }
- }],
- loc: {
- start: {line: 1, column: 6},
- end: {line: 1, column: 9}
- }
- },
- init: {
- type: "ArrayExpression",
- elements: [],
- loc: {
- start: {line: 1, column: 12},
- end: {line: 1, column: 14}
- }
- },
- loc: {
- start: {line: 1, column: 6},
- end: {line: 1, column: 14}
- }
- }],
- kind: "const",
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 14}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 14}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("let {a} = {}", {
- type: "Program",
- body: [{
- type: "VariableDeclaration",
- declarations: [{
- type: "VariableDeclarator",
- id: {
- type: "ObjectPattern",
- properties: [{
- type: "Property",
- key: {
- type: "Identifier",
- name: "a",
- loc: {
- start: {line: 1, column: 5},
- end: {line: 1, column: 6}
- }
- },
- value: {
- type: "Identifier",
- name: "a",
- loc: {
- start: {line: 1, column: 5},
- end: {line: 1, column: 6}
- }
- },
- kind: "init",
- method: false,
- shorthand: true,
- computed: false,
- loc: {
- start: {line: 1, column: 5},
- end: {line: 1, column: 6}
- }
- }],
- loc: {
- start: {line: 1, column: 4},
- end: {line: 1, column: 7}
- }
- },
- init: {
- type: "ObjectExpression",
- properties: [],
- loc: {
- start: {line: 1, column: 10},
- end: {line: 1, column: 12}
- }
- },
- loc: {
- start: {line: 1, column: 4},
- end: {line: 1, column: 12}
- }
- }],
- kind: "let",
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 12}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 12}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("let [a] = []", {
- type: "Program",
- body: [{
- type: "VariableDeclaration",
- declarations: [{
- type: "VariableDeclarator",
- id: {
- type: "ArrayPattern",
- elements: [{
- type: "Identifier",
- name: "a",
- loc: {
- start: {line: 1, column: 5},
- end: {line: 1, column: 6}
- }
- }],
- loc: {
- start: {line: 1, column: 4},
- end: {line: 1, column: 7}
- }
- },
- init: {
- type: "ArrayExpression",
- elements: [],
- loc: {
- start: {line: 1, column: 10},
- end: {line: 1, column: 12}
- }
- },
- loc: {
- start: {line: 1, column: 4},
- end: {line: 1, column: 12}
- }
- }],
- kind: "let",
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 12}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 12}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("var {a} = {}", {
- type: "Program",
- body: [{
- type: "VariableDeclaration",
- declarations: [{
- type: "VariableDeclarator",
- id: {
- type: "ObjectPattern",
- properties: [{
- type: "Property",
- key: {
- type: "Identifier",
- name: "a",
- loc: {
- start: {line: 1, column: 5},
- end: {line: 1, column: 6}
- }
- },
- value: {
- type: "Identifier",
- name: "a",
- loc: {
- start: {line: 1, column: 5},
- end: {line: 1, column: 6}
- }
- },
- kind: "init",
- method: false,
- shorthand: true,
- computed: false,
- loc: {
- start: {line: 1, column: 5},
- end: {line: 1, column: 6}
- }
- }],
- loc: {
- start: {line: 1, column: 4},
- end: {line: 1, column: 7}
- }
- },
- init: {
- type: "ObjectExpression",
- properties: [],
- loc: {
- start: {line: 1, column: 10},
- end: {line: 1, column: 12}
- }
- },
- loc: {
- start: {line: 1, column: 4},
- end: {line: 1, column: 12}
- }
- }],
- kind: "var",
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 12}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 12}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("var [a] = []", {
- type: "Program",
- body: [{
- type: "VariableDeclaration",
- declarations: [{
- type: "VariableDeclarator",
- id: {
- type: "ArrayPattern",
- elements: [{
- type: "Identifier",
- name: "a",
- loc: {
- start: {line: 1, column: 5},
- end: {line: 1, column: 6}
- }
- }],
- loc: {
- start: {line: 1, column: 4},
- end: {line: 1, column: 7}
- }
- },
- init: {
- type: "ArrayExpression",
- elements: [],
- loc: {
- start: {line: 1, column: 10},
- end: {line: 1, column: 12}
- }
- },
- loc: {
- start: {line: 1, column: 4},
- end: {line: 1, column: 12}
- }
- }],
- kind: "var",
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 12}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 12}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("const {a:b} = {}", {
- type: "Program",
- body: [{
- type: "VariableDeclaration",
- declarations: [{
- type: "VariableDeclarator",
- id: {
- type: "ObjectPattern",
- properties: [{
- type: "Property",
- key: {
- type: "Identifier",
- name: "a",
- loc: {
- start: {line: 1, column: 7},
- end: {line: 1, column: 8}
- }
- },
- value: {
- type: "Identifier",
- name: "b",
- loc: {
- start: {line: 1, column: 9},
- end: {line: 1, column: 10}
- }
- },
- kind: "init",
- method: false,
- shorthand: false,
- computed: false,
- loc: {
- start: {line: 1, column: 7},
- end: {line: 1, column: 10}
- }
- }],
- loc: {
- start: {line: 1, column: 6},
- end: {line: 1, column: 11}
- }
- },
- init: {
- type: "ObjectExpression",
- properties: [],
- loc: {
- start: {line: 1, column: 14},
- end: {line: 1, column: 16}
- }
- },
- loc: {
- start: {line: 1, column: 6},
- end: {line: 1, column: 16}
- }
- }],
- kind: "const",
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 16}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 16}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("let {a:b} = {}", {
- type: "Program",
- body: [{
- type: "VariableDeclaration",
- declarations: [{
- type: "VariableDeclarator",
- id: {
- type: "ObjectPattern",
- properties: [{
- type: "Property",
- key: {
- type: "Identifier",
- name: "a",
- loc: {
- start: {line: 1, column: 5},
- end: {line: 1, column: 6}
- }
- },
- value: {
- type: "Identifier",
- name: "b",
- loc: {
- start: {line: 1, column: 7},
- end: {line: 1, column: 8}
- }
- },
- kind: "init",
- method: false,
- shorthand: false,
- computed: false,
- loc: {
- start: {line: 1, column: 5},
- end: {line: 1, column: 8}
- }
- }],
- loc: {
- start: {line: 1, column: 4},
- end: {line: 1, column: 9}
- }
- },
- init: {
- type: "ObjectExpression",
- properties: [],
- loc: {
- start: {line: 1, column: 12},
- end: {line: 1, column: 14}
- }
- },
- loc: {
- start: {line: 1, column: 4},
- end: {line: 1, column: 14}
- }
- }],
- kind: "let",
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 14}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 14}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("var {a:b} = {}", {
- type: "Program",
- sourceType: "script",
- body: [{
- type: "VariableDeclaration",
- declarations: [{
- type: "VariableDeclarator",
- id: {
- type: "ObjectPattern",
- properties: [{
- type: "Property",
- key: {
- type: "Identifier",
- name: "a",
- loc: {
- start: {line: 1, column: 5},
- end: {line: 1, column: 6}
- }
- },
- value: {
- type: "Identifier",
- name: "b",
- loc: {
- start: {line: 1, column: 7},
- end: {line: 1, column: 8}
- }
- },
- kind: "init",
- method: false,
- shorthand: false,
- computed: false,
- loc: {
- start: {line: 1, column: 5},
- end: {line: 1, column: 8}
- }
- }],
- loc: {
- start: {line: 1, column: 4},
- end: {line: 1, column: 9}
- }
- },
- init: {
- type: "ObjectExpression",
- properties: [],
- loc: {
- start: {line: 1, column: 12},
- end: {line: 1, column: 14}
- }
- },
- loc: {
- start: {line: 1, column: 4},
- end: {line: 1, column: 14}
- }
- }],
- kind: "var",
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 14}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 14}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-// Harmony: Modules
-
-test("export var document", {
- type: "Program",
- sourceType: "module",
- body: [{
- type: "ExportNamedDeclaration",
- declaration: {
- type: "VariableDeclaration",
- declarations: [{
- type: "VariableDeclarator",
- id: {
- type: "Identifier",
- name: "document",
- loc: {
- start: {line: 1, column: 11},
- end: {line: 1, column: 19}
- }
- },
- init: null,
- loc: {
- start: {line: 1, column: 11},
- end: {line: 1, column: 19}
- }
- }],
- kind: "var",
- loc: {
- start: {line: 1, column: 7},
- end: {line: 1, column: 19}
- }
- },
- specifiers: [],
- source: null,
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 19}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 19}
- }
-}, {
- ecmaVersion: 6,
- sourceType: "module",
- ranges: true,
- locations: true
-});
-
-test("export var document = { }", {
- type: "Program",
- body: [{
- type: "ExportNamedDeclaration",
- declaration: {
- type: "VariableDeclaration",
- declarations: [{
- type: "VariableDeclarator",
- id: {
- type: "Identifier",
- name: "document",
- loc: {
- start: {line: 1, column: 11},
- end: {line: 1, column: 19}
- }
- },
- init: {
- type: "ObjectExpression",
- properties: [],
- loc: {
- start: {line: 1, column: 22},
- end: {line: 1, column: 25}
- }
- },
- loc: {
- start: {line: 1, column: 11},
- end: {line: 1, column: 25}
- }
- }],
- kind: "var",
- loc: {
- start: {line: 1, column: 7},
- end: {line: 1, column: 25}
- }
- },
- specifiers: [],
- source: null,
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 25}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 25}
- }
-}, {
- ecmaVersion: 6,
- sourceType: "module",
- ranges: true,
- locations: true
-});
-
-test("export let document", {
- type: "Program",
- body: [{
- type: "ExportNamedDeclaration",
- declaration: {
- type: "VariableDeclaration",
- declarations: [{
- type: "VariableDeclarator",
- id: {
- type: "Identifier",
- name: "document",
- loc: {
- start: {line: 1, column: 11},
- end: {line: 1, column: 19}
- }
- },
- init: null,
- loc: {
- start: {line: 1, column: 11},
- end: {line: 1, column: 19}
- }
- }],
- kind: "let",
- loc: {
- start: {line: 1, column: 7},
- end: {line: 1, column: 19}
- }
- },
- specifiers: [],
- source: null,
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 19}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 19}
- }
-}, {
- ecmaVersion: 6,
- sourceType: "module",
- ranges: true,
- locations: true
-});
-
-test("export let document = { }", {
- type: "Program",
- body: [{
- type: "ExportNamedDeclaration",
- declaration: {
- type: "VariableDeclaration",
- declarations: [{
- type: "VariableDeclarator",
- id: {
- type: "Identifier",
- name: "document",
- loc: {
- start: {line: 1, column: 11},
- end: {line: 1, column: 19}
- }
- },
- init: {
- type: "ObjectExpression",
- properties: [],
- loc: {
- start: {line: 1, column: 22},
- end: {line: 1, column: 25}
- }
- },
- loc: {
- start: {line: 1, column: 11},
- end: {line: 1, column: 25}
- }
- }],
- kind: "let",
- loc: {
- start: {line: 1, column: 7},
- end: {line: 1, column: 25}
- }
- },
- specifiers: [],
- source: null,
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 25}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 25}
- }
-}, {
- ecmaVersion: 6,
- sourceType: "module",
- ranges: true,
- locations: true
-});
-
-test("export const document = { }", {
- type: "Program",
- body: [{
- type: "ExportNamedDeclaration",
- declaration: {
- type: "VariableDeclaration",
- declarations: [{
- type: "VariableDeclarator",
- id: {
- type: "Identifier",
- name: "document",
- loc: {
- start: {line: 1, column: 13},
- end: {line: 1, column: 21}
- }
- },
- init: {
- type: "ObjectExpression",
- properties: [],
- loc: {
- start: {line: 1, column: 24},
- end: {line: 1, column: 27}
- }
- },
- loc: {
- start: {line: 1, column: 13},
- end: {line: 1, column: 27}
- }
- }],
- kind: "const",
- loc: {
- start: {line: 1, column: 7},
- end: {line: 1, column: 27}
- }
- },
- specifiers: [],
- source: null,
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 27}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 27}
- }
-}, {
- ecmaVersion: 6,
- sourceType: "module",
- ranges: true,
- locations: true
-});
-
-test("export function parse() { }", {
- type: "Program",
- body: [{
- type: "ExportNamedDeclaration",
- declaration: {
- type: "FunctionDeclaration",
- id: {
- type: "Identifier",
- name: "parse",
- loc: {
- start: {line: 1, column: 16},
- end: {line: 1, column: 21}
- }
- },
- params: [],
- body: {
- type: "BlockStatement",
- body: [],
- loc: {
- start: {line: 1, column: 24},
- end: {line: 1, column: 27}
- }
- },
- generator: false,
- expression: false,
- loc: {
- start: {line: 1, column: 7},
- end: {line: 1, column: 27}
- }
- },
- specifiers: [],
- source: null,
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 27}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 27}
- }
-}, {
- ecmaVersion: 6,
- sourceType: "module",
- ranges: true,
- locations: true
-});
-
-test("export class Class {}", {
- type: "Program",
- body: [{
- type: "ExportNamedDeclaration",
- declaration: {
- type: "ClassDeclaration",
- id: {
- type: "Identifier",
- name: "Class",
- loc: {
- start: {line: 1, column: 13},
- end: {line: 1, column: 18}
- }
- },
- superClass: null,
- body: {
- type: "ClassBody",
- body: [],
- loc: {
- start: {line: 1, column: 19},
- end: {line: 1, column: 21}
- }
- },
- loc: {
- start: {line: 1, column: 7},
- end: {line: 1, column: 21}
- }
- },
- specifiers: [],
- source: null,
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 21}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 21}
- }
-}, {
- ecmaVersion: 6,
- sourceType: "module",
- ranges: true,
- locations: true
-});
-
-test("export default 42", {
- type: "Program",
- body: [{
- type: "ExportDefaultDeclaration",
- declaration: {
- type: "Literal",
- value: 42,
- raw: "42",
- loc: {
- start: {line: 1, column: 15},
- end: {line: 1, column: 17}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 17}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 17}
- }
-}, {
- ecmaVersion: 6,
- sourceType: "module",
- ranges: true,
- locations: true
-});
-
-test("export default function () {}", {
- type: "Program",
- range: [0, 29],
- body: [{
- type: "ExportDefaultDeclaration",
- range: [0, 29],
- declaration: {
- type: "FunctionExpression",
- range: [15, 29],
- id: null,
- generator: false,
- expression: false,
- params: [],
- body: {
- type: "BlockStatement",
- range: [27, 29],
- body: []
- }
- }
- }]
-}, {ecmaVersion: 6, sourceType: "module", ranges: true});
-
-test("export default function f() {}", {
- type: "Program",
- range: [0, 30],
- body: [{
- type: "ExportDefaultDeclaration",
- range: [0, 30],
- declaration: {
- type: "FunctionDeclaration",
- range: [15, 30],
- id: {
- type: "Identifier",
- range: [24, 25],
- name: "f"
- },
- generator: false,
- expression: false,
- params: [],
- body: {
- type: "BlockStatement",
- range: [28, 30],
- body: []
- }
- }
- }]
-}, {ecmaVersion: 6, sourceType: "module", ranges: true});
-
-test("export default class {}", {
- type: "Program",
- range: [0, 23],
- body: [{
- type: "ExportDefaultDeclaration",
- range: [0, 23],
- declaration: {
- type: "ClassExpression",
- range: [15, 23],
- id: null,
- superClass: null,
- body: {
- type: "ClassBody",
- range: [21, 23],
- body: []
- }
- }
- }]
-}, {ecmaVersion: 6, sourceType: "module", ranges: true});
-
-test("export default class A {}", {
- type: "Program",
- range: [0, 25],
- body: [{
- type: "ExportDefaultDeclaration",
- range: [0, 25],
- declaration: {
- type: "ClassDeclaration",
- range: [15, 25],
- id: {
- type: "Identifier",
- range: [21, 22],
- name: "A"
- },
- superClass: null,
- body: {
- type: "ClassBody",
- range: [23, 25],
- body: []
- }
- }
- }]
-}, {ecmaVersion: 6, sourceType: "module", ranges: true});
-
-testFail("export *", "Unexpected token (1:8)", {ecmaVersion: 6, sourceType: "module"});
-
-test("export * from \"crypto\"", {
- type: "Program",
- body: [{
- type: "ExportAllDeclaration",
- source: {
- type: "Literal",
- value: "crypto",
- raw: "\"crypto\"",
- loc: {
- start: {line: 1, column: 14},
- end: {line: 1, column: 22}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 22}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 22}
- }
-}, {
- ecmaVersion: 6,
- sourceType: "module",
- ranges: true,
- locations: true
-});
-
-test("export { encrypt }", {
- type: "Program",
- body: [{
- type: "ExportNamedDeclaration",
- declaration: null,
- specifiers: [{
- type: "ExportSpecifier",
- exported: {
- type: "Identifier",
- name: "encrypt",
- loc: {
- start: {line: 1, column: 9},
- end: {line: 1, column: 16}
- }
- },
- local: {
- type: "Identifier",
- name: "encrypt",
- loc: {
- start: {line: 1, column: 9},
- end: {line: 1, column: 16}
- }
- },
- loc: {
- start: {line: 1, column: 9},
- end: {line: 1, column: 16}
- }
- }],
- source: null,
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 18}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 18}
- }
-}, {
- ecmaVersion: 6,
- sourceType: "module",
- ranges: true,
- locations: true
-});
-
-test("export { encrypt, decrypt }", {
- type: "Program",
- body: [{
- type: "ExportNamedDeclaration",
- declaration: null,
- specifiers: [
- {
- type: "ExportSpecifier",
- exported: {
- type: "Identifier",
- name: "encrypt",
- loc: {
- start: {line: 1, column: 9},
- end: {line: 1, column: 16}
- }
- },
- local: {
- type: "Identifier",
- name: "encrypt",
- loc: {
- start: {line: 1, column: 9},
- end: {line: 1, column: 16}
- }
- },
- loc: {
- start: {line: 1, column: 9},
- end: {line: 1, column: 16}
- }
- },
- {
- type: "ExportSpecifier",
- exported: {
- type: "Identifier",
- name: "decrypt",
- loc: {
- start: {line: 1, column: 18},
- end: {line: 1, column: 25}
- }
- },
- local: {
- type: "Identifier",
- name: "decrypt",
- loc: {
- start: {line: 1, column: 18},
- end: {line: 1, column: 25}
- }
- },
- loc: {
- start: {line: 1, column: 18},
- end: {line: 1, column: 25}
- }
- }
- ],
- source: null,
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 27}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 27}
- }
-}, {
- ecmaVersion: 6,
- sourceType: "module",
- ranges: true,
- locations: true
-});
-
-test("export { encrypt as default }", {
- type: "Program",
- body: [{
- type: "ExportNamedDeclaration",
- declaration: null,
- specifiers: [{
- type: "ExportSpecifier",
- exported: {
- type: "Identifier",
- name: "default",
- loc: {
- start: {line: 1, column: 20},
- end: {line: 1, column: 27}
- }
- },
- local: {
- type: "Identifier",
- name: "encrypt",
- loc: {
- start: {line: 1, column: 9},
- end: {line: 1, column: 16}
- }
- },
- loc: {
- start: {line: 1, column: 9},
- end: {line: 1, column: 27}
- }
- }],
- source: null,
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 29}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 29}
- }
-}, {
- ecmaVersion: 6,
- sourceType: "module",
- ranges: true,
- locations: true
-});
-
-test("export { encrypt, decrypt as dec }", {
- type: "Program",
- body: [{
- type: "ExportNamedDeclaration",
- declaration: null,
- specifiers: [
- {
- type: "ExportSpecifier",
- exported: {
- type: "Identifier",
- name: "encrypt",
- loc: {
- start: {line: 1, column: 9},
- end: {line: 1, column: 16}
- }
- },
- local: {
- type: "Identifier",
- name: "encrypt",
- loc: {
- start: {line: 1, column: 9},
- end: {line: 1, column: 16}
- }
- },
- loc: {
- start: {line: 1, column: 9},
- end: {line: 1, column: 16}
- }
- },
- {
- type: "ExportSpecifier",
- exported: {
- type: "Identifier",
- name: "dec",
- loc: {
- start: {line: 1, column: 29},
- end: {line: 1, column: 32}
- }
- },
- local: {
- type: "Identifier",
- name: "decrypt",
- loc: {
- start: {line: 1, column: 18},
- end: {line: 1, column: 25}
- }
- },
- loc: {
- start: {line: 1, column: 18},
- end: {line: 1, column: 32}
- }
- }
- ],
- source: null,
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 34}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 34}
- }
-}, {
- ecmaVersion: 6,
- sourceType: "module",
- ranges: true,
- locations: true
-});
-
-test("export { default } from \"other\"", {
- type: "Program",
- body: [{
- type: "ExportNamedDeclaration",
- declaration: null,
- specifiers: [
- {
- type: "ExportSpecifier",
- exported: {
- type: "Identifier",
- name: "default",
- loc: {
- start: {line: 1, column: 9},
- end: {line: 1, column: 16}
- }
- },
- local: {
- type: "Identifier",
- name: "default",
- loc: {
- start: {line: 1, column: 9},
- end: {line: 1, column: 16}
- }
- },
- loc: {
- start: {line: 1, column: 9},
- end: {line: 1, column: 16}
- }
- }
- ],
- source: {
- type: "Literal",
- loc: {
- start: {
- line: 1,
- column: 24
- },
- end: {
- line: 1,
- column: 31
- }
- },
- value: "other",
- raw: "\"other\""
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 31}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 31}
- }
-}, {
- ecmaVersion: 6,
- sourceType: "module",
- ranges: true,
- locations: true
-});
-
-test("import \"jquery\"", {
- type: "Program",
- body: [{
- type: "ImportDeclaration",
- specifiers: [],
- source: {
- type: "Literal",
- value: "jquery",
- raw: "\"jquery\"",
- loc: {
- start: {line: 1, column: 7},
- end: {line: 1, column: 15}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 15}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 15}
- }
-}, {
- ecmaVersion: 6,
- sourceType: "module",
- ranges: true,
- locations: true
-});
-
-test("import $ from \"jquery\"", {
- type: "Program",
- body: [{
- type: "ImportDeclaration",
- specifiers: [{
- type: "ImportDefaultSpecifier",
- local: {
- type: "Identifier",
- name: "$",
- loc: {
- start: {line: 1, column: 7},
- end: {line: 1, column: 8}
- }
- },
- loc: {
- start: {line: 1, column: 7},
- end: {line: 1, column: 8}
- }
- }],
- source: {
- type: "Literal",
- value: "jquery",
- raw: "\"jquery\"",
- loc: {
- start: {line: 1, column: 14},
- end: {line: 1, column: 22}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 22}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 22}
- }
-}, {
- ecmaVersion: 6,
- sourceType: "module",
- ranges: true,
- locations: true
-});
-
-test("import { encrypt, decrypt } from \"crypto\"", {
- type: "Program",
- body: [{
- type: "ImportDeclaration",
- specifiers: [
- {
- type: "ImportSpecifier",
- imported: {
- type: "Identifier",
- name: "encrypt",
- loc: {
- start: {line: 1, column: 9},
- end: {line: 1, column: 16}
- }
- },
- local: {
- type: "Identifier",
- name: "encrypt",
- loc: {
- start: {line: 1, column: 9},
- end: {line: 1, column: 16}
- }
- },
- loc: {
- start: {line: 1, column: 9},
- end: {line: 1, column: 16}
- }
- },
- {
- type: "ImportSpecifier",
- imported: {
- type: "Identifier",
- name: "decrypt",
- loc: {
- start: {line: 1, column: 18},
- end: {line: 1, column: 25}
- }
- },
- local: {
- type: "Identifier",
- name: "decrypt",
- loc: {
- start: {line: 1, column: 18},
- end: {line: 1, column: 25}
- }
- },
- loc: {
- start: {line: 1, column: 18},
- end: {line: 1, column: 25}
- }
- }
- ],
- source: {
- type: "Literal",
- value: "crypto",
- raw: "\"crypto\"",
- loc: {
- start: {line: 1, column: 33},
- end: {line: 1, column: 41}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 41}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 41}
- }
-}, {
- ecmaVersion: 6,
- sourceType: "module",
- ranges: true,
- locations: true
-});
-
-test("import { encrypt as enc } from \"crypto\"", {
- type: "Program",
- body: [{
- type: "ImportDeclaration",
- specifiers: [{
- type: "ImportSpecifier",
- imported: {
- type: "Identifier",
- name: "encrypt",
- loc: {
- start: {line: 1, column: 9},
- end: {line: 1, column: 16}
- }
- },
- local: {
- type: "Identifier",
- name: "enc",
- loc: {
- start: {line: 1, column: 20},
- end: {line: 1, column: 23}
- }
- },
- loc: {
- start: {line: 1, column: 9},
- end: {line: 1, column: 23}
- }
- }],
- source: {
- type: "Literal",
- value: "crypto",
- raw: "\"crypto\"",
- loc: {
- start: {line: 1, column: 31},
- end: {line: 1, column: 39}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 39}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 39}
- }
-}, {
- ecmaVersion: 6,
- sourceType: "module",
- ranges: true,
- locations: true
-});
-
-test("import crypto, { decrypt, encrypt as enc } from \"crypto\"", {
- type: "Program",
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 56}
- },
- body: [{
- type: "ImportDeclaration",
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 56}
- },
- specifiers: [
- {
- type: "ImportDefaultSpecifier",
- loc: {
- start: {line: 1, column: 7},
- end: {line: 1, column: 13}
- },
- local: {
- type: "Identifier",
- loc: {
- start: {line: 1, column: 7},
- end: {line: 1, column: 13}
- },
- name: "crypto"
- }
- },
- {
- type: "ImportSpecifier",
- loc: {
- start: {line: 1, column: 17},
- end: {line: 1, column: 24}
- },
- imported: {
- type: "Identifier",
- loc: {
- start: {line: 1, column: 17},
- end: {line: 1, column: 24}
- },
- name: "decrypt"
- },
- local: {
- type: "Identifier",
- loc: {
- start: {line: 1, column: 17},
- end: {line: 1, column: 24}
- },
- name: "decrypt"
- }
- },
- {
- type: "ImportSpecifier",
- loc: {
- start: {line: 1, column: 26},
- end: {line: 1, column: 40}
- },
- imported: {
- type: "Identifier",
- loc: {
- start: {line: 1, column: 26},
- end: {line: 1, column: 33}
- },
- name: "encrypt"
- },
- local: {
- type: "Identifier",
- loc: {
- start: {line: 1, column: 37},
- end: {line: 1, column: 40}
- },
- name: "enc"
- }
- }
- ],
- source: {
- type: "Literal",
- loc: {
- start: {line: 1, column: 48},
- end: {line: 1, column: 56}
- },
- value: "crypto",
- raw: "\"crypto\""
- }
- }]
-}, {
- ecmaVersion: 6,
- sourceType: "module",
- ranges: true,
- locations: true
-});
-
-testFail("import default from \"foo\"", "Unexpected token (1:7)", {ecmaVersion: 6, sourceType: "module"});
-
-test("import { null as nil } from \"bar\"", {
- type: "Program",
- body: [{
- type: "ImportDeclaration",
- specifiers: [{
- type: "ImportSpecifier",
- imported: {
- type: "Identifier",
- name: "null",
- loc: {
- start: {line: 1, column: 9},
- end: {line: 1, column: 13}
- }
- },
- local: {
- type: "Identifier",
- name: "nil",
- loc: {
- start: {line: 1, column: 17},
- end: {line: 1, column: 20}
- }
- },
- loc: {
- start: {line: 1, column: 9},
- end: {line: 1, column: 20}
- }
- }],
- source: {
- type: "Literal",
- value: "bar",
- raw: "\"bar\"",
- loc: {
- start: {line: 1, column: 28},
- end: {line: 1, column: 33}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 33}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 33}
- }
-}, {
- ecmaVersion: 6,
- sourceType: "module",
- ranges: true,
- locations: true
-});
-
-test("import * as crypto from \"crypto\"", {
- type: "Program",
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 32}
- },
- body: [{
- type: "ImportDeclaration",
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 32}
- },
- specifiers: [{
- type: "ImportNamespaceSpecifier",
- loc: {
- start: {line: 1, column: 7},
- end: {line: 1, column: 18}
- },
- local: {
- type: "Identifier",
- loc: {
- start: {line: 1, column: 12},
- end: {line: 1, column: 18}
- },
- name: "crypto"
- }
- }],
- source: {
- type: "Literal",
- loc: {
- start: {line: 1, column: 24},
- end: {line: 1, column: 32}
- },
- value: "crypto",
- raw: "\"crypto\""
- }
- }]
-}, {
- ecmaVersion: 6,
- sourceType: "module",
- ranges: true,
- locations: true
-});
-
-// Harmony: Yield Expression
-
-test("(function* () { yield v })", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "FunctionExpression",
- id: null,
- params: [],
- body: {
- type: "BlockStatement",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "YieldExpression",
- argument: {
- type: "Identifier",
- name: "v",
- loc: {
- start: {line: 1, column: 22},
- end: {line: 1, column: 23}
- }
- },
- delegate: false,
- loc: {
- start: {line: 1, column: 16},
- end: {line: 1, column: 23}
- }
- },
- loc: {
- start: {line: 1, column: 16},
- end: {line: 1, column: 23}
- }
- }],
- loc: {
- start: {line: 1, column: 14},
- end: {line: 1, column: 25}
- }
- },
- generator: true,
- expression: false,
- loc: {
- start: {line: 1, column: 1},
- end: {line: 1, column: 25}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 26}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 26}
- }
-}, {
- ecmaVersion: 6,
- sourceType: "module",
- ranges: true,
- locations: true
-});
-
-test("(function* () { yield\nv })", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "FunctionExpression",
- id: null,
- params: [],
- body: {
- type: "BlockStatement",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "YieldExpression",
- argument: null,
- delegate: false,
- loc: {
- start: {line: 1, column: 16},
- end: {line: 1, column: 21}
- }
- },
- loc: {
- start: {line: 1, column: 16},
- end: {line: 1, column: 21}
- }
- },
- {
- type: "ExpressionStatement",
- expression: {
- type: "Identifier",
- name: "v",
- loc: {
- start: {line: 2, column: 0},
- end: {line: 2, column: 1}
- }
- },
- loc: {
- start: {line: 2, column: 0},
- end: {line: 2, column: 1}
- }
- }
- ],
- loc: {
- start: {line: 1, column: 14},
- end: {line: 2, column: 3}
- }
- },
- generator: true,
- expression: false,
- loc: {
- start: {line: 1, column: 1},
- end: {line: 2, column: 3}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 2, column: 4}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 2, column: 4}
- }
-}, {
- ecmaVersion: 6,
- sourceType: "module",
- ranges: true,
- locations: true
-});
-
-test("(function* () { yield *v })", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "FunctionExpression",
- id: null,
- params: [],
- body: {
- type: "BlockStatement",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "YieldExpression",
- argument: {
- type: "Identifier",
- name: "v",
- loc: {
- start: {line: 1, column: 23},
- end: {line: 1, column: 24}
- }
- },
- delegate: true,
- loc: {
- start: {line: 1, column: 16},
- end: {line: 1, column: 24}
- }
- },
- loc: {
- start: {line: 1, column: 16},
- end: {line: 1, column: 24}
- }
- }],
- loc: {
- start: {line: 1, column: 14},
- end: {line: 1, column: 26}
- }
- },
- generator: true,
- expression: false,
- loc: {
- start: {line: 1, column: 1},
- end: {line: 1, column: 26}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 27}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 27}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("function* test () { yield *v }", {
- type: "Program",
- body: [{
- type: "FunctionDeclaration",
- id: {
- type: "Identifier",
- name: "test",
- loc: {
- start: {line: 1, column: 10},
- end: {line: 1, column: 14}
- }
- },
- params: [],
- body: {
- type: "BlockStatement",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "YieldExpression",
- argument: {
- type: "Identifier",
- name: "v",
- loc: {
- start: {line: 1, column: 27},
- end: {line: 1, column: 28}
- }
- },
- delegate: true,
- loc: {
- start: {line: 1, column: 20},
- end: {line: 1, column: 28}
- }
- },
- loc: {
- start: {line: 1, column: 20},
- end: {line: 1, column: 28}
- }
- }],
- loc: {
- start: {line: 1, column: 18},
- end: {line: 1, column: 30}
- }
- },
- generator: true,
- expression: false,
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 30}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 30}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("var x = { *test () { yield *v } };", {
- type: "Program",
- body: [{
- type: "VariableDeclaration",
- declarations: [{
- type: "VariableDeclarator",
- id: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {line: 1, column: 4},
- end: {line: 1, column: 5}
- }
- },
- init: {
- type: "ObjectExpression",
- properties: [{
- type: "Property",
- key: {
- type: "Identifier",
- name: "test",
- loc: {
- start: {line: 1, column: 11},
- end: {line: 1, column: 15}
- }
- },
- value: {
- type: "FunctionExpression",
- id: null,
- params: [],
- body: {
- type: "BlockStatement",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "YieldExpression",
- argument: {
- type: "Identifier",
- name: "v",
- loc: {
- start: {line: 1, column: 28},
- end: {line: 1, column: 29}
- }
- },
- delegate: true,
- loc: {
- start: {line: 1, column: 21},
- end: {line: 1, column: 29}
- }
- },
- loc: {
- start: {line: 1, column: 21},
- end: {line: 1, column: 29}
- }
- }],
- loc: {
- start: {line: 1, column: 19},
- end: {line: 1, column: 31}
- }
- },
- generator: true,
- expression: false,
- loc: {
- start: {line: 1, column: 16},
- end: {line: 1, column: 31}
- }
- },
- kind: "init",
- method: true,
- shorthand: false,
- computed: false,
- loc: {
- start: {line: 1, column: 10},
- end: {line: 1, column: 31}
- }
- }],
- loc: {
- start: {line: 1, column: 8},
- end: {line: 1, column: 33}
- }
- },
- loc: {
- start: {line: 1, column: 4},
- end: {line: 1, column: 33}
- }
- }],
- kind: "var",
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 34}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 34}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("function* foo() { console.log(yield); }", {
- body: [
- {
- id: {
- name: "foo",
- type: "Identifier",
- },
- generator: true,
- expression: false,
- params: [],
- body: {
- body: [
- {
- expression: {
- callee: {
- object: {
- name: "console",
- type: "Identifier",
- },
- property: {
- name: "log",
- type: "Identifier",
- },
- computed: false,
- type: "MemberExpression",
- },
- arguments: [
- {
- delegate: false,
- argument: null,
- type: "YieldExpression",
- }
- ],
- type: "CallExpression",
- },
- type: "ExpressionStatement",
- }
- ],
- type: "BlockStatement",
- },
- type: "FunctionDeclaration",
- }
- ],
- sourceType: "script",
- type: "Program"
-}, {ecmaVersion: 6})
-
-test("function* t() {}", {
- type: "Program",
- body: [{
- type: "FunctionDeclaration",
- id: {
- type: "Identifier",
- name: "t",
- loc: {
- start: {line: 1, column: 10},
- end: {line: 1, column: 11}
- }
- },
- params: [],
- body: {
- type: "BlockStatement",
- body: [],
- loc: {
- start: {line: 1, column: 14},
- end: {line: 1, column: 16}
- }
- },
- generator: true,
- expression: false,
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 16}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 16}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("(function* () { yield yield 10 })", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "FunctionExpression",
- id: null,
- params: [],
- body: {
- type: "BlockStatement",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "YieldExpression",
- argument: {
- type: "YieldExpression",
- argument: {
- type: "Literal",
- value: 10,
- raw: "10",
- loc: {
- start: {line: 1, column: 28},
- end: {line: 1, column: 30}
- }
- },
- delegate: false,
- loc: {
- start: {line: 1, column: 22},
- end: {line: 1, column: 30}
- }
- },
- delegate: false,
- loc: {
- start: {line: 1, column: 16},
- end: {line: 1, column: 30}
- }
- },
- loc: {
- start: {line: 1, column: 16},
- end: {line: 1, column: 30}
- }
- }],
- loc: {
- start: {line: 1, column: 14},
- end: {line: 1, column: 32}
- }
- },
- generator: true,
- expression: false,
- loc: {
- start: {line: 1, column: 1},
- end: {line: 1, column: 32}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 33}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 33}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-// Harmony: Iterators
-
-test("for(x of list) process(x);", {
- type: "Program",
- body: [{
- type: "ForOfStatement",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {line: 1, column: 4},
- end: {line: 1, column: 5}
- }
- },
- right: {
- type: "Identifier",
- name: "list",
- loc: {
- start: {line: 1, column: 9},
- end: {line: 1, column: 13}
- }
- },
- body: {
- type: "ExpressionStatement",
- expression: {
- type: "CallExpression",
- callee: {
- type: "Identifier",
- name: "process",
- loc: {
- start: {line: 1, column: 15},
- end: {line: 1, column: 22}
- }
- },
- arguments: [{
- type: "Identifier",
- name: "x",
- loc: {
- start: {line: 1, column: 23},
- end: {line: 1, column: 24}
- }
- }],
- loc: {
- start: {line: 1, column: 15},
- end: {line: 1, column: 25}
- }
- },
- loc: {
- start: {line: 1, column: 15},
- end: {line: 1, column: 26}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 26}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 26}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("for (var x of list) process(x);", {
- type: "Program",
- body: [{
- type: "ForOfStatement",
- left: {
- type: "VariableDeclaration",
- declarations: [{
- type: "VariableDeclarator",
- id: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {line: 1, column: 9},
- end: {line: 1, column: 10}
- }
- },
- init: null,
- loc: {
- start: {line: 1, column: 9},
- end: {line: 1, column: 10}
- }
- }],
- kind: "var",
- loc: {
- start: {line: 1, column: 5},
- end: {line: 1, column: 10}
- }
- },
- right: {
- type: "Identifier",
- name: "list",
- loc: {
- start: {line: 1, column: 14},
- end: {line: 1, column: 18}
- }
- },
- body: {
- type: "ExpressionStatement",
- expression: {
- type: "CallExpression",
- callee: {
- type: "Identifier",
- name: "process",
- loc: {
- start: {line: 1, column: 20},
- end: {line: 1, column: 27}
- }
- },
- arguments: [{
- type: "Identifier",
- name: "x",
- loc: {
- start: {line: 1, column: 28},
- end: {line: 1, column: 29}
- }
- }],
- loc: {
- start: {line: 1, column: 20},
- end: {line: 1, column: 30}
- }
- },
- loc: {
- start: {line: 1, column: 20},
- end: {line: 1, column: 31}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 31}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 31}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("for (var x = 42 of list) process(x);", {
- type: "Program",
- body: [{
- type: "ForOfStatement",
- left: {
- type: "VariableDeclaration",
- declarations: [{
- type: "VariableDeclarator",
- id: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {line: 1, column: 9},
- end: {line: 1, column: 10}
- }
- },
- init: {
- type: "Literal",
- value: 42,
- raw: "42",
- loc: {
- start: {line: 1, column: 13},
- end: {line: 1, column: 15}
- }
- },
- loc: {
- start: {line: 1, column: 9},
- end: {line: 1, column: 15}
- }
- }],
- kind: "var",
- loc: {
- start: {line: 1, column: 5},
- end: {line: 1, column: 15}
- }
- },
- right: {
- type: "Identifier",
- name: "list",
- loc: {
- start: {line: 1, column: 19},
- end: {line: 1, column: 23}
- }
- },
- body: {
- type: "ExpressionStatement",
- expression: {
- type: "CallExpression",
- callee: {
- type: "Identifier",
- name: "process",
- loc: {
- start: {line: 1, column: 25},
- end: {line: 1, column: 32}
- }
- },
- arguments: [{
- type: "Identifier",
- name: "x",
- loc: {
- start: {line: 1, column: 33},
- end: {line: 1, column: 34}
- }
- }],
- loc: {
- start: {line: 1, column: 25},
- end: {line: 1, column: 35}
- }
- },
- loc: {
- start: {line: 1, column: 25},
- end: {line: 1, column: 36}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 36}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 36}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("for (let x of list) process(x);", {
- type: "Program",
- body: [{
- type: "ForOfStatement",
- left: {
- type: "VariableDeclaration",
- declarations: [{
- type: "VariableDeclarator",
- id: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {line: 1, column: 9},
- end: {line: 1, column: 10}
- }
- },
- init: null,
- loc: {
- start: {line: 1, column: 9},
- end: {line: 1, column: 10}
- }
- }],
- kind: "let",
- loc: {
- start: {line: 1, column: 5},
- end: {line: 1, column: 10}
- }
- },
- right: {
- type: "Identifier",
- name: "list",
- loc: {
- start: {line: 1, column: 14},
- end: {line: 1, column: 18}
- }
- },
- body: {
- type: "ExpressionStatement",
- expression: {
- type: "CallExpression",
- callee: {
- type: "Identifier",
- name: "process",
- loc: {
- start: {line: 1, column: 20},
- end: {line: 1, column: 27}
- }
- },
- arguments: [{
- type: "Identifier",
- name: "x",
- loc: {
- start: {line: 1, column: 28},
- end: {line: 1, column: 29}
- }
- }],
- loc: {
- start: {line: 1, column: 20},
- end: {line: 1, column: 30}
- }
- },
- loc: {
- start: {line: 1, column: 20},
- end: {line: 1, column: 31}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 31}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 31}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-// Harmony: Class (strawman)
-
-test("var A = class extends B {}", {
- type: "Program",
- body: [{
- type: "VariableDeclaration",
- declarations: [{
- type: "VariableDeclarator",
- id: {
- type: "Identifier",
- name: "A",
- loc: {
- start: {line: 1, column: 4},
- end: {line: 1, column: 5}
- }
- },
- init: {
- type: "ClassExpression",
- superClass: {
- type: "Identifier",
- name: "B",
- loc: {
- start: {line: 1, column: 22},
- end: {line: 1, column: 23}
- }
- },
- body: {
- type: "ClassBody",
- body: [],
- loc: {
- start: {line: 1, column: 24},
- end: {line: 1, column: 26}
- }
- },
- loc: {
- start: {line: 1, column: 8},
- end: {line: 1, column: 26}
- }
- },
- loc: {
- start: {line: 1, column: 4},
- end: {line: 1, column: 26}
- }
- }],
- kind: "var",
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 26}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 26}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("class A extends class B extends C {} {}", {
- type: "Program",
- body: [{
- type: "ClassDeclaration",
- id: {
- type: "Identifier",
- name: "A",
- loc: {
- start: {line: 1, column: 6},
- end: {line: 1, column: 7}
- }
- },
- superClass: {
- type: "ClassExpression",
- id: {
- type: "Identifier",
- name: "B",
- loc: {
- start: {line: 1, column: 22},
- end: {line: 1, column: 23}
- }
- },
- superClass: {
- type: "Identifier",
- name: "C",
- loc: {
- start: {line: 1, column: 32},
- end: {line: 1, column: 33}
- }
- },
- body: {
- type: "ClassBody",
- body: [],
- loc: {
- start: {line: 1, column: 34},
- end: {line: 1, column: 36}
- }
- },
- loc: {
- start: {line: 1, column: 16},
- end: {line: 1, column: 36}
- }
- },
- body: {
- type: "ClassBody",
- body: [],
- loc: {
- start: {line: 1, column: 37},
- end: {line: 1, column: 39}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 39}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 39}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("class A {get() {}}", {
- type: "Program",
- body: [{
- type: "ClassDeclaration",
- id: {
- type: "Identifier",
- name: "A",
- loc: {
- start: {line: 1, column: 6},
- end: {line: 1, column: 7}
- }
- },
- superClass: null,
- body: {
- type: "ClassBody",
- body: [{
- type: "MethodDefinition",
- computed: false,
- key: {
- type: "Identifier",
- name: "get",
- loc: {
- start: {line: 1, column: 9},
- end: {line: 1, column: 12}
- }
- },
- value: {
- type: "FunctionExpression",
- id: null,
- params: [],
- body: {
- type: "BlockStatement",
- body: [],
- loc: {
- start: {line: 1, column: 15},
- end: {line: 1, column: 17}
- }
- },
- generator: false,
- expression: false,
- loc: {
- start: {line: 1, column: 12},
- end: {line: 1, column: 17}
- }
- },
- kind: "method",
- static: false,
- loc: {
- start: {line: 1, column: 9},
- end: {line: 1, column: 17}
- }
- }],
- loc: {
- start: {line: 1, column: 8},
- end: {line: 1, column: 18}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 18}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 18}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("class A { static get() {}}", {
- type: "Program",
- body: [{
- type: "ClassDeclaration",
- id: {
- type: "Identifier",
- name: "A",
- loc: {
- start: {line: 1, column: 6},
- end: {line: 1, column: 7}
- }
- },
- superClass: null,
- body: {
- type: "ClassBody",
- body: [{
- type: "MethodDefinition",
- computed: false,
- key: {
- type: "Identifier",
- name: "get",
- loc: {
- start: {line: 1, column: 17},
- end: {line: 1, column: 20}
- }
- },
- value: {
- type: "FunctionExpression",
- id: null,
- params: [],
- body: {
- type: "BlockStatement",
- body: [],
- loc: {
- start: {line: 1, column: 23},
- end: {line: 1, column: 25}
- }
- },
- generator: false,
- expression: false,
- loc: {
- start: {line: 1, column: 20},
- end: {line: 1, column: 25}
- }
- },
- kind: "method",
- static: true,
- loc: {
- start: {line: 1, column: 10},
- end: {line: 1, column: 25}
- }
- }],
- loc: {
- start: {line: 1, column: 8},
- end: {line: 1, column: 26}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 26}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 26}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("class A extends B {get foo() {}}", {
- type: "Program",
- body: [{
- type: "ClassDeclaration",
- id: {
- type: "Identifier",
- name: "A",
- loc: {
- start: {line: 1, column: 6},
- end: {line: 1, column: 7}
- }
- },
- superClass: {
- type: "Identifier",
- name: "B",
- loc: {
- start: {line: 1, column: 16},
- end: {line: 1, column: 17}
- }
- },
- body: {
- type: "ClassBody",
- body: [{
- type: "MethodDefinition",
- computed: false,
- key: {
- type: "Identifier",
- name: "foo",
- loc: {
- start: {line: 1, column: 23},
- end: {line: 1, column: 26}
- }
- },
- value: {
- type: "FunctionExpression",
- id: null,
- params: [],
- body: {
- type: "BlockStatement",
- body: [],
- loc: {
- start: {line: 1, column: 29},
- end: {line: 1, column: 31}
- }
- },
- generator: false,
- expression: false,
- loc: {
- start: {line: 1, column: 26},
- end: {line: 1, column: 31}
- }
- },
- kind: "get",
- static: false,
- loc: {
- start: {line: 1, column: 19},
- end: {line: 1, column: 31}
- }
- }],
- loc: {
- start: {line: 1, column: 18},
- end: {line: 1, column: 32}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 32}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 32}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("class A extends B { static get foo() {}}", {
- type: "Program",
- body: [{
- type: "ClassDeclaration",
- id: {
- type: "Identifier",
- name: "A",
- loc: {
- start: {line: 1, column: 6},
- end: {line: 1, column: 7}
- }
- },
- superClass: {
- type: "Identifier",
- name: "B",
- loc: {
- start: {line: 1, column: 16},
- end: {line: 1, column: 17}
- }
- },
- body: {
- type: "ClassBody",
- body: [{
- type: "MethodDefinition",
- computed: false,
- key: {
- type: "Identifier",
- name: "foo",
- loc: {
- start: {line: 1, column: 31},
- end: {line: 1, column: 34}
- }
- },
- value: {
- type: "FunctionExpression",
- id: null,
- params: [],
- body: {
- type: "BlockStatement",
- body: [],
- loc: {
- start: {line: 1, column: 37},
- end: {line: 1, column: 39}
- }
- },
- generator: false,
- expression: false,
- loc: {
- start: {line: 1, column: 34},
- end: {line: 1, column: 39}
- }
- },
- kind: "get",
- static: true,
- loc: {
- start: {line: 1, column: 20},
- end: {line: 1, column: 39}
- }
- }],
- loc: {
- start: {line: 1, column: 18},
- end: {line: 1, column: 40}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 40}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 40}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("class A {set a(v) {}}", {
- type: "Program",
- body: [{
- type: "ClassDeclaration",
- id: {
- type: "Identifier",
- name: "A",
- loc: {
- start: {line: 1, column: 6},
- end: {line: 1, column: 7}
- }
- },
- superClass: null,
- body: {
- type: "ClassBody",
- body: [{
- type: "MethodDefinition",
- computed: false,
- key: {
- type: "Identifier",
- name: "a",
- loc: {
- start: {line: 1, column: 13},
- end: {line: 1, column: 14}
- }
- },
- value: {
- type: "FunctionExpression",
- id: null,
- params: [{
- type: "Identifier",
- name: "v",
- loc: {
- start: {line: 1, column: 15},
- end: {line: 1, column: 16}
- }
- }],
- body: {
- type: "BlockStatement",
- body: [],
- loc: {
- start: {line: 1, column: 18},
- end: {line: 1, column: 20}
- }
- },
- generator: false,
- expression: false,
- loc: {
- start: {line: 1, column: 14},
- end: {line: 1, column: 20}
- }
- },
- kind: "set",
- static: false,
- loc: {
- start: {line: 1, column: 9},
- end: {line: 1, column: 20}
- }
- }],
- loc: {
- start: {line: 1, column: 8},
- end: {line: 1, column: 21}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 21}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 21}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("class A { static set a(v) {}}", {
- type: "Program",
- body: [{
- type: "ClassDeclaration",
- id: {
- type: "Identifier",
- name: "A",
- loc: {
- start: {line: 1, column: 6},
- end: {line: 1, column: 7}
- }
- },
- superClass: null,
- body: {
- type: "ClassBody",
- body: [{
- type: "MethodDefinition",
- computed: false,
- key: {
- type: "Identifier",
- name: "a",
- loc: {
- start: {line: 1, column: 21},
- end: {line: 1, column: 22}
- }
- },
- value: {
- type: "FunctionExpression",
- id: null,
- params: [{
- type: "Identifier",
- name: "v",
- loc: {
- start: {line: 1, column: 23},
- end: {line: 1, column: 24}
- }
- }],
- body: {
- type: "BlockStatement",
- body: [],
- loc: {
- start: {line: 1, column: 26},
- end: {line: 1, column: 28}
- }
- },
- generator: false,
- expression: false,
- loc: {
- start: {line: 1, column: 22},
- end: {line: 1, column: 28}
- }
- },
- kind: "set",
- static: true,
- loc: {
- start: {line: 1, column: 10},
- end: {line: 1, column: 28}
- }
- }],
- loc: {
- start: {line: 1, column: 8},
- end: {line: 1, column: 29}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 29}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 29}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("class A {set(v) {};}", {
- type: "Program",
- body: [{
- type: "ClassDeclaration",
- id: {
- type: "Identifier",
- name: "A",
- loc: {
- start: {line: 1, column: 6},
- end: {line: 1, column: 7}
- }
- },
- superClass: null,
- body: {
- type: "ClassBody",
- body: [{
- type: "MethodDefinition",
- computed: false,
- key: {
- type: "Identifier",
- name: "set",
- loc: {
- start: {line: 1, column: 9},
- end: {line: 1, column: 12}
- }
- },
- value: {
- type: "FunctionExpression",
- id: null,
- params: [{
- type: "Identifier",
- name: "v",
- loc: {
- start: {line: 1, column: 13},
- end: {line: 1, column: 14}
- }
- }],
- body: {
- type: "BlockStatement",
- body: [],
- loc: {
- start: {line: 1, column: 16},
- end: {line: 1, column: 18}
- }
- },
- generator: false,
- expression: false,
- loc: {
- start: {line: 1, column: 12},
- end: {line: 1, column: 18}
- }
- },
- kind: "method",
- static: false,
- loc: {
- start: {line: 1, column: 9},
- end: {line: 1, column: 18}
- }
- }],
- loc: {
- start: {line: 1, column: 8},
- end: {line: 1, column: 20}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 20}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 20}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("class A { static set(v) {};}", {
- type: "Program",
- body: [{
- type: "ClassDeclaration",
- id: {
- type: "Identifier",
- name: "A",
- loc: {
- start: {line: 1, column: 6},
- end: {line: 1, column: 7}
- }
- },
- superClass: null,
- body: {
- type: "ClassBody",
- body: [{
- type: "MethodDefinition",
- computed: false,
- key: {
- type: "Identifier",
- name: "set",
- loc: {
- start: {line: 1, column: 17},
- end: {line: 1, column: 20}
- }
- },
- value: {
- type: "FunctionExpression",
- id: null,
- params: [{
- type: "Identifier",
- name: "v",
- loc: {
- start: {line: 1, column: 21},
- end: {line: 1, column: 22}
- }
- }],
- body: {
- type: "BlockStatement",
- body: [],
- loc: {
- start: {line: 1, column: 24},
- end: {line: 1, column: 26}
- }
- },
- generator: false,
- expression: false,
- loc: {
- start: {line: 1, column: 20},
- end: {line: 1, column: 26}
- }
- },
- kind: "method",
- static: true,
- loc: {
- start: {line: 1, column: 10},
- end: {line: 1, column: 26}
- }
- }],
- loc: {
- start: {line: 1, column: 8},
- end: {line: 1, column: 28}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 28}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 28}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("class A {*gen(v) { yield v; }}", {
- type: "Program",
- body: [{
- type: "ClassDeclaration",
- id: {
- type: "Identifier",
- name: "A",
- loc: {
- start: {line: 1, column: 6},
- end: {line: 1, column: 7}
- }
- },
- superClass: null,
- body: {
- type: "ClassBody",
- body: [{
- type: "MethodDefinition",
- computed: false,
- key: {
- type: "Identifier",
- name: "gen",
- loc: {
- start: {line: 1, column: 10},
- end: {line: 1, column: 13}
- }
- },
- value: {
- type: "FunctionExpression",
- id: null,
- params: [{
- type: "Identifier",
- name: "v",
- loc: {
- start: {line: 1, column: 14},
- end: {line: 1, column: 15}
- }
- }],
- body: {
- type: "BlockStatement",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "YieldExpression",
- argument: {
- type: "Identifier",
- name: "v",
- loc: {
- start: {line: 1, column: 25},
- end: {line: 1, column: 26}
- }
- },
- delegate: false,
- loc: {
- start: {line: 1, column: 19},
- end: {line: 1, column: 26}
- }
- },
- loc: {
- start: {line: 1, column: 19},
- end: {line: 1, column: 27}
- }
- }],
- loc: {
- start: {line: 1, column: 17},
- end: {line: 1, column: 29}
- }
- },
- generator: true,
- expression: false,
- loc: {
- start: {line: 1, column: 13},
- end: {line: 1, column: 29}
- }
- },
- kind: "method",
- static: false,
- loc: {
- start: {line: 1, column: 9},
- end: {line: 1, column: 29}
- }
- }],
- loc: {
- start: {line: 1, column: 8},
- end: {line: 1, column: 30}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 30}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 30}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("class A { static *gen(v) { yield v; }}", {
- type: "Program",
- body: [{
- type: "ClassDeclaration",
- id: {
- type: "Identifier",
- name: "A",
- loc: {
- start: {line: 1, column: 6},
- end: {line: 1, column: 7}
- }
- },
- superClass: null,
- body: {
- type: "ClassBody",
- body: [{
- type: "MethodDefinition",
- computed: false,
- key: {
- type: "Identifier",
- name: "gen",
- loc: {
- start: {line: 1, column: 18},
- end: {line: 1, column: 21}
- }
- },
- value: {
- type: "FunctionExpression",
- id: null,
- params: [{
- type: "Identifier",
- name: "v",
- loc: {
- start: {line: 1, column: 22},
- end: {line: 1, column: 23}
- }
- }],
- body: {
- type: "BlockStatement",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "YieldExpression",
- argument: {
- type: "Identifier",
- name: "v",
- loc: {
- start: {line: 1, column: 33},
- end: {line: 1, column: 34}
- }
- },
- delegate: false,
- loc: {
- start: {line: 1, column: 27},
- end: {line: 1, column: 34}
- }
- },
- loc: {
- start: {line: 1, column: 27},
- end: {line: 1, column: 35}
- }
- }],
- loc: {
- start: {line: 1, column: 25},
- end: {line: 1, column: 37}
- }
- },
- generator: true,
- expression: false,
- loc: {
- start: {line: 1, column: 21},
- end: {line: 1, column: 37}
- }
- },
- kind: "method",
- static: true,
- loc: {
- start: {line: 1, column: 10},
- end: {line: 1, column: 37}
- }
- }],
- loc: {
- start: {line: 1, column: 8},
- end: {line: 1, column: 38}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 38}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 38}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("\"use strict\"; (class A {constructor() { super() }})", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "Literal",
- value: "use strict",
- raw: "\"use strict\"",
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 12}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 13}
- }
- },
- {
- type: "ExpressionStatement",
- expression: {
- type: "ClassExpression",
- id: {
- type: "Identifier",
- name: "A",
- loc: {
- start: {line: 1, column: 21},
- end: {line: 1, column: 22}
- }
- },
- superClass: null,
- body: {
- type: "ClassBody",
- body: [{
- type: "MethodDefinition",
- computed: false,
- key: {
- type: "Identifier",
- name: "constructor",
- loc: {
- start: {line: 1, column: 24},
- end: {line: 1, column: 35}
- }
- },
- value: {
- type: "FunctionExpression",
- id: null,
- params: [],
- body: {
- type: "BlockStatement",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "CallExpression",
- callee: {
- type: "Super",
- loc: {
- start: {line: 1, column: 40},
- end: {line: 1, column: 45}
- }
- },
- arguments: [],
- loc: {
- start: {line: 1, column: 40},
- end: {line: 1, column: 47}
- }
- },
- loc: {
- start: {line: 1, column: 40},
- end: {line: 1, column: 47}
- }
- }],
- loc: {
- start: {line: 1, column: 38},
- end: {line: 1, column: 49}
- }
- },
- generator: false,
- expression: false,
- loc: {
- start: {line: 1, column: 35},
- end: {line: 1, column: 49}
- }
- },
- kind: "constructor",
- static: false,
- loc: {
- start: {line: 1, column: 24},
- end: {line: 1, column: 49}
- }
- }],
- loc: {
- start: {line: 1, column: 23},
- end: {line: 1, column: 50}
- }
- },
- loc: {
- start: {line: 1, column: 15},
- end: {line: 1, column: 50}
- }
- },
- loc: {
- start: {line: 1, column: 14},
- end: {line: 1, column: 51}
- }
- }
- ],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 51}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("class A {'constructor'() {}}", {
- type: "Program",
- body: [{
- type: "ClassDeclaration",
- id: {type: "Identifier", name: "A"},
- superClass: null,
- body: {
- type: "ClassBody",
- body: [{
- type: "MethodDefinition",
- computed: false,
- key: {type: "Literal", value: "constructor"},
- static: false,
- kind: "constructor",
- value: {
- type: "FunctionExpression",
- id: null,
- generator: false,
- expression: false,
- params: [],
- body: {
- type: "BlockStatement",
- body: []
- }
- }
- }]
- }
- }]
-}, {ecmaVersion: 6});
-
-test("class A {static foo() {}}", {
- type: "Program",
- body: [{
- type: "ClassDeclaration",
- id: {
- type: "Identifier",
- name: "A",
- loc: {
- start: {line: 1, column: 6},
- end: {line: 1, column: 7}
- }
- },
- superClass: null,
- body: {
- type: "ClassBody",
- body: [{
- type: "MethodDefinition",
- computed: false,
- key: {
- type: "Identifier",
- name: "foo",
- loc: {
- start: {line: 1, column: 16},
- end: {line: 1, column: 19}
- }
- },
- value: {
- type: "FunctionExpression",
- id: null,
- params: [],
- body: {
- type: "BlockStatement",
- body: [],
- loc: {
- start: {line: 1, column: 22},
- end: {line: 1, column: 24}
- }
- },
- generator: false,
- expression: false,
- loc: {
- start: {line: 1, column: 19},
- end: {line: 1, column: 24}
- }
- },
- kind: "method",
- static: true,
- loc: {
- start: {line: 1, column: 9},
- end: {line: 1, column: 24}
- }
- }],
- loc: {
- start: {line: 1, column: 8},
- end: {line: 1, column: 25}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 25}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 25}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("class A {foo() {} static bar() {}}", {
- type: "Program",
- body: [{
- type: "ClassDeclaration",
- id: {
- type: "Identifier",
- name: "A",
- loc: {
- start: {line: 1, column: 6},
- end: {line: 1, column: 7}
- }
- },
- superClass: null,
- body: {
- type: "ClassBody",
- body: [
- {
- type: "MethodDefinition",
- computed: false,
- key: {
- type: "Identifier",
- name: "foo",
- loc: {
- start: {line: 1, column: 9},
- end: {line: 1, column: 12}
- }
- },
- value: {
- type: "FunctionExpression",
- id: null,
- params: [],
- body: {
- type: "BlockStatement",
- body: [],
- loc: {
- start: {line: 1, column: 15},
- end: {line: 1, column: 17}
- }
- },
- generator: false,
- expression: false,
- loc: {
- start: {line: 1, column: 12},
- end: {line: 1, column: 17}
- }
- },
- kind: "method",
- static: false,
- loc: {
- start: {line: 1, column: 9},
- end: {line: 1, column: 17}
- }
- },
- {
- type: "MethodDefinition",
- computed: false,
- key: {
- type: "Identifier",
- name: "bar",
- loc: {
- start: {line: 1, column: 25},
- end: {line: 1, column: 28}
- }
- },
- value: {
- type: "FunctionExpression",
- id: null,
- params: [],
- body: {
- type: "BlockStatement",
- body: [],
- loc: {
- start: {line: 1, column: 31},
- end: {line: 1, column: 33}
- }
- },
- generator: false,
- expression: false,
- loc: {
- start: {line: 1, column: 28},
- end: {line: 1, column: 33}
- }
- },
- kind: "method",
- static: true,
- loc: {
- start: {line: 1, column: 18},
- end: {line: 1, column: 33}
- }
- }
- ],
- loc: {
- start: {line: 1, column: 8},
- end: {line: 1, column: 34}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 34}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 34}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("\"use strict\"; (class A { static constructor() { super() }})", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "Literal",
- value: "use strict",
- raw: "\"use strict\"",
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 12}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 13}
- }
- },
- {
- type: "ExpressionStatement",
- expression: {
- type: "ClassExpression",
- id: {
- type: "Identifier",
- name: "A",
- loc: {
- start: {line: 1, column: 21},
- end: {line: 1, column: 22}
- }
- },
- superClass: null,
- body: {
- type: "ClassBody",
- body: [{
- type: "MethodDefinition",
- computed: false,
- key: {
- type: "Identifier",
- name: "constructor",
- loc: {
- start: {line: 1, column: 32},
- end: {line: 1, column: 43}
- }
- },
- value: {
- type: "FunctionExpression",
- id: null,
- params: [],
- body: {
- type: "BlockStatement",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "CallExpression",
- callee: {
- type: "Super",
- loc: {
- start: {line: 1, column: 48},
- end: {line: 1, column: 53}
- }
- },
- arguments: [],
- loc: {
- start: {line: 1, column: 48},
- end: {line: 1, column: 55}
- }
- },
- loc: {
- start: {line: 1, column: 48},
- end: {line: 1, column: 55}
- }
- }],
- loc: {
- start: {line: 1, column: 46},
- end: {line: 1, column: 57}
- }
- },
- generator: false,
- expression: false,
- loc: {
- start: {line: 1, column: 43},
- end: {line: 1, column: 57}
- }
- },
- kind: "method",
- static: true,
- loc: {
- start: {line: 1, column: 25},
- end: {line: 1, column: 57}
- }
- }],
- loc: {
- start: {line: 1, column: 23},
- end: {line: 1, column: 58}
- }
- },
- loc: {
- start: {line: 1, column: 15},
- end: {line: 1, column: 58}
- }
- },
- loc: {
- start: {line: 1, column: 14},
- end: {line: 1, column: 59}
- }
- }
- ],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 59}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("class A { foo() {} bar() {}}", {
- type: "Program",
- body: [{
- type: "ClassDeclaration",
- id: {
- type: "Identifier",
- name: "A",
- loc: {
- start: {line: 1, column: 6},
- end: {line: 1, column: 7}
- }
- },
- superClass: null,
- body: {
- type: "ClassBody",
- body: [
- {
- type: "MethodDefinition",
- computed: false,
- key: {
- type: "Identifier",
- name: "foo",
- loc: {
- start: {line: 1, column: 10},
- end: {line: 1, column: 13}
- }
- },
- value: {
- type: "FunctionExpression",
- id: null,
- params: [],
- body: {
- type: "BlockStatement",
- body: [],
- loc: {
- start: {line: 1, column: 16},
- end: {line: 1, column: 18}
- }
- },
- generator: false,
- expression: false,
- loc: {
- start: {line: 1, column: 13},
- end: {line: 1, column: 18}
- }
- },
- kind: "method",
- static: false,
- loc: {
- start: {line: 1, column: 10},
- end: {line: 1, column: 18}
- }
- },
- {
- type: "MethodDefinition",
- computed: false,
- key: {
- type: "Identifier",
- name: "bar",
- loc: {
- start: {line: 1, column: 19},
- end: {line: 1, column: 22}
- }
- },
- value: {
- type: "FunctionExpression",
- id: null,
- params: [],
- body: {
- type: "BlockStatement",
- body: [],
- loc: {
- start: {line: 1, column: 25},
- end: {line: 1, column: 27}
- }
- },
- generator: false,
- expression: false,
- loc: {
- start: {line: 1, column: 22},
- end: {line: 1, column: 27}
- }
- },
- kind: "method",
- static: false,
- loc: {
- start: {line: 1, column: 19},
- end: {line: 1, column: 27}
- }
- }
- ],
- loc: {
- start: {line: 1, column: 8},
- end: {line: 1, column: 28}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 28}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 28}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("class A { get foo() {} set foo(v) {}}", {
- type: "Program",
- body: [{
- type: "ClassDeclaration",
- id: {
- type: "Identifier",
- name: "A",
- loc: {
- start: {line: 1, column: 6},
- end: {line: 1, column: 7}
- }
- },
- superClass: null,
- body: {
- type: "ClassBody",
- body: [
- {
- type: "MethodDefinition",
- computed: false,
- key: {
- type: "Identifier",
- name: "foo",
- loc: {
- start: {line: 1, column: 14},
- end: {line: 1, column: 17}
- }
- },
- value: {
- type: "FunctionExpression",
- id: null,
- params: [],
- body: {
- type: "BlockStatement",
- body: [],
- loc: {
- start: {line: 1, column: 20},
- end: {line: 1, column: 22}
- }
- },
- generator: false,
- expression: false,
- loc: {
- start: {line: 1, column: 17},
- end: {line: 1, column: 22}
- }
- },
- kind: "get",
- static: false,
- loc: {
- start: {line: 1, column: 10},
- end: {line: 1, column: 22}
- }
- },
- {
- type: "MethodDefinition",
- computed: false,
- key: {
- type: "Identifier",
- name: "foo",
- loc: {
- start: {line: 1, column: 27},
- end: {line: 1, column: 30}
- }
- },
- value: {
- type: "FunctionExpression",
- id: null,
- params: [{
- type: "Identifier",
- name: "v",
- loc: {
- start: {line: 1, column: 31},
- end: {line: 1, column: 32}
- }
- }],
- body: {
- type: "BlockStatement",
- body: [],
- loc: {
- start: {line: 1, column: 34},
- end: {line: 1, column: 36}
- }
- },
- generator: false,
- expression: false,
- loc: {
- start: {line: 1, column: 30},
- end: {line: 1, column: 36}
- }
- },
- kind: "set",
- static: false,
- loc: {
- start: {line: 1, column: 23},
- end: {line: 1, column: 36}
- }
- }
- ],
- loc: {
- start: {line: 1, column: 8},
- end: {line: 1, column: 37}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 37}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 37}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("class A { static get foo() {} get foo() {}}", {
- type: "Program",
- body: [{
- type: "ClassDeclaration",
- id: {
- type: "Identifier",
- name: "A",
- loc: {
- start: {line: 1, column: 6},
- end: {line: 1, column: 7}
- }
- },
- superClass: null,
- body: {
- type: "ClassBody",
- body: [
- {
- type: "MethodDefinition",
- computed: false,
- key: {
- type: "Identifier",
- name: "foo",
- loc: {
- start: {line: 1, column: 21},
- end: {line: 1, column: 24}
- }
- },
- value: {
- type: "FunctionExpression",
- id: null,
- params: [],
- body: {
- type: "BlockStatement",
- body: [],
- loc: {
- start: {line: 1, column: 27},
- end: {line: 1, column: 29}
- }
- },
- generator: false,
- expression: false,
- loc: {
- start: {line: 1, column: 24},
- end: {line: 1, column: 29}
- }
- },
- kind: "get",
- static: true,
- loc: {
- start: {line: 1, column: 10},
- end: {line: 1, column: 29}
- }
- },
- {
- type: "MethodDefinition",
- computed: false,
- key: {
- type: "Identifier",
- name: "foo",
- loc: {
- start: {line: 1, column: 34},
- end: {line: 1, column: 37}
- }
- },
- value: {
- type: "FunctionExpression",
- id: null,
- params: [],
- body: {
- type: "BlockStatement",
- body: [],
- loc: {
- start: {line: 1, column: 40},
- end: {line: 1, column: 42}
- }
- },
- generator: false,
- expression: false,
- loc: {
- start: {line: 1, column: 37},
- end: {line: 1, column: 42}
- }
- },
- kind: "get",
- static: false,
- loc: {
- start: {line: 1, column: 30},
- end: {line: 1, column: 42}
- }
- }
- ],
- loc: {
- start: {line: 1, column: 8},
- end: {line: 1, column: 43}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 43}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 43}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("class A { static get foo() {} static get bar() {} }", {
- type: "Program",
- body: [{
- type: "ClassDeclaration",
- id: {
- type: "Identifier",
- name: "A",
- loc: {
- start: {line: 1, column: 6},
- end: {line: 1, column: 7}
- }
- },
- superClass: null,
- body: {
- type: "ClassBody",
- body: [
- {
- type: "MethodDefinition",
- computed: false,
- key: {
- type: "Identifier",
- name: "foo",
- loc: {
- start: {line: 1, column: 21},
- end: {line: 1, column: 24}
- }
- },
- value: {
- type: "FunctionExpression",
- id: null,
- params: [],
- body: {
- type: "BlockStatement",
- body: [],
- loc: {
- start: {line: 1, column: 27},
- end: {line: 1, column: 29}
- }
- },
- generator: false,
- expression: false,
- loc: {
- start: {line: 1, column: 24},
- end: {line: 1, column: 29}
- }
- },
- kind: "get",
- static: true,
- loc: {
- start: {line: 1, column: 10},
- end: {line: 1, column: 29}
- }
- },
- {
- type: "MethodDefinition",
- computed: false,
- key: {
- type: "Identifier",
- name: "bar",
- loc: {
- start: {line: 1, column: 41},
- end: {line: 1, column: 44}
- }
- },
- value: {
- type: "FunctionExpression",
- id: null,
- params: [],
- body: {
- type: "BlockStatement",
- body: [],
- loc: {
- start: {line: 1, column: 47},
- end: {line: 1, column: 49}
- }
- },
- generator: false,
- expression: false,
- loc: {
- start: {line: 1, column: 44},
- end: {line: 1, column: 49}
- }
- },
- kind: "get",
- static: true,
- loc: {
- start: {line: 1, column: 30},
- end: {line: 1, column: 49}
- }
- }
- ],
- loc: {
- start: {line: 1, column: 8},
- end: {line: 1, column: 51}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 51}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 51}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("class A { static get foo() {} static set foo(v) {} get foo() {} set foo(v) {}}", {
- type: "Program",
- body: [{
- type: "ClassDeclaration",
- id: {
- type: "Identifier",
- name: "A",
- loc: {
- start: {line: 1, column: 6},
- end: {line: 1, column: 7}
- }
- },
- superClass: null,
- body: {
- type: "ClassBody",
- body: [
- {
- type: "MethodDefinition",
- computed: false,
- key: {
- type: "Identifier",
- name: "foo",
- loc: {
- start: {line: 1, column: 21},
- end: {line: 1, column: 24}
- }
- },
- value: {
- type: "FunctionExpression",
- id: null,
- params: [],
- body: {
- type: "BlockStatement",
- body: [],
- loc: {
- start: {line: 1, column: 27},
- end: {line: 1, column: 29}
- }
- },
- generator: false,
- expression: false,
- loc: {
- start: {line: 1, column: 24},
- end: {line: 1, column: 29}
- }
- },
- kind: "get",
- static: true,
- loc: {
- start: {line: 1, column: 10},
- end: {line: 1, column: 29}
- }
- },
- {
- type: "MethodDefinition",
- computed: false,
- key: {
- type: "Identifier",
- name: "foo",
- loc: {
- start: {line: 1, column: 41},
- end: {line: 1, column: 44}
- }
- },
- value: {
- type: "FunctionExpression",
- id: null,
- params: [{
- type: "Identifier",
- name: "v",
- loc: {
- start: {line: 1, column: 45},
- end: {line: 1, column: 46}
- }
- }],
- body: {
- type: "BlockStatement",
- body: [],
- loc: {
- start: {line: 1, column: 48},
- end: {line: 1, column: 50}
- }
- },
- generator: false,
- expression: false,
- loc: {
- start: {line: 1, column: 44},
- end: {line: 1, column: 50}
- }
- },
- kind: "set",
- static: true,
- loc: {
- start: {line: 1, column: 30},
- end: {line: 1, column: 50}
- }
- },
- {
- type: "MethodDefinition",
- computed: false,
- key: {
- type: "Identifier",
- name: "foo",
- loc: {
- start: {line: 1, column: 55},
- end: {line: 1, column: 58}
- }
- },
- value: {
- type: "FunctionExpression",
- id: null,
- params: [],
- body: {
- type: "BlockStatement",
- body: [],
- loc: {
- start: {line: 1, column: 61},
- end: {line: 1, column: 63}
- }
- },
- generator: false,
- expression: false,
- loc: {
- start: {line: 1, column: 58},
- end: {line: 1, column: 63}
- }
- },
- kind: "get",
- static: false,
- loc: {
- start: {line: 1, column: 51},
- end: {line: 1, column: 63}
- }
- },
- {
- type: "MethodDefinition",
- computed: false,
- key: {
- type: "Identifier",
- name: "foo",
- loc: {
- start: {line: 1, column: 68},
- end: {line: 1, column: 71}
- }
- },
- value: {
- type: "FunctionExpression",
- id: null,
- params: [{
- type: "Identifier",
- name: "v",
- loc: {
- start: {line: 1, column: 72},
- end: {line: 1, column: 73}
- }
- }],
- body: {
- type: "BlockStatement",
- body: [],
- loc: {
- start: {line: 1, column: 75},
- end: {line: 1, column: 77}
- }
- },
- generator: false,
- expression: false,
- loc: {
- start: {line: 1, column: 71},
- end: {line: 1, column: 77}
- }
- },
- kind: "set",
- static: false,
- loc: {
- start: {line: 1, column: 64},
- end: {line: 1, column: 77}
- }
- }
- ],
- loc: {
- start: {line: 1, column: 8},
- end: {line: 1, column: 78}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 78}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 78}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-
-test("class A { static [foo]() {} }", {
- type: "Program",
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 29}
- },
- body: [{
- type: "ClassDeclaration",
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 29}
- },
- id: {
- type: "Identifier",
- loc: {
- start: {line: 1, column: 6},
- end: {line: 1, column: 7}
- },
- name: "A"
- },
- superClass: null,
- body: {
- type: "ClassBody",
- loc: {
- start: {line: 1, column: 8},
- end: {line: 1, column: 29}
- },
- body: [{
- type: "MethodDefinition",
- loc: {
- start: {line: 1, column: 10},
- end: {line: 1, column: 27}
- },
- static: true,
- computed: true,
- key: {
- type: "Identifier",
- loc: {
- start: {line: 1, column: 18},
- end: {line: 1, column: 21}
- },
- name: "foo"
- },
- kind: "method",
- value: {
- type: "FunctionExpression",
- loc: {
- start: {line: 1, column: 22},
- end: {line: 1, column: 27}
- },
- id: null,
- params: [],
- generator: false,
- body: {
- type: "BlockStatement",
- loc: {
- start: {line: 1, column: 25},
- end: {line: 1, column: 27}
- },
- body: []
- },
- expression: false
- }
- }]
- }
- }]
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("class A { static get [foo]() {} }", {
- type: "Program",
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 33}
- },
- body: [{
- type: "ClassDeclaration",
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 33}
- },
- id: {
- type: "Identifier",
- loc: {
- start: {line: 1, column: 6},
- end: {line: 1, column: 7}
- },
- range: [
- 6,
- 7
- ],
- name: "A"
- },
- superClass: null,
- body: {
- type: "ClassBody",
- loc: {
- start: {line: 1, column: 8},
- end: {line: 1, column: 33}
- },
- body: [{
- type: "MethodDefinition",
- loc: {
- start: {line: 1, column: 10},
- end: {line: 1, column: 31}
- },
- static: true,
- computed: true,
- key: {
- type: "Identifier",
- loc: {
- start: {line: 1, column: 22},
- end: {line: 1, column: 25}
- },
- name: "foo"
- },
- kind: "get",
- value: {
- type: "FunctionExpression",
- loc: {
- start: {line: 1, column: 26},
- end: {line: 1, column: 31}
- },
- id: null,
- params: [],
- generator: false,
- body: {
- type: "BlockStatement",
- loc: {
- start: {line: 1, column: 29},
- end: {line: 1, column: 31}
- },
- body: []
- },
- expression: false
- }
- }]
- }
- }]
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("class A { set foo(v) {} get foo() {} }", {
- type: "Program",
- body: [{
- type: "ClassDeclaration",
- id: {
- type: "Identifier",
- name: "A",
- loc: {
- start: {line: 1, column: 6},
- end: {line: 1, column: 7}
- }
- },
- superClass: null,
- body: {
- type: "ClassBody",
- body: [
- {
- type: "MethodDefinition",
- computed: false,
- key: {
- type: "Identifier",
- name: "foo",
- loc: {
- start: {line: 1, column: 14},
- end: {line: 1, column: 17}
- }
- },
- value: {
- type: "FunctionExpression",
- id: null,
- params: [{
- type: "Identifier",
- name: "v",
- loc: {
- start: {line: 1, column: 18},
- end: {line: 1, column: 19}
- }
- }],
- body: {
- type: "BlockStatement",
- body: [],
- loc: {
- start: {line: 1, column: 21},
- end: {line: 1, column: 23}
- }
- },
- generator: false,
- expression: false,
- loc: {
- start: {line: 1, column: 17},
- end: {line: 1, column: 23}
- }
- },
- kind: "set",
- static: false,
- loc: {
- start: {line: 1, column: 10},
- end: {line: 1, column: 23}
- }
- },
- {
- type: "MethodDefinition",
- computed: false,
- key: {
- type: "Identifier",
- name: "foo",
- loc: {
- start: {line: 1, column: 28},
- end: {line: 1, column: 31}
- }
- },
- value: {
- type: "FunctionExpression",
- id: null,
- params: [],
- body: {
- type: "BlockStatement",
- body: [],
- loc: {
- start: {line: 1, column: 34},
- end: {line: 1, column: 36}
- }
- },
- generator: false,
- expression: false,
- loc: {
- start: {line: 1, column: 31},
- end: {line: 1, column: 36}
- }
- },
- kind: "get",
- static: false,
- loc: {
- start: {line: 1, column: 24},
- end: {line: 1, column: 36}
- }
- }
- ],
- loc: {
- start: {line: 1, column: 8},
- end: {line: 1, column: 38}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 38}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 38}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("class A { foo() {} get foo() {} }",{
- type: "Program",
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 33}
- },
- body: [{
- type: "ClassDeclaration",
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 33}
- },
- id: {
- type: "Identifier",
- loc: {
- start: {line: 1, column: 6},
- end: {line: 1, column: 7}
- },
- name: "A"
- },
- superClass: null,
- body: {
- type: "ClassBody",
- loc: {
- start: {line: 1, column: 8},
- end: {line: 1, column: 33}
- },
- body: [
- {
- type: "MethodDefinition",
- loc: {
- start: {line: 1, column: 10},
- end: {line: 1, column: 18}
- },
- static: false,
- computed: false,
- key: {
- type: "Identifier",
- loc: {
- start: {line: 1, column: 10},
- end: {line: 1, column: 13}
- },
- name: "foo"
- },
- kind: "method",
- value: {
- type: "FunctionExpression",
- loc: {
- start: {line: 1, column: 13},
- end: {line: 1, column: 18}
- },
- id: null,
- params: [],
- generator: false,
- body: {
- type: "BlockStatement",
- loc: {
- start: {line: 1, column: 16},
- end: {line: 1, column: 18}
- },
- body: []
- },
- expression: false
- }
- },
- {
- type: "MethodDefinition",
- loc: {
- start: {line: 1, column: 19},
- end: {line: 1, column: 31}
- },
- static: false,
- computed: false,
- key: {
- type: "Identifier",
- loc: {
- start: {line: 1, column: 23},
- end: {line: 1, column: 26}
- },
- name: "foo"
- },
- kind: "get",
- value: {
- type: "FunctionExpression",
- loc: {
- start: {line: 1, column: 26},
- end: {line: 1, column: 31}
- },
- id: null,
- params: [],
- generator: false,
- body: {
- type: "BlockStatement",
- loc: {
- start: {line: 1, column: 29},
- end: {line: 1, column: 31}
- },
- body: []
- },
- expression: false
- }
- }
- ]
- }
- }]
-},{
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("class Semicolon { ; }", {
- type: "Program",
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 21}
- },
- body: [{
- type: "ClassDeclaration",
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 21}
- },
- id: {
- type: "Identifier",
- loc: {
- start: {line: 1, column: 6},
- end: {line: 1, column: 15}
- },
- name: "Semicolon"
- },
- superClass: null,
- body: {
- type: "ClassBody",
- loc: {
- start: {line: 1, column: 16},
- end: {line: 1, column: 21}
- },
- body: []
- }
- }]
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-// ES6: Computed Properties
-
-test("({[x]: 10})", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "ObjectExpression",
- properties: [{
- type: "Property",
- key: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {line: 1, column: 3},
- end: {line: 1, column: 4}
- }
- },
- value: {
- type: "Literal",
- value: 10,
- raw: "10",
- loc: {
- start: {line: 1, column: 7},
- end: {line: 1, column: 9}
- }
- },
- kind: "init",
- method: false,
- shorthand: false,
- computed: true,
- loc: {
- start: {line: 1, column: 2},
- end: {line: 1, column: 9}
- }
- }],
- loc: {
- start: {line: 1, column: 1},
- end: {line: 1, column: 10}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 11}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 11}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("({[\"x\" + \"y\"]: 10})", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "ObjectExpression",
- properties: [{
- type: "Property",
- key: {
- type: "BinaryExpression",
- operator: "+",
- left: {
- type: "Literal",
- value: "x",
- raw: "\"x\"",
- loc: {
- start: {line: 1, column: 3},
- end: {line: 1, column: 6}
- }
- },
- right: {
- type: "Literal",
- value: "y",
- raw: "\"y\"",
- loc: {
- start: {line: 1, column: 9},
- end: {line: 1, column: 12}
- }
- },
- loc: {
- start: {line: 1, column: 3},
- end: {line: 1, column: 12}
- }
- },
- value: {
- type: "Literal",
- value: 10,
- raw: "10",
- loc: {
- start: {line: 1, column: 15},
- end: {line: 1, column: 17}
- }
- },
- kind: "init",
- method: false,
- shorthand: false,
- computed: true,
- loc: {
- start: {line: 1, column: 2},
- end: {line: 1, column: 17}
- }
- }],
- loc: {
- start: {line: 1, column: 1},
- end: {line: 1, column: 18}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 19}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 19}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("({[x]: function() {}})", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "ObjectExpression",
- properties: [{
- type: "Property",
- key: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {line: 1, column: 3},
- end: {line: 1, column: 4}
- }
- },
- value: {
- type: "FunctionExpression",
- id: null,
- params: [],
- body: {
- type: "BlockStatement",
- body: [],
- loc: {
- start: {line: 1, column: 18},
- end: {line: 1, column: 20}
- }
- },
- generator: false,
- expression: false,
- loc: {
- start: {line: 1, column: 7},
- end: {line: 1, column: 20}
- }
- },
- kind: "init",
- method: false,
- shorthand: false,
- computed: true,
- loc: {
- start: {line: 1, column: 2},
- end: {line: 1, column: 20}
- }
- }],
- loc: {
- start: {line: 1, column: 1},
- end: {line: 1, column: 21}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 22}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 22}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("({[x]: 10, y: 20})", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "ObjectExpression",
- properties: [
- {
- type: "Property",
- key: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {line: 1, column: 3},
- end: {line: 1, column: 4}
- }
- },
- value: {
- type: "Literal",
- value: 10,
- raw: "10",
- loc: {
- start: {line: 1, column: 7},
- end: {line: 1, column: 9}
- }
- },
- kind: "init",
- method: false,
- shorthand: false,
- computed: true,
- loc: {
- start: {line: 1, column: 2},
- end: {line: 1, column: 9}
- }
- },
- {
- type: "Property",
- key: {
- type: "Identifier",
- name: "y",
- loc: {
- start: {line: 1, column: 11},
- end: {line: 1, column: 12}
- }
- },
- value: {
- type: "Literal",
- value: 20,
- raw: "20",
- loc: {
- start: {line: 1, column: 14},
- end: {line: 1, column: 16}
- }
- },
- kind: "init",
- method: false,
- shorthand: false,
- computed: false,
- loc: {
- start: {line: 1, column: 11},
- end: {line: 1, column: 16}
- }
- }
- ],
- loc: {
- start: {line: 1, column: 1},
- end: {line: 1, column: 17}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 18}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 18}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("({get [x]() {}, set [x](v) {}})", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "ObjectExpression",
- properties: [
- {
- type: "Property",
- key: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {line: 1, column: 7},
- end: {line: 1, column: 8}
- }
- },
- value: {
- type: "FunctionExpression",
- id: null,
- params: [],
- body: {
- type: "BlockStatement",
- body: [],
- loc: {
- start: {line: 1, column: 12},
- end: {line: 1, column: 14}
- }
- },
- generator: false,
- expression: false,
- loc: {
- start: {line: 1, column: 9},
- end: {line: 1, column: 14}
- }
- },
- kind: "get",
- method: false,
- shorthand: false,
- computed: true,
- loc: {
- start: {line: 1, column: 2},
- end: {line: 1, column: 14}
- }
- },
- {
- type: "Property",
- key: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {line: 1, column: 21},
- end: {line: 1, column: 22}
- }
- },
- value: {
- type: "FunctionExpression",
- id: null,
- params: [{
- type: "Identifier",
- name: "v",
- loc: {
- start: {line: 1, column: 24},
- end: {line: 1, column: 25}
- }
- }],
- body: {
- type: "BlockStatement",
- body: [],
- loc: {
- start: {line: 1, column: 27},
- end: {line: 1, column: 29}
- }
- },
- generator: false,
- expression: false,
- loc: {
- start: {line: 1, column: 23},
- end: {line: 1, column: 29}
- }
- },
- kind: "set",
- method: false,
- shorthand: false,
- computed: true,
- loc: {
- start: {line: 1, column: 16},
- end: {line: 1, column: 29}
- }
- }
- ],
- loc: {
- start: {line: 1, column: 1},
- end: {line: 1, column: 30}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 31}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 31}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("({[x]() {}})", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "ObjectExpression",
- properties: [{
- type: "Property",
- key: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {line: 1, column: 3},
- end: {line: 1, column: 4}
- }
- },
- value: {
- type: "FunctionExpression",
- id: null,
- params: [],
- body: {
- type: "BlockStatement",
- body: [],
- loc: {
- start: {line: 1, column: 8},
- end: {line: 1, column: 10}
- }
- },
- generator: false,
- expression: false,
- loc: {
- start: {line: 1, column: 5},
- end: {line: 1, column: 10}
- }
- },
- kind: "init",
- method: true,
- shorthand: false,
- computed: true,
- loc: {
- start: {line: 1, column: 2},
- end: {line: 1, column: 10}
- }
- }],
- loc: {
- start: {line: 1, column: 1},
- end: {line: 1, column: 11}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 12}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 12}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("var {[x]: y} = {y}", {
- type: "Program",
- body: [{
- type: "VariableDeclaration",
- declarations: [{
- type: "VariableDeclarator",
- id: {
- type: "ObjectPattern",
- properties: [{
- type: "Property",
- key: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {line: 1, column: 6},
- end: {line: 1, column: 7}
- }
- },
- value: {
- type: "Identifier",
- name: "y",
- loc: {
- start: {line: 1, column: 10},
- end: {line: 1, column: 11}
- }
- },
- kind: "init",
- method: false,
- shorthand: false,
- computed: true,
- loc: {
- start: {line: 1, column: 5},
- end: {line: 1, column: 11}
- }
- }],
- loc: {
- start: {line: 1, column: 4},
- end: {line: 1, column: 12}
- }
- },
- init: {
- type: "ObjectExpression",
- properties: [{
- type: "Property",
- key: {
- type: "Identifier",
- name: "y",
- loc: {
- start: {line: 1, column: 16},
- end: {line: 1, column: 17}
- }
- },
- value: {
- type: "Identifier",
- name: "y",
- loc: {
- start: {line: 1, column: 16},
- end: {line: 1, column: 17}
- }
- },
- kind: "init",
- method: false,
- shorthand: true,
- computed: false,
- loc: {
- start: {line: 1, column: 16},
- end: {line: 1, column: 17}
- }
- }],
- loc: {
- start: {line: 1, column: 15},
- end: {line: 1, column: 18}
- }
- },
- loc: {
- start: {line: 1, column: 4},
- end: {line: 1, column: 18}
- }
- }],
- kind: "var",
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 18}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 18}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("function f({[x]: y}) {}", {
- type: "Program",
- body: [{
- type: "FunctionDeclaration",
- id: {
- type: "Identifier",
- name: "f",
- loc: {
- start: {line: 1, column: 9},
- end: {line: 1, column: 10}
- }
- },
- params: [{
- type: "ObjectPattern",
- properties: [{
- type: "Property",
- key: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {line: 1, column: 13},
- end: {line: 1, column: 14}
- }
- },
- value: {
- type: "Identifier",
- name: "y",
- loc: {
- start: {line: 1, column: 17},
- end: {line: 1, column: 18}
- }
- },
- kind: "init",
- method: false,
- shorthand: false,
- computed: true,
- loc: {
- start: {line: 1, column: 12},
- end: {line: 1, column: 18}
- }
- }],
- loc: {
- start: {line: 1, column: 11},
- end: {line: 1, column: 19}
- }
- }],
- body: {
- type: "BlockStatement",
- body: [],
- loc: {
- start: {line: 1, column: 21},
- end: {line: 1, column: 23}
- }
- },
- generator: false,
- expression: false,
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 23}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 23}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("var x = {*[test]() { yield *v; }}", {
- type: "Program",
- body: [{
- type: "VariableDeclaration",
- declarations: [{
- type: "VariableDeclarator",
- id: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {line: 1, column: 4},
- end: {line: 1, column: 5}
- }
- },
- init: {
- type: "ObjectExpression",
- properties: [{
- type: "Property",
- key: {
- type: "Identifier",
- name: "test",
- loc: {
- start: {line: 1, column: 11},
- end: {line: 1, column: 15}
- }
- },
- value: {
- type: "FunctionExpression",
- id: null,
- params: [],
- body: {
- type: "BlockStatement",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "YieldExpression",
- argument: {
- type: "Identifier",
- name: "v",
- loc: {
- start: {line: 1, column: 28},
- end: {line: 1, column: 29}
- }
- },
- delegate: true,
- loc: {
- start: {line: 1, column: 21},
- end: {line: 1, column: 29}
- }
- },
- loc: {
- start: {line: 1, column: 21},
- end: {line: 1, column: 30}
- }
- }],
- loc: {
- start: {line: 1, column: 19},
- end: {line: 1, column: 32}
- }
- },
- generator: true,
- expression: false,
- loc: {
- start: {line: 1, column: 16},
- end: {line: 1, column: 32}
- }
- },
- kind: "init",
- method: true,
- shorthand: false,
- computed: true,
- loc: {
- start: {line: 1, column: 9},
- end: {line: 1, column: 32}
- }
- }],
- loc: {
- start: {line: 1, column: 8},
- end: {line: 1, column: 33}
- }
- },
- loc: {
- start: {line: 1, column: 4},
- end: {line: 1, column: 33}
- }
- }],
- kind: "var",
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 33}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 33}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("class A {[x]() {}}", {
- type: "Program",
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 18}
- },
- body: [{
- type: "ClassDeclaration",
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 18}
- },
- id: {
- type: "Identifier",
- loc: {
- start: {line: 1, column: 6},
- end: {line: 1, column: 7}
- },
- name: "A"
- },
- superClass: null,
- body: {
- type: "ClassBody",
- loc: {
- start: {line: 1, column: 8},
- end: {line: 1, column: 18}
- },
- body: [{
- type: "MethodDefinition",
- loc: {
- start: {line: 1, column: 9},
- end: {line: 1, column: 17}
- },
- static: false,
- computed: true,
- key: {
- type: "Identifier",
- loc: {
- start: {line: 1, column: 10},
- end: {line: 1, column: 11}
- },
- name: "x"
- },
- kind: "method",
- value: {
- type: "FunctionExpression",
- loc: {
- start: {line: 1, column: 12},
- end: {line: 1, column: 17}
- },
- id: null,
- params: [],
- generator: false,
- body: {
- type: "BlockStatement",
- loc: {
- start: {line: 1, column: 15},
- end: {line: 1, column: 17}
- },
- body: []
- },
- expression: false
- }
- }]
- }
- }]
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-testFail("({[x]})", "Unexpected token (1:5)", {ecmaVersion: 6});
-
-// ES6: Default parameters
-
-test("function f([x] = [1]) {}", {
- type: "Program",
- body: [{
- type: "FunctionDeclaration",
- id: {
- type: "Identifier",
- name: "f",
- loc: {
- start: {line: 1, column: 9},
- end: {line: 1, column: 10}
- }
- },
- params: [{
- type: "AssignmentPattern",
- left: {
- type: "ArrayPattern",
- elements: [{
- type: "Identifier",
- name: "x",
- loc: {
- start: {line: 1, column: 12},
- end: {line: 1, column: 13}
- }
- }],
- loc: {
- start: {line: 1, column: 11},
- end: {line: 1, column: 14}
- }
- },
- right: {
- type: "ArrayExpression",
- elements: [{
- type: "Literal",
- value: 1,
- raw: "1",
- loc: {
- start: {line: 1, column: 18},
- end: {line: 1, column: 19}
- }
- }],
- loc: {
- start: {line: 1, column: 17},
- end: {line: 1, column: 20}
- }
- },
- loc: {
- start: {line: 1, column: 11},
- end: {line: 1, column: 20}
- }
- }],
- body: {
- type: "BlockStatement",
- body: [],
- loc: {
- start: {line: 1, column: 22},
- end: {line: 1, column: 24}
- }
- },
- generator: false,
- expression: false,
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 24}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 24}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("function f({x} = {x: 10}) {}", {
- type: "Program",
- body: [{
- type: "FunctionDeclaration",
- id: {
- type: "Identifier",
- name: "f",
- loc: {
- start: {line: 1, column: 9},
- end: {line: 1, column: 10}
- }
- },
- params: [{
- type: "AssignmentPattern",
- left: {
- type: "ObjectPattern",
- properties: [{
- type: "Property",
- key: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {line: 1, column: 12},
- end: {line: 1, column: 13}
- }
- },
- value: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {line: 1, column: 12},
- end: {line: 1, column: 13}
- }
- },
- kind: "init",
- method: false,
- shorthand: true,
- computed: false,
- loc: {
- start: {line: 1, column: 12},
- end: {line: 1, column: 13}
- }
- }],
- loc: {
- start: {line: 1, column: 11},
- end: {line: 1, column: 14}
- }
- },
- right: {
- type: "ObjectExpression",
- properties: [{
- type: "Property",
- key: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {line: 1, column: 18},
- end: {line: 1, column: 19}
- }
- },
- value: {
- type: "Literal",
- value: 10,
- raw: "10",
- loc: {
- start: {line: 1, column: 21},
- end: {line: 1, column: 23}
- }
- },
- kind: "init",
- method: false,
- shorthand: false,
- computed: false,
- loc: {
- start: {line: 1, column: 18},
- end: {line: 1, column: 23}
- }
- }],
- loc: {
- start: {line: 1, column: 17},
- end: {line: 1, column: 24}
- }
- },
- loc: {
- start: {line: 1, column: 11},
- end: {line: 1, column: 24}
- }
- }],
- body: {
- type: "BlockStatement",
- body: [],
- loc: {
- start: {line: 1, column: 26},
- end: {line: 1, column: 28}
- }
- },
- generator: false,
- expression: false,
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 28}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 28}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("f = function({x} = {x: 10}) {}", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "AssignmentExpression",
- operator: "=",
- left: {
- type: "Identifier",
- name: "f",
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 1}
- }
- },
- right: {
- type: "FunctionExpression",
- id: null,
- params: [{
- type: "AssignmentPattern",
- left: {
- type: "ObjectPattern",
- properties: [{
- type: "Property",
- key: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {line: 1, column: 14},
- end: {line: 1, column: 15}
- }
- },
- value: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {line: 1, column: 14},
- end: {line: 1, column: 15}
- }
- },
- kind: "init",
- method: false,
- shorthand: true,
- computed: false,
- loc: {
- start: {line: 1, column: 14},
- end: {line: 1, column: 15}
- }
- }],
- loc: {
- start: {line: 1, column: 13},
- end: {line: 1, column: 16}
- }
- },
- right: {
- type: "ObjectExpression",
- properties: [{
- type: "Property",
- key: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {line: 1, column: 20},
- end: {line: 1, column: 21}
- }
- },
- value: {
- type: "Literal",
- value: 10,
- raw: "10",
- loc: {
- start: {line: 1, column: 23},
- end: {line: 1, column: 25}
- }
- },
- kind: "init",
- method: false,
- shorthand: false,
- computed: false,
- loc: {
- start: {line: 1, column: 20},
- end: {line: 1, column: 25}
- }
- }],
- loc: {
- start: {line: 1, column: 19},
- end: {line: 1, column: 26}
- }
- },
- loc: {
- start: {line: 1, column: 13},
- end: {line: 1, column: 26}
- }
- }],
- body: {
- type: "BlockStatement",
- body: [],
- loc: {
- start: {line: 1, column: 28},
- end: {line: 1, column: 30}
- }
- },
- generator: false,
- expression: false,
- loc: {
- start: {line: 1, column: 4},
- end: {line: 1, column: 30}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 30}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 30}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 30}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("({f: function({x} = {x: 10}) {}})", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "ObjectExpression",
- properties: [{
- type: "Property",
- key: {
- type: "Identifier",
- name: "f",
- loc: {
- start: {line: 1, column: 2},
- end: {line: 1, column: 3}
- }
- },
- value: {
- type: "FunctionExpression",
- id: null,
- params: [{
- type: "AssignmentPattern",
- left: {
- type: "ObjectPattern",
- properties: [{
- type: "Property",
- key: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {line: 1, column: 15},
- end: {line: 1, column: 16}
- }
- },
- value: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {line: 1, column: 15},
- end: {line: 1, column: 16}
- }
- },
- kind: "init",
- method: false,
- shorthand: true,
- computed: false,
- loc: {
- start: {line: 1, column: 15},
- end: {line: 1, column: 16}
- }
- }],
- loc: {
- start: {line: 1, column: 14},
- end: {line: 1, column: 17}
- }
- },
- right: {
- type: "ObjectExpression",
- properties: [{
- type: "Property",
- key: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {line: 1, column: 21},
- end: {line: 1, column: 22}
- }
- },
- value: {
- type: "Literal",
- value: 10,
- raw: "10",
- loc: {
- start: {line: 1, column: 24},
- end: {line: 1, column: 26}
- }
- },
- kind: "init",
- method: false,
- shorthand: false,
- computed: false,
- loc: {
- start: {line: 1, column: 21},
- end: {line: 1, column: 26}
- }
- }],
- loc: {
- start: {line: 1, column: 20},
- end: {line: 1, column: 27}
- }
- },
- loc: {
- start: {line: 1, column: 14},
- end: {line: 1, column: 27}
- }
- }],
- body: {
- type: "BlockStatement",
- body: [],
- loc: {
- start: {line: 1, column: 29},
- end: {line: 1, column: 31}
- }
- },
- generator: false,
- expression: false,
- loc: {
- start: {line: 1, column: 5},
- end: {line: 1, column: 31}
- }
- },
- kind: "init",
- method: false,
- shorthand: false,
- computed: false,
- loc: {
- start: {line: 1, column: 2},
- end: {line: 1, column: 31}
- }
- }],
- loc: {
- start: {line: 1, column: 1},
- end: {line: 1, column: 32}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 33}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 33}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("({f({x} = {x: 10}) {}})", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "ObjectExpression",
- properties: [{
- type: "Property",
- key: {
- type: "Identifier",
- name: "f",
- loc: {
- start: {line: 1, column: 2},
- end: {line: 1, column: 3}
- }
- },
- value: {
- type: "FunctionExpression",
- id: null,
- params: [{
- type: "AssignmentPattern",
- left: {
- type: "ObjectPattern",
- properties: [{
- type: "Property",
- key: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {line: 1, column: 5},
- end: {line: 1, column: 6}
- }
- },
- value: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {line: 1, column: 5},
- end: {line: 1, column: 6}
- }
- },
- kind: "init",
- method: false,
- shorthand: true,
- computed: false,
- loc: {
- start: {line: 1, column: 5},
- end: {line: 1, column: 6}
- }
- }],
- loc: {
- start: {line: 1, column: 4},
- end: {line: 1, column: 7}
- }
- },
- right: {
- type: "ObjectExpression",
- properties: [{
- type: "Property",
- key: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {line: 1, column: 11},
- end: {line: 1, column: 12}
- }
- },
- value: {
- type: "Literal",
- value: 10,
- raw: "10",
- loc: {
- start: {line: 1, column: 14},
- end: {line: 1, column: 16}
- }
- },
- kind: "init",
- method: false,
- shorthand: false,
- computed: false,
- loc: {
- start: {line: 1, column: 11},
- end: {line: 1, column: 16}
- }
- }],
- loc: {
- start: {line: 1, column: 10},
- end: {line: 1, column: 17}
- }
- },
- loc: {
- start: {line: 1, column: 4},
- end: {line: 1, column: 17}
- }
- }],
- body: {
- type: "BlockStatement",
- body: [],
- loc: {
- start: {line: 1, column: 19},
- end: {line: 1, column: 21}
- }
- },
- generator: false,
- expression: false,
- loc: {
- start: {line: 1, column: 3},
- end: {line: 1, column: 21}
- }
- },
- kind: "init",
- method: true,
- shorthand: false,
- computed: false,
- loc: {
- start: {line: 1, column: 2},
- end: {line: 1, column: 21}
- }
- }],
- loc: {
- start: {line: 1, column: 1},
- end: {line: 1, column: 22}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 23}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 23}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("(class {f({x} = {x: 10}) {}})", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "ClassExpression",
- superClass: null,
- body: {
- type: "ClassBody",
- body: [{
- type: "MethodDefinition",
- computed: false,
- key: {
- type: "Identifier",
- name: "f",
- loc: {
- start: {line: 1, column: 8},
- end: {line: 1, column: 9}
- }
- },
- value: {
- type: "FunctionExpression",
- id: null,
- params: [{
- type: "AssignmentPattern",
- left: {
- type: "ObjectPattern",
- properties: [{
- type: "Property",
- key: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {line: 1, column: 11},
- end: {line: 1, column: 12}
- }
- },
- value: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {line: 1, column: 11},
- end: {line: 1, column: 12}
- }
- },
- kind: "init",
- method: false,
- shorthand: true,
- computed: false,
- loc: {
- start: {line: 1, column: 11},
- end: {line: 1, column: 12}
- }
- }],
- loc: {
- start: {line: 1, column: 10},
- end: {line: 1, column: 13}
- }
- },
- right: {
- type: "ObjectExpression",
- properties: [{
- type: "Property",
- key: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {line: 1, column: 17},
- end: {line: 1, column: 18}
- }
- },
- value: {
- type: "Literal",
- value: 10,
- raw: "10",
- loc: {
- start: {line: 1, column: 20},
- end: {line: 1, column: 22}
- }
- },
- kind: "init",
- method: false,
- shorthand: false,
- computed: false,
- loc: {
- start: {line: 1, column: 17},
- end: {line: 1, column: 22}
- }
- }],
- loc: {
- start: {line: 1, column: 16},
- end: {line: 1, column: 23}
- }
- },
- loc: {
- start: {line: 1, column: 10},
- end: {line: 1, column: 23}
- }
- }],
- body: {
- type: "BlockStatement",
- body: [],
- loc: {
- start: {line: 1, column: 25},
- end: {line: 1, column: 27}
- }
- },
- generator: false,
- expression: false,
- loc: {
- start: {line: 1, column: 9},
- end: {line: 1, column: 27}
- }
- },
- kind: "method",
- static: false,
- loc: {
- start: {line: 1, column: 8},
- end: {line: 1, column: 27}
- }
- }],
- loc: {
- start: {line: 1, column: 7},
- end: {line: 1, column: 28}
- }
- },
- loc: {
- start: {line: 1, column: 1},
- end: {line: 1, column: 28}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 29}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 29}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("(({x} = {x: 10}) => {})", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "ArrowFunctionExpression",
- id: null,
- params: [{
- type: "AssignmentPattern",
- left: {
- type: "ObjectPattern",
- properties: [{
- type: "Property",
- key: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {line: 1, column: 3},
- end: {line: 1, column: 4}
- }
- },
- value: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {line: 1, column: 3},
- end: {line: 1, column: 4}
- }
- },
- kind: "init",
- method: false,
- shorthand: true,
- computed: false,
- loc: {
- start: {line: 1, column: 3},
- end: {line: 1, column: 4}
- }
- }],
- loc: {
- start: {line: 1, column: 2},
- end: {line: 1, column: 5}
- }
- },
- right: {
- type: "ObjectExpression",
- properties: [{
- type: "Property",
- key: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {line: 1, column: 9},
- end: {line: 1, column: 10}
- }
- },
- value: {
- type: "Literal",
- value: 10,
- raw: "10",
- loc: {
- start: {line: 1, column: 12},
- end: {line: 1, column: 14}
- }
- },
- kind: "init",
- method: false,
- shorthand: false,
- computed: false,
- loc: {
- start: {line: 1, column: 9},
- end: {line: 1, column: 14}
- }
- }],
- loc: {
- start: {line: 1, column: 8},
- end: {line: 1, column: 15}
- }
- },
- loc: {
- start: {line: 1, column: 2},
- end: {line: 1, column: 15}
- }
- }],
- body: {
- type: "BlockStatement",
- body: [],
- loc: {
- start: {line: 1, column: 20},
- end: {line: 1, column: 22}
- }
- },
- generator: false,
- expression: false,
- loc: {
- start: {line: 1, column: 1},
- end: {line: 1, column: 22}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 23}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 23}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("x = function(y = 1) {}", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "AssignmentExpression",
- operator: "=",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 1}
- }
- },
- right: {
- type: "FunctionExpression",
- id: null,
- params: [{
- type: "AssignmentPattern",
- left: {
- type: "Identifier",
- name: "y",
- loc: {
- start: {line: 1, column: 13},
- end: {line: 1, column: 14}
- }
- },
- right: {
- type: "Literal",
- value: 1,
- raw: "1",
- loc: {
- start: {line: 1, column: 17},
- end: {line: 1, column: 18}
- }
- },
- loc: {
- start: {line: 1, column: 13},
- end: {line: 1, column: 18}
- }
- }],
- body: {
- type: "BlockStatement",
- body: [],
- loc: {
- start: {line: 1, column: 20},
- end: {line: 1, column: 22}
- }
- },
- generator: false,
- expression: false,
- loc: {
- start: {line: 1, column: 4},
- end: {line: 1, column: 22}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 22}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 22}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 22}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("function f(a = 1) {}", {
- type: "Program",
- body: [{
- type: "FunctionDeclaration",
- id: {
- type: "Identifier",
- name: "f",
- loc: {
- start: {line: 1, column: 9},
- end: {line: 1, column: 10}
- }
- },
- params: [{
- type: "AssignmentPattern",
- left: {
- type: "Identifier",
- name: "a",
- loc: {
- start: {line: 1, column: 11},
- end: {line: 1, column: 12}
- }
- },
- right: {
- type: "Literal",
- value: 1,
- raw: "1",
- loc: {
- start: {line: 1, column: 15},
- end: {line: 1, column: 16}
- }
- },
- loc: {
- start: {line: 1, column: 11},
- end: {line: 1, column: 16}
- }
- }],
- body: {
- type: "BlockStatement",
- body: [],
- loc: {
- start: {line: 1, column: 18},
- end: {line: 1, column: 20}
- }
- },
- generator: false,
- expression: false,
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 20}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 20}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("x = { f: function(a=1) {} }", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "AssignmentExpression",
- operator: "=",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 1}
- }
- },
- right: {
- type: "ObjectExpression",
- properties: [{
- type: "Property",
- key: {
- type: "Identifier",
- name: "f",
- loc: {
- start: {line: 1, column: 6},
- end: {line: 1, column: 7}
- }
- },
- value: {
- type: "FunctionExpression",
- id: null,
- params: [{
- type: "AssignmentPattern",
- left: {
- type: "Identifier",
- name: "a",
- loc: {
- start: {line: 1, column: 18},
- end: {line: 1, column: 19}
- }
- },
- right: {
- type: "Literal",
- value: 1,
- raw: "1",
- loc: {
- start: {line: 1, column: 20},
- end: {line: 1, column: 21}
- }
- },
- loc: {
- start: {line: 1, column: 18},
- end: {line: 1, column: 21}
- }
- }],
- body: {
- type: "BlockStatement",
- body: [],
- loc: {
- start: {line: 1, column: 23},
- end: {line: 1, column: 25}
- }
- },
- generator: false,
- expression: false,
- loc: {
- start: {line: 1, column: 9},
- end: {line: 1, column: 25}
- }
- },
- kind: "init",
- method: false,
- shorthand: false,
- computed: false,
- loc: {
- start: {line: 1, column: 6},
- end: {line: 1, column: 25}
- }
- }],
- loc: {
- start: {line: 1, column: 4},
- end: {line: 1, column: 27}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 27}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 27}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 27}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("x = { f(a=1) {} }", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "AssignmentExpression",
- operator: "=",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 1}
- }
- },
- right: {
- type: "ObjectExpression",
- properties: [{
- type: "Property",
- key: {
- type: "Identifier",
- name: "f",
- loc: {
- start: {line: 1, column: 6},
- end: {line: 1, column: 7}
- }
- },
- value: {
- type: "FunctionExpression",
- id: null,
- params: [{
- type: "AssignmentPattern",
- left: {
- type: "Identifier",
- name: "a",
- loc: {
- start: {line: 1, column: 8},
- end: {line: 1, column: 9}
- }
- },
- right: {
- type: "Literal",
- value: 1,
- raw: "1",
- loc: {
- start: {line: 1, column: 10},
- end: {line: 1, column: 11}
- }
- },
- loc: {
- start: {line: 1, column: 8},
- end: {line: 1, column: 11}
- }
- }],
- body: {
- type: "BlockStatement",
- body: [],
- loc: {
- start: {line: 1, column: 13},
- end: {line: 1, column: 15}
- }
- },
- generator: false,
- expression: false,
- loc: {
- start: {line: 1, column: 7},
- end: {line: 1, column: 15}
- }
- },
- kind: "init",
- method: true,
- shorthand: false,
- computed: false,
- loc: {
- start: {line: 1, column: 6},
- end: {line: 1, column: 15}
- }
- }],
- loc: {
- start: {line: 1, column: 4},
- end: {line: 1, column: 17}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 17}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 17}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 17}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-// ES6: Rest parameters
-
-test("function f(a, ...b) {}", {
- type: "Program",
- body: [{
- type: "FunctionDeclaration",
- id: {
- type: "Identifier",
- name: "f",
- loc: {
- start: {line: 1, column: 9},
- end: {line: 1, column: 10}
- }
- },
- params: [
- {
- type: "Identifier",
- name: "a",
- loc: {
- start: {line: 1, column: 11},
- end: {line: 1, column: 12}
- }
- },
- {
- type: "RestElement",
- argument: {
- type: "Identifier",
- name: "b",
- loc: {
- start: {line: 1, column: 17},
- end: {line: 1, column: 18}
- }
- }
- }
- ],
- body: {
- type: "BlockStatement",
- body: [],
- loc: {
- start: {line: 1, column: 20},
- end: {line: 1, column: 22}
- }
- },
- generator: false,
- expression: false,
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 22}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 22}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-// ES6: Destructured Parameters
-
-test("function x([ a, b ]){}", {
- type: "Program",
- body: [{
- type: "FunctionDeclaration",
- id: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {line: 1, column: 9},
- end: {line: 1, column: 10}
- }
- },
- params: [{
- type: "ArrayPattern",
- elements: [
- {
- type: "Identifier",
- name: "a",
- loc: {
- start: {line: 1, column: 13},
- end: {line: 1, column: 14}
- }
- },
- {
- type: "Identifier",
- name: "b",
- loc: {
- start: {line: 1, column: 16},
- end: {line: 1, column: 17}
- }
- }
- ],
- loc: {
- start: {line: 1, column: 11},
- end: {line: 1, column: 19}
- }
- }],
- body: {
- type: "BlockStatement",
- body: [],
- loc: {
- start: {line: 1, column: 20},
- end: {line: 1, column: 22}
- }
- },
- generator: false,
- expression: false,
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 22}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 22}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("function x({ a, b }){}", {
- type: "Program",
- body: [{
- type: "FunctionDeclaration",
- id: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {line: 1, column: 9},
- end: {line: 1, column: 10}
- }
- },
- params: [{
- type: "ObjectPattern",
- properties: [
- {
- type: "Property",
- key: {
- type: "Identifier",
- name: "a",
- loc: {
- start: {line: 1, column: 13},
- end: {line: 1, column: 14}
- }
- },
- value: {
- type: "Identifier",
- name: "a",
- loc: {
- start: {line: 1, column: 13},
- end: {line: 1, column: 14}
- }
- },
- kind: "init",
- method: false,
- shorthand: true,
- computed: false,
- loc: {
- start: {line: 1, column: 13},
- end: {line: 1, column: 14}
- }
- },
- {
- type: "Property",
- key: {
- type: "Identifier",
- name: "b",
- loc: {
- start: {line: 1, column: 16},
- end: {line: 1, column: 17}
- }
- },
- value: {
- type: "Identifier",
- name: "b",
- loc: {
- start: {line: 1, column: 16},
- end: {line: 1, column: 17}
- }
- },
- kind: "init",
- method: false,
- shorthand: true,
- computed: false,
- loc: {
- start: {line: 1, column: 16},
- end: {line: 1, column: 17}
- }
- }
- ],
- loc: {
- start: {line: 1, column: 11},
- end: {line: 1, column: 19}
- }
- }],
- body: {
- type: "BlockStatement",
- body: [],
- loc: {
- start: {line: 1, column: 20},
- end: {line: 1, column: 22}
- }
- },
- generator: false,
- expression: false,
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 22}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 22}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("function x(a, { a }){}", {
- type: "Program",
- body: [{
- type: "FunctionDeclaration",
- id: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {line: 1, column: 9},
- end: {line: 1, column: 10}
- }
- },
- params: [
- {
- type: "Identifier",
- name: "a",
- loc: {
- start: {line: 1, column: 11},
- end: {line: 1, column: 12}
- }
- },
- {
- type: "ObjectPattern",
- properties: [{
- type: "Property",
- key: {
- type: "Identifier",
- name: "a",
- loc: {
- start: {line: 1, column: 16},
- end: {line: 1, column: 17}
- }
- },
- value: {
- type: "Identifier",
- name: "a",
- loc: {
- start: {line: 1, column: 16},
- end: {line: 1, column: 17}
- }
- },
- kind: "init",
- method: false,
- shorthand: true,
- computed: false,
- loc: {
- start: {line: 1, column: 16},
- end: {line: 1, column: 17}
- }
- }],
- loc: {
- start: {line: 1, column: 14},
- end: {line: 1, column: 19}
- }
- }
- ],
- body: {
- type: "BlockStatement",
- body: [],
- loc: {
- start: {line: 1, column: 20},
- end: {line: 1, column: 22}
- }
- },
- generator: false,
- expression: false,
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 22}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 22}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("function x(...[ a, b ]){}", {
- type: "Program",
- body: [{
- type: "FunctionDeclaration",
- id: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {line: 1, column: 9},
- end: {line: 1, column: 10}
- }
- },
- params: [{
- type: "RestElement",
- argument: {
- type: "ArrayPattern",
- elements: [
- {
- type: "Identifier",
- name: "a",
- loc: {
- start: {line: 1, column: 16},
- end: {line: 1, column: 17}
- }
- },
- {
- type: "Identifier",
- name: "b",
- loc: {
- start: {line: 1, column: 19},
- end: {line: 1, column: 20}
- }
- }
- ],
- loc: {
- start: {line: 1, column: 14},
- end: {line: 1, column: 22}
- }
- }
- }],
- body: {
- type: "BlockStatement",
- body: [],
- loc: {
- start: {line: 1, column: 23},
- end: {line: 1, column: 25}
- }
- },
- generator: false,
- expression: false,
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 25}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 25}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("function x({ a: { w, x }, b: [y, z] }, ...[a, b, c]){}", {
- type: "Program",
- body: [{
- type: "FunctionDeclaration",
- id: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {line: 1, column: 9},
- end: {line: 1, column: 10}
- }
- },
- params: [
- {
- type: "ObjectPattern",
- properties: [
- {
- type: "Property",
- key: {
- type: "Identifier",
- name: "a",
- loc: {
- start: {line: 1, column: 13},
- end: {line: 1, column: 14}
- }
- },
- value: {
- type: "ObjectPattern",
- properties: [
- {
- type: "Property",
- key: {
- type: "Identifier",
- name: "w",
- loc: {
- start: {line: 1, column: 18},
- end: {line: 1, column: 19}
- }
- },
- value: {
- type: "Identifier",
- name: "w",
- loc: {
- start: {line: 1, column: 18},
- end: {line: 1, column: 19}
- }
- },
- kind: "init",
- method: false,
- shorthand: true,
- computed: false,
- loc: {
- start: {line: 1, column: 18},
- end: {line: 1, column: 19}
- }
- },
- {
- type: "Property",
- key: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {line: 1, column: 21},
- end: {line: 1, column: 22}
- }
- },
- value: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {line: 1, column: 21},
- end: {line: 1, column: 22}
- }
- },
- kind: "init",
- method: false,
- shorthand: true,
- computed: false,
- loc: {
- start: {line: 1, column: 21},
- end: {line: 1, column: 22}
- }
- }
- ],
- loc: {
- start: {line: 1, column: 16},
- end: {line: 1, column: 24}
- }
- },
- kind: "init",
- method: false,
- shorthand: false,
- computed: false,
- loc: {
- start: {line: 1, column: 13},
- end: {line: 1, column: 24}
- }
- },
- {
- type: "Property",
- key: {
- type: "Identifier",
- name: "b",
- loc: {
- start: {line: 1, column: 26},
- end: {line: 1, column: 27}
- }
- },
- value: {
- type: "ArrayPattern",
- elements: [
- {
- type: "Identifier",
- name: "y",
- loc: {
- start: {line: 1, column: 30},
- end: {line: 1, column: 31}
- }
- },
- {
- type: "Identifier",
- name: "z",
- loc: {
- start: {line: 1, column: 33},
- end: {line: 1, column: 34}
- }
- }
- ],
- loc: {
- start: {line: 1, column: 29},
- end: {line: 1, column: 35}
- }
- },
- kind: "init",
- method: false,
- shorthand: false,
- computed: false,
- loc: {
- start: {line: 1, column: 26},
- end: {line: 1, column: 35}
- }
- }
- ],
- loc: {
- start: {line: 1, column: 11},
- end: {line: 1, column: 37}
- }
- },
- {
- type: "RestElement",
- argument: {
- type: "ArrayPattern",
- elements: [
- {
- type: "Identifier",
- name: "a",
- loc: {
- start: {line: 1, column: 43},
- end: {line: 1, column: 44}
- }
- },
- {
- type: "Identifier",
- name: "b",
- loc: {
- start: {line: 1, column: 46},
- end: {line: 1, column: 47}
- }
- },
- {
- type: "Identifier",
- name: "c",
- loc: {
- start: {line: 1, column: 49},
- end: {line: 1, column: 50}
- }
- }
- ],
- loc: {
- start: {line: 1, column: 42},
- end: {line: 1, column: 51}
- }
- }
- }
- ],
- body: {
- type: "BlockStatement",
- body: [],
- loc: {
- start: {line: 1, column: 52},
- end: {line: 1, column: 54}
- }
- },
- generator: false,
- expression: false,
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 54}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 54}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("(function x([ a, b ]){})", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "FunctionExpression",
- id: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {line: 1, column: 10},
- end: {line: 1, column: 11}
- }
- },
- params: [{
- type: "ArrayPattern",
- elements: [
- {
- type: "Identifier",
- name: "a",
- loc: {
- start: {line: 1, column: 14},
- end: {line: 1, column: 15}
- }
- },
- {
- type: "Identifier",
- name: "b",
- loc: {
- start: {line: 1, column: 17},
- end: {line: 1, column: 18}
- }
- }
- ],
- loc: {
- start: {line: 1, column: 12},
- end: {line: 1, column: 20}
- }
- }],
- body: {
- type: "BlockStatement",
- body: [],
- loc: {
- start: {line: 1, column: 21},
- end: {line: 1, column: 23}
- }
- },
- generator: false,
- expression: false,
- loc: {
- start: {line: 1, column: 1},
- end: {line: 1, column: 23}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 24}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 24}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("(function x({ a, b }){})", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "FunctionExpression",
- id: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {line: 1, column: 10},
- end: {line: 1, column: 11}
- }
- },
- params: [{
- type: "ObjectPattern",
- properties: [
- {
- type: "Property",
- key: {
- type: "Identifier",
- name: "a",
- loc: {
- start: {line: 1, column: 14},
- end: {line: 1, column: 15}
- }
- },
- value: {
- type: "Identifier",
- name: "a",
- loc: {
- start: {line: 1, column: 14},
- end: {line: 1, column: 15}
- }
- },
- kind: "init",
- method: false,
- shorthand: true,
- computed: false,
- loc: {
- start: {line: 1, column: 14},
- end: {line: 1, column: 15}
- }
- },
- {
- type: "Property",
- key: {
- type: "Identifier",
- name: "b",
- loc: {
- start: {line: 1, column: 17},
- end: {line: 1, column: 18}
- }
- },
- value: {
- type: "Identifier",
- name: "b",
- loc: {
- start: {line: 1, column: 17},
- end: {line: 1, column: 18}
- }
- },
- kind: "init",
- method: false,
- shorthand: true,
- computed: false,
- loc: {
- start: {line: 1, column: 17},
- end: {line: 1, column: 18}
- }
- }
- ],
- loc: {
- start: {line: 1, column: 12},
- end: {line: 1, column: 20}
- }
- }],
- body: {
- type: "BlockStatement",
- body: [],
- loc: {
- start: {line: 1, column: 21},
- end: {line: 1, column: 23}
- }
- },
- generator: false,
- expression: false,
- loc: {
- start: {line: 1, column: 1},
- end: {line: 1, column: 23}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 24}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 24}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("(function x(...[ a, b ]){})", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "FunctionExpression",
- id: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {line: 1, column: 10},
- end: {line: 1, column: 11}
- }
- },
- params: [{
- type: "RestElement",
- argument: {
- type: "ArrayPattern",
- elements: [
- {
- type: "Identifier",
- name: "a",
- loc: {
- start: {line: 1, column: 17},
- end: {line: 1, column: 18}
- }
- },
- {
- type: "Identifier",
- name: "b",
- loc: {
- start: {line: 1, column: 20},
- end: {line: 1, column: 21}
- }
- }
- ],
- loc: {
- start: {line: 1, column: 15},
- end: {line: 1, column: 23}
- }
- }
- }],
- body: {
- type: "BlockStatement",
- body: [],
- loc: {
- start: {line: 1, column: 24},
- end: {line: 1, column: 26}
- }
- },
- generator: false,
- expression: false,
- loc: {
- start: {line: 1, column: 1},
- end: {line: 1, column: 26}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 27}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 27}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("(function x({ a: { w, x }, b: [y, z] }, ...[a, b, c]){})", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "FunctionExpression",
- id: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {line: 1, column: 10},
- end: {line: 1, column: 11}
- }
- },
- params: [
- {
- type: "ObjectPattern",
- properties: [
- {
- type: "Property",
- key: {
- type: "Identifier",
- name: "a",
- loc: {
- start: {line: 1, column: 14},
- end: {line: 1, column: 15}
- }
- },
- value: {
- type: "ObjectPattern",
- properties: [
- {
- type: "Property",
- key: {
- type: "Identifier",
- name: "w",
- loc: {
- start: {line: 1, column: 19},
- end: {line: 1, column: 20}
- }
- },
- value: {
- type: "Identifier",
- name: "w",
- loc: {
- start: {line: 1, column: 19},
- end: {line: 1, column: 20}
- }
- },
- kind: "init",
- method: false,
- shorthand: true,
- computed: false,
- loc: {
- start: {line: 1, column: 19},
- end: {line: 1, column: 20}
- }
- },
- {
- type: "Property",
- key: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {line: 1, column: 22},
- end: {line: 1, column: 23}
- }
- },
- value: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {line: 1, column: 22},
- end: {line: 1, column: 23}
- }
- },
- kind: "init",
- method: false,
- shorthand: true,
- computed: false,
- loc: {
- start: {line: 1, column: 22},
- end: {line: 1, column: 23}
- }
- }
- ],
- loc: {
- start: {line: 1, column: 17},
- end: {line: 1, column: 25}
- }
- },
- kind: "init",
- method: false,
- shorthand: false,
- computed: false,
- loc: {
- start: {line: 1, column: 14},
- end: {line: 1, column: 25}
- }
- },
- {
- type: "Property",
- key: {
- type: "Identifier",
- name: "b",
- loc: {
- start: {line: 1, column: 27},
- end: {line: 1, column: 28}
- }
- },
- value: {
- type: "ArrayPattern",
- elements: [
- {
- type: "Identifier",
- name: "y",
- loc: {
- start: {line: 1, column: 31},
- end: {line: 1, column: 32}
- }
- },
- {
- type: "Identifier",
- name: "z",
- loc: {
- start: {line: 1, column: 34},
- end: {line: 1, column: 35}
- }
- }
- ],
- loc: {
- start: {line: 1, column: 30},
- end: {line: 1, column: 36}
- }
- },
- kind: "init",
- method: false,
- shorthand: false,
- computed: false,
- loc: {
- start: {line: 1, column: 27},
- end: {line: 1, column: 36}
- }
- }
- ],
- loc: {
- start: {line: 1, column: 12},
- end: {line: 1, column: 38}
- }
- },
- {
- type: "RestElement",
- argument: {
- type: "ArrayPattern",
- elements: [
- {
- type: "Identifier",
- name: "a",
- loc: {
- start: {line: 1, column: 44},
- end: {line: 1, column: 45}
- }
- },
- {
- type: "Identifier",
- name: "b",
- loc: {
- start: {line: 1, column: 47},
- end: {line: 1, column: 48}
- }
- },
- {
- type: "Identifier",
- name: "c",
- loc: {
- start: {line: 1, column: 50},
- end: {line: 1, column: 51}
- }
- }
- ],
- loc: {
- start: {line: 1, column: 43},
- end: {line: 1, column: 52}
- }
- }
- }
- ],
- body: {
- type: "BlockStatement",
- body: [],
- loc: {
- start: {line: 1, column: 53},
- end: {line: 1, column: 55}
- }
- },
- generator: false,
- expression: false,
- loc: {
- start: {line: 1, column: 1},
- end: {line: 1, column: 55}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 56}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 56}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("({ x([ a, b ]){} })", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "ObjectExpression",
- properties: [{
- type: "Property",
- key: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {line: 1, column: 3},
- end: {line: 1, column: 4}
- }
- },
- value: {
- type: "FunctionExpression",
- id: null,
- params: [{
- type: "ArrayPattern",
- elements: [
- {
- type: "Identifier",
- name: "a",
- loc: {
- start: {line: 1, column: 7},
- end: {line: 1, column: 8}
- }
- },
- {
- type: "Identifier",
- name: "b",
- loc: {
- start: {line: 1, column: 10},
- end: {line: 1, column: 11}
- }
- }
- ],
- loc: {
- start: {line: 1, column: 5},
- end: {line: 1, column: 13}
- }
- }],
- body: {
- type: "BlockStatement",
- body: [],
- loc: {
- start: {line: 1, column: 14},
- end: {line: 1, column: 16}
- }
- },
- generator: false,
- expression: false,
- loc: {
- start: {line: 1, column: 4},
- end: {line: 1, column: 16}
- }
- },
- kind: "init",
- method: true,
- shorthand: false,
- computed: false,
- loc: {
- start: {line: 1, column: 3},
- end: {line: 1, column: 16}
- }
- }],
- loc: {
- start: {line: 1, column: 1},
- end: {line: 1, column: 18}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 19}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 19}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("({ x(...[ a, b ]){} })", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "ObjectExpression",
- properties: [{
- type: "Property",
- key: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {line: 1, column: 3},
- end: {line: 1, column: 4}
- }
- },
- value: {
- type: "FunctionExpression",
- id: null,
- params: [{
- type: "RestElement",
- argument: {
- type: "ArrayPattern",
- elements: [
- {
- type: "Identifier",
- name: "a",
- loc: {
- start: {line: 1, column: 10},
- end: {line: 1, column: 11}
- }
- },
- {
- type: "Identifier",
- name: "b",
- loc: {
- start: {line: 1, column: 13},
- end: {line: 1, column: 14}
- }
- }
- ],
- loc: {
- start: {line: 1, column: 8},
- end: {line: 1, column: 16}
- }
- }
- }],
- body: {
- type: "BlockStatement",
- body: [],
- loc: {
- start: {line: 1, column: 17},
- end: {line: 1, column: 19}
- }
- },
- generator: false,
- expression: false,
- loc: {
- start: {line: 1, column: 4},
- end: {line: 1, column: 19}
- }
- },
- kind: "init",
- method: true,
- shorthand: false,
- computed: false,
- loc: {
- start: {line: 1, column: 3},
- end: {line: 1, column: 19}
- }
- }],
- loc: {
- start: {line: 1, column: 1},
- end: {line: 1, column: 21}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 22}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 22}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("({ x({ a: { w, x }, b: [y, z] }, ...[a, b, c]){} })", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "ObjectExpression",
- properties: [{
- type: "Property",
- key: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {line: 1, column: 3},
- end: {line: 1, column: 4}
- }
- },
- value: {
- type: "FunctionExpression",
- id: null,
- params: [
- {
- type: "ObjectPattern",
- properties: [
- {
- type: "Property",
- key: {
- type: "Identifier",
- name: "a",
- loc: {
- start: {line: 1, column: 7},
- end: {line: 1, column: 8}
- }
- },
- value: {
- type: "ObjectPattern",
- properties: [
- {
- type: "Property",
- key: {
- type: "Identifier",
- name: "w",
- loc: {
- start: {line: 1, column: 12},
- end: {line: 1, column: 13}
- }
- },
- value: {
- type: "Identifier",
- name: "w",
- loc: {
- start: {line: 1, column: 12},
- end: {line: 1, column: 13}
- }
- },
- kind: "init",
- method: false,
- shorthand: true,
- computed: false,
- loc: {
- start: {line: 1, column: 12},
- end: {line: 1, column: 13}
- }
- },
- {
- type: "Property",
- key: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {line: 1, column: 15},
- end: {line: 1, column: 16}
- }
- },
- value: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {line: 1, column: 15},
- end: {line: 1, column: 16}
- }
- },
- kind: "init",
- method: false,
- shorthand: true,
- computed: false,
- loc: {
- start: {line: 1, column: 15},
- end: {line: 1, column: 16}
- }
- }
- ],
- loc: {
- start: {line: 1, column: 10},
- end: {line: 1, column: 18}
- }
- },
- kind: "init",
- method: false,
- shorthand: false,
- computed: false,
- loc: {
- start: {line: 1, column: 7},
- end: {line: 1, column: 18}
- }
- },
- {
- type: "Property",
- key: {
- type: "Identifier",
- name: "b",
- loc: {
- start: {line: 1, column: 20},
- end: {line: 1, column: 21}
- }
- },
- value: {
- type: "ArrayPattern",
- elements: [
- {
- type: "Identifier",
- name: "y",
- loc: {
- start: {line: 1, column: 24},
- end: {line: 1, column: 25}
- }
- },
- {
- type: "Identifier",
- name: "z",
- loc: {
- start: {line: 1, column: 27},
- end: {line: 1, column: 28}
- }
- }
- ],
- loc: {
- start: {line: 1, column: 23},
- end: {line: 1, column: 29}
- }
- },
- kind: "init",
- method: false,
- shorthand: false,
- computed: false,
- loc: {
- start: {line: 1, column: 20},
- end: {line: 1, column: 29}
- }
- }
- ],
- loc: {
- start: {line: 1, column: 5},
- end: {line: 1, column: 31}
- }
- },
- {
- type: "RestElement",
- argument: {
- type: "ArrayPattern",
- elements: [
- {
- type: "Identifier",
- name: "a",
- loc: {
- start: {line: 1, column: 37},
- end: {line: 1, column: 38}
- }
- },
- {
- type: "Identifier",
- name: "b",
- loc: {
- start: {line: 1, column: 40},
- end: {line: 1, column: 41}
- }
- },
- {
- type: "Identifier",
- name: "c",
- loc: {
- start: {line: 1, column: 43},
- end: {line: 1, column: 44}
- }
- }
- ],
- loc: {
- start: {line: 1, column: 36},
- end: {line: 1, column: 45}
- }
- }
- }
- ],
- body: {
- type: "BlockStatement",
- body: [],
- loc: {
- start: {line: 1, column: 46},
- end: {line: 1, column: 48}
- }
- },
- generator: false,
- expression: false,
- loc: {
- start: {line: 1, column: 4},
- end: {line: 1, column: 48}
- }
- },
- kind: "init",
- method: true,
- shorthand: false,
- computed: false,
- loc: {
- start: {line: 1, column: 3},
- end: {line: 1, column: 48}
- }
- }],
- loc: {
- start: {line: 1, column: 1},
- end: {line: 1, column: 50}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 51}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 51}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("(...a) => {}", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "ArrowFunctionExpression",
- id: null,
- params: [{
- type: "RestElement",
- argument: {
- type: "Identifier",
- name: "a",
- loc: {
- start: {line: 1, column: 4},
- end: {line: 1, column: 5}
- }
- }
- }],
- body: {
- type: "BlockStatement",
- body: [],
- loc: {
- start: {line: 1, column: 10},
- end: {line: 1, column: 12}
- }
- },
- generator: false,
- expression: false,
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 12}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 12}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 12}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("(a, ...b) => {}", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "ArrowFunctionExpression",
- id: null,
- params: [
- {
- type: "Identifier",
- name: "a",
- loc: {
- start: {line: 1, column: 1},
- end: {line: 1, column: 2}
- }
- },
- {
- type: "RestElement",
- argument: {
- type: "Identifier",
- name: "b",
- loc: {
- start: {line: 1, column: 7},
- end: {line: 1, column: 8}
- }
- }
- }
- ],
- body: {
- type: "BlockStatement",
- body: [],
- loc: {
- start: {line: 1, column: 13},
- end: {line: 1, column: 15}
- }
- },
- generator: false,
- expression: false,
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 15}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 15}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 15}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("({ a }) => {}", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "ArrowFunctionExpression",
- id: null,
- params: [{
- type: "ObjectPattern",
- properties: [{
- type: "Property",
- key: {
- type: "Identifier",
- name: "a",
- loc: {
- start: {line: 1, column: 3},
- end: {line: 1, column: 4}
- }
- },
- value: {
- type: "Identifier",
- name: "a",
- loc: {
- start: {line: 1, column: 3},
- end: {line: 1, column: 4}
- }
- },
- kind: "init",
- method: false,
- shorthand: true,
- computed: false,
- loc: {
- start: {line: 1, column: 3},
- end: {line: 1, column: 4}
- }
- }],
- loc: {
- start: {line: 1, column: 1},
- end: {line: 1, column: 6}
- }
- }],
- body: {
- type: "BlockStatement",
- body: [],
- loc: {
- start: {line: 1, column: 11},
- end: {line: 1, column: 13}
- }
- },
- generator: false,
- expression: false,
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 13}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 13}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 13}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("({ a }, ...b) => {}", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "ArrowFunctionExpression",
- id: null,
- params: [
- {
- type: "ObjectPattern",
- properties: [{
- type: "Property",
- key: {
- type: "Identifier",
- name: "a",
- loc: {
- start: {line: 1, column: 3},
- end: {line: 1, column: 4}
- }
- },
- value: {
- type: "Identifier",
- name: "a",
- loc: {
- start: {line: 1, column: 3},
- end: {line: 1, column: 4}
- }
- },
- kind: "init",
- method: false,
- shorthand: true,
- computed: false,
- loc: {
- start: {line: 1, column: 3},
- end: {line: 1, column: 4}
- }
- }],
- loc: {
- start: {line: 1, column: 1},
- end: {line: 1, column: 6}
- }
- },
- {
- type: "RestElement",
- argument: {
- type: "Identifier",
- name: "b",
- loc: {
- start: {line: 1, column: 11},
- end: {line: 1, column: 12}
- }
- }
- }
- ],
- body: {
- type: "BlockStatement",
- body: [],
- loc: {
- start: {line: 1, column: 17},
- end: {line: 1, column: 19}
- }
- },
- generator: false,
- expression: false,
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 19}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 19}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 19}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("(...[a, b]) => {}", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "ArrowFunctionExpression",
- id: null,
- params: [{
- type: "RestElement",
- argument: {
- type: "ArrayPattern",
- elements: [
- {
- type: "Identifier",
- name: "a",
- loc: {
- start: {line: 1, column: 5},
- end: {line: 1, column: 6}
- }
- },
- {
- type: "Identifier",
- name: "b",
- loc: {
- start: {line: 1, column: 8},
- end: {line: 1, column: 9}
- }
- }
- ],
- loc: {
- start: {line: 1, column: 4},
- end: {line: 1, column: 10}
- }
- }
- }],
- body: {
- type: "BlockStatement",
- body: [],
- loc: {
- start: {line: 1, column: 15},
- end: {line: 1, column: 17}
- }
- },
- generator: false,
- expression: false,
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 17}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 17}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 17}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("(a, ...[b]) => {}", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "ArrowFunctionExpression",
- id: null,
- params: [
- {
- type: "Identifier",
- name: "a",
- loc: {
- start: {line: 1, column: 1},
- end: {line: 1, column: 2}
- }
- },
- {
- type: "RestElement",
- argument: {
- type: "ArrayPattern",
- elements: [{
- type: "Identifier",
- name: "b",
- loc: {
- start: {line: 1, column: 8},
- end: {line: 1, column: 9}
- }
- }],
- loc: {
- start: {line: 1, column: 7},
- end: {line: 1, column: 10}
- }
- }
- }
- ],
- body: {
- type: "BlockStatement",
- body: [],
- loc: {
- start: {line: 1, column: 15},
- end: {line: 1, column: 17}
- }
- },
- generator: false,
- expression: false,
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 17}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 17}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 17}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("({ a: [a, b] }, ...c) => {}", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "ArrowFunctionExpression",
- id: null,
- params: [
- {
- type: "ObjectPattern",
- properties: [{
- type: "Property",
- key: {
- type: "Identifier",
- name: "a",
- loc: {
- start: {line: 1, column: 3},
- end: {line: 1, column: 4}
- }
- },
- value: {
- type: "ArrayPattern",
- elements: [
- {
- type: "Identifier",
- name: "a",
- loc: {
- start: {line: 1, column: 7},
- end: {line: 1, column: 8}
- }
- },
- {
- type: "Identifier",
- name: "b",
- loc: {
- start: {line: 1, column: 10},
- end: {line: 1, column: 11}
- }
- }
- ],
- loc: {
- start: {line: 1, column: 6},
- end: {line: 1, column: 12}
- }
- },
- kind: "init",
- method: false,
- shorthand: false,
- computed: false,
- loc: {
- start: {line: 1, column: 3},
- end: {line: 1, column: 12}
- }
- }],
- loc: {
- start: {line: 1, column: 1},
- end: {line: 1, column: 14}
- }
- },
- {
- type: "RestElement",
- argument: {
- type: "Identifier",
- name: "c",
- loc: {
- start: {line: 1, column: 19},
- end: {line: 1, column: 20}
- }
- }
- }
- ],
- body: {
- type: "BlockStatement",
- body: [],
- loc: {
- start: {line: 1, column: 25},
- end: {line: 1, column: 27}
- }
- },
- generator: false,
- expression: false,
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 27}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 27}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 27}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("({ a: b, c }, [d, e], ...f) => {}", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "ArrowFunctionExpression",
- id: null,
- params: [
- {
- type: "ObjectPattern",
- properties: [
- {
- type: "Property",
- key: {
- type: "Identifier",
- name: "a",
- loc: {
- start: {line: 1, column: 3},
- end: {line: 1, column: 4}
- }
- },
- value: {
- type: "Identifier",
- name: "b",
- loc: {
- start: {line: 1, column: 6},
- end: {line: 1, column: 7}
- }
- },
- kind: "init",
- method: false,
- shorthand: false,
- computed: false,
- loc: {
- start: {line: 1, column: 3},
- end: {line: 1, column: 7}
- }
- },
- {
- type: "Property",
- key: {
- type: "Identifier",
- name: "c",
- loc: {
- start: {line: 1, column: 9},
- end: {line: 1, column: 10}
- }
- },
- value: {
- type: "Identifier",
- name: "c",
- loc: {
- start: {line: 1, column: 9},
- end: {line: 1, column: 10}
- }
- },
- kind: "init",
- method: false,
- shorthand: true,
- computed: false,
- loc: {
- start: {line: 1, column: 9},
- end: {line: 1, column: 10}
- }
- }
- ],
- loc: {
- start: {line: 1, column: 1},
- end: {line: 1, column: 12}
- }
- },
- {
- type: "ArrayPattern",
- elements: [
- {
- type: "Identifier",
- name: "d",
- loc: {
- start: {line: 1, column: 15},
- end: {line: 1, column: 16}
- }
- },
- {
- type: "Identifier",
- name: "e",
- loc: {
- start: {line: 1, column: 18},
- end: {line: 1, column: 19}
- }
- }
- ],
- loc: {
- start: {line: 1, column: 14},
- end: {line: 1, column: 20}
- }
- },
- {
- type: "RestElement",
- argument: {
- type: "Identifier",
- name: "f",
- loc: {
- start: {line: 1, column: 25},
- end: {line: 1, column: 26}
- }
- }
- }
- ],
- body: {
- type: "BlockStatement",
- body: [],
- loc: {
- start: {line: 1, column: 31},
- end: {line: 1, column: 33}
- }
- },
- generator: false,
- expression: false,
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 33}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 33}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 33}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-// ES6: SpreadElement
-
-test("[...a] = b", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "AssignmentExpression",
- operator: "=",
- left: {
- type: "ArrayPattern",
- elements: [{
- type: "RestElement",
- argument: {
- type: "Identifier",
- name: "a",
- loc: {
- start: {line: 1, column: 4},
- end: {line: 1, column: 5}
- }
- },
- loc: {
- start: {line: 1, column: 1},
- end: {line: 1, column: 5}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 6}
- }
- },
- right: {
- type: "Identifier",
- name: "b",
- loc: {
- start: {line: 1, column: 9},
- end: {line: 1, column: 10}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 10}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 10}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 10}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("[a, ...b] = c", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "AssignmentExpression",
- operator: "=",
- left: {
- type: "ArrayPattern",
- elements: [
- {
- type: "Identifier",
- name: "a",
- loc: {
- start: {line: 1, column: 1},
- end: {line: 1, column: 2}
- }
- },
- {
- type: "RestElement",
- argument: {
- type: "Identifier",
- name: "b",
- loc: {
- start: {line: 1, column: 7},
- end: {line: 1, column: 8}
- }
- },
- loc: {
- start: {line: 1, column: 4},
- end: {line: 1, column: 8}
- }
- }
- ],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 9}
- }
- },
- right: {
- type: "Identifier",
- name: "c",
- loc: {
- start: {line: 1, column: 12},
- end: {line: 1, column: 13}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 13}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 13}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 13}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("[{ a, b }, ...c] = d", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "AssignmentExpression",
- operator: "=",
- left: {
- type: "ArrayPattern",
- elements: [
- {
- type: "ObjectPattern",
- properties: [
- {
- type: "Property",
- key: {
- type: "Identifier",
- name: "a",
- loc: {
- start: {line: 1, column: 3},
- end: {line: 1, column: 4}
- }
- },
- value: {
- type: "Identifier",
- name: "a",
- loc: {
- start: {line: 1, column: 3},
- end: {line: 1, column: 4}
- }
- },
- kind: "init",
- method: false,
- shorthand: true,
- computed: false,
- loc: {
- start: {line: 1, column: 3},
- end: {line: 1, column: 4}
- }
- },
- {
- type: "Property",
- key: {
- type: "Identifier",
- name: "b",
- loc: {
- start: {line: 1, column: 6},
- end: {line: 1, column: 7}
- }
- },
- value: {
- type: "Identifier",
- name: "b",
- loc: {
- start: {line: 1, column: 6},
- end: {line: 1, column: 7}
- }
- },
- kind: "init",
- method: false,
- shorthand: true,
- computed: false,
- loc: {
- start: {line: 1, column: 6},
- end: {line: 1, column: 7}
- }
- }
- ],
- loc: {
- start: {line: 1, column: 1},
- end: {line: 1, column: 9}
- }
- },
- {
- type: "RestElement",
- argument: {
- type: "Identifier",
- name: "c",
- loc: {
- start: {line: 1, column: 14},
- end: {line: 1, column: 15}
- }
- },
- loc: {
- start: {line: 1, column: 11},
- end: {line: 1, column: 15}
- }
- }
- ],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 16}
- }
- },
- right: {
- type: "Identifier",
- name: "d",
- loc: {
- start: {line: 1, column: 19},
- end: {line: 1, column: 20}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 20}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 20}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 20}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("[a, ...[b, c]] = d", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "AssignmentExpression",
- operator: "=",
- left: {
- type: "ArrayPattern",
- elements: [
- {
- type: "Identifier",
- name: "a",
- loc: {
- start: {line: 1, column: 1},
- end: {line: 1, column: 2}
- }
- },
- {
- type: "RestElement",
- argument: {
- type: "ArrayPattern",
- elements: [
- {
- type: "Identifier",
- name: "b",
- loc: {
- start: {line: 1, column: 8},
- end: {line: 1, column: 9}
- }
- },
- {
- type: "Identifier",
- name: "c",
- loc: {
- start: {line: 1, column: 11},
- end: {line: 1, column: 12}
- }
- }
- ],
- loc: {
- start: {line: 1, column: 7},
- end: {line: 1, column: 13}
- }
- },
- loc: {
- start: {line: 1, column: 4},
- end: {line: 1, column: 13}
- }
- }
- ],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 14}
- }
- },
- right: {
- type: "Identifier",
- name: "d",
- loc: {
- start: {line: 1, column: 17},
- end: {line: 1, column: 18}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 18}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 18}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 18}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("var [...a] = b", {
- type: "Program",
- body: [{
- type: "VariableDeclaration",
- declarations: [{
- type: "VariableDeclarator",
- id: {
- type: "ArrayPattern",
- elements: [{
- type: "RestElement",
- argument: {
- type: "Identifier",
- name: "a",
- loc: {
- start: {line: 1, column: 8},
- end: {line: 1, column: 9}
- }
- },
- loc: {
- start: {line: 1, column: 5},
- end: {line: 1, column: 9}
- }
- }],
- loc: {
- start: {line: 1, column: 4},
- end: {line: 1, column: 10}
- }
- },
- init: {
- type: "Identifier",
- name: "b",
- loc: {
- start: {line: 1, column: 13},
- end: {line: 1, column: 14}
- }
- },
- loc: {
- start: {line: 1, column: 4},
- end: {line: 1, column: 14}
- }
- }],
- kind: "var",
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 14}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 14}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("var [a, ...b] = c", {
- type: "Program",
- body: [{
- type: "VariableDeclaration",
- declarations: [{
- type: "VariableDeclarator",
- id: {
- type: "ArrayPattern",
- elements: [
- {
- type: "Identifier",
- name: "a",
- loc: {
- start: {line: 1, column: 5},
- end: {line: 1, column: 6}
- }
- },
- {
- type: "RestElement",
- argument: {
- type: "Identifier",
- name: "b",
- loc: {
- start: {line: 1, column: 11},
- end: {line: 1, column: 12}
- }
- },
- loc: {
- start: {line: 1, column: 8},
- end: {line: 1, column: 12}
- }
- }
- ],
- loc: {
- start: {line: 1, column: 4},
- end: {line: 1, column: 13}
- }
- },
- init: {
- type: "Identifier",
- name: "c",
- loc: {
- start: {line: 1, column: 16},
- end: {line: 1, column: 17}
- }
- },
- loc: {
- start: {line: 1, column: 4},
- end: {line: 1, column: 17}
- }
- }],
- kind: "var",
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 17}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 17}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("var [{ a, b }, ...c] = d", {
- type: "Program",
- body: [{
- type: "VariableDeclaration",
- declarations: [{
- type: "VariableDeclarator",
- id: {
- type: "ArrayPattern",
- elements: [
- {
- type: "ObjectPattern",
- properties: [
- {
- type: "Property",
- key: {
- type: "Identifier",
- name: "a",
- loc: {
- start: {line: 1, column: 7},
- end: {line: 1, column: 8}
- }
- },
- value: {
- type: "Identifier",
- name: "a",
- loc: {
- start: {line: 1, column: 7},
- end: {line: 1, column: 8}
- }
- },
- kind: "init",
- method: false,
- shorthand: true,
- computed: false,
- loc: {
- start: {line: 1, column: 7},
- end: {line: 1, column: 8}
- }
- },
- {
- type: "Property",
- key: {
- type: "Identifier",
- name: "b",
- loc: {
- start: {line: 1, column: 10},
- end: {line: 1, column: 11}
- }
- },
- value: {
- type: "Identifier",
- name: "b",
- loc: {
- start: {line: 1, column: 10},
- end: {line: 1, column: 11}
- }
- },
- kind: "init",
- method: false,
- shorthand: true,
- computed: false,
- loc: {
- start: {line: 1, column: 10},
- end: {line: 1, column: 11}
- }
- }
- ],
- loc: {
- start: {line: 1, column: 5},
- end: {line: 1, column: 13}
- }
- },
- {
- type: "RestElement",
- argument: {
- type: "Identifier",
- name: "c",
- loc: {
- start: {line: 1, column: 18},
- end: {line: 1, column: 19}
- }
- },
- loc: {
- start: {line: 1, column: 15},
- end: {line: 1, column: 19}
- }
- }
- ],
- loc: {
- start: {line: 1, column: 4},
- end: {line: 1, column: 20}
- }
- },
- init: {
- type: "Identifier",
- name: "d",
- loc: {
- start: {line: 1, column: 23},
- end: {line: 1, column: 24}
- }
- },
- loc: {
- start: {line: 1, column: 4},
- end: {line: 1, column: 24}
- }
- }],
- kind: "var",
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 24}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 24}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("var [a, ...[b, c]] = d", {
- type: "Program",
- body: [{
- type: "VariableDeclaration",
- declarations: [{
- type: "VariableDeclarator",
- id: {
- type: "ArrayPattern",
- elements: [
- {
- type: "Identifier",
- name: "a",
- loc: {
- start: {line: 1, column: 5},
- end: {line: 1, column: 6}
- }
- },
- {
- type: "RestElement",
- argument: {
- type: "ArrayPattern",
- elements: [
- {
- type: "Identifier",
- name: "b",
- loc: {
- start: {line: 1, column: 12},
- end: {line: 1, column: 13}
- }
- },
- {
- type: "Identifier",
- name: "c",
- loc: {
- start: {line: 1, column: 15},
- end: {line: 1, column: 16}
- }
- }
- ],
- loc: {
- start: {line: 1, column: 11},
- end: {line: 1, column: 17}
- }
- },
- loc: {
- start: {line: 1, column: 8},
- end: {line: 1, column: 17}
- }
- }
- ],
- loc: {
- start: {line: 1, column: 4},
- end: {line: 1, column: 18}
- }
- },
- init: {
- type: "Identifier",
- name: "d",
- loc: {
- start: {line: 1, column: 21},
- end: {line: 1, column: 22}
- }
- },
- loc: {
- start: {line: 1, column: 4},
- end: {line: 1, column: 22}
- }
- }],
- kind: "var",
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 22}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 22}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("func(...a)", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "CallExpression",
- callee: {
- type: "Identifier",
- name: "func",
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 4}
- }
- },
- arguments: [{
- type: "SpreadElement",
- argument: {
- type: "Identifier",
- name: "a",
- loc: {
- start: {line: 1, column: 8},
- end: {line: 1, column: 9}
- }
- },
- loc: {
- start: {line: 1, column: 5},
- end: {line: 1, column: 9}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 10}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 10}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 10}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("func(a, ...b)", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "CallExpression",
- callee: {
- type: "Identifier",
- name: "func",
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 4}
- }
- },
- arguments: [
- {
- type: "Identifier",
- name: "a",
- loc: {
- start: {line: 1, column: 5},
- end: {line: 1, column: 6}
- }
- },
- {
- type: "SpreadElement",
- argument: {
- type: "Identifier",
- name: "b",
- loc: {
- start: {line: 1, column: 11},
- end: {line: 1, column: 12}
- }
- },
- loc: {
- start: {line: 1, column: 8},
- end: {line: 1, column: 12}
- }
- }
- ],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 13}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 13}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 13}
- }
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("func(...a, b)", {
- type: "Program",
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 13}
- },
- body: [{
- type: "ExpressionStatement",
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 13}
- },
- expression: {
- type: "CallExpression",
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 13}
- },
- callee: {
- type: "Identifier",
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 4}
- },
- name: "func"
- },
- arguments: [
- {
- type: "SpreadElement",
- loc: {
- start: {line: 1, column: 5},
- end: {line: 1, column: 9}
- },
- argument: {
- type: "Identifier",
- loc: {
- start: {line: 1, column: 8},
- end: {line: 1, column: 9}
- },
- name: "a"
- }
- },
- {
- type: "Identifier",
- loc: {
- start: {line: 1, column: 11},
- end: {line: 1, column: 12}
- },
- name: "b"
- }
- ]
- }
- }]
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("/[a-z]/u", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "Literal",
- regex: {
- pattern: "[a-z]",
- flags: "u"
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 8
- }
- }
- }
- }
- ]
-}, {
- locations: true,
- ecmaVersion: 6
-});
-
-test("/[\\uD834\\uDF06-\\uD834\\uDF08a-z]/u", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "Literal",
- regex: {
- pattern: "[\\uD834\\uDF06-\\uD834\\uDF08a-z]",
- flags: "u"
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 33
- }
- }
- }
- }
- ]
-}, {
- locations: true,
- ecmaVersion: 6
-});
-
-test("do {} while (false) foo();", {
- type: "Program",
- start: 0,
- end: 26,
- body: [
- {
- type: "DoWhileStatement",
- start: 0,
- end: 19,
- body: {
- type: "BlockStatement",
- start: 3,
- end: 5,
- body: []
- },
- test: {
- type: "Literal",
- start: 13,
- end: 18,
- value: false,
- raw: "false"
- }
- },
- {
- type: "ExpressionStatement",
- start: 20,
- end: 26,
- expression: {
- type: "CallExpression",
- start: 20,
- end: 25,
- callee: {
- type: "Identifier",
- start: 20,
- end: 23,
- name: "foo"
- },
- arguments: []
- }
- }
- ]
-}, {
- ecmaVersion: 6
-});
-
-// Harmony Invalid syntax
-
-testFail("0o", "Expected number in radix 8 (1:2)", {ecmaVersion: 6});
-
-testFail("0o1a", "Identifier directly after number (1:3)", {ecmaVersion: 6});
-
-testFail("0o9", "Expected number in radix 8 (1:2)", {ecmaVersion: 6});
-
-testFail("0o18", "Unexpected token (1:3)", {ecmaVersion: 6});
-
-testFail("0O", "Expected number in radix 8 (1:2)", {ecmaVersion: 6});
-
-testFail("0O1a", "Identifier directly after number (1:3)", {ecmaVersion: 6});
-
-testFail("0O9", "Expected number in radix 8 (1:2)", {ecmaVersion: 6});
-
-testFail("0O18", "Unexpected token (1:3)", {ecmaVersion: 6});
-
-testFail("0b", "Expected number in radix 2 (1:2)", {ecmaVersion: 6});
-
-testFail("0b1a", "Identifier directly after number (1:3)", {ecmaVersion: 6});
-
-testFail("0b9", "Expected number in radix 2 (1:2)", {ecmaVersion: 6});
-
-testFail("0b18", "Unexpected token (1:3)", {ecmaVersion: 6});
-
-testFail("0b12", "Unexpected token (1:3)", {ecmaVersion: 6});
-
-testFail("0B", "Expected number in radix 2 (1:2)", {ecmaVersion: 6});
-
-testFail("0B1a", "Identifier directly after number (1:3)", {ecmaVersion: 6});
-
-testFail("0B9", "Expected number in radix 2 (1:2)", {ecmaVersion: 6});
-
-testFail("0B18", "Unexpected token (1:3)", {ecmaVersion: 6});
-
-testFail("0B12", "Unexpected token (1:3)", {ecmaVersion: 6});
-
-testFail("\"\\u{110000}\"", "Unexpected token (1:0)", {ecmaVersion: 6});
-
-testFail("\"\\u{}\"", "Bad character escape sequence (1:0)", {ecmaVersion: 6});
-
-testFail("\"\\u{FFFF\"", "Bad character escape sequence (1:0)", {ecmaVersion: 6});
-
-testFail("\"\\u{FFZ}\"", "Bad character escape sequence (1:0)", {ecmaVersion: 6});
-
-testFail("[v] += ary", "Assigning to rvalue (1:0)", {ecmaVersion: 6});
-
-testFail("[2] = 42", "Assigning to rvalue (1:1)", {ecmaVersion: 6});
-
-testFail("({ obj:20 }) = 42", "Assigning to rvalue (1:7)", {ecmaVersion: 6});
-
-testFail("( { get x() {} } ) = 0", "Object pattern can't contain getter or setter (1:8)", {ecmaVersion: 6});
-
-testFail("x \n is y", "Unexpected token (2:4)", {ecmaVersion: 6});
-
-testFail("x \n isnt y", "Unexpected token (2:6)", {ecmaVersion: 6});
-
-testFail("function default() {}", "Unexpected token (1:9)", {ecmaVersion: 6});
-
-testFail("function hello() {'use strict'; ({ i: 10, s(eval) { } }); }", "Binding eval in strict mode (1:44)", {ecmaVersion: 6});
-
-testFail("function a() { \"use strict\"; ({ b(t, t) { } }); }", "Argument name clash in strict mode (1:37)", {ecmaVersion: 6});
-
-testFail("var super", "Unexpected token (1:4)", {ecmaVersion: 6});
-
-testFail("var default", "Unexpected token (1:4)", {ecmaVersion: 6});
-
-testFail("let default", "Unexpected token (1:4)", {ecmaVersion: 6});
-
-testFail("const default", "Unexpected token (1:6)", {ecmaVersion: 6});
-
-testFail("\"use strict\"; ({ v: eval }) = obj", "Assigning to eval in strict mode (1:20)", {ecmaVersion: 6});
-
-testFail("\"use strict\"; ({ v: arguments }) = obj", "Assigning to arguments in strict mode (1:20)", {ecmaVersion: 6});
-
-testFail("for (let x = 42 in list) process(x);", "Unexpected token (1:16)", {ecmaVersion: 6});
-
-testFail("for (let x = 42 of list) process(x);", "Unexpected token (1:16)", {ecmaVersion: 6});
-
-testFail("import foo", "Unexpected token (1:10)", {ecmaVersion: 6, sourceType: "module"});
-
-testFail("import { foo, bar }", "Unexpected token (1:19)", {ecmaVersion: 6, sourceType: "module"});
-
-testFail("import foo from bar", "Unexpected token (1:16)", {ecmaVersion: 6, sourceType: "module"});
-
-testFail("((a)) => 42", "Unexpected token (1:1)", {ecmaVersion: 6});
-
-testFail("(a, (b)) => 42", "Unexpected token (1:4)", {ecmaVersion: 6});
-
-testFail("\"use strict\"; (eval = 10) => 42", "Assigning to eval in strict mode (1:15)", {ecmaVersion: 6});
-
-testFail("\"use strict\"; eval => 42", "Binding eval in strict mode (1:14)", {ecmaVersion: 6});
-
-testFail("\"use strict\"; arguments => 42", "Binding arguments in strict mode (1:14)", {ecmaVersion: 6});
-
-testFail("\"use strict\"; (eval, a) => 42", "Binding eval in strict mode (1:15)", {ecmaVersion: 6});
-
-testFail("\"use strict\"; (arguments, a) => 42", "Binding arguments in strict mode (1:15)", {ecmaVersion: 6});
-
-testFail("\"use strict\"; (eval, a = 10) => 42", "Binding eval in strict mode (1:15)", {ecmaVersion: 6});
-
-testFail("\"use strict\"; (a, a) => 42", "Argument name clash in strict mode (1:18)", {ecmaVersion: 6});
-
-testFail("\"use strict\"; (a) => 00", "Invalid number (1:21)", {ecmaVersion: 6});
-
-testFail("() <= 42", "Unexpected token (1:1)", {ecmaVersion: 6});
-
-testFail("(10) => 00", "Assigning to rvalue (1:1)", {ecmaVersion: 6});
-
-testFail("(10, 20) => 00", "Assigning to rvalue (1:1)", {ecmaVersion: 6});
-
-testFail("yield v", "Unexpected token (1:6)", {ecmaVersion: 6});
-
-testFail("yield 10", "Unexpected token (1:6)", {ecmaVersion: 6});
-
-testFail("void { [1, 2]: 3 };", "Unexpected token (1:9)", {ecmaVersion: 6});
-
-test("yield* 10", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "BinaryExpression",
- operator: "*",
- left: {
- type: "Identifier",
- name: "yield",
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 5}
- }
- },
- right: {
- type: "Literal",
- value: 10,
- raw: "10",
- loc: {
- start: {line: 1, column: 7},
- end: {line: 1, column: 9}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 9}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 9}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 9}
- }
-}, {
- ecmaVersion: 6,
- loose: false,
- ranges: true,
- locations: true
-});
-
-test("e => yield* 10", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "ArrowFunctionExpression",
- id: null,
- params: [{
- type: "Identifier",
- name: "e",
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 1}
- }
- }],
- body: {
- type: "BinaryExpression",
- operator: "*",
- left: {
- type: "Identifier",
- name: "yield",
- loc: {
- start: {line: 1, column: 5},
- end: {line: 1, column: 10}
- }
- },
- right: {
- type: "Literal",
- value: 10,
- raw: "10",
- loc: {
- start: {line: 1, column: 12},
- end: {line: 1, column: 14}
- }
- },
- loc: {
- start: {line: 1, column: 5},
- end: {line: 1, column: 14}
- }
- },
- generator: false,
- expression: true,
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 14}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 14}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 14}
- }
-}, {
- ecmaVersion: 6,
- loose: false,
- ranges: true,
- locations: true
-});
-
-testFail("(function () { yield 10 })", "Unexpected token (1:21)", {ecmaVersion: 6});
-
-test("(function () { yield* 10 })", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "FunctionExpression",
- id: null,
- params: [],
- body: {
- type: "BlockStatement",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "BinaryExpression",
- operator: "*",
- left: {
- type: "Identifier",
- name: "yield",
- loc: {
- start: {line: 1, column: 15},
- end: {line: 1, column: 20}
- }
- },
- right: {
- type: "Literal",
- value: 10,
- raw: "10",
- loc: {
- start: {line: 1, column: 22},
- end: {line: 1, column: 24}
- }
- },
- loc: {
- start: {line: 1, column: 15},
- end: {line: 1, column: 24}
- }
- },
- loc: {
- start: {line: 1, column: 15},
- end: {line: 1, column: 24}
- }
- }],
- loc: {
- start: {line: 1, column: 13},
- end: {line: 1, column: 26}
- }
- },
- generator: false,
- expression: false,
- loc: {
- start: {line: 1, column: 1},
- end: {line: 1, column: 26}
- }
- },
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 27}
- }
- }],
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 27}
- }
-}, {
- ecmaVersion: 6,
- loose: false,
- ranges: true,
- locations: true
-});
-
-testFail("(function() { \"use strict\"; f(yield v) })", "Unexpected token (1:36)", {ecmaVersion: 6});
-
-testFail("var obj = { *test** }", "Unexpected token (1:17)", {ecmaVersion: 6});
-
-testFail("class A extends yield B { }", "Unexpected token (1:22)", {ecmaVersion: 6});
-
-testFail("class default", "Unexpected token (1:6)", {ecmaVersion: 6});
-
-testFail("`test", "Unterminated template (1:1)", {ecmaVersion: 6});
-
-testFail("switch `test`", "Unexpected token (1:7)", {ecmaVersion: 6});
-
-testFail("`hello ${10 `test`", "Unexpected token (1:18)", {ecmaVersion: 6});
-
-testFail("`hello ${10;test`", "Unexpected token (1:11)", {ecmaVersion: 6});
-
-testFail("function a() 1 // expression closure is not supported", "Unexpected token (1:13)", {ecmaVersion: 6});
-
-testFail("[for (let x of []) x]", "Unexpected token (1:6)", {ecmaVersion: 7});
-
-testFail("[for (const x of []) x]", "Unexpected token (1:6)", {ecmaVersion: 7});
-
-testFail("[for (var x of []) x]", "Unexpected token (1:6)", {ecmaVersion: 7});
-
-testFail("[for (a in []) x] // (a,b) ", "Unexpected token (1:8)", {ecmaVersion: 7});
-
-testFail("var a = [if (x) x]", "Unexpected token (1:9)", {ecmaVersion: 6});
-
-testFail("[for (x of [])] // no expression", "Unexpected token (1:14)", {ecmaVersion: 7});
-
-testFail("({ \"chance\" }) = obj", "Unexpected token (1:12)", {ecmaVersion: 6});
-
-testFail("({ 42 }) = obj", "Unexpected token (1:6)", {ecmaVersion: 6});
-
-testFail("function f(a, ...b, c)", "Unexpected token (1:18)", {ecmaVersion: 6});
-
-testFail("function f(a, ...b = 0)", "Unexpected token (1:19)", {ecmaVersion: 6});
-
-testFail("function x(...{ a }){}", "Unexpected token (1:14)", {ecmaVersion: 6});
-
-testFail("\"use strict\"; function x(a, { a }){}", "Argument name clash in strict mode (1:30)", {ecmaVersion: 6});
-
-testFail("\"use strict\"; function x({ b: { a } }, [{ b: { a } }]){}", "Argument name clash in strict mode (1:47)", {ecmaVersion: 6});
-
-testFail("\"use strict\"; function x(a, ...[a]){}", "Argument name clash in strict mode (1:32)", {ecmaVersion: 6});
-
-testFail("(...a, b) => {}", "Unexpected token (1:5)", {ecmaVersion: 6});
-
-testFail("([ 5 ]) => {}", "Assigning to rvalue (1:3)", {ecmaVersion: 6});
-
-testFail("({ 5 }) => {}", "Unexpected token (1:5)", {ecmaVersion: 6});
-
-testFail("(...[ 5 ]) => {}", "Unexpected token (1:6)", {ecmaVersion: 6});
-
-testFail("[...{ a }] = b", "Unexpected token (1:4)", {ecmaVersion: 6});
-
-testFail("[...a, b] = c", "Assigning to rvalue (1:1)", {ecmaVersion: 6});
-
-testFail("({ t(eval) { \"use strict\"; } });", "Binding eval in strict mode (1:5)", {ecmaVersion: 6});
-
-testFail("\"use strict\"; `${test}\\02`;", "Octal literal in strict mode (1:22)", {ecmaVersion: 6});
-
-testFail("if (1) import \"acorn\";", "'import' and 'export' may only appear at the top level (1:7)", {ecmaVersion: 6});
-
-test("[...a, ] = b", {
- type: "Program",
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 12}
- },
- body: [{
- type: "ExpressionStatement",
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 12}
- },
- expression: {
- type: "AssignmentExpression",
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 12}
- },
- operator: "=",
- left: {
- type: "ArrayPattern",
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 8}
- },
- elements: [{
- type: "RestElement",
- loc: {
- start: {line: 1, column: 1},
- end: {line: 1, column: 5}
- },
- argument: {
- type: "Identifier",
- loc: {
- start: {line: 1, column: 4},
- end: {line: 1, column: 5}
- },
- name: "a"
- }
- }]
- },
- right: {
- type: "Identifier",
- loc: {
- start: {line: 1, column: 11},
- end: {line: 1, column: 12}
- },
- name: "b"
- }
- }
- }]
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-testFail("if (b,...a, );", "Unexpected token (1:6)", {ecmaVersion: 6});
-
-testFail("(b, ...a)", "Unexpected token (1:4)", {ecmaVersion: 6});
-
-testFail("switch (cond) { case 10: let a = 20; ", "Unexpected token (1:37)", {ecmaVersion: 6});
-
-testFail("\"use strict\"; (eval) => 42", "Binding eval in strict mode (1:15)", {ecmaVersion: 6});
-
-testFail("(eval) => { \"use strict\"; 42 }", "Binding eval in strict mode (1:1)", {ecmaVersion: 6});
-
-testFail("({ get test() { } }) => 42", "Object pattern can't contain getter or setter (1:7)", {ecmaVersion: 6});
-
-/* Regression tests */
-
-// # https://github.com/marijnh/acorn/issues/127
-test('doSmth(`${x} + ${y} = ${x + y}`)', {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "CallExpression",
- callee: {
- type: "Identifier",
- name: "doSmth"
- },
- arguments: [{
- type: "TemplateLiteral",
- expressions: [
- {
- type: "Identifier",
- name: "x"
- },
- {
- type: "Identifier",
- name: "y"
- },
- {
- type: "BinaryExpression",
- left: {
- type: "Identifier",
- name: "x"
- },
- operator: "+",
- right: {
- type: "Identifier",
- name: "y"
- }
- }
- ],
- quasis: [
- {
- type: "TemplateElement",
- value: {cooked: "", raw: ""},
- tail: false
- },
- {
- type: "TemplateElement",
- value: {cooked: " + ", raw: " + "},
- tail: false
- },
- {
- type: "TemplateElement",
- value: {cooked: " = ", raw: " = "},
- tail: false
- },
- {
- type: "TemplateElement",
- value: {cooked: "", raw: ""},
- tail: true
- }
- ]
- }]
- }
- }]
-}, {ecmaVersion: 6});
-
-// # https://github.com/marijnh/acorn/issues/129
-test('function normal(x, y = 10) {}', {
- type: "Program",
- body: [{
- type: "FunctionDeclaration",
- id: {
- type: "Identifier",
- name: "normal"
- },
- params: [
- {
- type: "Identifier",
- name: "x"
- },
- {
- type: "AssignmentPattern",
- left: {
- type: "Identifier",
- name: "y"
- },
- right: {
- type: "Literal",
- value: 10,
- raw: "10"
- }
- }
- ],
- generator: false,
- body: {
- type: "BlockStatement",
- body: []
- },
- expression: false
- }]
-}, {ecmaVersion: 6});
-
-test("'use strict'; function f([x,,z]) {}", {}, {ecmaVersion: 6});
-
-// test preserveParens option with arrow functions
-test("() => 42", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "ArrowFunctionExpression"
- }
- }]
-}, {ecmaVersion: 6, preserveParens: true});
-
-// test preserveParens with generators
-test("(for (x of array) for (y of array2) if (x === test) x)", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "ComprehensionExpression"
- }
- }]
-}, {ecmaVersion: 7, preserveParens: true});
-
-// https://github.com/marijnh/acorn/issues/161
-test("import foo, * as bar from 'baz';", {
- type: "Program",
- body: [{
- type: "ImportDeclaration",
- specifiers: [
- {
- type: "ImportDefaultSpecifier",
- local: {
- type: "Identifier",
- name: "foo"
- }
- },
- {
- type: "ImportNamespaceSpecifier",
- local: {
- type: "Identifier",
- name: "bar"
- }
- }
- ],
- source: {
- type: "Literal",
- value: "baz",
- raw: "'baz'"
- }
- }]
-}, {ecmaVersion: 6, sourceType: "module"});
-
-// https://github.com/marijnh/acorn/issues/173
-test("`{${x}}`, `}`", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "SequenceExpression",
- expressions: [
- {
- type: "TemplateLiteral",
- expressions: [{
- type: "Identifier",
- name: "x"
- }],
- quasis: [
- {
- type: "TemplateElement",
- value: {cooked: "{", raw: "{"},
- tail: false
- },
- {
- type: "TemplateElement",
- value: {cooked: "}", raw: "}"},
- tail: true
- }
- ]
- },
- {
- type: "TemplateLiteral",
- expressions: [],
- quasis: [{
- type: "TemplateElement",
- value: {cooked: "}", raw: "}"},
- tail: true
- }]
- }
- ]
- }
- }]
-}, {ecmaVersion: 6});
-
-// https://github.com/marijnh/acorn/issues/186
-test('var {get} = obj;', {
- type: "Program",
- body: [{
- type: "VariableDeclaration",
- declarations: [{
- type: "VariableDeclarator",
- id: {
- type: "ObjectPattern",
- properties: [{
- type: "Property",
- method: false,
- shorthand: true,
- computed: false,
- key: {
- type: "Identifier",
- name: "get"
- },
- kind: "init",
- value: {
- type: "Identifier",
- name: "get"
- }
- }]
- },
- init: {
- type: "Identifier",
- name: "obj"
- }
- }],
- kind: "var"
- }]
-}, {ecmaVersion: 6});
-
-// Destructuring defaults (https://github.com/marijnh/acorn/issues/181)
-
-test("var {propName: localVar = defaultValue} = obj", {
- type: "Program",
- range: [0, 45],
- body: [{
- type: "VariableDeclaration",
- range: [0, 45],
- declarations: [{
- type: "VariableDeclarator",
- range: [4, 45],
- id: {
- type: "ObjectPattern",
- range: [4, 39],
- properties: [{
- type: "Property",
- range: [5, 38],
- method: false,
- shorthand: false,
- computed: false,
- key: {
- type: "Identifier",
- range: [5, 13],
- name: "propName"
- },
- value: {
- type: "AssignmentPattern",
- range: [15, 38],
- operator: "=",
- left: {
- type: "Identifier",
- range: [15, 23],
- name: "localVar"
- },
- right: {
- type: "Identifier",
- range: [26, 38],
- name: "defaultValue"
- }
- },
- kind: "init"
- }]
- },
- init: {
- type: "Identifier",
- range: [42, 45],
- name: "obj"
- }
- }],
- kind: "var"
- }]
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("var {propName = defaultValue} = obj", {
- type: "Program",
- range: [0, 35],
- body: [{
- type: "VariableDeclaration",
- range: [0, 35],
- declarations: [{
- type: "VariableDeclarator",
- range: [4, 35],
- id: {
- type: "ObjectPattern",
- range: [4, 29],
- properties: [{
- type: "Property",
- range: [5, 28],
- method: false,
- shorthand: true,
- computed: false,
- key: {
- type: "Identifier",
- range: [5, 13],
- name: "propName"
- },
- kind: "init",
- value: {
- type: "AssignmentPattern",
- range: [5, 28],
- operator: "=",
- left: {
- type: "Identifier",
- range: [5, 13],
- name: "propName"
- },
- right: {
- type: "Identifier",
- range: [16, 28],
- name: "defaultValue"
- }
- }
- }]
- },
- init: {
- type: "Identifier",
- range: [32, 35],
- name: "obj"
- }
- }],
- kind: "var"
- }]
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("var [localVar = defaultValue] = obj", {
- type: "Program",
- range: [0, 35],
- body: [{
- type: "VariableDeclaration",
- range: [0, 35],
- declarations: [{
- type: "VariableDeclarator",
- range: [4, 35],
- id: {
- type: "ArrayPattern",
- range: [4, 29],
- elements: [{
- type: "AssignmentPattern",
- range: [5, 28],
- operator: "=",
- left: {
- type: "Identifier",
- range: [5, 13],
- name: "localVar"
- },
- right: {
- type: "Identifier",
- range: [16, 28],
- name: "defaultValue"
- }
- }]
- },
- init: {
- type: "Identifier",
- range: [32, 35],
- name: "obj"
- }
- }],
- kind: "var"
- }]
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("({x = 0} = obj)", {
- type: "Program",
- range: [0, 15],
- body: [{
- type: "ExpressionStatement",
- range: [0, 15],
- expression: {
- type: "AssignmentExpression",
- range: [1, 14],
- operator: "=",
- left: {
- type: "ObjectPattern",
- range: [1, 8],
- properties: [{
- type: "Property",
- range: [2, 7],
- method: false,
- shorthand: true,
- computed: false,
- key: {
- type: "Identifier",
- range: [2, 3],
- name: "x"
- },
- kind: "init",
- value: {
- type: "AssignmentPattern",
- range: [2, 7],
- operator: "=",
- left: {
- type: "Identifier",
- range: [2, 3],
- name: "x"
- },
- right: {
- type: "Literal",
- range: [6, 7],
- value: 0
- }
- }
- }]
- },
- right: {
- type: "Identifier",
- range: [11, 14],
- name: "obj"
- }
- }
- }]
-}, {
- ecmaVersion: 6,
- ranges: true
-});
-
-test("({x = 0}) => x", {
- type: "Program",
- range: [0, 14],
- body: [{
- type: "ExpressionStatement",
- range: [0, 14],
- expression: {
- type: "ArrowFunctionExpression",
- range: [0, 14],
- id: null,
- generator: false,
- expression: true,
- params: [{
- type: "ObjectPattern",
- range: [1, 8],
- properties: [{
- type: "Property",
- range: [2, 7],
- method: false,
- shorthand: true,
- computed: false,
- key: {
- type: "Identifier",
- range: [2, 3],
- name: "x"
- },
- kind: "init",
- value: {
- type: "AssignmentPattern",
- range: [2, 7],
- operator: "=",
- left: {
- type: "Identifier",
- range: [2, 3],
- name: "x"
- },
- right: {
- type: "Literal",
- range: [6, 7],
- value: 0
- }
- }
- }]
- }],
- body: {
- type: "Identifier",
- range: [13, 14],
- name: "x"
- }
- }
- }]
-}, {
- ecmaVersion: 6,
- ranges: true
-});
-
-test("[a, {b: {c = 1}}] = arr", {
- type: "Program",
- range: [0, 23],
- body: [{
- type: "ExpressionStatement",
- range: [0, 23],
- expression: {
- type: "AssignmentExpression",
- range: [0, 23],
- operator: "=",
- left: {
- type: "ArrayPattern",
- range: [0, 17],
- elements: [
- {
- type: "Identifier",
- range: [1, 2],
- name: "a"
- },
- {
- type: "ObjectPattern",
- range: [4, 16],
- properties: [{
- type: "Property",
- range: [5, 15],
- method: false,
- shorthand: false,
- computed: false,
- key: {
- type: "Identifier",
- range: [5, 6],
- name: "b"
- },
- value: {
- type: "ObjectPattern",
- range: [8, 15],
- properties: [{
- type: "Property",
- range: [9, 14],
- method: false,
- shorthand: true,
- computed: false,
- key: {
- type: "Identifier",
- range: [9, 10],
- name: "c"
- },
- kind: "init",
- value: {
- type: "AssignmentPattern",
- range: [9, 14],
- operator: "=",
- left: {
- type: "Identifier",
- range: [9, 10],
- name: "c"
- },
- right: {
- type: "Literal",
- range: [13, 14],
- value: 1
- }
- }
- }]
- },
- kind: "init"
- }]
- }
- ]
- },
- right: {
- type: "Identifier",
- range: [20, 23],
- name: "arr"
- }
- }
- }]
-}, {
- ecmaVersion: 6,
- ranges: true
-});
-
-test("for ({x = 0} in arr);", {
- type: "Program",
- range: [0, 21],
- body: [{
- type: "ForInStatement",
- range: [0, 21],
- left: {
- type: "ObjectPattern",
- range: [5, 12],
- properties: [{
- type: "Property",
- range: [6, 11],
- method: false,
- shorthand: true,
- computed: false,
- key: {
- type: "Identifier",
- range: [6, 7],
- name: "x"
- },
- kind: "init",
- value: {
- type: "AssignmentPattern",
- range: [6, 11],
- operator: "=",
- left: {
- type: "Identifier",
- range: [6, 7],
- name: "x"
- },
- right: {
- type: "Literal",
- range: [10, 11],
- value: 0
- }
- }
- }]
- },
- right: {
- type: "Identifier",
- range: [16, 19],
- name: "arr"
- },
- body: {
- type: "EmptyStatement",
- range: [20, 21]
- }
- }]
-}, {
- ecmaVersion: 6,
- ranges: true
-});
-
-testFail("obj = {x = 0}", "Unexpected token (1:9)", {ecmaVersion: 6});
-
-testFail("f({x = 0})", "Unexpected token (1:5)", {ecmaVersion: 6});
-
-// https://github.com/marijnh/acorn/issues/191
-
-test("try {} catch ({message}) {}", {
- type: "Program",
- range: [0, 27],
- body: [{
- type: "TryStatement",
- range: [0, 27],
- block: {
- type: "BlockStatement",
- range: [4, 6],
- body: []
- },
- handler: {
- type: "CatchClause",
- range: [7, 27],
- param: {
- type: "ObjectPattern",
- range: [14, 23],
- properties: [{
- type: "Property",
- range: [15, 22],
- method: false,
- shorthand: true,
- computed: false,
- key: {
- type: "Identifier",
- range: [15, 22],
- name: "message"
- },
- kind: "init",
- value: {
- type: "Identifier",
- range: [15, 22],
- name: "message"
- }
- }]
- },
- guard: null,
- body: {
- type: "BlockStatement",
- range: [25, 27],
- body: []
- }
- },
- finalizer: null
- }]
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-// https://github.com/marijnh/acorn/issues/192
-
-test("class A { static() {} }", {
- type: "Program",
- range: [0, 23],
- body: [{
- type: "ClassDeclaration",
- range: [0, 23],
- id: {
- type: "Identifier",
- range: [6, 7],
- name: "A"
- },
- superClass: null,
- body: {
- type: "ClassBody",
- range: [8, 23],
- body: [{
- type: "MethodDefinition",
- range: [10, 21],
- computed: false,
- key: {
- type: "Identifier",
- range: [10, 16],
- name: "static"
- },
- static: false,
- kind: "method",
- value: {
- type: "FunctionExpression",
- range: [16, 21],
- id: null,
- params: [],
- generator: false,
- body: {
- type: "BlockStatement",
- range: [19, 21],
- body: []
- },
- expression: false
- }
- }]
- }
- }]
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-// https://github.com/marijnh/acorn/issues/213
-
-test("for (const x of list) process(x);", {
- type: "Program",
- body: [{
- type: "ForOfStatement",
- left: {
- type: "VariableDeclaration",
- declarations: [{
- type: "VariableDeclarator",
- id: {
- type: "Identifier",
- name: "x",
- range: [11, 12]
- },
- init: null,
- range: [11, 12]
- }],
- kind: "const",
- range: [5, 12]
- },
- right: {
- type: "Identifier",
- name: "list",
- range: [16, 20]
- },
- body: {
- type: "ExpressionStatement",
- expression: {
- type: "CallExpression",
- callee: {
- type: "Identifier",
- name: "process",
- range: [22, 29]
- },
- arguments: [{
- type: "Identifier",
- name: "x",
- range: [30, 31]
- }],
- range: [22, 32]
- },
- range: [22, 33]
- },
- range: [0, 33]
- }],
- range: [0, 33]
-}, {ecmaVersion: 6, ranges: true});
-
-test("class A { *static() {} }", {
- type: "Program",
- range: [0, 24],
- body: [{
- type: "ClassDeclaration",
- range: [0, 24],
- id: {
- type: "Identifier",
- range: [6, 7],
- name: "A"
- },
- superClass: null,
- body: {
- type: "ClassBody",
- range: [8, 24],
- body: [{
- type: "MethodDefinition",
- range: [10, 22],
- computed: false,
- key: {
- type: "Identifier",
- range: [11, 17],
- name: "static"
- },
- static: false,
- kind: "method",
- value: {
- type: "FunctionExpression",
- range: [17, 22],
- id: null,
- params: [],
- generator: true,
- body: {
- type: "BlockStatement",
- range: [20, 22],
- body: []
- },
- expression: false
- }
- }]
- }
- }]
-}, {
- ecmaVersion: 6,
- ranges: true,
- locations: true
-});
-
-test("`${/\\d/.exec('1')[0]}`", {
- "type": "Program",
- "start": 0,
- "end": 22,
- "body": [
- {
- "type": "ExpressionStatement",
- "start": 0,
- "end": 22,
- "expression": {
- "type": "TemplateLiteral",
- "start": 0,
- "end": 22,
- "expressions": [
- {
- "type": "MemberExpression",
- "start": 3,
- "end": 20,
- "object": {
- "type": "CallExpression",
- "start": 3,
- "end": 17,
- "callee": {
- "type": "MemberExpression",
- "start": 3,
- "end": 12,
- "object": {
- "type": "Literal",
- "start": 3,
- "end": 7,
- "regex": {
- "pattern": "\\d",
- "flags": ""
- },
- "value": /\d/,
- "raw": "/\\d/"
- },
- "property": {
- "type": "Identifier",
- "start": 8,
- "end": 12,
- "name": "exec"
- },
- "computed": false
- },
- "arguments": [
- {
- "type": "Literal",
- "start": 13,
- "end": 16,
- "value": "1",
- "raw": "'1'"
- }
- ]
- },
- "property": {
- "type": "Literal",
- "start": 18,
- "end": 19,
- "value": 0,
- "raw": "0"
- },
- "computed": true
- }
- ],
- "quasis": [
- {
- "type": "TemplateElement",
- "start": 1,
- "end": 1,
- "value": {
- "raw": "",
- "cooked": ""
- },
- "tail": false
- },
- {
- "type": "TemplateElement",
- "start": 21,
- "end": 21,
- "value": {
- "raw": "",
- "cooked": ""
- },
- "tail": true
- }
- ]
- }
- }
- ]
-}, {
- ecmaVersion: 6
-});
-
-test("var _𐒦 = 10;", {
- "type": "Program",
- "start": 0,
- "end": 13,
- "body": [
- {
- "type": "VariableDeclaration",
- "start": 0,
- "end": 13,
- "declarations": [
- {
- "type": "VariableDeclarator",
- "start": 4,
- "end": 12,
- "id": {
- "type": "Identifier",
- "start": 4,
- "end": 7,
- "name": "_𐒦"
- },
- "init": {
- "type": "Literal",
- "start": 10,
- "end": 12,
- "value": 10,
- "raw": "10"
- }
- }
- ],
- "kind": "var"
- }
- ]
-}, {ecmaVersion: 6});
-
-test("var 𫠝_ = 10;", {
- "type": "Program",
- "start": 0,
- "end": 13,
- "body": [
- {
- "type": "VariableDeclaration",
- "start": 0,
- "end": 13,
- "declarations": [
- {
- "type": "VariableDeclarator",
- "start": 4,
- "end": 12,
- "id": {
- "type": "Identifier",
- "start": 4,
- "end": 7,
- "name": "𫠝_"
- },
- "init": {
- "type": "Literal",
- "start": 10,
- "end": 12,
- "value": 10,
- "raw": "10"
- }
- }
- ],
- "kind": "var"
- }
- ]
-}, {ecmaVersion: 6});
-
-test("var _\\u{104A6} = 10;", {
- "type": "Program",
- "start": 0,
- "end": 20,
- "body": [
- {
- "type": "VariableDeclaration",
- "start": 0,
- "end": 20,
- "declarations": [
- {
- "type": "VariableDeclarator",
- "start": 4,
- "end": 19,
- "id": {
- "type": "Identifier",
- "start": 4,
- "end": 14,
- "name": "_𐒦"
- },
- "init": {
- "type": "Literal",
- "start": 17,
- "end": 19,
- "value": 10,
- "raw": "10"
- }
- }
- ],
- "kind": "var"
- }
- ]
-}, {ecmaVersion: 6});
-
-test("let [x,] = [1]", {
- "start": 0,
- "body": [
- {
- "start": 0,
- "declarations": [
- {
- "start": 4,
- "id": {
- "start": 4,
- "elements": [
- {
- "start": 5,
- "name": "x",
- "type": "Identifier",
- "end": 6
- }
- ],
- "type": "ArrayPattern",
- "end": 8
- },
- "init": {
- "start": 11,
- "elements": [
- {
- "start": 12,
- "value": 1,
- "raw": "1",
- "type": "Literal",
- "end": 13
- }
- ],
- "type": "ArrayExpression",
- "end": 14
- },
- "type": "VariableDeclarator",
- "end": 14
- }
- ],
- "kind": "let",
- "type": "VariableDeclaration",
- "end": 14
- }
- ],
- "type": "Program",
- "end": 14
-}, {ecmaVersion: 6});
-
-test("let {x} = y", {
- "start": 0,
- "body": [
- {
- "start": 0,
- "declarations": [
- {
- "start": 4,
- "id": {
- "start": 4,
- "properties": [
- {
- "start": 5,
- "method": false,
- "shorthand": true,
- "computed": false,
- "key": {
- "start": 5,
- "name": "x",
- "type": "Identifier",
- "end": 6
- },
- "kind": "init",
- "value": {
- "start": 5,
- "name": "x",
- "type": "Identifier",
- "end": 6
- },
- "type": "Property",
- "end": 6
- }
- ],
- "type": "ObjectPattern",
- "end": 7
- },
- "init": {
- "start": 10,
- "name": "y",
- "type": "Identifier",
- "end": 11
- },
- "type": "VariableDeclarator",
- "end": 11
- }
- ],
- "kind": "let",
- "type": "VariableDeclaration",
- "end": 11
- }
- ],
- "type": "Program",
- "end": 11
-}, {ecmaVersion: 6})
-
-test("[x,,] = 1", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "AssignmentExpression",
- operator: "=",
- left: {
- type: "ArrayPattern",
- elements: [
- {
- type: "Identifier",
- name: "x"
- },
- null
- ]
- },
- right: {
- type: "Literal",
- value: 1,
- raw: "1"
- }
- }
- }
- ]
-}, {ecmaVersion: 6});
-
-test("for (var [name, value] in obj) {}", {
- body: [
- {
- left: {
- declarations: [
- {
- id: {
- elements: [
- {
- name: "name",
- type: "Identifier"
- },
- {
- name: "value",
- type: "Identifier"
- }
- ],
- type: "ArrayPattern"
- },
- init: null,
- type: "VariableDeclarator"
- }
- ],
- kind: "var",
- type: "VariableDeclaration"
- },
- right: {
- name: "obj",
- type: "Identifier"
- },
- body: {
- body: [],
- type: "BlockStatement"
- },
- type: "ForInStatement"
- }
- ],
- sourceType: "script",
- type: "Program"
-}, {ecmaVersion: 6})
-
-testFail("let [x]", "Complex binding patterns require an initialization value (1:7)", {ecmaVersion: 6})
-testFail("var [x]", "Complex binding patterns require an initialization value (1:7)", {ecmaVersion: 6})
-testFail("var _𖫵 = 11;", "Unexpected character '𖫵' (1:5)", {ecmaVersion: 6});
-testFail("var _ = 12;", "Unexpected character '' (1:4)", {ecmaVersion: 6});
-testFail("var 𫠝_ = 10;", "Unexpected character '𫠝' (1:4)", {ecmaVersion: 5});
-testFail("if (1) let x = 10;", "Unexpected token (1:7)", {ecmaVersion: 6});
-testFail("for (;;) const x = 10;", "Unexpected token (1:9)", {ecmaVersion: 6});
-testFail("while (1) function foo(){}", "Unexpected token (1:10)", {ecmaVersion: 6});
-testFail("if (1) ; else class Cls {}", "Unexpected token (1:14)", {ecmaVersion: 6});
-
-testFail("'use strict'; [...eval] = arr", "Assigning to eval in strict mode (1:18)", {ecmaVersion: 6});
-testFail("'use strict'; ({eval = defValue} = obj)", "Assigning to eval in strict mode (1:16)", {ecmaVersion: 6});
-
-testFail("[...eval] = arr", "Assigning to eval in strict mode (1:4)", {ecmaVersion: 6, sourceType: "module"});
-
-testFail("function* y({yield}) {}", "Binding yield (1:13)", {ecmaVersion: 6});
-
-test("new.target", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "MetaProperty",
- meta: {type: "Identifier", name: "new"},
- property: {type: "Identifier", name: "target"}
- }
- }],
- sourceType: "script"
-}, {ecmaVersion: 6});
-
-testFail("new.prop", "The only valid meta property for new is new.target (1:4)", {ecmaVersion: 6});
diff --git a/test/tests-jsx.js b/test/tests-jsx.js
deleted file mode 100644
index 68c4af80f9..0000000000
--- a/test/tests-jsx.js
+++ /dev/null
@@ -1,3647 +0,0 @@
-// React JSX tests
-
-var fbTestFixture = {
- // Taken and adapted from esprima-fb/fbtest.js.
- 'JSX': {
- '': {
- type: "ExpressionStatement",
- expression: {
- type: "JSXElement",
- openingElement: {
- type: "JSXOpeningElement",
- name: {
- type: "JSXIdentifier",
- name: "a",
- range: [1, 2],
- loc: {
- start: { line: 1, column: 1 },
- end: { line: 1, column: 2 }
- }
- },
- selfClosing: true,
- attributes: [],
- range: [0, 5],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 5 }
- }
- },
- closingElement: null,
- children: [],
- range: [0, 5],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 5 }
- }
- },
- range: [0, 5],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 5 }
- }
- },
-
- '': {
- type: 'ExpressionStatement',
- expression: {
- type: 'JSXElement',
- openingElement: {
- type: 'JSXOpeningElement',
- name: {
- type: 'JSXNamespacedName',
- namespace: {
- type: 'JSXIdentifier',
- name: 'n',
- range: [1, 2],
- loc: {
- start: { line: 1, column: 1 },
- end: { line: 1, column: 2 }
- }
- },
- name: {
- type: 'JSXIdentifier',
- name: 'a',
- range: [3, 4],
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 4 }
- }
- },
- range: [1, 4],
- loc: {
- start: { line: 1, column: 1 },
- end: { line: 1, column: 4 }
- }
- },
- selfClosing: true,
- attributes: [{
- type: 'JSXAttribute',
- name: {
- type: 'JSXNamespacedName',
- namespace: {
- type: 'JSXIdentifier',
- name: 'n',
- range: [5, 6],
- loc: {
- start: { line: 1, column: 5 },
- end: { line: 1, column: 6 }
- }
- },
- name: {
- type: 'JSXIdentifier',
- name: 'v',
- range: [7, 8],
- loc: {
- start: { line: 1, column: 7 },
- end: { line: 1, column: 8 }
- }
- },
- range: [5, 8],
- loc: {
- start: { line: 1, column: 5 },
- end: { line: 1, column: 8 }
- }
- },
- value: null,
- range: [5, 8],
- loc: {
- start: { line: 1, column: 5 },
- end: { line: 1, column: 8 }
- }
- }],
- range: [0, 11],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 11 }
- }
- },
- closingElement: null,
- children: [],
- range: [0, 11],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 11 }
- }
- },
- range: [0, 11],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 11 }
- }
- },
-
- ' {value} ': {
- type: 'ExpressionStatement',
- expression: {
- type: 'JSXElement',
- openingElement: {
- type: 'JSXOpeningElement',
- name: {
- type: 'JSXIdentifier',
- name: 'a',
- range: [1, 2],
- loc: {
- start: { line: 1, column: 1 },
- end: { line: 1, column: 2 }
- }
- },
- selfClosing: false,
- attributes: [{
- type: 'JSXAttribute',
- name: {
- type: 'JSXNamespacedName',
- namespace: {
- type: 'JSXIdentifier',
- name: 'n',
- range: [3, 4],
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 4 }
- }
- },
- name: {
- type: 'JSXIdentifier',
- name: 'foo',
- range: [5, 8],
- loc: {
- start: { line: 1, column: 5 },
- end: { line: 1, column: 8 }
- }
- },
- range: [3, 8],
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 8 }
- }
- },
- value: {
- type: 'Literal',
- value: 'bar',
- raw: '"bar"',
- range: [9, 14],
- loc: {
- start: { line: 1, column: 9 },
- end: { line: 1, column: 14 }
- }
- },
- range: [3, 14],
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 14 }
- }
- }],
- range: [0, 15],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 15 }
- }
- },
- closingElement: {
- type: 'JSXClosingElement',
- name: {
- type: 'JSXIdentifier',
- name: 'a',
- range: [38, 39],
- loc: {
- start: { line: 1, column: 38 },
- end: { line: 1, column: 39 }
- }
- },
- range: [36, 40],
- loc: {
- start: { line: 1, column: 36 },
- end: { line: 1, column: 40 }
- }
- },
- children: [{
- type: 'Literal',
- value: ' ',
- raw: ' ',
- range: [15, 16],
- loc: {
- start: { line: 1, column: 15 },
- end: { line: 1, column: 16 }
- }
- }, {
- type: 'JSXExpressionContainer',
- expression: {
- type: 'Identifier',
- name: 'value',
- range: [17, 22],
- loc: {
- start: { line: 1, column: 17 },
- end: { line: 1, column: 22 }
- }
- },
- range: [16, 23],
- loc: {
- start: { line: 1, column: 16 },
- end: { line: 1, column: 23 }
- }
- }, {
- type: 'Literal',
- value: ' ',
- raw: ' ',
- range: [23, 24],
- loc: {
- start: { line: 1, column: 23 },
- end: { line: 1, column: 24 }
- }
- }, {
- type: 'JSXElement',
- openingElement: {
- type: 'JSXOpeningElement',
- name: {
- type: 'JSXIdentifier',
- name: 'b',
- range: [25, 26],
- loc: {
- start: { line: 1, column: 25 },
- end: { line: 1, column: 26 }
- }
- },
- selfClosing: false,
- attributes: [],
- range: [24, 27],
- loc: {
- start: { line: 1, column: 24 },
- end: { line: 1, column: 27 }
- }
- },
- closingElement: {
- type: 'JSXClosingElement',
- name: {
- type: 'JSXIdentifier',
- name: 'b',
- range: [34, 35],
- loc: {
- start: { line: 1, column: 34 },
- end: { line: 1, column: 35 }
- }
- },
- range: [32, 36],
- loc: {
- start: { line: 1, column: 32 },
- end: { line: 1, column: 36 }
- }
- },
- children: [{
- type: 'JSXElement',
- openingElement: {
- type: 'JSXOpeningElement',
- name: {
- type: 'JSXIdentifier',
- name: 'c',
- range: [28, 29],
- loc: {
- start: { line: 1, column: 28 },
- end: { line: 1, column: 29 }
- }
- },
- selfClosing: true,
- attributes: [],
- range: [27, 32],
- loc: {
- start: { line: 1, column: 27 },
- end: { line: 1, column: 32 }
- }
- },
- closingElement: null,
- children: [],
- range: [27, 32],
- loc: {
- start: { line: 1, column: 27 },
- end: { line: 1, column: 32 }
- }
- }],
- range: [24, 36],
- loc: {
- start: { line: 1, column: 24 },
- end: { line: 1, column: 36 }
- }
- }],
- range: [0, 40],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 40 }
- }
- },
- range: [0, 40],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 40 }
- }
- },
-
- '': {
- type: "ExpressionStatement",
- expression: {
- type: "JSXElement",
- openingElement: {
- type: "JSXOpeningElement",
- name: {
- type: "JSXIdentifier",
- name: "a",
- range: [1, 2]
- },
- selfClosing: true,
- attributes: [
- {
- type: "JSXAttribute",
- name: {
- type: "JSXIdentifier",
- name: "b",
- range: [3, 4]
- },
- value: {
- type: "JSXExpressionContainer",
- expression: {
- type: "Literal",
- value: " ",
- raw: "\" \"",
- range: [6, 9]
- },
- range: [5, 10]
- },
- range: [3, 10]
- },
- {
- type: "JSXAttribute",
- name: {
- type: "JSXIdentifier",
- name: "c",
- range: [11, 12]
- },
- value: {
- type: "Literal",
- value: " ",
- raw: "\" \"",
- range: [13, 16]
- },
- range: [11, 16]
- },
- {
- type: "JSXAttribute",
- name: {
- type: "JSXIdentifier",
- name: "d",
- range: [17, 18]
- },
- value: {
- type: "Literal",
- value: "&",
- raw: "\"&\"",
- range: [19, 26]
- },
- range: [17, 26]
- },
- {
- type: "JSXAttribute",
- name: {
- type: "JSXIdentifier",
- name: "e",
- range: [27, 28]
- },
- value: {
- type: "Literal",
- value: "&r;",
- raw: "\"&r;\"",
- range: [29, 37]
- },
- range: [27, 37]
- }
- ],
- range: [0, 40]
- },
- closingElement: null,
- children: [],
- range: [0, 40]
- },
- range: [0, 40]
- },
-
- '': {
- type: "ExpressionStatement",
- expression: {
- type: "JSXElement",
- openingElement: {
- type: "JSXOpeningElement",
- name: {
- type: "JSXIdentifier",
- name: "a",
- range: [
- 1,
- 2
- ],
- loc: {
- start: {
- line: 1,
- column: 1
- },
- end: {
- line: 1,
- column: 2
- }
- }
- },
- selfClosing: true,
- attributes: [],
- range: [
- 0,
- 5
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 2,
- column: 2
- }
- }
- },
- closingElement: null,
- children: [],
- range: [
- 0,
- 5
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 2,
- column: 2
- }
- }
- },
- range: [
- 0,
- 5
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 2,
- column: 2
- }
- }
- },
-
- '<日本語>日本語>': {
- type: "ExpressionStatement",
- expression: {
- type: "JSXElement",
- openingElement: {
- type: "JSXOpeningElement",
- name: {
- type: "JSXIdentifier",
- name: "日本語",
- range: [
- 1,
- 4
- ],
- loc: {
- start: {
- line: 1,
- column: 1
- },
- end: {
- line: 1,
- column: 4
- }
- }
- },
- selfClosing: false,
- attributes: [],
- range: [
- 0,
- 5
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 5
- }
- }
- },
- closingElement: {
- type: "JSXClosingElement",
- name: {
- type: "JSXIdentifier",
- name: "日本語",
- range: [
- 7,
- 10
- ],
- loc: {
- start: {
- line: 1,
- column: 7
- },
- end: {
- line: 1,
- column: 10
- }
- }
- },
- range: [
- 5,
- 11
- ],
- loc: {
- start: {
- line: 1,
- column: 5
- },
- end: {
- line: 1,
- column: 11
- }
- }
- },
- children: [],
- range: [
- 0,
- 11
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 11
- }
- }
- },
- range: [
- 0,
- 11
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 11
- }
- }
- },
-
- '\nbar\nbaz\n': {
- type: "ExpressionStatement",
- expression: {
- type: "JSXElement",
- openingElement: {
- type: "JSXOpeningElement",
- name: {
- type: "JSXIdentifier",
- name: "AbC-def",
- range: [
- 1,
- 8
- ],
- loc: {
- start: {
- line: 1,
- column: 1
- },
- end: {
- line: 1,
- column: 8
- }
- }
- },
- selfClosing: false,
- attributes: [
- {
- type: "JSXAttribute",
- name: {
- type: "JSXIdentifier",
- name: "test",
- range: [
- 11,
- 15
- ],
- loc: {
- start: {
- line: 2,
- column: 2
- },
- end: {
- line: 2,
- column: 6
- }
- }
- },
- value: {
- type: "Literal",
- value: "&&",
- raw: "\"&&\"",
- range: [
- 16,
- 31
- ],
- loc: {
- start: {
- line: 2,
- column: 7
- },
- end: {
- line: 2,
- column: 22
- }
- }
- },
- range: [
- 11,
- 31
- ],
- loc: {
- start: {
- line: 2,
- column: 2
- },
- end: {
- line: 2,
- column: 22
- }
- }
- }
- ],
- range: [
- 0,
- 32
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 2,
- column: 23
- }
- }
- },
- closingElement: {
- type: "JSXClosingElement",
- name: {
- type: "JSXIdentifier",
- name: "AbC-def",
- range: [
- 43,
- 50
- ],
- loc: {
- start: {
- line: 5,
- column: 2
- },
- end: {
- line: 5,
- column: 9
- }
- }
- },
- range: [
- 41,
- 51
- ],
- loc: {
- start: {
- line: 5,
- column: 0
- },
- end: {
- line: 5,
- column: 10
- }
- }
- },
- children: [
- {
- type: "Literal",
- value: "\nbar\nbaz\n",
- raw: "\nbar\nbaz\n",
- range: [
- 32,
- 41
- ],
- loc: {
- start: {
- line: 2,
- column: 23
- },
- end: {
- line: 5,
- column: 0
- }
- }
- }
- ],
- range: [
- 0,
- 51
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 5,
- column: 10
- }
- }
- },
- range: [
- 0,
- 51
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 5,
- column: 10
- }
- }
- },
-
- ' : } />': {
- type: "ExpressionStatement",
- expression: {
- type: "JSXElement",
- openingElement: {
- type: "JSXOpeningElement",
- name: {
- type: "JSXIdentifier",
- name: "a",
- range: [
- 1,
- 2
- ],
- loc: {
- start: {
- line: 1,
- column: 1
- },
- end: {
- line: 1,
- column: 2
- }
- }
- },
- selfClosing: true,
- attributes: [
- {
- type: "JSXAttribute",
- name: {
- type: "JSXIdentifier",
- name: "b",
- range: [
- 3,
- 4
- ],
- loc: {
- start: {
- line: 1,
- column: 3
- },
- end: {
- line: 1,
- column: 4
- }
- }
- },
- value: {
- type: "JSXExpressionContainer",
- expression: {
- type: "ConditionalExpression",
- test: {
- type: "Identifier",
- name: "x",
- range: [
- 6,
- 7
- ],
- loc: {
- start: {
- line: 1,
- column: 6
- },
- end: {
- line: 1,
- column: 7
- }
- }
- },
- consequent: {
- type: "JSXElement",
- openingElement: {
- type: "JSXOpeningElement",
- name: {
- type: "JSXIdentifier",
- name: "c",
- range: [
- 11,
- 12
- ],
- loc: {
- start: {
- line: 1,
- column: 11
- },
- end: {
- line: 1,
- column: 12
- }
- }
- },
- selfClosing: true,
- attributes: [],
- range: [
- 10,
- 15
- ],
- loc: {
- start: {
- line: 1,
- column: 10
- },
- end: {
- line: 1,
- column: 15
- }
- }
- },
- closingElement: null,
- children: [],
- range: [
- 10,
- 15
- ],
- loc: {
- start: {
- line: 1,
- column: 10
- },
- end: {
- line: 1,
- column: 15
- }
- }
- },
- alternate: {
- type: "JSXElement",
- openingElement: {
- type: "JSXOpeningElement",
- name: {
- type: "JSXIdentifier",
- name: "d",
- range: [
- 19,
- 20
- ],
- loc: {
- start: {
- line: 1,
- column: 19
- },
- end: {
- line: 1,
- column: 20
- }
- }
- },
- selfClosing: true,
- attributes: [],
- range: [
- 18,
- 23
- ],
- loc: {
- start: {
- line: 1,
- column: 18
- },
- end: {
- line: 1,
- column: 23
- }
- }
- },
- closingElement: null,
- children: [],
- range: [
- 18,
- 23
- ],
- loc: {
- start: {
- line: 1,
- column: 18
- },
- end: {
- line: 1,
- column: 23
- }
- }
- },
- range: [
- 6,
- 23
- ],
- loc: {
- start: {
- line: 1,
- column: 6
- },
- end: {
- line: 1,
- column: 23
- }
- }
- },
- range: [
- 5,
- 24
- ],
- loc: {
- start: {
- line: 1,
- column: 5
- },
- end: {
- line: 1,
- column: 24
- }
- }
- },
- range: [
- 3,
- 24
- ],
- loc: {
- start: {
- line: 1,
- column: 3
- },
- end: {
- line: 1,
- column: 24
- }
- }
- }
- ],
- range: [
- 0,
- 27
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 27
- }
- }
- },
- closingElement: null,
- children: [],
- range: [
- 0,
- 27
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 27
- }
- }
- },
- range: [
- 0,
- 27
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 27
- }
- }
- },
-
- '{}': {
- type: 'ExpressionStatement',
- expression: {
- type: 'JSXElement',
- openingElement: {
- type: 'JSXOpeningElement',
- name: {
- type: 'JSXIdentifier',
- name: 'a',
- range: [1, 2],
- loc: {
- start: { line: 1, column: 1 },
- end: { line: 1, column: 2 }
- }
- },
- selfClosing: false,
- attributes: [],
- range: [0, 3],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 3 }
- }
- },
- closingElement: {
- type: 'JSXClosingElement',
- name: {
- type: 'JSXIdentifier',
- name: 'a',
- range: [7, 8],
- loc: {
- start: { line: 1, column: 7 },
- end: { line: 1, column: 8 }
- }
- },
- range: [5, 9],
- loc: {
- start: { line: 1, column: 5 },
- end: { line: 1, column: 9 }
- }
- },
- children: [{
- type: 'JSXExpressionContainer',
- expression: {
- type: 'JSXEmptyExpression',
- range: [4, 4],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 4 }
- }
- },
- range: [3, 5],
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 5 }
- }
- }],
- range: [0, 9],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 9 }
- }
- },
- range: [0, 9],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 9 }
- }
- },
-
- '{/* this is a comment */}': {
- type: 'ExpressionStatement',
- expression: {
- type: 'JSXElement',
- openingElement: {
- type: 'JSXOpeningElement',
- name: {
- type: 'JSXIdentifier',
- name: 'a',
- range: [1, 2],
- loc: {
- start: { line: 1, column: 1 },
- end: { line: 1, column: 2 }
- }
- },
- selfClosing: false,
- attributes: [],
- range: [0, 3],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 3 }
- }
- },
- closingElement: {
- type: 'JSXClosingElement',
- name: {
- type: 'JSXIdentifier',
- name: 'a',
- range: [30, 31],
- loc: {
- start: { line: 1, column: 30 },
- end: { line: 1, column: 31 }
- }
- },
- range: [28, 32],
- loc: {
- start: { line: 1, column: 28 },
- end: { line: 1, column: 32 }
- }
- },
- children: [{
- type: 'JSXExpressionContainer',
- expression: {
- type: 'JSXEmptyExpression',
- range: [4, 27],
- loc: {
- start: { line: 1, column: 4 },
- end: { line: 1, column: 27 }
- }
- },
- range: [3, 28],
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 28 }
- }
- }],
- range: [0, 32],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 32 }
- }
- },
- range: [0, 32],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 32 }
- }
- },
-
- '@test content
': {
- type: 'ExpressionStatement',
- expression: {
- type: 'JSXElement',
- openingElement: {
- type: 'JSXOpeningElement',
- name: {
- type: 'JSXIdentifier',
- name: 'div',
- range: [1, 4],
- loc: {
- start: { line: 1, column: 1 },
- end: { line: 1, column: 4 }
- }
- },
- selfClosing: false,
- attributes: [],
- range: [0, 5],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 5 }
- }
- },
- closingElement: {
- type: 'JSXClosingElement',
- name: {
- type: 'JSXIdentifier',
- name: 'div',
- range: [20, 23],
- loc: {
- start: { line: 1, column: 20 },
- end: { line: 1, column: 23 }
- }
- },
- range: [18, 24],
- loc: {
- start: { line: 1, column: 18 },
- end: { line: 1, column: 24 }
- }
- },
- children: [{
- type: 'Literal',
- value: '@test content',
- raw: '@test content',
- range: [5, 18],
- loc: {
- start: { line: 1, column: 5 },
- end: { line: 1, column: 18 }
- }
- }],
- range: [0, 24],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 24 }
- }
- },
- range: [0, 24],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 24 }
- }
- },
-
- '
7x invalid-js-identifier
': {
- type: 'ExpressionStatement',
- expression: {
- type: 'JSXElement',
- openingElement: {
- type: 'JSXOpeningElement',
- name: {
- type: 'JSXIdentifier',
- name: 'div',
- range: [
- 1,
- 4
- ],
- loc: {
- start: {
- line: 1,
- column: 1
- },
- end: {
- line: 1,
- column: 4
- }
- }
- },
- selfClosing: false,
- attributes: [],
- range: [
- 0,
- 5
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 5
- }
- }
- },
- closingElement: {
- type: 'JSXClosingElement',
- name: {
- type: 'JSXIdentifier',
- name: 'div',
- range: [
- 37,
- 40
- ],
- loc: {
- start: {
- line: 1,
- column: 37
- },
- end: {
- line: 1,
- column: 40
- }
- }
- },
- range: [
- 35,
- 41
- ],
- loc: {
- start: {
- line: 1,
- column: 35
- },
- end: {
- line: 1,
- column: 41
- }
- }
- },
- children: [{
- type: 'JSXElement',
- openingElement: {
- type: 'JSXOpeningElement',
- name: {
- type: 'JSXIdentifier',
- name: 'br',
- range: [
- 6,
- 8
- ],
- loc: {
- start: {
- line: 1,
- column: 6
- },
- end: {
- line: 1,
- column: 8
- }
- }
- },
- selfClosing: true,
- attributes: [],
- range: [
- 5,
- 11
- ],
- loc: {
- start: {
- line: 1,
- column: 5
- },
- end: {
- line: 1,
- column: 11
- }
- }
- },
- closingElement: null,
- children: [],
- range: [
- 5,
- 11
- ],
- loc: {
- start: {
- line: 1,
- column: 5
- },
- end: {
- line: 1,
- column: 11
- }
- }
- }, {
- type: 'Literal',
- value: '7x invalid-js-identifier',
- raw: '7x invalid-js-identifier',
- range: [
- 11,
- 35
- ],
- loc: {
- start: {
- line: 1,
- column: 11
- },
- end: {
- line: 1,
- column: 35
- }
- }
- }],
- range: [
- 0,
- 41
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 41
- }
- }
- },
- range: [
- 0,
- 41
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 41
- }
- }
- },
-
- ' right=monkeys /> gorillas />': {
- "type": "ExpressionStatement",
- "expression": {
- "type": "JSXElement",
- "openingElement": {
- "type": "JSXOpeningElement",
- "name": {
- "type": "JSXIdentifier",
- "name": "LeftRight",
- "range": [
- 1,
- 10
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 1
- },
- "end": {
- "line": 1,
- "column": 10
- }
- }
- },
- "selfClosing": true,
- "attributes": [
- {
- "type": "JSXAttribute",
- "name": {
- "type": "JSXIdentifier",
- "name": "left",
- "range": [
- 11,
- 15
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 11
- },
- "end": {
- "line": 1,
- "column": 15
- }
- }
- },
- "value": {
- "type": "JSXElement",
- "openingElement": {
- "type": "JSXOpeningElement",
- "name": {
- "type": "JSXIdentifier",
- "name": "a",
- "range": [
- 17,
- 18
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 17
- },
- "end": {
- "line": 1,
- "column": 18
- }
- }
- },
- "selfClosing": true,
- "attributes": [],
- "range": [
- 16,
- 21
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 16
- },
- "end": {
- "line": 1,
- "column": 21
- }
- }
- },
- closingElement: null,
- "children": [],
- "range": [
- 16,
- 21
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 16
- },
- "end": {
- "line": 1,
- "column": 21
- }
- }
- },
- "range": [
- 11,
- 21
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 11
- },
- "end": {
- "line": 1,
- "column": 21
- }
- }
- },
- {
- "type": "JSXAttribute",
- "name": {
- "type": "JSXIdentifier",
- "name": "right",
- "range": [
- 22,
- 27
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 22
- },
- "end": {
- "line": 1,
- "column": 27
- }
- }
- },
- "value": {
- "type": "JSXElement",
- "openingElement": {
- "type": "JSXOpeningElement",
- "name": {
- "type": "JSXIdentifier",
- "name": "b",
- "range": [
- 29,
- 30
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 29
- },
- "end": {
- "line": 1,
- "column": 30
- }
- }
- },
- "selfClosing": false,
- "attributes": [],
- "range": [
- 28,
- 31
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 28
- },
- "end": {
- "line": 1,
- "column": 31
- }
- }
- },
- "closingElement": {
- "type": "JSXClosingElement",
- "name": {
- "type": "JSXIdentifier",
- "name": "b",
- "range": [
- 52,
- 53
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 52
- },
- "end": {
- "line": 1,
- "column": 53
- }
- }
- },
- "range": [
- 50,
- 54
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 50
- },
- "end": {
- "line": 1,
- "column": 54
- }
- }
- },
- "children": [
- {
- "type": "Literal",
- "value": "monkeys /> gorillas",
- "raw": "monkeys /> gorillas",
- "range": [
- 31,
- 50
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 31
- },
- "end": {
- "line": 1,
- "column": 50
- }
- }
- }
- ],
- "range": [
- 28,
- 54
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 28
- },
- "end": {
- "line": 1,
- "column": 54
- }
- }
- },
- "range": [
- 22,
- 54
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 22
- },
- "end": {
- "line": 1,
- "column": 54
- }
- }
- }
- ],
- "range": [
- 0,
- 57
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 0
- },
- "end": {
- "line": 1,
- "column": 57
- }
- }
- },
- closingElement: null,
- "children": [],
- "range": [
- 0,
- 57
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 0
- },
- "end": {
- "line": 1,
- "column": 57
- }
- }
- },
- "range": [
- 0,
- 57
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 0
- },
- "end": {
- "line": 1,
- "column": 57
- }
- }
- },
-
- '': {
- type: 'ExpressionStatement',
- expression: {
- type: 'JSXElement',
- openingElement: {
- type: 'JSXOpeningElement',
- name: {
- type: 'JSXMemberExpression',
- object: {
- type: 'JSXIdentifier',
- name: 'a',
- range: [1, 2],
- loc: {
- start: { line: 1, column: 1 },
- end: { line: 1, column: 2 }
- }
- },
- property: {
- type: 'JSXIdentifier',
- name: 'b',
- range: [3, 4],
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 4 }
- }
- },
- range: [1, 4],
- loc: {
- start: { line: 1, column: 1 },
- end: { line: 1, column: 4 }
- }
- },
- selfClosing: false,
- attributes: [],
- range: [0, 5],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 5 }
- }
- },
- closingElement: {
- type: 'JSXClosingElement',
- name: {
- type: 'JSXMemberExpression',
- object: {
- type: 'JSXIdentifier',
- name: 'a',
- range: [7, 8],
- loc: {
- start: { line: 1, column: 7 },
- end: { line: 1, column: 8 }
- }
- },
- property: {
- type: 'JSXIdentifier',
- name: 'b',
- range: [9, 10],
- loc: {
- start: { line: 1, column: 9 },
- end: { line: 1, column: 10 }
- }
- },
- range: [7, 10],
- loc: {
- start: { line: 1, column: 7 },
- end: { line: 1, column: 10 }
- }
- },
- range: [5, 11],
- loc: {
- start: { line: 1, column: 5 },
- end: { line: 1, column: 11 }
- }
- },
- children: [],
- range: [0, 11],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 11 }
- }
- },
- range: [0, 11],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 11 }
- }
- },
-
- '': {
- type: 'ExpressionStatement',
- expression: {
- type: 'JSXElement',
- openingElement: {
- type: 'JSXOpeningElement',
- name: {
- type: 'JSXMemberExpression',
- object: {
- type: 'JSXMemberExpression',
- object: {
- type: 'JSXIdentifier',
- name: 'a',
- range: [1, 2],
- loc: {
- start: { line: 1, column: 1 },
- end: { line: 1, column: 2 }
- }
- },
- property: {
- type: 'JSXIdentifier',
- name: 'b',
- range: [3, 4],
- loc: {
- start: { line: 1, column: 3 },
- end: { line: 1, column: 4 }
- }
- },
- range: [1, 4],
- loc: {
- start: { line: 1, column: 1 },
- end: { line: 1, column: 4 }
- }
- },
- property: {
- type: 'JSXIdentifier',
- name: 'c',
- range: [5, 6],
- loc: {
- start: { line: 1, column: 5 },
- end: { line: 1, column: 6 }
- }
- },
- range: [1, 6],
- loc: {
- start: { line: 1, column: 1 },
- end: { line: 1, column: 6 }
- }
- },
- selfClosing: false,
- attributes: [],
- range: [0, 7],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 7 }
- }
- },
- closingElement: {
- type: 'JSXClosingElement',
- name: {
- type: 'JSXMemberExpression',
- object: {
- type: 'JSXMemberExpression',
- object: {
- type: 'JSXIdentifier',
- name: 'a',
- range: [9, 10],
- loc: {
- start: { line: 1, column: 9 },
- end: { line: 1, column: 10 }
- }
- },
- property: {
- type: 'JSXIdentifier',
- name: 'b',
- range: [11, 12],
- loc: {
- start: { line: 1, column: 11 },
- end: { line: 1, column: 12 }
- }
- },
- range: [9, 12],
- loc: {
- start: { line: 1, column: 9 },
- end: { line: 1, column: 12 }
- }
- },
- property: {
- type: 'JSXIdentifier',
- name: 'c',
- range: [13, 14],
- loc: {
- start: { line: 1, column: 13 },
- end: { line: 1, column: 14 }
- }
- },
- range: [9, 14],
- loc: {
- start: { line: 1, column: 9 },
- end: { line: 1, column: 14 }
- }
- },
- range: [7, 15],
- loc: {
- start: { line: 1, column: 7 },
- end: { line: 1, column: 15 }
- }
- },
- children: [],
- range: [0, 15],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 15 }
- }
- },
- range: [0, 15],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 15 }
- }
- },
-
- // In order to more useful parse errors, we disallow following an
- // JSXElement by a less-than symbol. In the rare case that the binary
- // operator was intended, the tag can be wrapped in parentheses:
- '() < x;': {
- type: 'ExpressionStatement',
- expression: {
- type: 'BinaryExpression',
- operator: '<',
- left: {
- type: 'JSXElement',
- openingElement: {
- type: 'JSXOpeningElement',
- name: {
- type: 'JSXIdentifier',
- name: 'div',
- range: [2, 5],
- loc: {
- start: { line: 1, column: 2 },
- end: { line: 1, column: 5 }
- }
- },
- selfClosing: true,
- attributes: [],
- range: [1, 8],
- loc: {
- start: { line: 1, column: 1 },
- end: { line: 1, column: 8 }
- }
- },
- closingElement: null,
- children: [],
- range: [1, 8],
- loc: {
- start: { line: 1, column: 1 },
- end: { line: 1, column: 8 }
- }
- },
- right: {
- type: 'Identifier',
- name: 'x',
- range: [12, 13],
- loc: {
- start: { line: 1, column: 12 },
- end: { line: 1, column: 13 }
- }
- },
- range: [0, 13],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 13 }
- }
- },
- range: [0, 14],
- loc: {
- start: { line: 1, column: 0 },
- end: { line: 1, column: 14 }
- }
- },
-
- '': {
- "type": "ExpressionStatement",
- "expression": {
- "type": "JSXElement",
- "openingElement": {
- "type": "JSXOpeningElement",
- "name": {
- "type": "JSXIdentifier",
- "name": "div",
- "range": [
- 1,
- 4
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 1
- },
- "end": {
- "line": 1,
- "column": 4
- }
- }
- },
- "selfClosing": true,
- "attributes": [
- {
- "type": "JSXSpreadAttribute",
- "argument": {
- "type": "Identifier",
- "name": "props",
- "range": [
- 9,
- 14
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 9
- },
- "end": {
- "line": 1,
- "column": 14
- }
- }
- },
- "range": [
- 5,
- 15
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 5
- },
- "end": {
- "line": 1,
- "column": 15
- }
- }
- }
- ],
- "range": [
- 0,
- 18
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 0
- },
- "end": {
- "line": 1,
- "column": 18
- }
- }
- },
- closingElement: null,
- "children": [],
- "range": [
- 0,
- 18
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 0
- },
- "end": {
- "line": 1,
- "column": 18
- }
- }
- },
- "range": [
- 0,
- 18
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 0
- },
- "end": {
- "line": 1,
- "column": 18
- }
- }
- },
-
- '': {
- "type": "ExpressionStatement",
- "expression": {
- "type": "JSXElement",
- "openingElement": {
- "type": "JSXOpeningElement",
- "name": {
- "type": "JSXIdentifier",
- "name": "div",
- "range": [
- 1,
- 4
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 1
- },
- "end": {
- "line": 1,
- "column": 4
- }
- }
- },
- "selfClosing": true,
- "attributes": [
- {
- "type": "JSXSpreadAttribute",
- "argument": {
- "type": "Identifier",
- "name": "props",
- "range": [
- 9,
- 14
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 9
- },
- "end": {
- "line": 1,
- "column": 14
- }
- }
- },
- "range": [
- 5,
- 15
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 5
- },
- "end": {
- "line": 1,
- "column": 15
- }
- }
- },
- {
- "type": "JSXAttribute",
- "name": {
- "type": "JSXIdentifier",
- "name": "post",
- "range": [
- 16,
- 20
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 16
- },
- "end": {
- "line": 1,
- "column": 20
- }
- }
- },
- "value": {
- "type": "Literal",
- "value": "attribute",
- "raw": "\"attribute\"",
- "range": [
- 21,
- 32
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 21
- },
- "end": {
- "line": 1,
- "column": 32
- }
- }
- },
- "range": [
- 16,
- 32
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 16
- },
- "end": {
- "line": 1,
- "column": 32
- }
- }
- }
- ],
- "range": [
- 0,
- 35
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 0
- },
- "end": {
- "line": 1,
- "column": 35
- }
- }
- },
- closingElement: null,
- "children": [],
- "range": [
- 0,
- 35
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 0
- },
- "end": {
- "line": 1,
- "column": 35
- }
- }
- },
- "range": [
- 0,
- 35
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 0
- },
- "end": {
- "line": 1,
- "column": 35
- }
- }
- },
-
- '': {
- "type": "ExpressionStatement",
- "expression": {
- "type": "JSXElement",
- "openingElement": {
- "type": "JSXOpeningElement",
- "name": {
- "type": "JSXIdentifier",
- "name": "div",
- "range": [
- 1,
- 4
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 1
- },
- "end": {
- "line": 1,
- "column": 4
- }
- }
- },
- "selfClosing": false,
- "attributes": [
- {
- "type": "JSXAttribute",
- "name": {
- "type": "JSXIdentifier",
- "name": "pre",
- "range": [
- 5,
- 8
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 5
- },
- "end": {
- "line": 1,
- "column": 8
- }
- }
- },
- "value": {
- "type": "Literal",
- "value": "leading",
- "raw": "\"leading\"",
- "range": [
- 9,
- 18
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 9
- },
- "end": {
- "line": 1,
- "column": 18
- }
- }
- },
- "range": [
- 5,
- 18
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 5
- },
- "end": {
- "line": 1,
- "column": 18
- }
- }
- },
- {
- "type": "JSXAttribute",
- "name": {
- "type": "JSXIdentifier",
- "name": "pre2",
- "range": [
- 19,
- 23
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 19
- },
- "end": {
- "line": 1,
- "column": 23
- }
- }
- },
- "value": {
- "type": "Literal",
- "value": "attribute",
- "raw": "\"attribute\"",
- "range": [
- 24,
- 35
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 24
- },
- "end": {
- "line": 1,
- "column": 35
- }
- }
- },
- "range": [
- 19,
- 35
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 19
- },
- "end": {
- "line": 1,
- "column": 35
- }
- }
- },
- {
- "type": "JSXSpreadAttribute",
- "argument": {
- "type": "Identifier",
- "name": "props",
- "range": [
- 40,
- 45
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 40
- },
- "end": {
- "line": 1,
- "column": 45
- }
- }
- },
- "range": [
- 36,
- 46
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 36
- },
- "end": {
- "line": 1,
- "column": 46
- }
- }
- }
- ],
- "range": [
- 0,
- 47
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 0
- },
- "end": {
- "line": 1,
- "column": 47
- }
- }
- },
- "closingElement": {
- "type": "JSXClosingElement",
- "name": {
- "type": "JSXIdentifier",
- "name": "div",
- "range": [
- 49,
- 52
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 49
- },
- "end": {
- "line": 1,
- "column": 52
- }
- }
- },
- "range": [
- 47,
- 53
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 47
- },
- "end": {
- "line": 1,
- "column": 53
- }
- }
- },
- "children": [],
- "range": [
- 0,
- 53
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 0
- },
- "end": {
- "line": 1,
- "column": 53
- }
- }
- },
- "range": [
- 0,
- 53
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 0
- },
- "end": {
- "line": 1,
- "column": 53
- }
- }
- },
-
- '{aa.b}
': {
- "type": "ExpressionStatement",
- "start": 0,
- "end": 52,
- "loc": {
- "start": {
- "line": 1,
- "column": 0
- },
- "end": {
- "line": 1,
- "column": 52
- }
- },
- "range": [
- 0,
- 52
- ],
- "expression": {
- "type": "JSXElement",
- "start": 0,
- "end": 52,
- "loc": {
- "start": {
- "line": 1,
- "column": 0
- },
- "end": {
- "line": 1,
- "column": 52
- }
- },
- "range": [
- 0,
- 52
- ],
- "openingElement": {
- "type": "JSXOpeningElement",
- "start": 0,
- "end": 31,
- "loc": {
- "start": {
- "line": 1,
- "column": 0
- },
- "end": {
- "line": 1,
- "column": 31
- }
- },
- "range": [
- 0,
- 31
- ],
- "attributes": [
- {
- "type": "JSXAttribute",
- "start": 3,
- "end": 16,
- "loc": {
- "start": {
- "line": 1,
- "column": 3
- },
- "end": {
- "line": 1,
- "column": 16
- }
- },
- "range": [
- 3,
- 16
- ],
- "name": {
- "type": "JSXIdentifier",
- "start": 3,
- "end": 5,
- "loc": {
- "start": {
- "line": 1,
- "column": 3
- },
- "end": {
- "line": 1,
- "column": 5
- }
- },
- "range": [
- 3,
- 5
- ],
- "name": "aa"
- },
- "value": {
- "type": "JSXExpressionContainer",
- "start": 6,
- "end": 16,
- "loc": {
- "start": {
- "line": 1,
- "column": 6
- },
- "end": {
- "line": 1,
- "column": 16
- }
- },
- "range": [
- 6,
- 16
- ],
- "expression": {
- "type": "MemberExpression",
- "start": 7,
- "end": 15,
- "loc": {
- "start": {
- "line": 1,
- "column": 7
- },
- "end": {
- "line": 1,
- "column": 15
- }
- },
- "range": [
- 7,
- 15
- ],
- "object": {
- "type": "MemberExpression",
- "start": 7,
- "end": 12,
- "loc": {
- "start": {
- "line": 1,
- "column": 7
- },
- "end": {
- "line": 1,
- "column": 12
- }
- },
- "range": [
- 7,
- 12
- ],
- "object": {
- "type": "Identifier",
- "start": 7,
- "end": 9,
- "loc": {
- "start": {
- "line": 1,
- "column": 7
- },
- "end": {
- "line": 1,
- "column": 9
- }
- },
- "range": [
- 7,
- 9
- ],
- "name": "aa"
- },
- "property": {
- "type": "Identifier",
- "start": 10,
- "end": 12,
- "loc": {
- "start": {
- "line": 1,
- "column": 10
- },
- "end": {
- "line": 1,
- "column": 12
- }
- },
- "range": [
- 10,
- 12
- ],
- "name": "bb"
- },
- "computed": false
- },
- "property": {
- "type": "Identifier",
- "start": 13,
- "end": 15,
- "loc": {
- "start": {
- "line": 1,
- "column": 13
- },
- "end": {
- "line": 1,
- "column": 15
- }
- },
- "range": [
- 13,
- 15
- ],
- "name": "cc"
- },
- "computed": false
- }
- }
- },
- {
- "type": "JSXAttribute",
- "start": 17,
- "end": 30,
- "loc": {
- "start": {
- "line": 1,
- "column": 17
- },
- "end": {
- "line": 1,
- "column": 30
- }
- },
- "range": [
- 17,
- 30
- ],
- "name": {
- "type": "JSXIdentifier",
- "start": 17,
- "end": 19,
- "loc": {
- "start": {
- "line": 1,
- "column": 17
- },
- "end": {
- "line": 1,
- "column": 19
- }
- },
- "range": [
- 17,
- 19
- ],
- "name": "bb"
- },
- "value": {
- "type": "JSXExpressionContainer",
- "start": 20,
- "end": 30,
- "loc": {
- "start": {
- "line": 1,
- "column": 20
- },
- "end": {
- "line": 1,
- "column": 30
- }
- },
- "range": [
- 20,
- 30
- ],
- "expression": {
- "type": "MemberExpression",
- "start": 21,
- "end": 29,
- "loc": {
- "start": {
- "line": 1,
- "column": 21
- },
- "end": {
- "line": 1,
- "column": 29
- }
- },
- "range": [
- 21,
- 29
- ],
- "object": {
- "type": "MemberExpression",
- "start": 21,
- "end": 26,
- "loc": {
- "start": {
- "line": 1,
- "column": 21
- },
- "end": {
- "line": 1,
- "column": 26
- }
- },
- "range": [
- 21,
- 26
- ],
- "object": {
- "type": "Identifier",
- "start": 21,
- "end": 23,
- "loc": {
- "start": {
- "line": 1,
- "column": 21
- },
- "end": {
- "line": 1,
- "column": 23
- }
- },
- "range": [
- 21,
- 23
- ],
- "name": "bb"
- },
- "property": {
- "type": "Identifier",
- "start": 24,
- "end": 26,
- "loc": {
- "start": {
- "line": 1,
- "column": 24
- },
- "end": {
- "line": 1,
- "column": 26
- }
- },
- "range": [
- 24,
- 26
- ],
- "name": "cc"
- },
- "computed": false
- },
- "property": {
- "type": "Identifier",
- "start": 27,
- "end": 29,
- "loc": {
- "start": {
- "line": 1,
- "column": 27
- },
- "end": {
- "line": 1,
- "column": 29
- }
- },
- "range": [
- 27,
- 29
- ],
- "name": "dd"
- },
- "computed": false
- }
- }
- }
- ],
- "name": {
- "type": "JSXIdentifier",
- "start": 1,
- "end": 2,
- "loc": {
- "start": {
- "line": 1,
- "column": 1
- },
- "end": {
- "line": 1,
- "column": 2
- }
- },
- "range": [
- 1,
- 2
- ],
- "name": "A"
- },
- "selfClosing": false
- },
- "closingElement": {
- "type": "JSXClosingElement",
- "start": 48,
- "end": 52,
- "loc": {
- "start": {
- "line": 1,
- "column": 48
- },
- "end": {
- "line": 1,
- "column": 52
- }
- },
- "range": [
- 48,
- 52
- ],
- "name": {
- "type": "JSXIdentifier",
- "start": 50,
- "end": 51,
- "loc": {
- "start": {
- "line": 1,
- "column": 50
- },
- "end": {
- "line": 1,
- "column": 51
- }
- },
- "range": [
- 50,
- 51
- ],
- "name": "A"
- }
- },
- "children": [
- {
- "type": "JSXElement",
- "start": 31,
- "end": 48,
- "loc": {
- "start": {
- "line": 1,
- "column": 31
- },
- "end": {
- "line": 1,
- "column": 48
- }
- },
- "range": [
- 31,
- 48
- ],
- "openingElement": {
- "type": "JSXOpeningElement",
- "start": 31,
- "end": 36,
- "loc": {
- "start": {
- "line": 1,
- "column": 31
- },
- "end": {
- "line": 1,
- "column": 36
- }
- },
- "range": [
- 31,
- 36
- ],
- "attributes": [],
- "name": {
- "type": "JSXIdentifier",
- "start": 32,
- "end": 35,
- "loc": {
- "start": {
- "line": 1,
- "column": 32
- },
- "end": {
- "line": 1,
- "column": 35
- }
- },
- "range": [
- 32,
- 35
- ],
- "name": "div"
- },
- "selfClosing": false
- },
- "closingElement": {
- "type": "JSXClosingElement",
- "start": 42,
- "end": 48,
- "loc": {
- "start": {
- "line": 1,
- "column": 42
- },
- "end": {
- "line": 1,
- "column": 48
- }
- },
- "range": [
- 42,
- 48
- ],
- "name": {
- "type": "JSXIdentifier",
- "start": 44,
- "end": 47,
- "loc": {
- "start": {
- "line": 1,
- "column": 44
- },
- "end": {
- "line": 1,
- "column": 47
- }
- },
- "range": [
- 44,
- 47
- ],
- "name": "div"
- }
- },
- "children": [
- {
- "type": "JSXExpressionContainer",
- "start": 36,
- "end": 42,
- "loc": {
- "start": {
- "line": 1,
- "column": 36
- },
- "end": {
- "line": 1,
- "column": 42
- }
- },
- "range": [
- 36,
- 42
- ],
- "expression": {
- "type": "MemberExpression",
- "start": 37,
- "end": 41,
- "loc": {
- "start": {
- "line": 1,
- "column": 37
- },
- "end": {
- "line": 1,
- "column": 41
- }
- },
- "range": [
- 37,
- 41
- ],
- "object": {
- "type": "Identifier",
- "start": 37,
- "end": 39,
- "loc": {
- "start": {
- "line": 1,
- "column": 37
- },
- "end": {
- "line": 1,
- "column": 39
- }
- },
- "range": [
- 37,
- 39
- ],
- "name": "aa"
- },
- "property": {
- "type": "Identifier",
- "start": 40,
- "end": 41,
- "loc": {
- "start": {
- "line": 1,
- "column": 40
- },
- "end": {
- "line": 1,
- "column": 41
- }
- },
- "range": [
- 40,
- 41
- ],
- "name": "b"
- },
- "computed": false
- }
- }
- ]
- }
- ]
- }
- }
- },
- 'Regression': {
- 'foo bar baz
;': {
- type: "ExpressionStatement",
- start: 0,
- end: 40,
- expression: {
- type: "JSXElement",
- start: 0,
- end: 38,
- openingElement: {
- type: "JSXOpeningElement",
- start: 0,
- end: 3,
- attributes: [],
- name: {
- type: "JSXIdentifier",
- start: 1,
- end: 2,
- name: "p"
- },
- selfClosing: false
- },
- closingElement: {
- type: "JSXClosingElement",
- start: 34,
- end: 38,
- name: {
- type: "JSXIdentifier",
- start: 36,
- end: 37,
- name: "p"
- }
- },
- children: [
- {
- type: "Literal",
- start: 3,
- end: 7,
- value: "foo ",
- raw: "foo "
- },
- {
- type: "JSXElement",
- start: 7,
- end: 30,
- openingElement: {
- type: "JSXOpeningElement",
- start: 7,
- end: 22,
- attributes: [{
- type: "JSXAttribute",
- start: 10,
- end: 21,
- name: {
- type: "JSXIdentifier",
- start: 10,
- end: 14,
- name: "href"
- },
- value: {
- type: "Literal",
- start: 15,
- end: 21,
- value: "test",
- raw: "\"test\""
- }
- }],
- name: {
- type: "JSXIdentifier",
- start: 8,
- end: 9,
- name: "a"
- },
- selfClosing: false
- },
- closingElement: {
- type: "JSXClosingElement",
- start: 26,
- end: 30,
- name: {
- type: "JSXIdentifier",
- start: 28,
- end: 29,
- name: "a"
- }
- },
- children: [{
- type: "Literal",
- start: 22,
- end: 26,
- value: " bar",
- raw: " bar"
- }]
- },
- {
- type: "Literal",
- start: 30,
- end: 34,
- value: " baz",
- raw: " baz"
- }
- ]
- }
- },
-
- '': {
- type: 'ExpressionStatement',
- start: 0,
- end: 30,
- expression: {
- type: 'JSXElement',
- start: 0,
- end: 30,
- openingElement: {
- type: 'JSXOpeningElement',
- start: 0,
- end: 5,
- attributes: [],
- name: {
- type: 'JSXIdentifier',
- start: 1,
- end: 4,
- name: 'div'
- },
- selfClosing: false
- },
- closingElement: {
- type: 'JSXClosingElement',
- start: 24,
- end: 30,
- name: {
- type: 'JSXIdentifier',
- start: 26,
- end: 29,
- name: 'div'
- }
- },
- children: [{
- type: 'JSXExpressionContainer',
- start: 5,
- end: 24,
- expression: {
- type: 'JSXElement',
- start: 6,
- end: 23,
- openingElement: {
- type: 'JSXOpeningElement',
- start: 6,
- end: 23,
- attributes: [
- {
- type: 'JSXSpreadAttribute',
- start: 11,
- end: 20,
- argument: {
- type: 'Identifier',
- start: 15,
- end: 19,
- name: 'test'
- }
- }
- ],
- name: {
- type: 'JSXIdentifier',
- start: 7,
- end: 10,
- name: 'div'
- },
- selfClosing: true
- },
- closingElement: null,
- children: []
- }
- }]
- }
- },
-
- '{ {a} }
': {
- type: "ExpressionStatement",
- start: 0,
- end: 18,
- expression: {
- type: "JSXElement",
- start: 0,
- end: 18,
- openingElement: {
- type: "JSXOpeningElement",
- start: 0,
- end: 5,
- attributes: [],
- name: {
- type: "JSXIdentifier",
- start: 1,
- end: 4,
- name: "div"
- },
- selfClosing: false
- },
- closingElement: {
- type: "JSXClosingElement",
- start: 12,
- end: 18,
- name: {
- type: "JSXIdentifier",
- start: 14,
- end: 17,
- name: "div"
- }
- },
- children: [{
- type: "JSXExpressionContainer",
- start: 5,
- end: 12,
- expression: {
- type: "ObjectExpression",
- start: 7,
- end: 10,
- properties: [{
- type: "Property",
- start: 8,
- end: 9,
- method: false,
- shorthand: true,
- computed: false,
- key: {
- type: "Identifier",
- start: 8,
- end: 9,
- name: "a"
- },
- kind: "init",
- value: {
- type: "Identifier",
- start: 8,
- end: 9,
- name: "a"
- }
- }]
- }
- }]
- }
- },
-
- '/text
': {
- type: "ExpressionStatement",
- start: 0,
- end: 16,
- expression: {
- type: "JSXElement",
- start: 0,
- end: 16,
- openingElement: {
- type: "JSXOpeningElement",
- start: 0,
- end: 5,
- attributes: [],
- name: {
- type: "JSXIdentifier",
- start: 1,
- end: 4,
- name: "div"
- },
- selfClosing: false
- },
- closingElement: {
- type: "JSXClosingElement",
- start: 10,
- end: 16,
- name: {
- type: "JSXIdentifier",
- start: 12,
- end: 15,
- name: "div"
- }
- },
- children: [{
- type: "Literal",
- start: 5,
- end: 10,
- value: "/text",
- raw: "/text"
- }]
- }
- },
-
- '{a}{b}
': {
- type: "ExpressionStatement",
- start: 0,
- end: 17,
- expression: {
- type: "JSXElement",
- start: 0,
- end: 17,
- openingElement: {
- type: "JSXOpeningElement",
- start: 0,
- end: 5,
- attributes: [],
- name: {
- type: "JSXIdentifier",
- start: 1,
- end: 4,
- name: "div"
- },
- selfClosing: false
- },
- closingElement: {
- type: "JSXClosingElement",
- start: 11,
- end: 17,
- name: {
- type: "JSXIdentifier",
- start: 13,
- end: 16,
- name: "div"
- }
- },
- children: [{
- type: 'JSXExpressionContainer',
- expression: {
- type: 'Identifier',
- name: 'a',
- range: [6, 7],
- loc: {
- start: {
- line: 1,
- column: 6
- },
- end: {
- line: 1,
- column: 7
- }
- }
- },
- range: [5, 8],
- loc: {
- start: {
- line: 1,
- column: 5
- },
- end: {
- line: 1,
- column: 8
- }
- }
- }, {
- type: 'JSXExpressionContainer',
- expression: {
- type: 'Identifier',
- name: 'b',
- range: [9, 10],
- loc: {
- start: {
- line: 1,
- column: 9
- },
- end: {
- line: 1,
- column: 10
- }
- }
- },
- range: [8, 11],
- loc: {
- start: {
- line: 1,
- column: 8
- },
- end: {
- line: 1,
- column: 11
- }
- }
- }
- ]
- }
- },
-
- '': {
- type: "ExpressionStatement",
- range: [0, 32],
- expression: {
- type: "JSXElement",
- range: [0, 32],
- openingElement: {
- type: "JSXOpeningElement",
- range: [0, 32],
- attributes: [
- {
- type: "JSXAttribute",
- range: [5, 18],
- name: {
- type: "JSXIdentifier",
- range: [5, 8],
- name: "pre"
- },
- value: {
- type: "Literal",
- range: [9, 18],
- value: "leading"
- }
- },
- {
- type: "JSXSpreadAttribute",
- range: [19, 29],
- argument: {
- type: "Identifier",
- range: [23, 28],
- name: "props"
- }
- }
- ],
- name: {
- type: "JSXIdentifier",
- range: [1, 4],
- name: "div"
- },
- selfClosing: true
- },
- closingElement: null,
- children: []
- }
- },
- '': {
- type: "ExpressionStatement",
- expression: {
- type: "JSXElement",
- range: [0, 64],
- openingElement: {
- type: "JSXOpeningElement",
- range: [0, 64],
- attributes: [
- {
- type: "JSXAttribute",
- range: [6, 62],
- name: {
- type: "JSXIdentifier",
- range: [6, 7],
- name: "d"
- },
- value: {
- type: "Literal",
- range: [8, 62],
- value: "M230 80\n\t\tA 45 45, 0, 1, 0, 275 125 \r\n L 275 80 Z",
- raw: "\"M230 80\n\t\tA 45 45, 0, 1, 0, 275 125 \r\n L 275 80 Z\""
- }
- }
- ],
- name: {
- type: "JSXIdentifier",
- range: [1, 5],
- name: "path"
- },
- selfClosing: true
- },
- closingElement: null,
- children: []
- }
- }
- }
-};
-
-if (typeof exports !== "undefined") {
- var test = require("./driver.js").test;
-}
-
-for (var ns in fbTestFixture) {
- ns = fbTestFixture[ns];
- for (var code in ns) {
- test(code, {
- type: 'Program',
- body: [ns[code]]
- }, {
- ecmaVersion: 6,
- plugins: { jsx: true },
- locations: true,
- ranges: true
- });
- }
-}
diff --git a/test/tests.js b/test/tests.js
deleted file mode 100755
index 944597f6a6..0000000000
--- a/test/tests.js
+++ /dev/null
@@ -1,28934 +0,0 @@
-// Tests largely based on those of Esprima
-// (http://esprima.org/test/)
-
-if (typeof exports != "undefined") {
- var driver = require("./driver.js");
- var test = driver.test, testFail = driver.testFail, testAssert = driver.testAssert, misMatch = driver.misMatch;
- var acorn = require("..");
-}
-
-test("this\n", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "ThisExpression",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 4
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 4
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 2,
- column: 0
- }
- }
-});
-
-test("null\n", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "Literal",
- value: null,
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 4
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 4
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 2,
- column: 0
- }
- }
-});
-
-test("\n 42\n\n", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "Literal",
- value: 42,
- loc: {
- start: {
- line: 2,
- column: 4
- },
- end: {
- line: 2,
- column: 6
- }
- }
- },
- loc: {
- start: {
- line: 2,
- column: 4
- },
- end: {
- line: 2,
- column: 6
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 4,
- column: 0
- }
- }
-});
-
-test("/foobar/", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "Literal",
- value: /foobar/,
- regex: {
- pattern: "foobar",
- flags: ""
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 8
- }
- }
- }
- }
- ]
-});
-
-test("/[a-z]/g", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "Literal",
- value: /[a-z]/g,
- regex: {
- pattern: "[a-z]",
- flags: "g"
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 8
- }
- }
- }
- }
- ]
-});
-
-test("(1 + 2 ) * 3", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "BinaryExpression",
- left: {
- type: "BinaryExpression",
- left: {
- type: "Literal",
- value: 1,
- loc: {
- start: {
- line: 1,
- column: 1
- },
- end: {
- line: 1,
- column: 2
- }
- }
- },
- operator: "+",
- right: {
- type: "Literal",
- value: 2,
- loc: {
- start: {
- line: 1,
- column: 5
- },
- end: {
- line: 1,
- column: 6
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 1
- },
- end: {
- line: 1,
- column: 6
- }
- }
- },
- operator: "*",
- right: {
- type: "Literal",
- value: 3,
- loc: {
- start: {
- line: 1,
- column: 11
- },
- end: {
- line: 1,
- column: 12
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 12
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 12
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 12
- }
- }
-});
-
-test("(1 + 2 ) * 3", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "BinaryExpression",
- left: {
- type: "ParenthesizedExpression",
- expression: {
- type: "BinaryExpression",
- left: {
- type: "Literal",
- value: 1,
- loc: {
- start: {
- line: 1,
- column: 1
- },
- end: {
- line: 1,
- column: 2
- }
- }
- },
- operator: "+",
- right: {
- type: "Literal",
- value: 2,
- loc: {
- start: {
- line: 1,
- column: 5
- },
- end: {
- line: 1,
- column: 6
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 1
- },
- end: {
- line: 1,
- column: 6
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 8
- }
- }
- },
- operator: "*",
- right: {
- type: "Literal",
- value: 3,
- loc: {
- start: {
- line: 1,
- column: 11
- },
- end: {
- line: 1,
- column: 12
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 12
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 12
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 12
- }
- }
-}, {
- locations: true,
- preserveParens: true
-});
-
-testFail("(x) = 23", "Assigning to rvalue (1:0)", { preserveParens: true });
-
-test("x = []", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "AssignmentExpression",
- operator: "=",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- },
- right: {
- type: "ArrayExpression",
- elements: [],
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 6
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 6
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 6
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 6
- }
- }
-});
-
-test("x = [ ]", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "AssignmentExpression",
- operator: "=",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- },
- right: {
- type: "ArrayExpression",
- elements: [],
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 7
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 7
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 7
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 7
- }
- }
-});
-
-test("x = [ 42 ]", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "AssignmentExpression",
- operator: "=",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- },
- right: {
- type: "ArrayExpression",
- elements: [
- {
- type: "Literal",
- value: 42,
- loc: {
- start: {
- line: 1,
- column: 6
- },
- end: {
- line: 1,
- column: 8
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 10
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 10
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 10
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 10
- }
- }
-});
-
-test("x = [ 42, ]", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "AssignmentExpression",
- operator: "=",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- },
- right: {
- type: "ArrayExpression",
- elements: [
- {
- type: "Literal",
- value: 42,
- loc: {
- start: {
- line: 1,
- column: 6
- },
- end: {
- line: 1,
- column: 8
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 11
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 11
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 11
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 11
- }
- }
-});
-
-test("x = [ ,, 42 ]", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "AssignmentExpression",
- operator: "=",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- },
- right: {
- type: "ArrayExpression",
- elements: [
- null,
- null,
- {
- type: "Literal",
- value: 42,
- loc: {
- start: {
- line: 1,
- column: 9
- },
- end: {
- line: 1,
- column: 11
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 13
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 13
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 13
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 13
- }
- }
-});
-
-test("x = [ 1, 2, 3, ]", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "AssignmentExpression",
- operator: "=",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- },
- right: {
- type: "ArrayExpression",
- elements: [
- {
- type: "Literal",
- value: 1,
- loc: {
- start: {
- line: 1,
- column: 6
- },
- end: {
- line: 1,
- column: 7
- }
- }
- },
- {
- type: "Literal",
- value: 2,
- loc: {
- start: {
- line: 1,
- column: 9
- },
- end: {
- line: 1,
- column: 10
- }
- }
- },
- {
- type: "Literal",
- value: 3,
- loc: {
- start: {
- line: 1,
- column: 12
- },
- end: {
- line: 1,
- column: 13
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 16
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 16
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 16
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 16
- }
- }
-});
-
-test("x = [ 1, 2,, 3, ]", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "AssignmentExpression",
- operator: "=",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- },
- right: {
- type: "ArrayExpression",
- elements: [
- {
- type: "Literal",
- value: 1,
- loc: {
- start: {
- line: 1,
- column: 6
- },
- end: {
- line: 1,
- column: 7
- }
- }
- },
- {
- type: "Literal",
- value: 2,
- loc: {
- start: {
- line: 1,
- column: 9
- },
- end: {
- line: 1,
- column: 10
- }
- }
- },
- null,
- {
- type: "Literal",
- value: 3,
- loc: {
- start: {
- line: 1,
- column: 13
- },
- end: {
- line: 1,
- column: 14
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 17
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 17
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 17
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 17
- }
- }
-});
-
-test("日本語 = []", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "AssignmentExpression",
- operator: "=",
- left: {
- type: "Identifier",
- name: "日本語",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 3
- }
- }
- },
- right: {
- type: "ArrayExpression",
- elements: [],
- loc: {
- start: {
- line: 1,
- column: 6
- },
- end: {
- line: 1,
- column: 8
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 8
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 8
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 8
- }
- }
-});
-
-test("T‿ = []", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "AssignmentExpression",
- operator: "=",
- left: {
- type: "Identifier",
- name: "T‿",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 2
- }
- }
- },
- right: {
- type: "ArrayExpression",
- elements: [],
- loc: {
- start: {
- line: 1,
- column: 5
- },
- end: {
- line: 1,
- column: 7
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 7
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 7
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 7
- }
- }
-});
-
-test("T = []", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "AssignmentExpression",
- operator: "=",
- left: {
- type: "Identifier",
- name: "T",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 2
- }
- }
- },
- right: {
- type: "ArrayExpression",
- elements: [],
- loc: {
- start: {
- line: 1,
- column: 5
- },
- end: {
- line: 1,
- column: 7
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 7
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 7
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 7
- }
- }
-});
-
-test("T = []", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "AssignmentExpression",
- operator: "=",
- left: {
- type: "Identifier",
- name: "T",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 2
- }
- }
- },
- right: {
- type: "ArrayExpression",
- elements: [],
- loc: {
- start: {
- line: 1,
- column: 5
- },
- end: {
- line: 1,
- column: 7
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 7
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 7
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 7
- }
- }
-});
-
-test("ⅣⅡ = []", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "AssignmentExpression",
- operator: "=",
- left: {
- type: "Identifier",
- name: "ⅣⅡ",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 2
- }
- }
- },
- right: {
- type: "ArrayExpression",
- elements: [],
- loc: {
- start: {
- line: 1,
- column: 5
- },
- end: {
- line: 1,
- column: 7
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 7
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 7
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 7
- }
- }
-});
-
-test("ⅣⅡ = []", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "AssignmentExpression",
- operator: "=",
- left: {
- type: "Identifier",
- name: "ⅣⅡ",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 2
- }
- }
- },
- right: {
- type: "ArrayExpression",
- elements: [],
- loc: {
- start: {
- line: 1,
- column: 5
- },
- end: {
- line: 1,
- column: 7
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 7
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 7
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 7
- }
- }
-});
-
-test("x = {}", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "AssignmentExpression",
- operator: "=",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- },
- right: {
- type: "ObjectExpression",
- properties: [],
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 6
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 6
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 6
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 6
- }
- }
-});
-
-test("x = { }", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "AssignmentExpression",
- operator: "=",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- },
- right: {
- type: "ObjectExpression",
- properties: [],
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 7
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 7
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 7
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 7
- }
- }
-});
-
-test("x = { answer: 42 }", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "AssignmentExpression",
- operator: "=",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- },
- right: {
- type: "ObjectExpression",
- properties: [
- {
- type: "Property",
- key: {
- type: "Identifier",
- name: "answer",
- loc: {
- start: {
- line: 1,
- column: 6
- },
- end: {
- line: 1,
- column: 12
- }
- }
- },
- value: {
- type: "Literal",
- value: 42,
- loc: {
- start: {
- line: 1,
- column: 14
- },
- end: {
- line: 1,
- column: 16
- }
- }
- },
- kind: "init"
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 18
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 18
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 18
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 18
- }
- }
-});
-
-test("x = { if: 42 }", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "AssignmentExpression",
- operator: "=",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- },
- right: {
- type: "ObjectExpression",
- properties: [
- {
- type: "Property",
- key: {
- type: "Identifier",
- name: "if",
- loc: {
- start: {
- line: 1,
- column: 6
- },
- end: {
- line: 1,
- column: 8
- }
- }
- },
- value: {
- type: "Literal",
- value: 42,
- loc: {
- start: {
- line: 1,
- column: 10
- },
- end: {
- line: 1,
- column: 12
- }
- }
- },
- kind: "init"
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 14
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 14
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 14
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 14
- }
- }
-});
-
-test("x = { true: 42 }", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "AssignmentExpression",
- operator: "=",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- },
- right: {
- type: "ObjectExpression",
- properties: [
- {
- type: "Property",
- key: {
- type: "Identifier",
- name: "true",
- loc: {
- start: {
- line: 1,
- column: 6
- },
- end: {
- line: 1,
- column: 10
- }
- }
- },
- value: {
- type: "Literal",
- value: 42,
- loc: {
- start: {
- line: 1,
- column: 12
- },
- end: {
- line: 1,
- column: 14
- }
- }
- },
- kind: "init"
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 16
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 16
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 16
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 16
- }
- }
-});
-
-test("x = { false: 42 }", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "AssignmentExpression",
- operator: "=",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- },
- right: {
- type: "ObjectExpression",
- properties: [
- {
- type: "Property",
- key: {
- type: "Identifier",
- name: "false",
- loc: {
- start: {
- line: 1,
- column: 6
- },
- end: {
- line: 1,
- column: 11
- }
- }
- },
- value: {
- type: "Literal",
- value: 42,
- loc: {
- start: {
- line: 1,
- column: 13
- },
- end: {
- line: 1,
- column: 15
- }
- }
- },
- kind: "init"
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 17
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 17
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 17
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 17
- }
- }
-});
-
-test("x = { null: 42 }", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "AssignmentExpression",
- operator: "=",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- },
- right: {
- type: "ObjectExpression",
- properties: [
- {
- type: "Property",
- key: {
- type: "Identifier",
- name: "null",
- loc: {
- start: {
- line: 1,
- column: 6
- },
- end: {
- line: 1,
- column: 10
- }
- }
- },
- value: {
- type: "Literal",
- value: 42,
- loc: {
- start: {
- line: 1,
- column: 12
- },
- end: {
- line: 1,
- column: 14
- }
- }
- },
- kind: "init"
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 16
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 16
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 16
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 16
- }
- }
-});
-
-test("x = { \"answer\": 42 }", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "AssignmentExpression",
- operator: "=",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- },
- right: {
- type: "ObjectExpression",
- properties: [
- {
- type: "Property",
- key: {
- type: "Literal",
- value: "answer",
- loc: {
- start: {
- line: 1,
- column: 6
- },
- end: {
- line: 1,
- column: 14
- }
- }
- },
- value: {
- type: "Literal",
- value: 42,
- loc: {
- start: {
- line: 1,
- column: 16
- },
- end: {
- line: 1,
- column: 18
- }
- }
- },
- kind: "init"
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 20
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 20
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 20
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 20
- }
- }
-});
-
-test("x = { x: 1, x: 2 }", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "AssignmentExpression",
- operator: "=",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- },
- right: {
- type: "ObjectExpression",
- properties: [
- {
- type: "Property",
- key: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 6
- },
- end: {
- line: 1,
- column: 7
- }
- }
- },
- value: {
- type: "Literal",
- value: 1,
- loc: {
- start: {
- line: 1,
- column: 9
- },
- end: {
- line: 1,
- column: 10
- }
- }
- },
- kind: "init"
- },
- {
- type: "Property",
- key: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 12
- },
- end: {
- line: 1,
- column: 13
- }
- }
- },
- value: {
- type: "Literal",
- value: 2,
- loc: {
- start: {
- line: 1,
- column: 15
- },
- end: {
- line: 1,
- column: 16
- }
- }
- },
- kind: "init"
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 18
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 18
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 18
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 18
- }
- }
-});
-
-test("x = { get width() { return m_width } }", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "AssignmentExpression",
- operator: "=",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- },
- right: {
- type: "ObjectExpression",
- properties: [
- {
- type: "Property",
- key: {
- type: "Identifier",
- name: "width",
- loc: {
- start: {
- line: 1,
- column: 10
- },
- end: {
- line: 1,
- column: 15
- }
- }
- },
- kind: "get",
- value: {
- type: "FunctionExpression",
- id: null,
- params: [],
- body: {
- type: "BlockStatement",
- body: [
- {
- type: "ReturnStatement",
- argument: {
- type: "Identifier",
- name: "m_width",
- loc: {
- start: {
- line: 1,
- column: 27
- },
- end: {
- line: 1,
- column: 34
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 20
- },
- end: {
- line: 1,
- column: 34
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 18
- },
- end: {
- line: 1,
- column: 36
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 15
- },
- end: {
- line: 1,
- column: 36
- }
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 38
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 38
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 38
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 38
- }
- }
-});
-
-test("x = { get undef() {} }", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "AssignmentExpression",
- operator: "=",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- },
- right: {
- type: "ObjectExpression",
- properties: [
- {
- type: "Property",
- key: {
- type: "Identifier",
- name: "undef",
- loc: {
- start: {
- line: 1,
- column: 10
- },
- end: {
- line: 1,
- column: 15
- }
- }
- },
- kind: "get",
- value: {
- type: "FunctionExpression",
- id: null,
- params: [],
- body: {
- type: "BlockStatement",
- body: [],
- loc: {
- start: {
- line: 1,
- column: 18
- },
- end: {
- line: 1,
- column: 20
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 15
- },
- end: {
- line: 1,
- column: 20
- }
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 22
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 22
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 22
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 22
- }
- }
-});
-
-test("x = { get if() {} }", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "AssignmentExpression",
- operator: "=",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- },
- right: {
- type: "ObjectExpression",
- properties: [
- {
- type: "Property",
- key: {
- type: "Identifier",
- name: "if",
- loc: {
- start: {
- line: 1,
- column: 10
- },
- end: {
- line: 1,
- column: 12
- }
- }
- },
- kind: "get",
- value: {
- type: "FunctionExpression",
- id: null,
- params: [],
- body: {
- type: "BlockStatement",
- body: [],
- loc: {
- start: {
- line: 1,
- column: 15
- },
- end: {
- line: 1,
- column: 17
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 12
- },
- end: {
- line: 1,
- column: 17
- }
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 19
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 19
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 19
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 19
- }
- }
-});
-
-test("x = { get true() {} }", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "AssignmentExpression",
- operator: "=",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- },
- right: {
- type: "ObjectExpression",
- properties: [
- {
- type: "Property",
- key: {
- type: "Identifier",
- name: "true",
- loc: {
- start: {
- line: 1,
- column: 10
- },
- end: {
- line: 1,
- column: 14
- }
- }
- },
- kind: "get",
- value: {
- type: "FunctionExpression",
- id: null,
- params: [],
- body: {
- type: "BlockStatement",
- body: [],
- loc: {
- start: {
- line: 1,
- column: 17
- },
- end: {
- line: 1,
- column: 19
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 14
- },
- end: {
- line: 1,
- column: 19
- }
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 21
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 21
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 21
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 21
- }
- }
-});
-
-test("x = { get false() {} }", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "AssignmentExpression",
- operator: "=",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- },
- right: {
- type: "ObjectExpression",
- properties: [
- {
- type: "Property",
- key: {
- type: "Identifier",
- name: "false",
- loc: {
- start: {
- line: 1,
- column: 10
- },
- end: {
- line: 1,
- column: 15
- }
- }
- },
- kind: "get",
- value: {
- type: "FunctionExpression",
- id: null,
- params: [],
- body: {
- type: "BlockStatement",
- body: [],
- loc: {
- start: {
- line: 1,
- column: 18
- },
- end: {
- line: 1,
- column: 20
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 15
- },
- end: {
- line: 1,
- column: 20
- }
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 22
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 22
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 22
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 22
- }
- }
-});
-
-test("x = { get null() {} }", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "AssignmentExpression",
- operator: "=",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- },
- right: {
- type: "ObjectExpression",
- properties: [
- {
- type: "Property",
- key: {
- type: "Identifier",
- name: "null",
- loc: {
- start: {
- line: 1,
- column: 10
- },
- end: {
- line: 1,
- column: 14
- }
- }
- },
- kind: "get",
- value: {
- type: "FunctionExpression",
- id: null,
- params: [],
- body: {
- type: "BlockStatement",
- body: [],
- loc: {
- start: {
- line: 1,
- column: 17
- },
- end: {
- line: 1,
- column: 19
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 14
- },
- end: {
- line: 1,
- column: 19
- }
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 21
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 21
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 21
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 21
- }
- }
-});
-
-test("x = { get \"undef\"() {} }", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "AssignmentExpression",
- operator: "=",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- },
- right: {
- type: "ObjectExpression",
- properties: [
- {
- type: "Property",
- key: {
- type: "Literal",
- value: "undef",
- loc: {
- start: {
- line: 1,
- column: 10
- },
- end: {
- line: 1,
- column: 17
- }
- }
- },
- kind: "get",
- value: {
- type: "FunctionExpression",
- id: null,
- params: [],
- body: {
- type: "BlockStatement",
- body: [],
- loc: {
- start: {
- line: 1,
- column: 20
- },
- end: {
- line: 1,
- column: 22
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 17
- },
- end: {
- line: 1,
- column: 22
- }
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 24
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 24
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 24
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 24
- }
- }
-});
-
-test("x = { get 10() {} }", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "AssignmentExpression",
- operator: "=",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- },
- right: {
- type: "ObjectExpression",
- properties: [
- {
- type: "Property",
- key: {
- type: "Literal",
- value: 10,
- loc: {
- start: {
- line: 1,
- column: 10
- },
- end: {
- line: 1,
- column: 12
- }
- }
- },
- kind: "get",
- value: {
- type: "FunctionExpression",
- id: null,
- params: [],
- body: {
- type: "BlockStatement",
- body: [],
- loc: {
- start: {
- line: 1,
- column: 15
- },
- end: {
- line: 1,
- column: 17
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 12
- },
- end: {
- line: 1,
- column: 17
- }
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 19
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 19
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 19
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 19
- }
- }
-});
-
-test("x = { set width(w) { m_width = w } }", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "AssignmentExpression",
- operator: "=",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- },
- right: {
- type: "ObjectExpression",
- properties: [
- {
- type: "Property",
- key: {
- type: "Identifier",
- name: "width",
- loc: {
- start: {
- line: 1,
- column: 10
- },
- end: {
- line: 1,
- column: 15
- }
- }
- },
- kind: "set",
- value: {
- type: "FunctionExpression",
- id: null,
- params: [
- {
- type: "Identifier",
- name: "w",
- loc: {
- start: {
- line: 1,
- column: 16
- },
- end: {
- line: 1,
- column: 17
- }
- }
- }
- ],
- body: {
- type: "BlockStatement",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "AssignmentExpression",
- operator: "=",
- left: {
- type: "Identifier",
- name: "m_width",
- loc: {
- start: {
- line: 1,
- column: 21
- },
- end: {
- line: 1,
- column: 28
- }
- }
- },
- right: {
- type: "Identifier",
- name: "w",
- loc: {
- start: {
- line: 1,
- column: 31
- },
- end: {
- line: 1,
- column: 32
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 21
- },
- end: {
- line: 1,
- column: 32
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 21
- },
- end: {
- line: 1,
- column: 32
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 19
- },
- end: {
- line: 1,
- column: 34
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 15
- },
- end: {
- line: 1,
- column: 34
- }
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 36
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 36
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 36
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 36
- }
- }
-});
-
-test("x = { set if(w) { m_if = w } }", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "AssignmentExpression",
- operator: "=",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- },
- right: {
- type: "ObjectExpression",
- properties: [
- {
- type: "Property",
- key: {
- type: "Identifier",
- name: "if",
- loc: {
- start: {
- line: 1,
- column: 10
- },
- end: {
- line: 1,
- column: 12
- }
- }
- },
- kind: "set",
- value: {
- type: "FunctionExpression",
- id: null,
- params: [
- {
- type: "Identifier",
- name: "w",
- loc: {
- start: {
- line: 1,
- column: 13
- },
- end: {
- line: 1,
- column: 14
- }
- }
- }
- ],
- body: {
- type: "BlockStatement",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "AssignmentExpression",
- operator: "=",
- left: {
- type: "Identifier",
- name: "m_if",
- loc: {
- start: {
- line: 1,
- column: 18
- },
- end: {
- line: 1,
- column: 22
- }
- }
- },
- right: {
- type: "Identifier",
- name: "w",
- loc: {
- start: {
- line: 1,
- column: 25
- },
- end: {
- line: 1,
- column: 26
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 18
- },
- end: {
- line: 1,
- column: 26
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 18
- },
- end: {
- line: 1,
- column: 26
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 16
- },
- end: {
- line: 1,
- column: 28
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 12
- },
- end: {
- line: 1,
- column: 28
- }
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 30
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 30
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 30
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 30
- }
- }
-});
-
-test("x = { set true(w) { m_true = w } }", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "AssignmentExpression",
- operator: "=",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- },
- right: {
- type: "ObjectExpression",
- properties: [
- {
- type: "Property",
- key: {
- type: "Identifier",
- name: "true",
- loc: {
- start: {
- line: 1,
- column: 10
- },
- end: {
- line: 1,
- column: 14
- }
- }
- },
- kind: "set",
- value: {
- type: "FunctionExpression",
- id: null,
- params: [
- {
- type: "Identifier",
- name: "w",
- loc: {
- start: {
- line: 1,
- column: 15
- },
- end: {
- line: 1,
- column: 16
- }
- }
- }
- ],
- body: {
- type: "BlockStatement",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "AssignmentExpression",
- operator: "=",
- left: {
- type: "Identifier",
- name: "m_true",
- loc: {
- start: {
- line: 1,
- column: 20
- },
- end: {
- line: 1,
- column: 26
- }
- }
- },
- right: {
- type: "Identifier",
- name: "w",
- loc: {
- start: {
- line: 1,
- column: 29
- },
- end: {
- line: 1,
- column: 30
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 20
- },
- end: {
- line: 1,
- column: 30
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 20
- },
- end: {
- line: 1,
- column: 30
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 18
- },
- end: {
- line: 1,
- column: 32
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 14
- },
- end: {
- line: 1,
- column: 32
- }
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 34
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 34
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 34
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 34
- }
- }
-});
-
-test("x = { set false(w) { m_false = w } }", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "AssignmentExpression",
- operator: "=",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- },
- right: {
- type: "ObjectExpression",
- properties: [
- {
- type: "Property",
- key: {
- type: "Identifier",
- name: "false",
- loc: {
- start: {
- line: 1,
- column: 10
- },
- end: {
- line: 1,
- column: 15
- }
- }
- },
- kind: "set",
- value: {
- type: "FunctionExpression",
- id: null,
- params: [
- {
- type: "Identifier",
- name: "w",
- loc: {
- start: {
- line: 1,
- column: 16
- },
- end: {
- line: 1,
- column: 17
- }
- }
- }
- ],
- body: {
- type: "BlockStatement",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "AssignmentExpression",
- operator: "=",
- left: {
- type: "Identifier",
- name: "m_false",
- loc: {
- start: {
- line: 1,
- column: 21
- },
- end: {
- line: 1,
- column: 28
- }
- }
- },
- right: {
- type: "Identifier",
- name: "w",
- loc: {
- start: {
- line: 1,
- column: 31
- },
- end: {
- line: 1,
- column: 32
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 21
- },
- end: {
- line: 1,
- column: 32
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 21
- },
- end: {
- line: 1,
- column: 32
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 19
- },
- end: {
- line: 1,
- column: 34
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 15
- },
- end: {
- line: 1,
- column: 34
- }
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 36
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 36
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 36
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 36
- }
- }
-});
-
-test("x = { set null(w) { m_null = w } }", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "AssignmentExpression",
- operator: "=",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- },
- right: {
- type: "ObjectExpression",
- properties: [
- {
- type: "Property",
- key: {
- type: "Identifier",
- name: "null",
- loc: {
- start: {
- line: 1,
- column: 10
- },
- end: {
- line: 1,
- column: 14
- }
- }
- },
- kind: "set",
- value: {
- type: "FunctionExpression",
- id: null,
- params: [
- {
- type: "Identifier",
- name: "w",
- loc: {
- start: {
- line: 1,
- column: 15
- },
- end: {
- line: 1,
- column: 16
- }
- }
- }
- ],
- body: {
- type: "BlockStatement",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "AssignmentExpression",
- operator: "=",
- left: {
- type: "Identifier",
- name: "m_null",
- loc: {
- start: {
- line: 1,
- column: 20
- },
- end: {
- line: 1,
- column: 26
- }
- }
- },
- right: {
- type: "Identifier",
- name: "w",
- loc: {
- start: {
- line: 1,
- column: 29
- },
- end: {
- line: 1,
- column: 30
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 20
- },
- end: {
- line: 1,
- column: 30
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 20
- },
- end: {
- line: 1,
- column: 30
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 18
- },
- end: {
- line: 1,
- column: 32
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 14
- },
- end: {
- line: 1,
- column: 32
- }
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 34
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 34
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 34
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 34
- }
- }
-});
-
-test("x = { set \"null\"(w) { m_null = w } }", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "AssignmentExpression",
- operator: "=",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- },
- right: {
- type: "ObjectExpression",
- properties: [
- {
- type: "Property",
- key: {
- type: "Literal",
- value: "null",
- loc: {
- start: {
- line: 1,
- column: 10
- },
- end: {
- line: 1,
- column: 16
- }
- }
- },
- kind: "set",
- value: {
- type: "FunctionExpression",
- id: null,
- params: [
- {
- type: "Identifier",
- name: "w",
- loc: {
- start: {
- line: 1,
- column: 17
- },
- end: {
- line: 1,
- column: 18
- }
- }
- }
- ],
- body: {
- type: "BlockStatement",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "AssignmentExpression",
- operator: "=",
- left: {
- type: "Identifier",
- name: "m_null",
- loc: {
- start: {
- line: 1,
- column: 22
- },
- end: {
- line: 1,
- column: 28
- }
- }
- },
- right: {
- type: "Identifier",
- name: "w",
- loc: {
- start: {
- line: 1,
- column: 31
- },
- end: {
- line: 1,
- column: 32
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 22
- },
- end: {
- line: 1,
- column: 32
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 22
- },
- end: {
- line: 1,
- column: 32
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 20
- },
- end: {
- line: 1,
- column: 34
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 16
- },
- end: {
- line: 1,
- column: 34
- }
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 36
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 36
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 36
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 36
- }
- }
-});
-
-test("x = { set 10(w) { m_null = w } }", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "AssignmentExpression",
- operator: "=",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- },
- right: {
- type: "ObjectExpression",
- properties: [
- {
- type: "Property",
- key: {
- type: "Literal",
- value: 10,
- loc: {
- start: {
- line: 1,
- column: 10
- },
- end: {
- line: 1,
- column: 12
- }
- }
- },
- kind: "set",
- value: {
- type: "FunctionExpression",
- id: null,
- params: [
- {
- type: "Identifier",
- name: "w",
- loc: {
- start: {
- line: 1,
- column: 13
- },
- end: {
- line: 1,
- column: 14
- }
- }
- }
- ],
- body: {
- type: "BlockStatement",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "AssignmentExpression",
- operator: "=",
- left: {
- type: "Identifier",
- name: "m_null",
- loc: {
- start: {
- line: 1,
- column: 18
- },
- end: {
- line: 1,
- column: 24
- }
- }
- },
- right: {
- type: "Identifier",
- name: "w",
- loc: {
- start: {
- line: 1,
- column: 27
- },
- end: {
- line: 1,
- column: 28
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 18
- },
- end: {
- line: 1,
- column: 28
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 18
- },
- end: {
- line: 1,
- column: 28
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 16
- },
- end: {
- line: 1,
- column: 30
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 12
- },
- end: {
- line: 1,
- column: 30
- }
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 32
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 32
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 32
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 32
- }
- }
-});
-
-test("x = { get: 42 }", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "AssignmentExpression",
- operator: "=",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- },
- right: {
- type: "ObjectExpression",
- properties: [
- {
- type: "Property",
- key: {
- type: "Identifier",
- name: "get",
- loc: {
- start: {
- line: 1,
- column: 6
- },
- end: {
- line: 1,
- column: 9
- }
- }
- },
- value: {
- type: "Literal",
- value: 42,
- loc: {
- start: {
- line: 1,
- column: 11
- },
- end: {
- line: 1,
- column: 13
- }
- }
- },
- kind: "init"
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 15
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 15
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 15
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 15
- }
- }
-});
-
-test("x = { set: 43 }", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "AssignmentExpression",
- operator: "=",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- },
- right: {
- type: "ObjectExpression",
- properties: [
- {
- type: "Property",
- key: {
- type: "Identifier",
- name: "set",
- loc: {
- start: {
- line: 1,
- column: 6
- },
- end: {
- line: 1,
- column: 9
- }
- }
- },
- value: {
- type: "Literal",
- value: 43,
- loc: {
- start: {
- line: 1,
- column: 11
- },
- end: {
- line: 1,
- column: 13
- }
- }
- },
- kind: "init"
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 15
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 15
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 15
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 15
- }
- }
-});
-
-test("/* block comment */ 42", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "Literal",
- value: 42,
- loc: {
- start: {
- line: 1,
- column: 20
- },
- end: {
- line: 1,
- column: 22
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 20
- },
- end: {
- line: 1,
- column: 22
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 22
- }
- }
-});
-
-test("42 /*The*/ /*Answer*/", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "Literal",
- value: 42,
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 2
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 2
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 21
- }
- }
-});
-
-test("42 /*the*/ /*answer*/", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "Literal",
- value: 42,
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 2
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 2
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 21
- }
- }
-});
-
-test("/* multiline\ncomment\nshould\nbe\nignored */ 42", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "Literal",
- value: 42,
- loc: {
- start: {
- line: 5,
- column: 11
- },
- end: {
- line: 5,
- column: 13
- }
- }
- },
- loc: {
- start: {
- line: 5,
- column: 11
- },
- end: {
- line: 5,
- column: 13
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 5,
- column: 13
- }
- }
-});
-
-test("/*a\r\nb*/ 42", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "Literal",
- value: 42,
- loc: {
- start: {
- line: 2,
- column: 4
- },
- end: {
- line: 2,
- column: 6
- }
- }
- },
- loc: {
- start: {
- line: 2,
- column: 4
- },
- end: {
- line: 2,
- column: 6
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 2,
- column: 6
- }
- }
-});
-
-test("/*a\rb*/ 42", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "Literal",
- value: 42,
- loc: {
- start: {
- line: 2,
- column: 4
- },
- end: {
- line: 2,
- column: 6
- }
- }
- },
- loc: {
- start: {
- line: 2,
- column: 4
- },
- end: {
- line: 2,
- column: 6
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 2,
- column: 6
- }
- }
-});
-
-test("/*a\nb*/ 42", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "Literal",
- value: 42,
- loc: {
- start: {
- line: 2,
- column: 4
- },
- end: {
- line: 2,
- column: 6
- }
- }
- },
- loc: {
- start: {
- line: 2,
- column: 4
- },
- end: {
- line: 2,
- column: 6
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 2,
- column: 6
- }
- }
-});
-
-test("/*a\nc*/ 42", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "Literal",
- value: 42,
- loc: {
- start: {
- line: 2,
- column: 4
- },
- end: {
- line: 2,
- column: 6
- }
- }
- },
- loc: {
- start: {
- line: 2,
- column: 4
- },
- end: {
- line: 2,
- column: 6
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 2,
- column: 6
- }
- }
-});
-
-test("// line comment\n42", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "Literal",
- value: 42,
- loc: {
- start: {
- line: 2,
- column: 0
- },
- end: {
- line: 2,
- column: 2
- }
- }
- },
- loc: {
- start: {
- line: 2,
- column: 0
- },
- end: {
- line: 2,
- column: 2
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 2,
- column: 2
- }
- }
-});
-
-test("42 // line comment", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "Literal",
- value: 42,
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 2
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 2
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 18
- }
- }
-});
-
-test("// Hello, world!\n42", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "Literal",
- value: 42,
- loc: {
- start: {
- line: 2,
- column: 0
- },
- end: {
- line: 2,
- column: 2
- }
- }
- },
- loc: {
- start: {
- line: 2,
- column: 0
- },
- end: {
- line: 2,
- column: 2
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 2,
- column: 2
- }
- }
-});
-
-test("// Hello, world!\n", {
- type: "Program",
- body: [],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 2,
- column: 0
- }
- }
-});
-
-test("// Hallo, world!\n", {
- type: "Program",
- body: [],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 2,
- column: 0
- }
- }
-});
-
-test("//\n42", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "Literal",
- value: 42,
- loc: {
- start: {
- line: 2,
- column: 0
- },
- end: {
- line: 2,
- column: 2
- }
- }
- },
- loc: {
- start: {
- line: 2,
- column: 0
- },
- end: {
- line: 2,
- column: 2
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 2,
- column: 2
- }
- }
-});
-
-test("//", {
- type: "Program",
- body: [],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 2
- }
- }
-});
-
-test("// ", {
- type: "Program",
- body: [],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 3
- }
- }
-});
-
-test("/**/42", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "Literal",
- value: 42,
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 6
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 6
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 6
- }
- }
-});
-
-test("// Hello, world!\n\n// Another hello\n42", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "Literal",
- value: 42,
- loc: {
- start: {
- line: 4,
- column: 0
- },
- end: {
- line: 4,
- column: 2
- }
- }
- },
- loc: {
- start: {
- line: 4,
- column: 0
- },
- end: {
- line: 4,
- column: 2
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 4,
- column: 2
- }
- }
-});
-
-test("if (x) { // Some comment\ndoThat(); }", {
- type: "Program",
- body: [
- {
- type: "IfStatement",
- test: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 5
- }
- }
- },
- consequent: {
- type: "BlockStatement",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "CallExpression",
- callee: {
- type: "Identifier",
- name: "doThat",
- loc: {
- start: {
- line: 2,
- column: 0
- },
- end: {
- line: 2,
- column: 6
- }
- }
- },
- arguments: [],
- loc: {
- start: {
- line: 2,
- column: 0
- },
- end: {
- line: 2,
- column: 8
- }
- }
- },
- loc: {
- start: {
- line: 2,
- column: 0
- },
- end: {
- line: 2,
- column: 9
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 7
- },
- end: {
- line: 2,
- column: 11
- }
- }
- },
- alternate: null,
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 2,
- column: 11
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 2,
- column: 11
- }
- }
-});
-
-test("switch (answer) { case 42: /* perfect */ bingo() }", {
- type: "Program",
- body: [
- {
- type: "SwitchStatement",
- discriminant: {
- type: "Identifier",
- name: "answer",
- loc: {
- start: {
- line: 1,
- column: 8
- },
- end: {
- line: 1,
- column: 14
- }
- }
- },
- cases: [
- {
- type: "SwitchCase",
- consequent: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "CallExpression",
- callee: {
- type: "Identifier",
- name: "bingo",
- loc: {
- start: {
- line: 1,
- column: 41
- },
- end: {
- line: 1,
- column: 46
- }
- }
- },
- arguments: [],
- loc: {
- start: {
- line: 1,
- column: 41
- },
- end: {
- line: 1,
- column: 48
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 41
- },
- end: {
- line: 1,
- column: 48
- }
- }
- }
- ],
- test: {
- type: "Literal",
- value: 42,
- loc: {
- start: {
- line: 1,
- column: 23
- },
- end: {
- line: 1,
- column: 25
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 18
- },
- end: {
- line: 1,
- column: 48
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 50
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 50
- }
- }
-});
-
-test("0", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "Literal",
- value: 0,
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
-});
-
-test("3", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "Literal",
- value: 3,
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
-});
-
-test("5", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "Literal",
- value: 5,
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
-});
-
-test("42", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "Literal",
- value: 42,
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 2
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 2
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 2
- }
- }
-});
-
-test(".14", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "Literal",
- value: 0.14,
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 3
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 3
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 3
- }
- }
-});
-
-test("3.14159", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "Literal",
- value: 3.14159,
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 7
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 7
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 7
- }
- }
-});
-
-test("6.02214179e+23", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "Literal",
- value: 6.02214179e+23,
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 14
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 14
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 14
- }
- }
-});
-
-test("1.492417830e-10", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "Literal",
- value: 1.49241783e-10,
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 15
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 15
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 15
- }
- }
-});
-
-test("0x0", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "Literal",
- value: 0,
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 3
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 3
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 3
- }
- }
-});
-
-test("0e+100", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "Literal",
- value: 0,
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 6
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 6
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 6
- }
- }
-});
-
-test("0xabc", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "Literal",
- value: 2748,
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 5
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 5
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 5
- }
- }
-});
-
-test("0xdef", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "Literal",
- value: 3567,
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 5
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 5
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 5
- }
- }
-});
-
-test("0X1A", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "Literal",
- value: 26,
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 4
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 4
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 4
- }
- }
-});
-
-test("0x10", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "Literal",
- value: 16,
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 4
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 4
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 4
- }
- }
-});
-
-test("0x100", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "Literal",
- value: 256,
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 5
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 5
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 5
- }
- }
-});
-
-test("0X04", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "Literal",
- value: 4,
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 4
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 4
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 4
- }
- }
-});
-
-test("02", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "Literal",
- value: 2,
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 2
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 2
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 2
- }
- }
-});
-
-test("012", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "Literal",
- value: 10,
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 3
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 3
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 3
- }
- }
-});
-
-test("0012", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "Literal",
- value: 10,
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 4
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 4
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 4
- }
- }
-});
-
-test("\"Hello\"", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "Literal",
- value: "Hello",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 7
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 7
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 7
- }
- }
-});
-
-test("\"\\n\\r\\t\\v\\b\\f\\\\\\'\\\"\\0\"", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "Literal",
- value: "\n\r\t\u000b\b\f\\'\"\u0000",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 22
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 22
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 22
- }
- }
-});
-
-test("\"\\u0061\"", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "Literal",
- value: "a",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 8
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 8
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 8
- }
- }
-});
-
-test("\"\\x61\"", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "Literal",
- value: "a",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 6
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 6
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 6
- }
- }
-});
-
-test("\"Hello\\nworld\"", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "Literal",
- value: "Hello\nworld",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 14
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 14
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 14
- }
- }
-});
-
-test("\"Hello\\\nworld\"", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "Literal",
- value: "Helloworld",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 2,
- column: 6
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 2,
- column: 6
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 2,
- column: 6
- }
- }
-});
-
-test("\"Hello\\02World\"", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "Literal",
- value: "Hello\u0002World",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 15
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 15
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 15
- }
- }
-});
-
-test("\"Hello\\012World\"", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "Literal",
- value: "Hello\nWorld",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 16
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 16
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 16
- }
- }
-});
-
-test("\"Hello\\122World\"", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "Literal",
- value: "HelloRWorld",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 16
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 16
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 16
- }
- }
-});
-
-test("\"Hello\\0122World\"", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "Literal",
- value: "Hello\n2World",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 17
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 17
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 17
- }
- }
-});
-
-test("\"Hello\\312World\"", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "Literal",
- value: "HelloÊWorld",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 16
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 16
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 16
- }
- }
-});
-
-test("\"Hello\\412World\"", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "Literal",
- value: "Hello!2World",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 16
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 16
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 16
- }
- }
-});
-
-test("\"Hello\\812World\"", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "Literal",
- value: "Hello812World",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 16
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 16
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 16
- }
- }
-});
-
-test("\"Hello\\712World\"", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "Literal",
- value: "Hello92World",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 16
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 16
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 16
- }
- }
-});
-
-test("\"Hello\\0World\"", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "Literal",
- value: "Hello\u0000World",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 14
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 14
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 14
- }
- }
-});
-
-test("\"Hello\\\r\nworld\"", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "Literal",
- value: "Helloworld",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 2,
- column: 6
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 2,
- column: 6
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 2,
- column: 6
- }
- }
-});
-
-test("\"Hello\\1World\"", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "Literal",
- value: "Hello\u0001World",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 14
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 14
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 14
- }
- }
-});
-
-test("var x = /[a-z]/i", {
- type: "Program",
- body: [
- {
- type: "VariableDeclaration",
- declarations: [
- {
- type: "VariableDeclarator",
- id: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 5
- }
- }
- },
- init: {
- type: "Literal",
- value: /[a-z]/i,
- loc: {
- start: {
- line: 1,
- column: 8
- },
- end: {
- line: 1,
- column: 16
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 16
- }
- }
- }
- ],
- kind: "var",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 16
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 16
- }
- }
-});
-
-test("var x = /[x-z]/i", {
- type: "Program",
- body: [
- {
- type: "VariableDeclaration",
- declarations: [
- {
- type: "VariableDeclarator",
- id: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 5
- }
- }
- },
- init: {
- type: "Literal",
- value: /[x-z]/i,
- loc: {
- start: {
- line: 1,
- column: 8
- },
- end: {
- line: 1,
- column: 16
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 16
- }
- }
- }
- ],
- kind: "var",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 16
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 16
- }
- }
-});
-
-test("var x = /[a-c]/i", {
- type: "Program",
- body: [
- {
- type: "VariableDeclaration",
- declarations: [
- {
- type: "VariableDeclarator",
- id: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 5
- }
- }
- },
- init: {
- type: "Literal",
- value: /[a-c]/i,
- loc: {
- start: {
- line: 1,
- column: 8
- },
- end: {
- line: 1,
- column: 16
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 16
- }
- }
- }
- ],
- kind: "var",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 16
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 16
- }
- }
-});
-
-test("var x = /[P QR]/i", {
- type: "Program",
- body: [
- {
- type: "VariableDeclaration",
- declarations: [
- {
- type: "VariableDeclarator",
- id: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 5
- }
- }
- },
- init: {
- type: "Literal",
- value: /[P QR]/i,
- loc: {
- start: {
- line: 1,
- column: 8
- },
- end: {
- line: 1,
- column: 17
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 17
- }
- }
- }
- ],
- kind: "var",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 17
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 17
- }
- }
-});
-
-test("var x = /foo\\/bar/", {
- type: "Program",
- body: [
- {
- type: "VariableDeclaration",
- declarations: [
- {
- type: "VariableDeclarator",
- id: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 5
- }
- }
- },
- init: {
- type: "Literal",
- value: /foo\/bar/,
- loc: {
- start: {
- line: 1,
- column: 8
- },
- end: {
- line: 1,
- column: 18
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 18
- }
- }
- }
- ],
- kind: "var",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 18
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 18
- }
- }
-});
-
-test("var x = /=([^=\\s])+/g", {
- type: "Program",
- body: [
- {
- type: "VariableDeclaration",
- declarations: [
- {
- type: "VariableDeclarator",
- id: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 5
- }
- }
- },
- init: {
- type: "Literal",
- value: /=([^=\s])+/g,
- loc: {
- start: {
- line: 1,
- column: 8
- },
- end: {
- line: 1,
- column: 21
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 21
- }
- }
- }
- ],
- kind: "var",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 21
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 21
- }
- }
-});
-
-test("var x = /[P QR]/\\u0067", {
- type: "Program",
- body: [
- {
- type: "VariableDeclaration",
- declarations: [
- {
- type: "VariableDeclarator",
- id: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 5
- }
- }
- },
- init: {
- type: "Literal",
- value: /[P QR]/g,
- loc: {
- start: {
- line: 1,
- column: 8
- },
- end: {
- line: 1,
- column: 22
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 22
- }
- }
- }
- ],
- kind: "var",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 22
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 22
- }
- }
-});
-
-test("new Button", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "NewExpression",
- callee: {
- type: "Identifier",
- name: "Button",
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 10
- }
- }
- },
- arguments: [],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 10
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 10
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 10
- }
- }
-});
-
-test("new Button()", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "NewExpression",
- callee: {
- type: "Identifier",
- name: "Button",
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 10
- }
- }
- },
- arguments: [],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 12
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 12
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 12
- }
- }
-});
-
-test("new new foo", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "NewExpression",
- callee: {
- type: "NewExpression",
- callee: {
- type: "Identifier",
- name: "foo",
- loc: {
- start: {
- line: 1,
- column: 8
- },
- end: {
- line: 1,
- column: 11
- }
- }
- },
- arguments: [],
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 11
- }
- }
- },
- arguments: [],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 11
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 11
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 11
- }
- }
-});
-
-test("new new foo()", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "NewExpression",
- callee: {
- type: "NewExpression",
- callee: {
- type: "Identifier",
- name: "foo",
- loc: {
- start: {
- line: 1,
- column: 8
- },
- end: {
- line: 1,
- column: 11
- }
- }
- },
- arguments: [],
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 13
- }
- }
- },
- arguments: [],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 13
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 13
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 13
- }
- }
-});
-
-test("new foo().bar()", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "CallExpression",
- callee: {
- type: "MemberExpression",
- object: {
- type: "NewExpression",
- callee: {
- type: "Identifier",
- name: "foo",
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 7
- }
- }
- },
- arguments: [],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 9
- }
- }
- },
- property: {
- type: "Identifier",
- name: "bar",
- loc: {
- start: {
- line: 1,
- column: 10
- },
- end: {
- line: 1,
- column: 13
- }
- }
- },
- computed: false,
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 13
- }
- }
- },
- arguments: [],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 15
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 15
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 15
- }
- }
-});
-
-test("new foo[bar]", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "NewExpression",
- callee: {
- type: "MemberExpression",
- object: {
- type: "Identifier",
- name: "foo",
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 7
- }
- }
- },
- property: {
- type: "Identifier",
- name: "bar",
- loc: {
- start: {
- line: 1,
- column: 8
- },
- end: {
- line: 1,
- column: 11
- }
- }
- },
- computed: true,
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 12
- }
- }
- },
- arguments: [],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 12
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 12
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 12
- }
- }
-});
-
-test("new foo.bar()", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "NewExpression",
- callee: {
- type: "MemberExpression",
- object: {
- type: "Identifier",
- name: "foo",
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 7
- }
- }
- },
- property: {
- type: "Identifier",
- name: "bar",
- loc: {
- start: {
- line: 1,
- column: 8
- },
- end: {
- line: 1,
- column: 11
- }
- }
- },
- computed: false,
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 11
- }
- }
- },
- arguments: [],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 13
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 13
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 13
- }
- }
-});
-
-test("( new foo).bar()", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "CallExpression",
- callee: {
- type: "MemberExpression",
- object: {
- type: "NewExpression",
- callee: {
- type: "Identifier",
- name: "foo",
- loc: {
- start: {
- line: 1,
- column: 6
- },
- end: {
- line: 1,
- column: 9
- }
- }
- },
- arguments: [],
- loc: {
- start: {
- line: 1,
- column: 2
- },
- end: {
- line: 1,
- column: 9
- }
- }
- },
- property: {
- type: "Identifier",
- name: "bar",
- loc: {
- start: {
- line: 1,
- column: 11
- },
- end: {
- line: 1,
- column: 14
- }
- }
- },
- computed: false,
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 14
- }
- }
- },
- arguments: [],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 16
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 16
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 16
- }
- }
-});
-
-test("foo(bar, baz)", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "CallExpression",
- callee: {
- type: "Identifier",
- name: "foo",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 3
- }
- }
- },
- arguments: [
- {
- type: "Identifier",
- name: "bar",
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 7
- }
- }
- },
- {
- type: "Identifier",
- name: "baz",
- loc: {
- start: {
- line: 1,
- column: 9
- },
- end: {
- line: 1,
- column: 12
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 13
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 13
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 13
- }
- }
-});
-
-test("( foo )()", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "CallExpression",
- callee: {
- type: "Identifier",
- name: "foo",
- loc: {
- start: {
- line: 1,
- column: 5
- },
- end: {
- line: 1,
- column: 8
- }
- }
- },
- arguments: [],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 13
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 13
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 13
- }
- }
-});
-
-test("universe.milkyway", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "MemberExpression",
- object: {
- type: "Identifier",
- name: "universe",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 8
- }
- }
- },
- property: {
- type: "Identifier",
- name: "milkyway",
- loc: {
- start: {
- line: 1,
- column: 9
- },
- end: {
- line: 1,
- column: 17
- }
- }
- },
- computed: false,
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 17
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 17
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 17
- }
- }
-});
-
-test("universe.milkyway.solarsystem", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "MemberExpression",
- object: {
- type: "MemberExpression",
- object: {
- type: "Identifier",
- name: "universe",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 8
- }
- }
- },
- property: {
- type: "Identifier",
- name: "milkyway",
- loc: {
- start: {
- line: 1,
- column: 9
- },
- end: {
- line: 1,
- column: 17
- }
- }
- },
- computed: false,
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 17
- }
- }
- },
- property: {
- type: "Identifier",
- name: "solarsystem",
- loc: {
- start: {
- line: 1,
- column: 18
- },
- end: {
- line: 1,
- column: 29
- }
- }
- },
- computed: false,
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 29
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 29
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 29
- }
- }
-});
-
-test("universe.milkyway.solarsystem.Earth", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "MemberExpression",
- object: {
- type: "MemberExpression",
- object: {
- type: "MemberExpression",
- object: {
- type: "Identifier",
- name: "universe",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 8
- }
- }
- },
- property: {
- type: "Identifier",
- name: "milkyway",
- loc: {
- start: {
- line: 1,
- column: 9
- },
- end: {
- line: 1,
- column: 17
- }
- }
- },
- computed: false,
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 17
- }
- }
- },
- property: {
- type: "Identifier",
- name: "solarsystem",
- loc: {
- start: {
- line: 1,
- column: 18
- },
- end: {
- line: 1,
- column: 29
- }
- }
- },
- computed: false,
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 29
- }
- }
- },
- property: {
- type: "Identifier",
- name: "Earth",
- loc: {
- start: {
- line: 1,
- column: 30
- },
- end: {
- line: 1,
- column: 35
- }
- }
- },
- computed: false,
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 35
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 35
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 35
- }
- }
-});
-
-test("universe[galaxyName, otherUselessName]", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "MemberExpression",
- object: {
- type: "Identifier",
- name: "universe",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 8
- }
- }
- },
- property: {
- type: "SequenceExpression",
- expressions: [
- {
- type: "Identifier",
- name: "galaxyName",
- loc: {
- start: {
- line: 1,
- column: 9
- },
- end: {
- line: 1,
- column: 19
- }
- }
- },
- {
- type: "Identifier",
- name: "otherUselessName",
- loc: {
- start: {
- line: 1,
- column: 21
- },
- end: {
- line: 1,
- column: 37
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 9
- },
- end: {
- line: 1,
- column: 37
- }
- }
- },
- computed: true,
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 38
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 38
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 38
- }
- }
-});
-
-test("universe[galaxyName]", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "MemberExpression",
- object: {
- type: "Identifier",
- name: "universe",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 8
- }
- }
- },
- property: {
- type: "Identifier",
- name: "galaxyName",
- loc: {
- start: {
- line: 1,
- column: 9
- },
- end: {
- line: 1,
- column: 19
- }
- }
- },
- computed: true,
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 20
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 20
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 20
- }
- }
-});
-
-test("universe[42].galaxies", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "MemberExpression",
- object: {
- type: "MemberExpression",
- object: {
- type: "Identifier",
- name: "universe",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 8
- }
- }
- },
- property: {
- type: "Literal",
- value: 42,
- loc: {
- start: {
- line: 1,
- column: 9
- },
- end: {
- line: 1,
- column: 11
- }
- }
- },
- computed: true,
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 12
- }
- }
- },
- property: {
- type: "Identifier",
- name: "galaxies",
- loc: {
- start: {
- line: 1,
- column: 13
- },
- end: {
- line: 1,
- column: 21
- }
- }
- },
- computed: false,
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 21
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 21
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 21
- }
- }
-});
-
-test("universe(42).galaxies", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "MemberExpression",
- object: {
- type: "CallExpression",
- callee: {
- type: "Identifier",
- name: "universe",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 8
- }
- }
- },
- arguments: [
- {
- type: "Literal",
- value: 42,
- loc: {
- start: {
- line: 1,
- column: 9
- },
- end: {
- line: 1,
- column: 11
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 12
- }
- }
- },
- property: {
- type: "Identifier",
- name: "galaxies",
- loc: {
- start: {
- line: 1,
- column: 13
- },
- end: {
- line: 1,
- column: 21
- }
- }
- },
- computed: false,
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 21
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 21
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 21
- }
- }
-});
-
-test("universe(42).galaxies(14, 3, 77).milkyway", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "MemberExpression",
- object: {
- type: "CallExpression",
- callee: {
- type: "MemberExpression",
- object: {
- type: "CallExpression",
- callee: {
- type: "Identifier",
- name: "universe",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 8
- }
- }
- },
- arguments: [
- {
- type: "Literal",
- value: 42,
- loc: {
- start: {
- line: 1,
- column: 9
- },
- end: {
- line: 1,
- column: 11
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 12
- }
- }
- },
- property: {
- type: "Identifier",
- name: "galaxies",
- loc: {
- start: {
- line: 1,
- column: 13
- },
- end: {
- line: 1,
- column: 21
- }
- }
- },
- computed: false,
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 21
- }
- }
- },
- arguments: [
- {
- type: "Literal",
- value: 14,
- loc: {
- start: {
- line: 1,
- column: 22
- },
- end: {
- line: 1,
- column: 24
- }
- }
- },
- {
- type: "Literal",
- value: 3,
- loc: {
- start: {
- line: 1,
- column: 26
- },
- end: {
- line: 1,
- column: 27
- }
- }
- },
- {
- type: "Literal",
- value: 77,
- loc: {
- start: {
- line: 1,
- column: 29
- },
- end: {
- line: 1,
- column: 31
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 32
- }
- }
- },
- property: {
- type: "Identifier",
- name: "milkyway",
- loc: {
- start: {
- line: 1,
- column: 33
- },
- end: {
- line: 1,
- column: 41
- }
- }
- },
- computed: false,
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 41
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 41
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 41
- }
- }
-});
-
-test("earth.asia.Indonesia.prepareForElection(2014)", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "CallExpression",
- callee: {
- type: "MemberExpression",
- object: {
- type: "MemberExpression",
- object: {
- type: "MemberExpression",
- object: {
- type: "Identifier",
- name: "earth",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 5
- }
- }
- },
- property: {
- type: "Identifier",
- name: "asia",
- loc: {
- start: {
- line: 1,
- column: 6
- },
- end: {
- line: 1,
- column: 10
- }
- }
- },
- computed: false,
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 10
- }
- }
- },
- property: {
- type: "Identifier",
- name: "Indonesia",
- loc: {
- start: {
- line: 1,
- column: 11
- },
- end: {
- line: 1,
- column: 20
- }
- }
- },
- computed: false,
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 20
- }
- }
- },
- property: {
- type: "Identifier",
- name: "prepareForElection",
- loc: {
- start: {
- line: 1,
- column: 21
- },
- end: {
- line: 1,
- column: 39
- }
- }
- },
- computed: false,
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 39
- }
- }
- },
- arguments: [
- {
- type: "Literal",
- value: 2014,
- loc: {
- start: {
- line: 1,
- column: 40
- },
- end: {
- line: 1,
- column: 44
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 45
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 45
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 45
- }
- }
-});
-
-test("universe.if", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "MemberExpression",
- object: {
- type: "Identifier",
- name: "universe",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 8
- }
- }
- },
- property: {
- type: "Identifier",
- name: "if",
- loc: {
- start: {
- line: 1,
- column: 9
- },
- end: {
- line: 1,
- column: 11
- }
- }
- },
- computed: false,
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 11
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 11
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 11
- }
- }
-});
-
-test("universe.true", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "MemberExpression",
- object: {
- type: "Identifier",
- name: "universe",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 8
- }
- }
- },
- property: {
- type: "Identifier",
- name: "true",
- loc: {
- start: {
- line: 1,
- column: 9
- },
- end: {
- line: 1,
- column: 13
- }
- }
- },
- computed: false,
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 13
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 13
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 13
- }
- }
-});
-
-test("universe.false", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "MemberExpression",
- object: {
- type: "Identifier",
- name: "universe",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 8
- }
- }
- },
- property: {
- type: "Identifier",
- name: "false",
- loc: {
- start: {
- line: 1,
- column: 9
- },
- end: {
- line: 1,
- column: 14
- }
- }
- },
- computed: false,
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 14
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 14
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 14
- }
- }
-});
-
-test("universe.null", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "MemberExpression",
- object: {
- type: "Identifier",
- name: "universe",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 8
- }
- }
- },
- property: {
- type: "Identifier",
- name: "null",
- loc: {
- start: {
- line: 1,
- column: 9
- },
- end: {
- line: 1,
- column: 13
- }
- }
- },
- computed: false,
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 13
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 13
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 13
- }
- }
-});
-
-test("x++", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "UpdateExpression",
- operator: "++",
- prefix: false,
- argument: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 3
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 3
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 3
- }
- }
-});
-
-test("x--", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "UpdateExpression",
- operator: "--",
- prefix: false,
- argument: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 3
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 3
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 3
- }
- }
-});
-
-test("eval++", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "UpdateExpression",
- operator: "++",
- prefix: false,
- argument: {
- type: "Identifier",
- name: "eval",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 4
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 6
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 6
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 6
- }
- }
-});
-
-test("eval--", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "UpdateExpression",
- operator: "--",
- prefix: false,
- argument: {
- type: "Identifier",
- name: "eval",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 4
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 6
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 6
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 6
- }
- }
-});
-
-test("arguments++", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "UpdateExpression",
- operator: "++",
- prefix: false,
- argument: {
- type: "Identifier",
- name: "arguments",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 9
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 11
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 11
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 11
- }
- }
-});
-
-test("arguments--", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "UpdateExpression",
- operator: "--",
- prefix: false,
- argument: {
- type: "Identifier",
- name: "arguments",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 9
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 11
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 11
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 11
- }
- }
-});
-
-test("++x", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "UpdateExpression",
- operator: "++",
- prefix: true,
- argument: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 2
- },
- end: {
- line: 1,
- column: 3
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 3
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 3
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 3
- }
- }
-});
-
-test("--x", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "UpdateExpression",
- operator: "--",
- prefix: true,
- argument: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 2
- },
- end: {
- line: 1,
- column: 3
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 3
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 3
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 3
- }
- }
-});
-
-test("++eval", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "UpdateExpression",
- operator: "++",
- prefix: true,
- argument: {
- type: "Identifier",
- name: "eval",
- loc: {
- start: {
- line: 1,
- column: 2
- },
- end: {
- line: 1,
- column: 6
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 6
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 6
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 6
- }
- }
-});
-
-test("--eval", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "UpdateExpression",
- operator: "--",
- prefix: true,
- argument: {
- type: "Identifier",
- name: "eval",
- loc: {
- start: {
- line: 1,
- column: 2
- },
- end: {
- line: 1,
- column: 6
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 6
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 6
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 6
- }
- }
-});
-
-test("++arguments", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "UpdateExpression",
- operator: "++",
- prefix: true,
- argument: {
- type: "Identifier",
- name: "arguments",
- loc: {
- start: {
- line: 1,
- column: 2
- },
- end: {
- line: 1,
- column: 11
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 11
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 11
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 11
- }
- }
-});
-
-test("--arguments", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "UpdateExpression",
- operator: "--",
- prefix: true,
- argument: {
- type: "Identifier",
- name: "arguments",
- loc: {
- start: {
- line: 1,
- column: 2
- },
- end: {
- line: 1,
- column: 11
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 11
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 11
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 11
- }
- }
-});
-
-test("+x", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "UnaryExpression",
- operator: "+",
- prefix: true,
- argument: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 1
- },
- end: {
- line: 1,
- column: 2
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 2
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 2
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 2
- }
- }
-});
-
-test("-x", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "UnaryExpression",
- operator: "-",
- prefix: true,
- argument: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 1
- },
- end: {
- line: 1,
- column: 2
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 2
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 2
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 2
- }
- }
-});
-
-test("~x", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "UnaryExpression",
- operator: "~",
- prefix: true,
- argument: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 1
- },
- end: {
- line: 1,
- column: 2
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 2
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 2
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 2
- }
- }
-});
-
-test("!x", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "UnaryExpression",
- operator: "!",
- prefix: true,
- argument: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 1
- },
- end: {
- line: 1,
- column: 2
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 2
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 2
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 2
- }
- }
-});
-
-test("void x", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "UnaryExpression",
- operator: "void",
- prefix: true,
- argument: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 5
- },
- end: {
- line: 1,
- column: 6
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 6
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 6
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 6
- }
- }
-});
-
-test("delete x", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "UnaryExpression",
- operator: "delete",
- prefix: true,
- argument: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 7
- },
- end: {
- line: 1,
- column: 8
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 8
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 8
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 8
- }
- }
-});
-
-test("typeof x", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "UnaryExpression",
- operator: "typeof",
- prefix: true,
- argument: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 7
- },
- end: {
- line: 1,
- column: 8
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 8
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 8
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 8
- }
- }
-});
-
-test("x * y", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "BinaryExpression",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- },
- operator: "*",
- right: {
- type: "Identifier",
- name: "y",
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 5
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 5
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 5
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 5
- }
- }
-});
-
-test("x / y", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "BinaryExpression",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- },
- operator: "/",
- right: {
- type: "Identifier",
- name: "y",
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 5
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 5
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 5
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 5
- }
- }
-});
-
-test("x % y", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "BinaryExpression",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- },
- operator: "%",
- right: {
- type: "Identifier",
- name: "y",
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 5
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 5
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 5
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 5
- }
- }
-});
-
-test("x + y", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "BinaryExpression",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- },
- operator: "+",
- right: {
- type: "Identifier",
- name: "y",
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 5
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 5
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 5
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 5
- }
- }
-});
-
-test("x - y", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "BinaryExpression",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- },
- operator: "-",
- right: {
- type: "Identifier",
- name: "y",
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 5
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 5
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 5
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 5
- }
- }
-});
-
-test("x << y", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "BinaryExpression",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- },
- operator: "<<",
- right: {
- type: "Identifier",
- name: "y",
- loc: {
- start: {
- line: 1,
- column: 5
- },
- end: {
- line: 1,
- column: 6
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 6
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 6
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 6
- }
- }
-});
-
-test("x >> y", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "BinaryExpression",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- },
- operator: ">>",
- right: {
- type: "Identifier",
- name: "y",
- loc: {
- start: {
- line: 1,
- column: 5
- },
- end: {
- line: 1,
- column: 6
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 6
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 6
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 6
- }
- }
-});
-
-test("x >>> y", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "BinaryExpression",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- },
- operator: ">>>",
- right: {
- type: "Identifier",
- name: "y",
- loc: {
- start: {
- line: 1,
- column: 6
- },
- end: {
- line: 1,
- column: 7
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 7
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 7
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 7
- }
- }
-});
-
-test("x < y", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "BinaryExpression",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- },
- operator: "<",
- right: {
- type: "Identifier",
- name: "y",
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 5
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 5
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 5
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 5
- }
- }
-});
-
-test("x > y", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "BinaryExpression",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- },
- operator: ">",
- right: {
- type: "Identifier",
- name: "y",
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 5
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 5
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 5
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 5
- }
- }
-});
-
-test("x <= y", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "BinaryExpression",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- },
- operator: "<=",
- right: {
- type: "Identifier",
- name: "y",
- loc: {
- start: {
- line: 1,
- column: 5
- },
- end: {
- line: 1,
- column: 6
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 6
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 6
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 6
- }
- }
-});
-
-test("x >= y", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "BinaryExpression",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- },
- operator: ">=",
- right: {
- type: "Identifier",
- name: "y",
- loc: {
- start: {
- line: 1,
- column: 5
- },
- end: {
- line: 1,
- column: 6
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 6
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 6
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 6
- }
- }
-});
-
-test("x in y", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "BinaryExpression",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- },
- operator: "in",
- right: {
- type: "Identifier",
- name: "y",
- loc: {
- start: {
- line: 1,
- column: 5
- },
- end: {
- line: 1,
- column: 6
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 6
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 6
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 6
- }
- }
-});
-
-test("x instanceof y", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "BinaryExpression",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- },
- operator: "instanceof",
- right: {
- type: "Identifier",
- name: "y",
- loc: {
- start: {
- line: 1,
- column: 13
- },
- end: {
- line: 1,
- column: 14
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 14
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 14
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 14
- }
- }
-});
-
-test("x < y < z", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "BinaryExpression",
- left: {
- type: "BinaryExpression",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- },
- operator: "<",
- right: {
- type: "Identifier",
- name: "y",
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 5
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 5
- }
- }
- },
- operator: "<",
- right: {
- type: "Identifier",
- name: "z",
- loc: {
- start: {
- line: 1,
- column: 8
- },
- end: {
- line: 1,
- column: 9
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 9
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 9
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 9
- }
- }
-});
-
-test("x == y", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "BinaryExpression",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- },
- operator: "==",
- right: {
- type: "Identifier",
- name: "y",
- loc: {
- start: {
- line: 1,
- column: 5
- },
- end: {
- line: 1,
- column: 6
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 6
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 6
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 6
- }
- }
-});
-
-test("x != y", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "BinaryExpression",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- },
- operator: "!=",
- right: {
- type: "Identifier",
- name: "y",
- loc: {
- start: {
- line: 1,
- column: 5
- },
- end: {
- line: 1,
- column: 6
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 6
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 6
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 6
- }
- }
-});
-
-test("x === y", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "BinaryExpression",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- },
- operator: "===",
- right: {
- type: "Identifier",
- name: "y",
- loc: {
- start: {
- line: 1,
- column: 6
- },
- end: {
- line: 1,
- column: 7
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 7
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 7
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 7
- }
- }
-});
-
-test("x !== y", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "BinaryExpression",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- },
- operator: "!==",
- right: {
- type: "Identifier",
- name: "y",
- loc: {
- start: {
- line: 1,
- column: 6
- },
- end: {
- line: 1,
- column: 7
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 7
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 7
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 7
- }
- }
-});
-
-test("x & y", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "BinaryExpression",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- },
- operator: "&",
- right: {
- type: "Identifier",
- name: "y",
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 5
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 5
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 5
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 5
- }
- }
-});
-
-test("x ^ y", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "BinaryExpression",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- },
- operator: "^",
- right: {
- type: "Identifier",
- name: "y",
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 5
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 5
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 5
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 5
- }
- }
-});
-
-test("x | y", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "BinaryExpression",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- },
- operator: "|",
- right: {
- type: "Identifier",
- name: "y",
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 5
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 5
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 5
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 5
- }
- }
-});
-
-test("x + y + z", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "BinaryExpression",
- left: {
- type: "BinaryExpression",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- },
- operator: "+",
- right: {
- type: "Identifier",
- name: "y",
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 5
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 5
- }
- }
- },
- operator: "+",
- right: {
- type: "Identifier",
- name: "z",
- loc: {
- start: {
- line: 1,
- column: 8
- },
- end: {
- line: 1,
- column: 9
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 9
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 9
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 9
- }
- }
-});
-
-test("x - y + z", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "BinaryExpression",
- left: {
- type: "BinaryExpression",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- },
- operator: "-",
- right: {
- type: "Identifier",
- name: "y",
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 5
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 5
- }
- }
- },
- operator: "+",
- right: {
- type: "Identifier",
- name: "z",
- loc: {
- start: {
- line: 1,
- column: 8
- },
- end: {
- line: 1,
- column: 9
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 9
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 9
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 9
- }
- }
-});
-
-test("x + y - z", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "BinaryExpression",
- left: {
- type: "BinaryExpression",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- },
- operator: "+",
- right: {
- type: "Identifier",
- name: "y",
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 5
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 5
- }
- }
- },
- operator: "-",
- right: {
- type: "Identifier",
- name: "z",
- loc: {
- start: {
- line: 1,
- column: 8
- },
- end: {
- line: 1,
- column: 9
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 9
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 9
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 9
- }
- }
-});
-
-test("x - y - z", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "BinaryExpression",
- left: {
- type: "BinaryExpression",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- },
- operator: "-",
- right: {
- type: "Identifier",
- name: "y",
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 5
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 5
- }
- }
- },
- operator: "-",
- right: {
- type: "Identifier",
- name: "z",
- loc: {
- start: {
- line: 1,
- column: 8
- },
- end: {
- line: 1,
- column: 9
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 9
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 9
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 9
- }
- }
-});
-
-test("x + y * z", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "BinaryExpression",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- },
- operator: "+",
- right: {
- type: "BinaryExpression",
- left: {
- type: "Identifier",
- name: "y",
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 5
- }
- }
- },
- operator: "*",
- right: {
- type: "Identifier",
- name: "z",
- loc: {
- start: {
- line: 1,
- column: 8
- },
- end: {
- line: 1,
- column: 9
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 9
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 9
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 9
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 9
- }
- }
-});
-
-test("x + y / z", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "BinaryExpression",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- },
- operator: "+",
- right: {
- type: "BinaryExpression",
- left: {
- type: "Identifier",
- name: "y",
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 5
- }
- }
- },
- operator: "/",
- right: {
- type: "Identifier",
- name: "z",
- loc: {
- start: {
- line: 1,
- column: 8
- },
- end: {
- line: 1,
- column: 9
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 9
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 9
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 9
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 9
- }
- }
-});
-
-test("x - y % z", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "BinaryExpression",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- },
- operator: "-",
- right: {
- type: "BinaryExpression",
- left: {
- type: "Identifier",
- name: "y",
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 5
- }
- }
- },
- operator: "%",
- right: {
- type: "Identifier",
- name: "z",
- loc: {
- start: {
- line: 1,
- column: 8
- },
- end: {
- line: 1,
- column: 9
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 9
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 9
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 9
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 9
- }
- }
-});
-
-test("x * y * z", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "BinaryExpression",
- left: {
- type: "BinaryExpression",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- },
- operator: "*",
- right: {
- type: "Identifier",
- name: "y",
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 5
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 5
- }
- }
- },
- operator: "*",
- right: {
- type: "Identifier",
- name: "z",
- loc: {
- start: {
- line: 1,
- column: 8
- },
- end: {
- line: 1,
- column: 9
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 9
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 9
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 9
- }
- }
-});
-
-test("x * y / z", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "BinaryExpression",
- left: {
- type: "BinaryExpression",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- },
- operator: "*",
- right: {
- type: "Identifier",
- name: "y",
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 5
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 5
- }
- }
- },
- operator: "/",
- right: {
- type: "Identifier",
- name: "z",
- loc: {
- start: {
- line: 1,
- column: 8
- },
- end: {
- line: 1,
- column: 9
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 9
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 9
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 9
- }
- }
-});
-
-test("x * y % z", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "BinaryExpression",
- left: {
- type: "BinaryExpression",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- },
- operator: "*",
- right: {
- type: "Identifier",
- name: "y",
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 5
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 5
- }
- }
- },
- operator: "%",
- right: {
- type: "Identifier",
- name: "z",
- loc: {
- start: {
- line: 1,
- column: 8
- },
- end: {
- line: 1,
- column: 9
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 9
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 9
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 9
- }
- }
-});
-
-test("x % y * z", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "BinaryExpression",
- left: {
- type: "BinaryExpression",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- },
- operator: "%",
- right: {
- type: "Identifier",
- name: "y",
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 5
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 5
- }
- }
- },
- operator: "*",
- right: {
- type: "Identifier",
- name: "z",
- loc: {
- start: {
- line: 1,
- column: 8
- },
- end: {
- line: 1,
- column: 9
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 9
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 9
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 9
- }
- }
-});
-
-test("x << y << z", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "BinaryExpression",
- left: {
- type: "BinaryExpression",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- },
- operator: "<<",
- right: {
- type: "Identifier",
- name: "y",
- loc: {
- start: {
- line: 1,
- column: 5
- },
- end: {
- line: 1,
- column: 6
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 6
- }
- }
- },
- operator: "<<",
- right: {
- type: "Identifier",
- name: "z",
- loc: {
- start: {
- line: 1,
- column: 10
- },
- end: {
- line: 1,
- column: 11
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 11
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 11
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 11
- }
- }
-});
-
-test("x | y | z", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "BinaryExpression",
- left: {
- type: "BinaryExpression",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- },
- operator: "|",
- right: {
- type: "Identifier",
- name: "y",
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 5
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 5
- }
- }
- },
- operator: "|",
- right: {
- type: "Identifier",
- name: "z",
- loc: {
- start: {
- line: 1,
- column: 8
- },
- end: {
- line: 1,
- column: 9
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 9
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 9
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 9
- }
- }
-});
-
-test("x & y & z", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "BinaryExpression",
- left: {
- type: "BinaryExpression",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- },
- operator: "&",
- right: {
- type: "Identifier",
- name: "y",
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 5
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 5
- }
- }
- },
- operator: "&",
- right: {
- type: "Identifier",
- name: "z",
- loc: {
- start: {
- line: 1,
- column: 8
- },
- end: {
- line: 1,
- column: 9
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 9
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 9
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 9
- }
- }
-});
-
-test("x ^ y ^ z", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "BinaryExpression",
- left: {
- type: "BinaryExpression",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- },
- operator: "^",
- right: {
- type: "Identifier",
- name: "y",
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 5
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 5
- }
- }
- },
- operator: "^",
- right: {
- type: "Identifier",
- name: "z",
- loc: {
- start: {
- line: 1,
- column: 8
- },
- end: {
- line: 1,
- column: 9
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 9
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 9
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 9
- }
- }
-});
-
-test("x & y | z", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "BinaryExpression",
- left: {
- type: "BinaryExpression",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- },
- operator: "&",
- right: {
- type: "Identifier",
- name: "y",
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 5
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 5
- }
- }
- },
- operator: "|",
- right: {
- type: "Identifier",
- name: "z",
- loc: {
- start: {
- line: 1,
- column: 8
- },
- end: {
- line: 1,
- column: 9
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 9
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 9
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 9
- }
- }
-});
-
-test("x | y ^ z", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "BinaryExpression",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- },
- operator: "|",
- right: {
- type: "BinaryExpression",
- left: {
- type: "Identifier",
- name: "y",
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 5
- }
- }
- },
- operator: "^",
- right: {
- type: "Identifier",
- name: "z",
- loc: {
- start: {
- line: 1,
- column: 8
- },
- end: {
- line: 1,
- column: 9
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 9
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 9
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 9
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 9
- }
- }
-});
-
-test("x | y & z", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "BinaryExpression",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- },
- operator: "|",
- right: {
- type: "BinaryExpression",
- left: {
- type: "Identifier",
- name: "y",
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 5
- }
- }
- },
- operator: "&",
- right: {
- type: "Identifier",
- name: "z",
- loc: {
- start: {
- line: 1,
- column: 8
- },
- end: {
- line: 1,
- column: 9
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 9
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 9
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 9
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 9
- }
- }
-});
-
-test("x || y", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "LogicalExpression",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- },
- operator: "||",
- right: {
- type: "Identifier",
- name: "y",
- loc: {
- start: {
- line: 1,
- column: 5
- },
- end: {
- line: 1,
- column: 6
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 6
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 6
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 6
- }
- }
-});
-
-test("x && y", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "LogicalExpression",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- },
- operator: "&&",
- right: {
- type: "Identifier",
- name: "y",
- loc: {
- start: {
- line: 1,
- column: 5
- },
- end: {
- line: 1,
- column: 6
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 6
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 6
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 6
- }
- }
-});
-
-test("x || y || z", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "LogicalExpression",
- left: {
- type: "LogicalExpression",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- },
- operator: "||",
- right: {
- type: "Identifier",
- name: "y",
- loc: {
- start: {
- line: 1,
- column: 5
- },
- end: {
- line: 1,
- column: 6
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 6
- }
- }
- },
- operator: "||",
- right: {
- type: "Identifier",
- name: "z",
- loc: {
- start: {
- line: 1,
- column: 10
- },
- end: {
- line: 1,
- column: 11
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 11
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 11
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 11
- }
- }
-});
-
-test("x && y && z", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "LogicalExpression",
- left: {
- type: "LogicalExpression",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- },
- operator: "&&",
- right: {
- type: "Identifier",
- name: "y",
- loc: {
- start: {
- line: 1,
- column: 5
- },
- end: {
- line: 1,
- column: 6
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 6
- }
- }
- },
- operator: "&&",
- right: {
- type: "Identifier",
- name: "z",
- loc: {
- start: {
- line: 1,
- column: 10
- },
- end: {
- line: 1,
- column: 11
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 11
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 11
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 11
- }
- }
-});
-
-test("x || y && z", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "LogicalExpression",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- },
- operator: "||",
- right: {
- type: "LogicalExpression",
- left: {
- type: "Identifier",
- name: "y",
- loc: {
- start: {
- line: 1,
- column: 5
- },
- end: {
- line: 1,
- column: 6
- }
- }
- },
- operator: "&&",
- right: {
- type: "Identifier",
- name: "z",
- loc: {
- start: {
- line: 1,
- column: 10
- },
- end: {
- line: 1,
- column: 11
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 5
- },
- end: {
- line: 1,
- column: 11
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 11
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 11
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 11
- }
- }
-});
-
-test("x || y ^ z", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "LogicalExpression",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- },
- operator: "||",
- right: {
- type: "BinaryExpression",
- left: {
- type: "Identifier",
- name: "y",
- loc: {
- start: {
- line: 1,
- column: 5
- },
- end: {
- line: 1,
- column: 6
- }
- }
- },
- operator: "^",
- right: {
- type: "Identifier",
- name: "z",
- loc: {
- start: {
- line: 1,
- column: 9
- },
- end: {
- line: 1,
- column: 10
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 5
- },
- end: {
- line: 1,
- column: 10
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 10
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 10
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 10
- }
- }
-});
-
-test("y ? 1 : 2", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "ConditionalExpression",
- test: {
- type: "Identifier",
- name: "y",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- },
- consequent: {
- type: "Literal",
- value: 1,
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 5
- }
- }
- },
- alternate: {
- type: "Literal",
- value: 2,
- loc: {
- start: {
- line: 1,
- column: 8
- },
- end: {
- line: 1,
- column: 9
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 9
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 9
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 9
- }
- }
-});
-
-test("x && y ? 1 : 2", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "ConditionalExpression",
- test: {
- type: "LogicalExpression",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- },
- operator: "&&",
- right: {
- type: "Identifier",
- name: "y",
- loc: {
- start: {
- line: 1,
- column: 5
- },
- end: {
- line: 1,
- column: 6
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 6
- }
- }
- },
- consequent: {
- type: "Literal",
- value: 1,
- loc: {
- start: {
- line: 1,
- column: 9
- },
- end: {
- line: 1,
- column: 10
- }
- }
- },
- alternate: {
- type: "Literal",
- value: 2,
- loc: {
- start: {
- line: 1,
- column: 13
- },
- end: {
- line: 1,
- column: 14
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 14
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 14
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 14
- }
- }
-});
-
-test("x = 42", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "AssignmentExpression",
- operator: "=",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- },
- right: {
- type: "Literal",
- value: 42,
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 6
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 6
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 6
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 6
- }
- }
-});
-
-test("eval = 42", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "AssignmentExpression",
- operator: "=",
- left: {
- type: "Identifier",
- name: "eval",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 4
- }
- }
- },
- right: {
- type: "Literal",
- value: 42,
- loc: {
- start: {
- line: 1,
- column: 7
- },
- end: {
- line: 1,
- column: 9
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 9
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 9
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 9
- }
- }
-});
-
-test("arguments = 42", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "AssignmentExpression",
- operator: "=",
- left: {
- type: "Identifier",
- name: "arguments",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 9
- }
- }
- },
- right: {
- type: "Literal",
- value: 42,
- loc: {
- start: {
- line: 1,
- column: 12
- },
- end: {
- line: 1,
- column: 14
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 14
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 14
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 14
- }
- }
-});
-
-test("x *= 42", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "AssignmentExpression",
- operator: "*=",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- },
- right: {
- type: "Literal",
- value: 42,
- loc: {
- start: {
- line: 1,
- column: 5
- },
- end: {
- line: 1,
- column: 7
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 7
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 7
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 7
- }
- }
-});
-
-test("x /= 42", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "AssignmentExpression",
- operator: "/=",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- },
- right: {
- type: "Literal",
- value: 42,
- loc: {
- start: {
- line: 1,
- column: 5
- },
- end: {
- line: 1,
- column: 7
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 7
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 7
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 7
- }
- }
-});
-
-test("x %= 42", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "AssignmentExpression",
- operator: "%=",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- },
- right: {
- type: "Literal",
- value: 42,
- loc: {
- start: {
- line: 1,
- column: 5
- },
- end: {
- line: 1,
- column: 7
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 7
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 7
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 7
- }
- }
-});
-
-test("x += 42", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "AssignmentExpression",
- operator: "+=",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- },
- right: {
- type: "Literal",
- value: 42,
- loc: {
- start: {
- line: 1,
- column: 5
- },
- end: {
- line: 1,
- column: 7
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 7
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 7
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 7
- }
- }
-});
-
-test("x -= 42", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "AssignmentExpression",
- operator: "-=",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- },
- right: {
- type: "Literal",
- value: 42,
- loc: {
- start: {
- line: 1,
- column: 5
- },
- end: {
- line: 1,
- column: 7
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 7
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 7
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 7
- }
- }
-});
-
-test("x <<= 42", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "AssignmentExpression",
- operator: "<<=",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- },
- right: {
- type: "Literal",
- value: 42,
- loc: {
- start: {
- line: 1,
- column: 6
- },
- end: {
- line: 1,
- column: 8
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 8
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 8
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 8
- }
- }
-});
-
-test("x >>= 42", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "AssignmentExpression",
- operator: ">>=",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- },
- right: {
- type: "Literal",
- value: 42,
- loc: {
- start: {
- line: 1,
- column: 6
- },
- end: {
- line: 1,
- column: 8
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 8
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 8
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 8
- }
- }
-});
-
-test("x >>>= 42", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "AssignmentExpression",
- operator: ">>>=",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- },
- right: {
- type: "Literal",
- value: 42,
- loc: {
- start: {
- line: 1,
- column: 7
- },
- end: {
- line: 1,
- column: 9
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 9
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 9
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 9
- }
- }
-});
-
-test("x &= 42", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "AssignmentExpression",
- operator: "&=",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- },
- right: {
- type: "Literal",
- value: 42,
- loc: {
- start: {
- line: 1,
- column: 5
- },
- end: {
- line: 1,
- column: 7
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 7
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 7
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 7
- }
- }
-});
-
-test("x ^= 42", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "AssignmentExpression",
- operator: "^=",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- },
- right: {
- type: "Literal",
- value: 42,
- loc: {
- start: {
- line: 1,
- column: 5
- },
- end: {
- line: 1,
- column: 7
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 7
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 7
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 7
- }
- }
-});
-
-test("x |= 42", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "AssignmentExpression",
- operator: "|=",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- },
- right: {
- type: "Literal",
- value: 42,
- loc: {
- start: {
- line: 1,
- column: 5
- },
- end: {
- line: 1,
- column: 7
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 7
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 7
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 7
- }
- }
-});
-
-test("{ foo }", {
- type: "Program",
- body: [
- {
- type: "BlockStatement",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "Identifier",
- name: "foo",
- loc: {
- start: {
- line: 1,
- column: 2
- },
- end: {
- line: 1,
- column: 5
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 2
- },
- end: {
- line: 1,
- column: 5
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 7
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 7
- }
- }
-});
-
-test("{ doThis(); doThat(); }", {
- type: "Program",
- body: [
- {
- type: "BlockStatement",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "CallExpression",
- callee: {
- type: "Identifier",
- name: "doThis",
- loc: {
- start: {
- line: 1,
- column: 2
- },
- end: {
- line: 1,
- column: 8
- }
- }
- },
- arguments: [],
- loc: {
- start: {
- line: 1,
- column: 2
- },
- end: {
- line: 1,
- column: 10
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 2
- },
- end: {
- line: 1,
- column: 11
- }
- }
- },
- {
- type: "ExpressionStatement",
- expression: {
- type: "CallExpression",
- callee: {
- type: "Identifier",
- name: "doThat",
- loc: {
- start: {
- line: 1,
- column: 12
- },
- end: {
- line: 1,
- column: 18
- }
- }
- },
- arguments: [],
- loc: {
- start: {
- line: 1,
- column: 12
- },
- end: {
- line: 1,
- column: 20
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 12
- },
- end: {
- line: 1,
- column: 21
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 23
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 23
- }
- }
-});
-
-test("{}", {
- type: "Program",
- body: [
- {
- type: "BlockStatement",
- body: [],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 2
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 2
- }
- }
-});
-
-test("var x", {
- type: "Program",
- body: [
- {
- type: "VariableDeclaration",
- declarations: [
- {
- type: "VariableDeclarator",
- id: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 5
- }
- }
- },
- init: null,
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 5
- }
- }
- }
- ],
- kind: "var",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 5
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 5
- }
- }
-});
-
-test("var x, y;", {
- type: "Program",
- body: [
- {
- type: "VariableDeclaration",
- declarations: [
- {
- type: "VariableDeclarator",
- id: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 5
- }
- }
- },
- init: null,
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 5
- }
- }
- },
- {
- type: "VariableDeclarator",
- id: {
- type: "Identifier",
- name: "y",
- loc: {
- start: {
- line: 1,
- column: 7
- },
- end: {
- line: 1,
- column: 8
- }
- }
- },
- init: null,
- loc: {
- start: {
- line: 1,
- column: 7
- },
- end: {
- line: 1,
- column: 8
- }
- }
- }
- ],
- kind: "var",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 9
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 9
- }
- }
-});
-
-test("var x = 42", {
- type: "Program",
- body: [
- {
- type: "VariableDeclaration",
- declarations: [
- {
- type: "VariableDeclarator",
- id: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 5
- }
- }
- },
- init: {
- type: "Literal",
- value: 42,
- loc: {
- start: {
- line: 1,
- column: 8
- },
- end: {
- line: 1,
- column: 10
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 10
- }
- }
- }
- ],
- kind: "var",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 10
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 10
- }
- }
-});
-
-test("var eval = 42, arguments = 42", {
- type: "Program",
- body: [
- {
- type: "VariableDeclaration",
- declarations: [
- {
- type: "VariableDeclarator",
- id: {
- type: "Identifier",
- name: "eval",
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 8
- }
- }
- },
- init: {
- type: "Literal",
- value: 42,
- loc: {
- start: {
- line: 1,
- column: 11
- },
- end: {
- line: 1,
- column: 13
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 13
- }
- }
- },
- {
- type: "VariableDeclarator",
- id: {
- type: "Identifier",
- name: "arguments",
- loc: {
- start: {
- line: 1,
- column: 15
- },
- end: {
- line: 1,
- column: 24
- }
- }
- },
- init: {
- type: "Literal",
- value: 42,
- loc: {
- start: {
- line: 1,
- column: 27
- },
- end: {
- line: 1,
- column: 29
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 15
- },
- end: {
- line: 1,
- column: 29
- }
- }
- }
- ],
- kind: "var",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 29
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 29
- }
- }
-});
-
-test("var x = 14, y = 3, z = 1977", {
- type: "Program",
- body: [
- {
- type: "VariableDeclaration",
- declarations: [
- {
- type: "VariableDeclarator",
- id: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 5
- }
- }
- },
- init: {
- type: "Literal",
- value: 14,
- loc: {
- start: {
- line: 1,
- column: 8
- },
- end: {
- line: 1,
- column: 10
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 10
- }
- }
- },
- {
- type: "VariableDeclarator",
- id: {
- type: "Identifier",
- name: "y",
- loc: {
- start: {
- line: 1,
- column: 12
- },
- end: {
- line: 1,
- column: 13
- }
- }
- },
- init: {
- type: "Literal",
- value: 3,
- loc: {
- start: {
- line: 1,
- column: 16
- },
- end: {
- line: 1,
- column: 17
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 12
- },
- end: {
- line: 1,
- column: 17
- }
- }
- },
- {
- type: "VariableDeclarator",
- id: {
- type: "Identifier",
- name: "z",
- loc: {
- start: {
- line: 1,
- column: 19
- },
- end: {
- line: 1,
- column: 20
- }
- }
- },
- init: {
- type: "Literal",
- value: 1977,
- loc: {
- start: {
- line: 1,
- column: 23
- },
- end: {
- line: 1,
- column: 27
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 19
- },
- end: {
- line: 1,
- column: 27
- }
- }
- }
- ],
- kind: "var",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 27
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 27
- }
- }
-});
-
-test("var implements, interface, package", {
- type: "Program",
- body: [
- {
- type: "VariableDeclaration",
- declarations: [
- {
- type: "VariableDeclarator",
- id: {
- type: "Identifier",
- name: "implements",
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 14
- }
- }
- },
- init: null,
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 14
- }
- }
- },
- {
- type: "VariableDeclarator",
- id: {
- type: "Identifier",
- name: "interface",
- loc: {
- start: {
- line: 1,
- column: 16
- },
- end: {
- line: 1,
- column: 25
- }
- }
- },
- init: null,
- loc: {
- start: {
- line: 1,
- column: 16
- },
- end: {
- line: 1,
- column: 25
- }
- }
- },
- {
- type: "VariableDeclarator",
- id: {
- type: "Identifier",
- name: "package",
- loc: {
- start: {
- line: 1,
- column: 27
- },
- end: {
- line: 1,
- column: 34
- }
- }
- },
- init: null,
- loc: {
- start: {
- line: 1,
- column: 27
- },
- end: {
- line: 1,
- column: 34
- }
- }
- }
- ],
- kind: "var",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 34
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 34
- }
- }
-});
-
-test("var private, protected, public, static", {
- type: "Program",
- body: [
- {
- type: "VariableDeclaration",
- declarations: [
- {
- type: "VariableDeclarator",
- id: {
- type: "Identifier",
- name: "private",
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 11
- }
- }
- },
- init: null,
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 11
- }
- }
- },
- {
- type: "VariableDeclarator",
- id: {
- type: "Identifier",
- name: "protected",
- loc: {
- start: {
- line: 1,
- column: 13
- },
- end: {
- line: 1,
- column: 22
- }
- }
- },
- init: null,
- loc: {
- start: {
- line: 1,
- column: 13
- },
- end: {
- line: 1,
- column: 22
- }
- }
- },
- {
- type: "VariableDeclarator",
- id: {
- type: "Identifier",
- name: "public",
- loc: {
- start: {
- line: 1,
- column: 24
- },
- end: {
- line: 1,
- column: 30
- }
- }
- },
- init: null,
- loc: {
- start: {
- line: 1,
- column: 24
- },
- end: {
- line: 1,
- column: 30
- }
- }
- },
- {
- type: "VariableDeclarator",
- id: {
- type: "Identifier",
- name: "static",
- loc: {
- start: {
- line: 1,
- column: 32
- },
- end: {
- line: 1,
- column: 38
- }
- }
- },
- init: null,
- loc: {
- start: {
- line: 1,
- column: 32
- },
- end: {
- line: 1,
- column: 38
- }
- }
- }
- ],
- kind: "var",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 38
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 38
- }
- }
-});
-
-test(";", {
- type: "Program",
- body: [
- {
- type: "EmptyStatement",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
-});
-
-test("x", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
-});
-
-test("x, y", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "SequenceExpression",
- expressions: [
- {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 1
- }
- }
- },
- {
- type: "Identifier",
- name: "y",
- loc: {
- start: {
- line: 1,
- column: 3
- },
- end: {
- line: 1,
- column: 4
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 4
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 4
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 4
- }
- }
-});
-
-test("\\u0061", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "Identifier",
- name: "a",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 6
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 6
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 6
- }
- }
-});
-
-test("a\\u0061", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "Identifier",
- name: "aa",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 7
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 7
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 7
- }
- }
-});
-
-test("if (morning) goodMorning()", {
- type: "Program",
- body: [
- {
- type: "IfStatement",
- test: {
- type: "Identifier",
- name: "morning",
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 11
- }
- }
- },
- consequent: {
- type: "ExpressionStatement",
- expression: {
- type: "CallExpression",
- callee: {
- type: "Identifier",
- name: "goodMorning",
- loc: {
- start: {
- line: 1,
- column: 13
- },
- end: {
- line: 1,
- column: 24
- }
- }
- },
- arguments: [],
- loc: {
- start: {
- line: 1,
- column: 13
- },
- end: {
- line: 1,
- column: 26
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 13
- },
- end: {
- line: 1,
- column: 26
- }
- }
- },
- alternate: null,
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 26
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 26
- }
- }
-});
-
-test("if (morning) (function(){})", {
- type: "Program",
- body: [
- {
- type: "IfStatement",
- test: {
- type: "Identifier",
- name: "morning",
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 11
- }
- }
- },
- consequent: {
- type: "ExpressionStatement",
- expression: {
- type: "FunctionExpression",
- id: null,
- params: [],
- body: {
- type: "BlockStatement",
- body: [],
- loc: {
- start: {
- line: 1,
- column: 24
- },
- end: {
- line: 1,
- column: 26
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 14
- },
- end: {
- line: 1,
- column: 26
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 13
- },
- end: {
- line: 1,
- column: 27
- }
- }
- },
- alternate: null,
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 27
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 27
- }
- }
-});
-
-test("if (morning) var x = 0;", {
- type: "Program",
- body: [
- {
- type: "IfStatement",
- test: {
- type: "Identifier",
- name: "morning",
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 11
- }
- }
- },
- consequent: {
- type: "VariableDeclaration",
- declarations: [
- {
- type: "VariableDeclarator",
- id: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 17
- },
- end: {
- line: 1,
- column: 18
- }
- }
- },
- init: {
- type: "Literal",
- value: 0,
- loc: {
- start: {
- line: 1,
- column: 21
- },
- end: {
- line: 1,
- column: 22
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 17
- },
- end: {
- line: 1,
- column: 22
- }
- }
- }
- ],
- kind: "var",
- loc: {
- start: {
- line: 1,
- column: 13
- },
- end: {
- line: 1,
- column: 23
- }
- }
- },
- alternate: null,
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 23
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 23
- }
- }
-});
-
-test("if (morning) function a(){}", {
- type: "Program",
- body: [
- {
- type: "IfStatement",
- test: {
- type: "Identifier",
- name: "morning",
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 11
- }
- }
- },
- consequent: {
- type: "FunctionDeclaration",
- id: {
- type: "Identifier",
- name: "a",
- loc: {
- start: {
- line: 1,
- column: 22
- },
- end: {
- line: 1,
- column: 23
- }
- }
- },
- params: [],
- body: {
- type: "BlockStatement",
- body: [],
- loc: {
- start: {
- line: 1,
- column: 25
- },
- end: {
- line: 1,
- column: 27
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 13
- },
- end: {
- line: 1,
- column: 27
- }
- }
- },
- alternate: null,
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 27
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 27
- }
- }
-});
-
-test("if (morning) goodMorning(); else goodDay()", {
- type: "Program",
- body: [
- {
- type: "IfStatement",
- test: {
- type: "Identifier",
- name: "morning",
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 11
- }
- }
- },
- consequent: {
- type: "ExpressionStatement",
- expression: {
- type: "CallExpression",
- callee: {
- type: "Identifier",
- name: "goodMorning",
- loc: {
- start: {
- line: 1,
- column: 13
- },
- end: {
- line: 1,
- column: 24
- }
- }
- },
- arguments: [],
- loc: {
- start: {
- line: 1,
- column: 13
- },
- end: {
- line: 1,
- column: 26
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 13
- },
- end: {
- line: 1,
- column: 27
- }
- }
- },
- alternate: {
- type: "ExpressionStatement",
- expression: {
- type: "CallExpression",
- callee: {
- type: "Identifier",
- name: "goodDay",
- loc: {
- start: {
- line: 1,
- column: 33
- },
- end: {
- line: 1,
- column: 40
- }
- }
- },
- arguments: [],
- loc: {
- start: {
- line: 1,
- column: 33
- },
- end: {
- line: 1,
- column: 42
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 33
- },
- end: {
- line: 1,
- column: 42
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 42
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 42
- }
- }
-});
-
-test("do keep(); while (true)", {
- type: "Program",
- body: [
- {
- type: "DoWhileStatement",
- body: {
- type: "ExpressionStatement",
- expression: {
- type: "CallExpression",
- callee: {
- type: "Identifier",
- name: "keep",
- loc: {
- start: {
- line: 1,
- column: 3
- },
- end: {
- line: 1,
- column: 7
- }
- }
- },
- arguments: [],
- loc: {
- start: {
- line: 1,
- column: 3
- },
- end: {
- line: 1,
- column: 9
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 3
- },
- end: {
- line: 1,
- column: 10
- }
- }
- },
- test: {
- type: "Literal",
- value: true,
- loc: {
- start: {
- line: 1,
- column: 18
- },
- end: {
- line: 1,
- column: 22
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 23
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 23
- }
- }
-});
-
-test("do keep(); while (true);", {
- type: "Program",
- body: [
- {
- type: "DoWhileStatement",
- body: {
- type: "ExpressionStatement",
- expression: {
- type: "CallExpression",
- callee: {
- type: "Identifier",
- name: "keep",
- loc: {
- start: {
- line: 1,
- column: 3
- },
- end: {
- line: 1,
- column: 7
- }
- }
- },
- arguments: [],
- loc: {
- start: {
- line: 1,
- column: 3
- },
- end: {
- line: 1,
- column: 9
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 3
- },
- end: {
- line: 1,
- column: 10
- }
- }
- },
- test: {
- type: "Literal",
- value: true,
- loc: {
- start: {
- line: 1,
- column: 18
- },
- end: {
- line: 1,
- column: 22
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 24
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 24
- }
- }
-});
-
-test("do { x++; y--; } while (x < 10)", {
- type: "Program",
- body: [
- {
- type: "DoWhileStatement",
- body: {
- type: "BlockStatement",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "UpdateExpression",
- operator: "++",
- prefix: false,
- argument: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 5
- },
- end: {
- line: 1,
- column: 6
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 5
- },
- end: {
- line: 1,
- column: 8
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 5
- },
- end: {
- line: 1,
- column: 9
- }
- }
- },
- {
- type: "ExpressionStatement",
- expression: {
- type: "UpdateExpression",
- operator: "--",
- prefix: false,
- argument: {
- type: "Identifier",
- name: "y",
- loc: {
- start: {
- line: 1,
- column: 10
- },
- end: {
- line: 1,
- column: 11
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 10
- },
- end: {
- line: 1,
- column: 13
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 10
- },
- end: {
- line: 1,
- column: 14
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 3
- },
- end: {
- line: 1,
- column: 16
- }
- }
- },
- test: {
- type: "BinaryExpression",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 24
- },
- end: {
- line: 1,
- column: 25
- }
- }
- },
- operator: "<",
- right: {
- type: "Literal",
- value: 10,
- loc: {
- start: {
- line: 1,
- column: 28
- },
- end: {
- line: 1,
- column: 30
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 24
- },
- end: {
- line: 1,
- column: 30
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 31
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 31
- }
- }
-});
-
-test("{ do { } while (false);false }", {
- type: "Program",
- body: [
- {
- type: "BlockStatement",
- body: [
- {
- type: "DoWhileStatement",
- body: {
- type: "BlockStatement",
- body: [],
- loc: {
- start: {
- line: 1,
- column: 5
- },
- end: {
- line: 1,
- column: 8
- }
- }
- },
- test: {
- type: "Literal",
- value: false,
- loc: {
- start: {
- line: 1,
- column: 16
- },
- end: {
- line: 1,
- column: 21
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 2
- },
- end: {
- line: 1,
- column: 23
- }
- }
- },
- {
- type: "ExpressionStatement",
- expression: {
- type: "Literal",
- value: false,
- loc: {
- start: {
- line: 1,
- column: 23
- },
- end: {
- line: 1,
- column: 28
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 23
- },
- end: {
- line: 1,
- column: 28
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 30
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 30
- }
- }
-});
-
-test("while (true) doSomething()", {
- type: "Program",
- body: [
- {
- type: "WhileStatement",
- test: {
- type: "Literal",
- value: true,
- loc: {
- start: {
- line: 1,
- column: 7
- },
- end: {
- line: 1,
- column: 11
- }
- }
- },
- body: {
- type: "ExpressionStatement",
- expression: {
- type: "CallExpression",
- callee: {
- type: "Identifier",
- name: "doSomething",
- loc: {
- start: {
- line: 1,
- column: 13
- },
- end: {
- line: 1,
- column: 24
- }
- }
- },
- arguments: [],
- loc: {
- start: {
- line: 1,
- column: 13
- },
- end: {
- line: 1,
- column: 26
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 13
- },
- end: {
- line: 1,
- column: 26
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 26
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 26
- }
- }
-});
-
-test("while (x < 10) { x++; y--; }", {
- type: "Program",
- body: [
- {
- type: "WhileStatement",
- test: {
- type: "BinaryExpression",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 7
- },
- end: {
- line: 1,
- column: 8
- }
- }
- },
- operator: "<",
- right: {
- type: "Literal",
- value: 10,
- loc: {
- start: {
- line: 1,
- column: 11
- },
- end: {
- line: 1,
- column: 13
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 7
- },
- end: {
- line: 1,
- column: 13
- }
- }
- },
- body: {
- type: "BlockStatement",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "UpdateExpression",
- operator: "++",
- prefix: false,
- argument: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 17
- },
- end: {
- line: 1,
- column: 18
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 17
- },
- end: {
- line: 1,
- column: 20
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 17
- },
- end: {
- line: 1,
- column: 21
- }
- }
- },
- {
- type: "ExpressionStatement",
- expression: {
- type: "UpdateExpression",
- operator: "--",
- prefix: false,
- argument: {
- type: "Identifier",
- name: "y",
- loc: {
- start: {
- line: 1,
- column: 22
- },
- end: {
- line: 1,
- column: 23
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 22
- },
- end: {
- line: 1,
- column: 25
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 22
- },
- end: {
- line: 1,
- column: 26
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 15
- },
- end: {
- line: 1,
- column: 28
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 28
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 28
- }
- }
-});
-
-test("for(;;);", {
- type: "Program",
- body: [
- {
- type: "ForStatement",
- init: null,
- test: null,
- update: null,
- body: {
- type: "EmptyStatement",
- loc: {
- start: {
- line: 1,
- column: 7
- },
- end: {
- line: 1,
- column: 8
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 8
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 8
- }
- }
-});
-
-test("for(;;){}", {
- type: "Program",
- body: [
- {
- type: "ForStatement",
- init: null,
- test: null,
- update: null,
- body: {
- type: "BlockStatement",
- body: [],
- loc: {
- start: {
- line: 1,
- column: 7
- },
- end: {
- line: 1,
- column: 9
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 9
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 9
- }
- }
-});
-
-test("for(x = 0;;);", {
- type: "Program",
- body: [
- {
- type: "ForStatement",
- init: {
- type: "AssignmentExpression",
- operator: "=",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 5
- }
- }
- },
- right: {
- type: "Literal",
- value: 0,
- loc: {
- start: {
- line: 1,
- column: 8
- },
- end: {
- line: 1,
- column: 9
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 9
- }
- }
- },
- test: null,
- update: null,
- body: {
- type: "EmptyStatement",
- loc: {
- start: {
- line: 1,
- column: 12
- },
- end: {
- line: 1,
- column: 13
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 13
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 13
- }
- }
-});
-
-test("for(var x = 0;;);", {
- type: "Program",
- body: [
- {
- type: "ForStatement",
- init: {
- type: "VariableDeclaration",
- declarations: [
- {
- type: "VariableDeclarator",
- id: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 8
- },
- end: {
- line: 1,
- column: 9
- }
- }
- },
- init: {
- type: "Literal",
- value: 0,
- loc: {
- start: {
- line: 1,
- column: 12
- },
- end: {
- line: 1,
- column: 13
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 8
- },
- end: {
- line: 1,
- column: 13
- }
- }
- }
- ],
- kind: "var",
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 13
- }
- }
- },
- test: null,
- update: null,
- body: {
- type: "EmptyStatement",
- loc: {
- start: {
- line: 1,
- column: 16
- },
- end: {
- line: 1,
- column: 17
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 17
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 17
- }
- }
-});
-
-test("for(var x = 0, y = 1;;);", {
- type: "Program",
- body: [
- {
- type: "ForStatement",
- init: {
- type: "VariableDeclaration",
- declarations: [
- {
- type: "VariableDeclarator",
- id: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 8
- },
- end: {
- line: 1,
- column: 9
- }
- }
- },
- init: {
- type: "Literal",
- value: 0,
- loc: {
- start: {
- line: 1,
- column: 12
- },
- end: {
- line: 1,
- column: 13
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 8
- },
- end: {
- line: 1,
- column: 13
- }
- }
- },
- {
- type: "VariableDeclarator",
- id: {
- type: "Identifier",
- name: "y",
- loc: {
- start: {
- line: 1,
- column: 15
- },
- end: {
- line: 1,
- column: 16
- }
- }
- },
- init: {
- type: "Literal",
- value: 1,
- loc: {
- start: {
- line: 1,
- column: 19
- },
- end: {
- line: 1,
- column: 20
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 15
- },
- end: {
- line: 1,
- column: 20
- }
- }
- }
- ],
- kind: "var",
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 20
- }
- }
- },
- test: null,
- update: null,
- body: {
- type: "EmptyStatement",
- loc: {
- start: {
- line: 1,
- column: 23
- },
- end: {
- line: 1,
- column: 24
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 24
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 24
- }
- }
-});
-
-test("for(x = 0; x < 42;);", {
- type: "Program",
- body: [
- {
- type: "ForStatement",
- init: {
- type: "AssignmentExpression",
- operator: "=",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 5
- }
- }
- },
- right: {
- type: "Literal",
- value: 0,
- loc: {
- start: {
- line: 1,
- column: 8
- },
- end: {
- line: 1,
- column: 9
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 9
- }
- }
- },
- test: {
- type: "BinaryExpression",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 11
- },
- end: {
- line: 1,
- column: 12
- }
- }
- },
- operator: "<",
- right: {
- type: "Literal",
- value: 42,
- loc: {
- start: {
- line: 1,
- column: 15
- },
- end: {
- line: 1,
- column: 17
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 11
- },
- end: {
- line: 1,
- column: 17
- }
- }
- },
- update: null,
- body: {
- type: "EmptyStatement",
- loc: {
- start: {
- line: 1,
- column: 19
- },
- end: {
- line: 1,
- column: 20
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 20
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 20
- }
- }
-});
-
-test("for(x = 0; x < 42; x++);", {
- type: "Program",
- body: [
- {
- type: "ForStatement",
- init: {
- type: "AssignmentExpression",
- operator: "=",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 5
- }
- }
- },
- right: {
- type: "Literal",
- value: 0,
- loc: {
- start: {
- line: 1,
- column: 8
- },
- end: {
- line: 1,
- column: 9
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 9
- }
- }
- },
- test: {
- type: "BinaryExpression",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 11
- },
- end: {
- line: 1,
- column: 12
- }
- }
- },
- operator: "<",
- right: {
- type: "Literal",
- value: 42,
- loc: {
- start: {
- line: 1,
- column: 15
- },
- end: {
- line: 1,
- column: 17
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 11
- },
- end: {
- line: 1,
- column: 17
- }
- }
- },
- update: {
- type: "UpdateExpression",
- operator: "++",
- prefix: false,
- argument: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 19
- },
- end: {
- line: 1,
- column: 20
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 19
- },
- end: {
- line: 1,
- column: 22
- }
- }
- },
- body: {
- type: "EmptyStatement",
- loc: {
- start: {
- line: 1,
- column: 23
- },
- end: {
- line: 1,
- column: 24
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 24
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 24
- }
- }
-});
-
-test("for(x = 0; x < 42; x++) process(x);", {
- type: "Program",
- body: [
- {
- type: "ForStatement",
- init: {
- type: "AssignmentExpression",
- operator: "=",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 5
- }
- }
- },
- right: {
- type: "Literal",
- value: 0,
- loc: {
- start: {
- line: 1,
- column: 8
- },
- end: {
- line: 1,
- column: 9
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 9
- }
- }
- },
- test: {
- type: "BinaryExpression",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 11
- },
- end: {
- line: 1,
- column: 12
- }
- }
- },
- operator: "<",
- right: {
- type: "Literal",
- value: 42,
- loc: {
- start: {
- line: 1,
- column: 15
- },
- end: {
- line: 1,
- column: 17
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 11
- },
- end: {
- line: 1,
- column: 17
- }
- }
- },
- update: {
- type: "UpdateExpression",
- operator: "++",
- prefix: false,
- argument: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 19
- },
- end: {
- line: 1,
- column: 20
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 19
- },
- end: {
- line: 1,
- column: 22
- }
- }
- },
- body: {
- type: "ExpressionStatement",
- expression: {
- type: "CallExpression",
- callee: {
- type: "Identifier",
- name: "process",
- loc: {
- start: {
- line: 1,
- column: 24
- },
- end: {
- line: 1,
- column: 31
- }
- }
- },
- arguments: [
- {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 32
- },
- end: {
- line: 1,
- column: 33
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 24
- },
- end: {
- line: 1,
- column: 34
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 24
- },
- end: {
- line: 1,
- column: 35
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 35
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 35
- }
- }
-});
-
-test("for(x in list) process(x);", {
- type: "Program",
- body: [
- {
- type: "ForInStatement",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 5
- }
- }
- },
- right: {
- type: "Identifier",
- name: "list",
- loc: {
- start: {
- line: 1,
- column: 9
- },
- end: {
- line: 1,
- column: 13
- }
- }
- },
- body: {
- type: "ExpressionStatement",
- expression: {
- type: "CallExpression",
- callee: {
- type: "Identifier",
- name: "process",
- loc: {
- start: {
- line: 1,
- column: 15
- },
- end: {
- line: 1,
- column: 22
- }
- }
- },
- arguments: [
- {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 23
- },
- end: {
- line: 1,
- column: 24
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 15
- },
- end: {
- line: 1,
- column: 25
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 15
- },
- end: {
- line: 1,
- column: 26
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 26
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 26
- }
- }
-});
-
-test("for (var x in list) process(x);", {
- type: "Program",
- body: [
- {
- type: "ForInStatement",
- left: {
- type: "VariableDeclaration",
- declarations: [
- {
- type: "VariableDeclarator",
- id: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 9
- },
- end: {
- line: 1,
- column: 10
- }
- }
- },
- init: null,
- loc: {
- start: {
- line: 1,
- column: 9
- },
- end: {
- line: 1,
- column: 10
- }
- }
- }
- ],
- kind: "var",
- loc: {
- start: {
- line: 1,
- column: 5
- },
- end: {
- line: 1,
- column: 10
- }
- }
- },
- right: {
- type: "Identifier",
- name: "list",
- loc: {
- start: {
- line: 1,
- column: 14
- },
- end: {
- line: 1,
- column: 18
- }
- }
- },
- body: {
- type: "ExpressionStatement",
- expression: {
- type: "CallExpression",
- callee: {
- type: "Identifier",
- name: "process",
- loc: {
- start: {
- line: 1,
- column: 20
- },
- end: {
- line: 1,
- column: 27
- }
- }
- },
- arguments: [
- {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 28
- },
- end: {
- line: 1,
- column: 29
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 20
- },
- end: {
- line: 1,
- column: 30
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 20
- },
- end: {
- line: 1,
- column: 31
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 31
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 31
- }
- }
-});
-
-test("for (var x = 42 in list) process(x);", {
- type: "Program",
- body: [
- {
- type: "ForInStatement",
- left: {
- type: "VariableDeclaration",
- declarations: [
- {
- type: "VariableDeclarator",
- id: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 9
- },
- end: {
- line: 1,
- column: 10
- }
- }
- },
- init: {
- type: "Literal",
- value: 42,
- loc: {
- start: {
- line: 1,
- column: 13
- },
- end: {
- line: 1,
- column: 15
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 9
- },
- end: {
- line: 1,
- column: 15
- }
- }
- }
- ],
- kind: "var",
- loc: {
- start: {
- line: 1,
- column: 5
- },
- end: {
- line: 1,
- column: 15
- }
- }
- },
- right: {
- type: "Identifier",
- name: "list",
- loc: {
- start: {
- line: 1,
- column: 19
- },
- end: {
- line: 1,
- column: 23
- }
- }
- },
- body: {
- type: "ExpressionStatement",
- expression: {
- type: "CallExpression",
- callee: {
- type: "Identifier",
- name: "process",
- loc: {
- start: {
- line: 1,
- column: 25
- },
- end: {
- line: 1,
- column: 32
- }
- }
- },
- arguments: [
- {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 33
- },
- end: {
- line: 1,
- column: 34
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 25
- },
- end: {
- line: 1,
- column: 35
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 25
- },
- end: {
- line: 1,
- column: 36
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 36
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 36
- }
- }
-});
-
-test("for (var i = function() { return 10 in [] } in list) process(x);", {
- type: "Program",
- body: [
- {
- type: "ForInStatement",
- left: {
- type: "VariableDeclaration",
- declarations: [
- {
- type: "VariableDeclarator",
- id: {
- type: "Identifier",
- name: "i",
- loc: {
- start: {
- line: 1,
- column: 9
- },
- end: {
- line: 1,
- column: 10
- }
- }
- },
- init: {
- type: "FunctionExpression",
- id: null,
- params: [],
- body: {
- type: "BlockStatement",
- body: [
- {
- type: "ReturnStatement",
- argument: {
- type: "BinaryExpression",
- left: {
- type: "Literal",
- value: 10,
- loc: {
- start: {
- line: 1,
- column: 33
- },
- end: {
- line: 1,
- column: 35
- }
- }
- },
- operator: "in",
- right: {
- type: "ArrayExpression",
- elements: [],
- loc: {
- start: {
- line: 1,
- column: 39
- },
- end: {
- line: 1,
- column: 41
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 33
- },
- end: {
- line: 1,
- column: 41
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 26
- },
- end: {
- line: 1,
- column: 41
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 24
- },
- end: {
- line: 1,
- column: 43
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 13
- },
- end: {
- line: 1,
- column: 43
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 9
- },
- end: {
- line: 1,
- column: 43
- }
- }
- }
- ],
- kind: "var",
- loc: {
- start: {
- line: 1,
- column: 5
- },
- end: {
- line: 1,
- column: 43
- }
- }
- },
- right: {
- type: "Identifier",
- name: "list",
- loc: {
- start: {
- line: 1,
- column: 47
- },
- end: {
- line: 1,
- column: 51
- }
- }
- },
- body: {
- type: "ExpressionStatement",
- expression: {
- type: "CallExpression",
- callee: {
- type: "Identifier",
- name: "process",
- loc: {
- start: {
- line: 1,
- column: 53
- },
- end: {
- line: 1,
- column: 60
- }
- }
- },
- arguments: [
- {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 61
- },
- end: {
- line: 1,
- column: 62
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 53
- },
- end: {
- line: 1,
- column: 63
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 53
- },
- end: {
- line: 1,
- column: 64
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 64
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 64
- }
- }
-});
-
-test("while (true) { continue; }", {
- type: "Program",
- body: [
- {
- type: "WhileStatement",
- test: {
- type: "Literal",
- value: true,
- loc: {
- start: {
- line: 1,
- column: 7
- },
- end: {
- line: 1,
- column: 11
- }
- }
- },
- body: {
- type: "BlockStatement",
- body: [
- {
- type: "ContinueStatement",
- label: null,
- loc: {
- start: {
- line: 1,
- column: 15
- },
- end: {
- line: 1,
- column: 24
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 13
- },
- end: {
- line: 1,
- column: 26
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 26
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 26
- }
- }
-});
-
-test("while (true) { continue }", {
- type: "Program",
- body: [
- {
- type: "WhileStatement",
- test: {
- type: "Literal",
- value: true,
- loc: {
- start: {
- line: 1,
- column: 7
- },
- end: {
- line: 1,
- column: 11
- }
- }
- },
- body: {
- type: "BlockStatement",
- body: [
- {
- type: "ContinueStatement",
- label: null,
- loc: {
- start: {
- line: 1,
- column: 15
- },
- end: {
- line: 1,
- column: 23
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 13
- },
- end: {
- line: 1,
- column: 25
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 25
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 25
- }
- }
-});
-
-test("done: while (true) { continue done }", {
- type: "Program",
- body: [
- {
- type: "LabeledStatement",
- body: {
- type: "WhileStatement",
- test: {
- type: "Literal",
- value: true,
- loc: {
- start: {
- line: 1,
- column: 13
- },
- end: {
- line: 1,
- column: 17
- }
- }
- },
- body: {
- type: "BlockStatement",
- body: [
- {
- type: "ContinueStatement",
- label: {
- type: "Identifier",
- name: "done",
- loc: {
- start: {
- line: 1,
- column: 30
- },
- end: {
- line: 1,
- column: 34
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 21
- },
- end: {
- line: 1,
- column: 34
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 19
- },
- end: {
- line: 1,
- column: 36
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 6
- },
- end: {
- line: 1,
- column: 36
- }
- }
- },
- label: {
- type: "Identifier",
- name: "done",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 4
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 36
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 36
- }
- }
-});
-
-test("done: while (true) { continue done; }", {
- type: "Program",
- body: [
- {
- type: "LabeledStatement",
- body: {
- type: "WhileStatement",
- test: {
- type: "Literal",
- value: true,
- loc: {
- start: {
- line: 1,
- column: 13
- },
- end: {
- line: 1,
- column: 17
- }
- }
- },
- body: {
- type: "BlockStatement",
- body: [
- {
- type: "ContinueStatement",
- label: {
- type: "Identifier",
- name: "done",
- loc: {
- start: {
- line: 1,
- column: 30
- },
- end: {
- line: 1,
- column: 34
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 21
- },
- end: {
- line: 1,
- column: 35
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 19
- },
- end: {
- line: 1,
- column: 37
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 6
- },
- end: {
- line: 1,
- column: 37
- }
- }
- },
- label: {
- type: "Identifier",
- name: "done",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 4
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 37
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 37
- }
- }
-});
-
-test("while (true) { break }", {
- type: "Program",
- body: [
- {
- type: "WhileStatement",
- test: {
- type: "Literal",
- value: true,
- loc: {
- start: {
- line: 1,
- column: 7
- },
- end: {
- line: 1,
- column: 11
- }
- }
- },
- body: {
- type: "BlockStatement",
- body: [
- {
- type: "BreakStatement",
- label: null,
- loc: {
- start: {
- line: 1,
- column: 15
- },
- end: {
- line: 1,
- column: 20
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 13
- },
- end: {
- line: 1,
- column: 22
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 22
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 22
- }
- }
-});
-
-test("done: while (true) { break done }", {
- type: "Program",
- body: [
- {
- type: "LabeledStatement",
- body: {
- type: "WhileStatement",
- test: {
- type: "Literal",
- value: true,
- loc: {
- start: {
- line: 1,
- column: 13
- },
- end: {
- line: 1,
- column: 17
- }
- }
- },
- body: {
- type: "BlockStatement",
- body: [
- {
- type: "BreakStatement",
- label: {
- type: "Identifier",
- name: "done",
- loc: {
- start: {
- line: 1,
- column: 27
- },
- end: {
- line: 1,
- column: 31
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 21
- },
- end: {
- line: 1,
- column: 31
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 19
- },
- end: {
- line: 1,
- column: 33
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 6
- },
- end: {
- line: 1,
- column: 33
- }
- }
- },
- label: {
- type: "Identifier",
- name: "done",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 4
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 33
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 33
- }
- }
-});
-
-test("done: while (true) { break done; }", {
- type: "Program",
- body: [
- {
- type: "LabeledStatement",
- body: {
- type: "WhileStatement",
- test: {
- type: "Literal",
- value: true,
- loc: {
- start: {
- line: 1,
- column: 13
- },
- end: {
- line: 1,
- column: 17
- }
- }
- },
- body: {
- type: "BlockStatement",
- body: [
- {
- type: "BreakStatement",
- label: {
- type: "Identifier",
- name: "done",
- loc: {
- start: {
- line: 1,
- column: 27
- },
- end: {
- line: 1,
- column: 31
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 21
- },
- end: {
- line: 1,
- column: 32
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 19
- },
- end: {
- line: 1,
- column: 34
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 6
- },
- end: {
- line: 1,
- column: 34
- }
- }
- },
- label: {
- type: "Identifier",
- name: "done",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 4
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 34
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 34
- }
- }
-});
-
-test("(function(){ return })", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "FunctionExpression",
- id: null,
- params: [],
- body: {
- type: "BlockStatement",
- body: [
- {
- type: "ReturnStatement",
- argument: null,
- loc: {
- start: {
- line: 1,
- column: 13
- },
- end: {
- line: 1,
- column: 19
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 11
- },
- end: {
- line: 1,
- column: 21
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 1
- },
- end: {
- line: 1,
- column: 21
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 22
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 22
- }
- }
-});
-
-test("(function(){ return; })", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "FunctionExpression",
- id: null,
- params: [],
- body: {
- type: "BlockStatement",
- body: [
- {
- type: "ReturnStatement",
- argument: null,
- loc: {
- start: {
- line: 1,
- column: 13
- },
- end: {
- line: 1,
- column: 20
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 11
- },
- end: {
- line: 1,
- column: 22
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 1
- },
- end: {
- line: 1,
- column: 22
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 23
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 23
- }
- }
-});
-
-test("(function(){ return x; })", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "FunctionExpression",
- id: null,
- params: [],
- body: {
- type: "BlockStatement",
- body: [
- {
- type: "ReturnStatement",
- argument: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 20
- },
- end: {
- line: 1,
- column: 21
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 13
- },
- end: {
- line: 1,
- column: 22
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 11
- },
- end: {
- line: 1,
- column: 24
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 1
- },
- end: {
- line: 1,
- column: 24
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 25
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 25
- }
- }
-});
-
-test("(function(){ return x * y })", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "FunctionExpression",
- id: null,
- params: [],
- body: {
- type: "BlockStatement",
- body: [
- {
- type: "ReturnStatement",
- argument: {
- type: "BinaryExpression",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 20
- },
- end: {
- line: 1,
- column: 21
- }
- }
- },
- operator: "*",
- right: {
- type: "Identifier",
- name: "y",
- loc: {
- start: {
- line: 1,
- column: 24
- },
- end: {
- line: 1,
- column: 25
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 20
- },
- end: {
- line: 1,
- column: 25
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 13
- },
- end: {
- line: 1,
- column: 25
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 11
- },
- end: {
- line: 1,
- column: 27
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 1
- },
- end: {
- line: 1,
- column: 27
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 28
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 28
- }
- }
-});
-
-test("with (x) foo = bar", {
- type: "Program",
- body: [
- {
- type: "WithStatement",
- object: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 6
- },
- end: {
- line: 1,
- column: 7
- }
- }
- },
- body: {
- type: "ExpressionStatement",
- expression: {
- type: "AssignmentExpression",
- operator: "=",
- left: {
- type: "Identifier",
- name: "foo",
- loc: {
- start: {
- line: 1,
- column: 9
- },
- end: {
- line: 1,
- column: 12
- }
- }
- },
- right: {
- type: "Identifier",
- name: "bar",
- loc: {
- start: {
- line: 1,
- column: 15
- },
- end: {
- line: 1,
- column: 18
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 9
- },
- end: {
- line: 1,
- column: 18
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 9
- },
- end: {
- line: 1,
- column: 18
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 18
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 18
- }
- }
-});
-
-test("with (x) foo = bar;", {
- type: "Program",
- body: [
- {
- type: "WithStatement",
- object: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 6
- },
- end: {
- line: 1,
- column: 7
- }
- }
- },
- body: {
- type: "ExpressionStatement",
- expression: {
- type: "AssignmentExpression",
- operator: "=",
- left: {
- type: "Identifier",
- name: "foo",
- loc: {
- start: {
- line: 1,
- column: 9
- },
- end: {
- line: 1,
- column: 12
- }
- }
- },
- right: {
- type: "Identifier",
- name: "bar",
- loc: {
- start: {
- line: 1,
- column: 15
- },
- end: {
- line: 1,
- column: 18
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 9
- },
- end: {
- line: 1,
- column: 18
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 9
- },
- end: {
- line: 1,
- column: 19
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 19
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 19
- }
- }
-});
-
-test("with (x) { foo = bar }", {
- type: "Program",
- body: [
- {
- type: "WithStatement",
- object: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 6
- },
- end: {
- line: 1,
- column: 7
- }
- }
- },
- body: {
- type: "BlockStatement",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "AssignmentExpression",
- operator: "=",
- left: {
- type: "Identifier",
- name: "foo",
- loc: {
- start: {
- line: 1,
- column: 11
- },
- end: {
- line: 1,
- column: 14
- }
- }
- },
- right: {
- type: "Identifier",
- name: "bar",
- loc: {
- start: {
- line: 1,
- column: 17
- },
- end: {
- line: 1,
- column: 20
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 11
- },
- end: {
- line: 1,
- column: 20
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 11
- },
- end: {
- line: 1,
- column: 20
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 9
- },
- end: {
- line: 1,
- column: 22
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 22
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 22
- }
- }
-});
-
-test("switch (x) {}", {
- type: "Program",
- body: [
- {
- type: "SwitchStatement",
- discriminant: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 8
- },
- end: {
- line: 1,
- column: 9
- }
- }
- },
- cases: [],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 13
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 13
- }
- }
-});
-
-test("switch (answer) { case 42: hi(); break; }", {
- type: "Program",
- body: [
- {
- type: "SwitchStatement",
- discriminant: {
- type: "Identifier",
- name: "answer",
- loc: {
- start: {
- line: 1,
- column: 8
- },
- end: {
- line: 1,
- column: 14
- }
- }
- },
- cases: [
- {
- type: "SwitchCase",
- consequent: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "CallExpression",
- callee: {
- type: "Identifier",
- name: "hi",
- loc: {
- start: {
- line: 1,
- column: 27
- },
- end: {
- line: 1,
- column: 29
- }
- }
- },
- arguments: [],
- loc: {
- start: {
- line: 1,
- column: 27
- },
- end: {
- line: 1,
- column: 31
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 27
- },
- end: {
- line: 1,
- column: 32
- }
- }
- },
- {
- type: "BreakStatement",
- label: null,
- loc: {
- start: {
- line: 1,
- column: 33
- },
- end: {
- line: 1,
- column: 39
- }
- }
- }
- ],
- test: {
- type: "Literal",
- value: 42,
- loc: {
- start: {
- line: 1,
- column: 23
- },
- end: {
- line: 1,
- column: 25
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 18
- },
- end: {
- line: 1,
- column: 39
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 41
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 41
- }
- }
-});
-
-test("switch (answer) { case 42: hi(); break; default: break }", {
- type: "Program",
- body: [
- {
- type: "SwitchStatement",
- discriminant: {
- type: "Identifier",
- name: "answer",
- loc: {
- start: {
- line: 1,
- column: 8
- },
- end: {
- line: 1,
- column: 14
- }
- }
- },
- cases: [
- {
- type: "SwitchCase",
- consequent: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "CallExpression",
- callee: {
- type: "Identifier",
- name: "hi",
- loc: {
- start: {
- line: 1,
- column: 27
- },
- end: {
- line: 1,
- column: 29
- }
- }
- },
- arguments: [],
- loc: {
- start: {
- line: 1,
- column: 27
- },
- end: {
- line: 1,
- column: 31
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 27
- },
- end: {
- line: 1,
- column: 32
- }
- }
- },
- {
- type: "BreakStatement",
- label: null,
- loc: {
- start: {
- line: 1,
- column: 33
- },
- end: {
- line: 1,
- column: 39
- }
- }
- }
- ],
- test: {
- type: "Literal",
- value: 42,
- loc: {
- start: {
- line: 1,
- column: 23
- },
- end: {
- line: 1,
- column: 25
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 18
- },
- end: {
- line: 1,
- column: 39
- }
- }
- },
- {
- type: "SwitchCase",
- consequent: [
- {
- type: "BreakStatement",
- label: null,
- loc: {
- start: {
- line: 1,
- column: 49
- },
- end: {
- line: 1,
- column: 54
- }
- }
- }
- ],
- test: null,
- loc: {
- start: {
- line: 1,
- column: 40
- },
- end: {
- line: 1,
- column: 54
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 56
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 56
- }
- }
-});
-
-test("start: for (;;) break start", {
- type: "Program",
- body: [
- {
- type: "LabeledStatement",
- body: {
- type: "ForStatement",
- init: null,
- test: null,
- update: null,
- body: {
- type: "BreakStatement",
- label: {
- type: "Identifier",
- name: "start",
- loc: {
- start: {
- line: 1,
- column: 22
- },
- end: {
- line: 1,
- column: 27
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 16
- },
- end: {
- line: 1,
- column: 27
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 7
- },
- end: {
- line: 1,
- column: 27
- }
- }
- },
- label: {
- type: "Identifier",
- name: "start",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 5
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 27
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 27
- }
- }
-});
-
-test("start: while (true) break start", {
- type: "Program",
- body: [
- {
- type: "LabeledStatement",
- body: {
- type: "WhileStatement",
- test: {
- type: "Literal",
- value: true,
- loc: {
- start: {
- line: 1,
- column: 14
- },
- end: {
- line: 1,
- column: 18
- }
- }
- },
- body: {
- type: "BreakStatement",
- label: {
- type: "Identifier",
- name: "start",
- loc: {
- start: {
- line: 1,
- column: 26
- },
- end: {
- line: 1,
- column: 31
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 20
- },
- end: {
- line: 1,
- column: 31
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 7
- },
- end: {
- line: 1,
- column: 31
- }
- }
- },
- label: {
- type: "Identifier",
- name: "start",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 5
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 31
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 31
- }
- }
-});
-
-test("throw x;", {
- type: "Program",
- body: [
- {
- type: "ThrowStatement",
- argument: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 6
- },
- end: {
- line: 1,
- column: 7
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 8
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 8
- }
- }
-});
-
-test("throw x * y", {
- type: "Program",
- body: [
- {
- type: "ThrowStatement",
- argument: {
- type: "BinaryExpression",
- left: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 6
- },
- end: {
- line: 1,
- column: 7
- }
- }
- },
- operator: "*",
- right: {
- type: "Identifier",
- name: "y",
- loc: {
- start: {
- line: 1,
- column: 10
- },
- end: {
- line: 1,
- column: 11
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 6
- },
- end: {
- line: 1,
- column: 11
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 11
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 11
- }
- }
-});
-
-test("throw { message: \"Error\" }", {
- type: "Program",
- body: [
- {
- type: "ThrowStatement",
- argument: {
- type: "ObjectExpression",
- properties: [
- {
- type: "Property",
- key: {
- type: "Identifier",
- name: "message",
- loc: {
- start: {
- line: 1,
- column: 8
- },
- end: {
- line: 1,
- column: 15
- }
- }
- },
- value: {
- type: "Literal",
- value: "Error",
- loc: {
- start: {
- line: 1,
- column: 17
- },
- end: {
- line: 1,
- column: 24
- }
- }
- },
- kind: "init"
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 6
- },
- end: {
- line: 1,
- column: 26
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 26
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 26
- }
- }
-});
-
-test("try { } catch (e) { }", {
- type: "Program",
- body: [
- {
- type: "TryStatement",
- block: {
- type: "BlockStatement",
- body: [],
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 7
- }
- }
- },
- handler: {
- type: "CatchClause",
- param: {
- type: "Identifier",
- name: "e",
- loc: {
- start: {
- line: 1,
- column: 15
- },
- end: {
- line: 1,
- column: 16
- }
- }
- },
- guard: null,
- body: {
- type: "BlockStatement",
- body: [],
- loc: {
- start: {
- line: 1,
- column: 18
- },
- end: {
- line: 1,
- column: 21
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 8
- },
- end: {
- line: 1,
- column: 21
- }
- }
- }
- ,
- finalizer: null,
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 21
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 21
- }
- }
-});
-
-test("try { } catch (eval) { }", {
- type: "Program",
- body: [
- {
- type: "TryStatement",
- block: {
- type: "BlockStatement",
- body: [],
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 7
- }
- }
- },
- handler:
- {
- type: "CatchClause",
- param: {
- type: "Identifier",
- name: "eval",
- loc: {
- start: {
- line: 1,
- column: 15
- },
- end: {
- line: 1,
- column: 19
- }
- }
- },
- guard: null,
- body: {
- type: "BlockStatement",
- body: [],
- loc: {
- start: {
- line: 1,
- column: 21
- },
- end: {
- line: 1,
- column: 24
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 8
- },
- end: {
- line: 1,
- column: 24
- }
- }
- }
- ,
- finalizer: null,
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 24
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 24
- }
- }
-});
-
-test("try { } catch (arguments) { }", {
- type: "Program",
- body: [
- {
- type: "TryStatement",
- block: {
- type: "BlockStatement",
- body: [],
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 7
- }
- }
- },
- handler:
- {
- type: "CatchClause",
- param: {
- type: "Identifier",
- name: "arguments",
- loc: {
- start: {
- line: 1,
- column: 15
- },
- end: {
- line: 1,
- column: 24
- }
- }
- },
- guard: null,
- body: {
- type: "BlockStatement",
- body: [],
- loc: {
- start: {
- line: 1,
- column: 26
- },
- end: {
- line: 1,
- column: 29
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 8
- },
- end: {
- line: 1,
- column: 29
- }
- }
- }
- ,
- finalizer: null,
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 29
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 29
- }
- }
-});
-
-test("try { } catch (e) { say(e) }", {
- type: "Program",
- body: [
- {
- type: "TryStatement",
- block: {
- type: "BlockStatement",
- body: [],
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 7
- }
- }
- },
- handler:
- {
- type: "CatchClause",
- param: {
- type: "Identifier",
- name: "e",
- loc: {
- start: {
- line: 1,
- column: 15
- },
- end: {
- line: 1,
- column: 16
- }
- }
- },
- guard: null,
- body: {
- type: "BlockStatement",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "CallExpression",
- callee: {
- type: "Identifier",
- name: "say",
- loc: {
- start: {
- line: 1,
- column: 20
- },
- end: {
- line: 1,
- column: 23
- }
- }
- },
- arguments: [
- {
- type: "Identifier",
- name: "e",
- loc: {
- start: {
- line: 1,
- column: 24
- },
- end: {
- line: 1,
- column: 25
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 20
- },
- end: {
- line: 1,
- column: 26
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 20
- },
- end: {
- line: 1,
- column: 26
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 18
- },
- end: {
- line: 1,
- column: 28
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 8
- },
- end: {
- line: 1,
- column: 28
- }
- }
- }
- ,
- finalizer: null,
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 28
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 28
- }
- }
-});
-
-test("try { } finally { cleanup(stuff) }", {
- type: "Program",
- body: [
- {
- type: "TryStatement",
- block: {
- type: "BlockStatement",
- body: [],
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 7
- }
- }
- },
- handler: null,
- finalizer: {
- type: "BlockStatement",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "CallExpression",
- callee: {
- type: "Identifier",
- name: "cleanup",
- loc: {
- start: {
- line: 1,
- column: 18
- },
- end: {
- line: 1,
- column: 25
- }
- }
- },
- arguments: [
- {
- type: "Identifier",
- name: "stuff",
- loc: {
- start: {
- line: 1,
- column: 26
- },
- end: {
- line: 1,
- column: 31
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 18
- },
- end: {
- line: 1,
- column: 32
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 18
- },
- end: {
- line: 1,
- column: 32
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 16
- },
- end: {
- line: 1,
- column: 34
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 34
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 34
- }
- }
-});
-
-test("try { doThat(); } catch (e) { say(e) }", {
- type: "Program",
- body: [
- {
- type: "TryStatement",
- block: {
- type: "BlockStatement",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "CallExpression",
- callee: {
- type: "Identifier",
- name: "doThat",
- loc: {
- start: {
- line: 1,
- column: 6
- },
- end: {
- line: 1,
- column: 12
- }
- }
- },
- arguments: [],
- loc: {
- start: {
- line: 1,
- column: 6
- },
- end: {
- line: 1,
- column: 14
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 6
- },
- end: {
- line: 1,
- column: 15
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 17
- }
- }
- },
- handler:
- {
- type: "CatchClause",
- param: {
- type: "Identifier",
- name: "e",
- loc: {
- start: {
- line: 1,
- column: 25
- },
- end: {
- line: 1,
- column: 26
- }
- }
- },
- guard: null,
- body: {
- type: "BlockStatement",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "CallExpression",
- callee: {
- type: "Identifier",
- name: "say",
- loc: {
- start: {
- line: 1,
- column: 30
- },
- end: {
- line: 1,
- column: 33
- }
- }
- },
- arguments: [
- {
- type: "Identifier",
- name: "e",
- loc: {
- start: {
- line: 1,
- column: 34
- },
- end: {
- line: 1,
- column: 35
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 30
- },
- end: {
- line: 1,
- column: 36
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 30
- },
- end: {
- line: 1,
- column: 36
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 28
- },
- end: {
- line: 1,
- column: 38
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 18
- },
- end: {
- line: 1,
- column: 38
- }
- }
- }
- ,
- finalizer: null,
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 38
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 38
- }
- }
-});
-
-test("try { doThat(); } catch (e) { say(e) } finally { cleanup(stuff) }", {
- type: "Program",
- body: [
- {
- type: "TryStatement",
- block: {
- type: "BlockStatement",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "CallExpression",
- callee: {
- type: "Identifier",
- name: "doThat",
- loc: {
- start: {
- line: 1,
- column: 6
- },
- end: {
- line: 1,
- column: 12
- }
- }
- },
- arguments: [],
- loc: {
- start: {
- line: 1,
- column: 6
- },
- end: {
- line: 1,
- column: 14
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 6
- },
- end: {
- line: 1,
- column: 15
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 17
- }
- }
- },
- handler:
- {
- type: "CatchClause",
- param: {
- type: "Identifier",
- name: "e",
- loc: {
- start: {
- line: 1,
- column: 25
- },
- end: {
- line: 1,
- column: 26
- }
- }
- },
- guard: null,
- body: {
- type: "BlockStatement",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "CallExpression",
- callee: {
- type: "Identifier",
- name: "say",
- loc: {
- start: {
- line: 1,
- column: 30
- },
- end: {
- line: 1,
- column: 33
- }
- }
- },
- arguments: [
- {
- type: "Identifier",
- name: "e",
- loc: {
- start: {
- line: 1,
- column: 34
- },
- end: {
- line: 1,
- column: 35
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 30
- },
- end: {
- line: 1,
- column: 36
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 30
- },
- end: {
- line: 1,
- column: 36
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 28
- },
- end: {
- line: 1,
- column: 38
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 18
- },
- end: {
- line: 1,
- column: 38
- }
- }
- }
- ,
- finalizer: {
- type: "BlockStatement",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "CallExpression",
- callee: {
- type: "Identifier",
- name: "cleanup",
- loc: {
- start: {
- line: 1,
- column: 49
- },
- end: {
- line: 1,
- column: 56
- }
- }
- },
- arguments: [
- {
- type: "Identifier",
- name: "stuff",
- loc: {
- start: {
- line: 1,
- column: 57
- },
- end: {
- line: 1,
- column: 62
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 49
- },
- end: {
- line: 1,
- column: 63
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 49
- },
- end: {
- line: 1,
- column: 63
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 47
- },
- end: {
- line: 1,
- column: 65
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 65
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 65
- }
- }
-});
-
-test("debugger;", {
- type: "Program",
- body: [
- {
- type: "DebuggerStatement",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 9
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 9
- }
- }
-});
-
-test("function hello() { sayHi(); }", {
- type: "Program",
- body: [
- {
- type: "FunctionDeclaration",
- id: {
- type: "Identifier",
- name: "hello",
- loc: {
- start: {
- line: 1,
- column: 9
- },
- end: {
- line: 1,
- column: 14
- }
- }
- },
- params: [],
- body: {
- type: "BlockStatement",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "CallExpression",
- callee: {
- type: "Identifier",
- name: "sayHi",
- loc: {
- start: {
- line: 1,
- column: 19
- },
- end: {
- line: 1,
- column: 24
- }
- }
- },
- arguments: [],
- loc: {
- start: {
- line: 1,
- column: 19
- },
- end: {
- line: 1,
- column: 26
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 19
- },
- end: {
- line: 1,
- column: 27
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 17
- },
- end: {
- line: 1,
- column: 29
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 29
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 29
- }
- }
-});
-
-test("function eval() { }", {
- type: "Program",
- body: [
- {
- type: "FunctionDeclaration",
- id: {
- type: "Identifier",
- name: "eval",
- loc: {
- start: {
- line: 1,
- column: 9
- },
- end: {
- line: 1,
- column: 13
- }
- }
- },
- params: [],
- body: {
- type: "BlockStatement",
- body: [],
- loc: {
- start: {
- line: 1,
- column: 16
- },
- end: {
- line: 1,
- column: 19
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 19
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 19
- }
- }
-});
-
-test("function arguments() { }", {
- type: "Program",
- body: [
- {
- type: "FunctionDeclaration",
- id: {
- type: "Identifier",
- name: "arguments",
- loc: {
- start: {
- line: 1,
- column: 9
- },
- end: {
- line: 1,
- column: 18
- }
- }
- },
- params: [],
- body: {
- type: "BlockStatement",
- body: [],
- loc: {
- start: {
- line: 1,
- column: 21
- },
- end: {
- line: 1,
- column: 24
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 24
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 24
- }
- }
-});
-
-test("function test(t, t) { }", {
- type: "Program",
- body: [
- {
- type: "FunctionDeclaration",
- id: {
- type: "Identifier",
- name: "test",
- loc: {
- start: {
- line: 1,
- column: 9
- },
- end: {
- line: 1,
- column: 13
- }
- }
- },
- params: [
- {
- type: "Identifier",
- name: "t",
- loc: {
- start: {
- line: 1,
- column: 14
- },
- end: {
- line: 1,
- column: 15
- }
- }
- },
- {
- type: "Identifier",
- name: "t",
- loc: {
- start: {
- line: 1,
- column: 17
- },
- end: {
- line: 1,
- column: 18
- }
- }
- }
- ],
- body: {
- type: "BlockStatement",
- body: [],
- loc: {
- start: {
- line: 1,
- column: 20
- },
- end: {
- line: 1,
- column: 23
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 23
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 23
- }
- }
-});
-
-test("(function test(t, t) { })", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "FunctionExpression",
- id: {
- type: "Identifier",
- name: "test",
- loc: {
- start: {
- line: 1,
- column: 10
- },
- end: {
- line: 1,
- column: 14
- }
- }
- },
- params: [
- {
- type: "Identifier",
- name: "t",
- loc: {
- start: {
- line: 1,
- column: 15
- },
- end: {
- line: 1,
- column: 16
- }
- }
- },
- {
- type: "Identifier",
- name: "t",
- loc: {
- start: {
- line: 1,
- column: 18
- },
- end: {
- line: 1,
- column: 19
- }
- }
- }
- ],
- body: {
- type: "BlockStatement",
- body: [],
- loc: {
- start: {
- line: 1,
- column: 21
- },
- end: {
- line: 1,
- column: 24
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 1
- },
- end: {
- line: 1,
- column: 24
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 25
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 25
- }
- }
-});
-
-test("function eval() { function inner() { \"use strict\" } }", {
- type: "Program",
- body: [
- {
- type: "FunctionDeclaration",
- id: {
- type: "Identifier",
- name: "eval",
- loc: {
- start: {
- line: 1,
- column: 9
- },
- end: {
- line: 1,
- column: 13
- }
- }
- },
- params: [],
- body: {
- type: "BlockStatement",
- body: [
- {
- type: "FunctionDeclaration",
- id: {
- type: "Identifier",
- name: "inner",
- loc: {
- start: {
- line: 1,
- column: 27
- },
- end: {
- line: 1,
- column: 32
- }
- }
- },
- params: [],
- body: {
- type: "BlockStatement",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "Literal",
- value: "use strict",
- loc: {
- start: {
- line: 1,
- column: 37
- },
- end: {
- line: 1,
- column: 49
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 37
- },
- end: {
- line: 1,
- column: 49
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 35
- },
- end: {
- line: 1,
- column: 51
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 18
- },
- end: {
- line: 1,
- column: 51
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 16
- },
- end: {
- line: 1,
- column: 53
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 53
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 53
- }
- }
-});
-
-test("function hello(a) { sayHi(); }", {
- type: "Program",
- body: [
- {
- type: "FunctionDeclaration",
- id: {
- type: "Identifier",
- name: "hello",
- loc: {
- start: {
- line: 1,
- column: 9
- },
- end: {
- line: 1,
- column: 14
- }
- }
- },
- params: [
- {
- type: "Identifier",
- name: "a",
- loc: {
- start: {
- line: 1,
- column: 15
- },
- end: {
- line: 1,
- column: 16
- }
- }
- }
- ],
- body: {
- type: "BlockStatement",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "CallExpression",
- callee: {
- type: "Identifier",
- name: "sayHi",
- loc: {
- start: {
- line: 1,
- column: 20
- },
- end: {
- line: 1,
- column: 25
- }
- }
- },
- arguments: [],
- loc: {
- start: {
- line: 1,
- column: 20
- },
- end: {
- line: 1,
- column: 27
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 20
- },
- end: {
- line: 1,
- column: 28
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 18
- },
- end: {
- line: 1,
- column: 30
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 30
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 30
- }
- }
-});
-
-test("function hello(a, b) { sayHi(); }", {
- type: "Program",
- body: [
- {
- type: "FunctionDeclaration",
- id: {
- type: "Identifier",
- name: "hello",
- loc: {
- start: {
- line: 1,
- column: 9
- },
- end: {
- line: 1,
- column: 14
- }
- }
- },
- params: [
- {
- type: "Identifier",
- name: "a",
- loc: {
- start: {
- line: 1,
- column: 15
- },
- end: {
- line: 1,
- column: 16
- }
- }
- },
- {
- type: "Identifier",
- name: "b",
- loc: {
- start: {
- line: 1,
- column: 18
- },
- end: {
- line: 1,
- column: 19
- }
- }
- }
- ],
- body: {
- type: "BlockStatement",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "CallExpression",
- callee: {
- type: "Identifier",
- name: "sayHi",
- loc: {
- start: {
- line: 1,
- column: 23
- },
- end: {
- line: 1,
- column: 28
- }
- }
- },
- arguments: [],
- loc: {
- start: {
- line: 1,
- column: 23
- },
- end: {
- line: 1,
- column: 30
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 23
- },
- end: {
- line: 1,
- column: 31
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 21
- },
- end: {
- line: 1,
- column: 33
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 33
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 33
- }
- }
-});
-
-test("function hello(...rest) { }", {
- type: "Program",
- body: [
- {
- type: "FunctionDeclaration",
- id: {
- type: "Identifier",
- name: "hello",
- loc: {
- start: {
- line: 1,
- column: 9
- },
- end: {
- line: 1,
- column: 14
- }
- }
- },
- params: [{
- type: "RestElement",
- argument: {
- type: "Identifier",
- name: "rest",
- loc: {
- start: {
- line: 1,
- column: 18
- },
- end: {
- line: 1,
- column: 22
- }
- }
- }
- }],
- body: {
- type: "BlockStatement",
- body: [],
- loc: {
- start: {
- line: 1,
- column: 24
- },
- end: {
- line: 1,
- column: 27
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 27
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 27
- }
- }
-}, {
- ecmaVersion: 6,
- locations: true
-});
-
-test("function hello(a, ...rest) { }", {
- type: "Program",
- body: [
- {
- type: "FunctionDeclaration",
- id: {
- type: "Identifier",
- name: "hello",
- loc: {
- start: {
- line: 1,
- column: 9
- },
- end: {
- line: 1,
- column: 14
- }
- }
- },
- params: [
- {
- type: "Identifier",
- name: "a",
- loc: {
- start: {
- line: 1,
- column: 15
- },
- end: {
- line: 1,
- column: 16
- }
- }
- },
- {
- type: "RestElement",
- argument: {
- type: "Identifier",
- name: "rest",
- loc: {
- start: {
- line: 1,
- column: 21
- },
- end: {
- line: 1,
- column: 25
- }
- }
- }
- }
- ],
- body: {
- type: "BlockStatement",
- body: [],
- loc: {
- start: {
- line: 1,
- column: 27
- },
- end: {
- line: 1,
- column: 30
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 30
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 30
- }
- }
-}, {
- ecmaVersion: 6,
- locations: true
-});
-
-test("var hi = function() { sayHi() };", {
- type: "Program",
- body: [
- {
- type: "VariableDeclaration",
- declarations: [
- {
- type: "VariableDeclarator",
- id: {
- type: "Identifier",
- name: "hi",
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 6
- }
- }
- },
- init: {
- type: "FunctionExpression",
- id: null,
- params: [],
- body: {
- type: "BlockStatement",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "CallExpression",
- callee: {
- type: "Identifier",
- name: "sayHi",
- loc: {
- start: {
- line: 1,
- column: 22
- },
- end: {
- line: 1,
- column: 27
- }
- }
- },
- arguments: [],
- loc: {
- start: {
- line: 1,
- column: 22
- },
- end: {
- line: 1,
- column: 29
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 22
- },
- end: {
- line: 1,
- column: 29
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 20
- },
- end: {
- line: 1,
- column: 31
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 9
- },
- end: {
- line: 1,
- column: 31
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 31
- }
- }
- }
- ],
- kind: "var",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 32
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 32
- }
- }
-});
-
-test("var hi = function (...r) { sayHi() };", {
- type: "Program",
- body: [
- {
- type: "VariableDeclaration",
- declarations: [
- {
- type: "VariableDeclarator",
- id: {
- type: "Identifier",
- name: "hi",
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 6
- }
- }
- },
- init: {
- type: "FunctionExpression",
- id: null,
- params: [{
- type: "RestElement",
- argument: {
- type: "Identifier",
- name: "r",
- loc: {
- start: {
- line: 1,
- column: 22
- },
- end: {
- line: 1,
- column: 23
- }
- }
- }
- }],
- body: {
- type: "BlockStatement",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "CallExpression",
- callee: {
- type: "Identifier",
- name: "sayHi",
- loc: {
- start: {
- line: 1,
- column: 27
- },
- end: {
- line: 1,
- column: 32
- }
- }
- },
- arguments: [],
- loc: {
- start: {
- line: 1,
- column: 27
- },
- end: {
- line: 1,
- column: 34
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 27
- },
- end: {
- line: 1,
- column: 34
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 25
- },
- end: {
- line: 1,
- column: 36
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 9
- },
- end: {
- line: 1,
- column: 36
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 36
- }
- }
- }
- ],
- kind: "var",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 37
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 37
- }
- }
-}, {
- ecmaVersion: 6,
- locations: true
-});
-
-test("var hi = function eval() { };", {
- type: "Program",
- body: [
- {
- type: "VariableDeclaration",
- declarations: [
- {
- type: "VariableDeclarator",
- id: {
- type: "Identifier",
- name: "hi",
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 6
- }
- }
- },
- init: {
- type: "FunctionExpression",
- id: {
- type: "Identifier",
- name: "eval",
- loc: {
- start: {
- line: 1,
- column: 18
- },
- end: {
- line: 1,
- column: 22
- }
- }
- },
- params: [],
- body: {
- type: "BlockStatement",
- body: [],
- loc: {
- start: {
- line: 1,
- column: 25
- },
- end: {
- line: 1,
- column: 28
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 9
- },
- end: {
- line: 1,
- column: 28
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 28
- }
- }
- }
- ],
- kind: "var",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 29
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 29
- }
- }
-});
-
-test("var hi = function arguments() { };", {
- type: "Program",
- body: [
- {
- type: "VariableDeclaration",
- declarations: [
- {
- type: "VariableDeclarator",
- id: {
- type: "Identifier",
- name: "hi",
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 6
- }
- }
- },
- init: {
- type: "FunctionExpression",
- id: {
- type: "Identifier",
- name: "arguments",
- loc: {
- start: {
- line: 1,
- column: 18
- },
- end: {
- line: 1,
- column: 27
- }
- }
- },
- params: [],
- body: {
- type: "BlockStatement",
- body: [],
- loc: {
- start: {
- line: 1,
- column: 30
- },
- end: {
- line: 1,
- column: 33
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 9
- },
- end: {
- line: 1,
- column: 33
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 33
- }
- }
- }
- ],
- kind: "var",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 34
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 34
- }
- }
-});
-
-test("var hello = function hi() { sayHi() };", {
- type: "Program",
- body: [
- {
- type: "VariableDeclaration",
- declarations: [
- {
- type: "VariableDeclarator",
- id: {
- type: "Identifier",
- name: "hello",
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 9
- }
- }
- },
- init: {
- type: "FunctionExpression",
- id: {
- type: "Identifier",
- name: "hi",
- loc: {
- start: {
- line: 1,
- column: 21
- },
- end: {
- line: 1,
- column: 23
- }
- }
- },
- params: [],
- body: {
- type: "BlockStatement",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "CallExpression",
- callee: {
- type: "Identifier",
- name: "sayHi",
- loc: {
- start: {
- line: 1,
- column: 28
- },
- end: {
- line: 1,
- column: 33
- }
- }
- },
- arguments: [],
- loc: {
- start: {
- line: 1,
- column: 28
- },
- end: {
- line: 1,
- column: 35
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 28
- },
- end: {
- line: 1,
- column: 35
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 26
- },
- end: {
- line: 1,
- column: 37
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 12
- },
- end: {
- line: 1,
- column: 37
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 37
- }
- }
- }
- ],
- kind: "var",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 38
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 38
- }
- }
-});
-
-test("(function(){})", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "FunctionExpression",
- id: null,
- params: [],
- body: {
- type: "BlockStatement",
- body: [],
- loc: {
- start: {
- line: 1,
- column: 11
- },
- end: {
- line: 1,
- column: 13
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 1
- },
- end: {
- line: 1,
- column: 13
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 14
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 14
- }
- }
-});
-
-test("{ x\n++y }", {
- type: "Program",
- body: [
- {
- type: "BlockStatement",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 2
- },
- end: {
- line: 1,
- column: 3
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 2
- },
- end: {
- line: 1,
- column: 3
- }
- }
- },
- {
- type: "ExpressionStatement",
- expression: {
- type: "UpdateExpression",
- operator: "++",
- prefix: true,
- argument: {
- type: "Identifier",
- name: "y",
- loc: {
- start: {
- line: 2,
- column: 2
- },
- end: {
- line: 2,
- column: 3
- }
- }
- },
- loc: {
- start: {
- line: 2,
- column: 0
- },
- end: {
- line: 2,
- column: 3
- }
- }
- },
- loc: {
- start: {
- line: 2,
- column: 0
- },
- end: {
- line: 2,
- column: 3
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 2,
- column: 5
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 2,
- column: 5
- }
- }
-});
-
-test("{ x\n--y }", {
- type: "Program",
- body: [
- {
- type: "BlockStatement",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 2
- },
- end: {
- line: 1,
- column: 3
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 2
- },
- end: {
- line: 1,
- column: 3
- }
- }
- },
- {
- type: "ExpressionStatement",
- expression: {
- type: "UpdateExpression",
- operator: "--",
- prefix: true,
- argument: {
- type: "Identifier",
- name: "y",
- loc: {
- start: {
- line: 2,
- column: 2
- },
- end: {
- line: 2,
- column: 3
- }
- }
- },
- loc: {
- start: {
- line: 2,
- column: 0
- },
- end: {
- line: 2,
- column: 3
- }
- }
- },
- loc: {
- start: {
- line: 2,
- column: 0
- },
- end: {
- line: 2,
- column: 3
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 2,
- column: 5
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 2,
- column: 5
- }
- }
-});
-
-test("var x /* comment */;", {
- type: "Program",
- body: [
- {
- type: "VariableDeclaration",
- declarations: [
- {
- type: "VariableDeclarator",
- id: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 5
- }
- }
- },
- init: null,
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 5
- }
- }
- }
- ],
- kind: "var",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 20
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 20
- }
- }
-});
-
-test("{ var x = 14, y = 3\nz; }", {
- type: "Program",
- body: [
- {
- type: "BlockStatement",
- body: [
- {
- type: "VariableDeclaration",
- declarations: [
- {
- type: "VariableDeclarator",
- id: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 6
- },
- end: {
- line: 1,
- column: 7
- }
- }
- },
- init: {
- type: "Literal",
- value: 14,
- loc: {
- start: {
- line: 1,
- column: 10
- },
- end: {
- line: 1,
- column: 12
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 6
- },
- end: {
- line: 1,
- column: 12
- }
- }
- },
- {
- type: "VariableDeclarator",
- id: {
- type: "Identifier",
- name: "y",
- loc: {
- start: {
- line: 1,
- column: 14
- },
- end: {
- line: 1,
- column: 15
- }
- }
- },
- init: {
- type: "Literal",
- value: 3,
- loc: {
- start: {
- line: 1,
- column: 18
- },
- end: {
- line: 1,
- column: 19
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 14
- },
- end: {
- line: 1,
- column: 19
- }
- }
- }
- ],
- kind: "var",
- loc: {
- start: {
- line: 1,
- column: 2
- },
- end: {
- line: 1,
- column: 19
- }
- }
- },
- {
- type: "ExpressionStatement",
- expression: {
- type: "Identifier",
- name: "z",
- loc: {
- start: {
- line: 2,
- column: 0
- },
- end: {
- line: 2,
- column: 1
- }
- }
- },
- loc: {
- start: {
- line: 2,
- column: 0
- },
- end: {
- line: 2,
- column: 2
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 2,
- column: 4
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 2,
- column: 4
- }
- }
-});
-
-test("while (true) { continue\nthere; }", {
- type: "Program",
- body: [
- {
- type: "WhileStatement",
- test: {
- type: "Literal",
- value: true,
- loc: {
- start: {
- line: 1,
- column: 7
- },
- end: {
- line: 1,
- column: 11
- }
- }
- },
- body: {
- type: "BlockStatement",
- body: [
- {
- type: "ContinueStatement",
- label: null,
- loc: {
- start: {
- line: 1,
- column: 15
- },
- end: {
- line: 1,
- column: 23
- }
- }
- },
- {
- type: "ExpressionStatement",
- expression: {
- type: "Identifier",
- name: "there",
- loc: {
- start: {
- line: 2,
- column: 0
- },
- end: {
- line: 2,
- column: 5
- }
- }
- },
- loc: {
- start: {
- line: 2,
- column: 0
- },
- end: {
- line: 2,
- column: 6
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 13
- },
- end: {
- line: 2,
- column: 8
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 2,
- column: 8
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 2,
- column: 8
- }
- }
-});
-
-test("while (true) { continue // Comment\nthere; }", {
- type: "Program",
- body: [
- {
- type: "WhileStatement",
- test: {
- type: "Literal",
- value: true,
- loc: {
- start: {
- line: 1,
- column: 7
- },
- end: {
- line: 1,
- column: 11
- }
- }
- },
- body: {
- type: "BlockStatement",
- body: [
- {
- type: "ContinueStatement",
- label: null,
- loc: {
- start: {
- line: 1,
- column: 15
- },
- end: {
- line: 1,
- column: 23
- }
- }
- },
- {
- type: "ExpressionStatement",
- expression: {
- type: "Identifier",
- name: "there",
- loc: {
- start: {
- line: 2,
- column: 0
- },
- end: {
- line: 2,
- column: 5
- }
- }
- },
- loc: {
- start: {
- line: 2,
- column: 0
- },
- end: {
- line: 2,
- column: 6
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 13
- },
- end: {
- line: 2,
- column: 8
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 2,
- column: 8
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 2,
- column: 8
- }
- }
-});
-
-test("while (true) { continue /* Multiline\nComment */there; }", {
- type: "Program",
- body: [
- {
- type: "WhileStatement",
- test: {
- type: "Literal",
- value: true,
- loc: {
- start: {
- line: 1,
- column: 7
- },
- end: {
- line: 1,
- column: 11
- }
- }
- },
- body: {
- type: "BlockStatement",
- body: [
- {
- type: "ContinueStatement",
- label: null,
- loc: {
- start: {
- line: 1,
- column: 15
- },
- end: {
- line: 1,
- column: 23
- }
- }
- },
- {
- type: "ExpressionStatement",
- expression: {
- type: "Identifier",
- name: "there",
- loc: {
- start: {
- line: 2,
- column: 10
- },
- end: {
- line: 2,
- column: 15
- }
- }
- },
- loc: {
- start: {
- line: 2,
- column: 10
- },
- end: {
- line: 2,
- column: 16
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 13
- },
- end: {
- line: 2,
- column: 18
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 2,
- column: 18
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 2,
- column: 18
- }
- }
-});
-
-test("while (true) { break\nthere; }", {
- type: "Program",
- body: [
- {
- type: "WhileStatement",
- test: {
- type: "Literal",
- value: true,
- loc: {
- start: {
- line: 1,
- column: 7
- },
- end: {
- line: 1,
- column: 11
- }
- }
- },
- body: {
- type: "BlockStatement",
- body: [
- {
- type: "BreakStatement",
- label: null,
- loc: {
- start: {
- line: 1,
- column: 15
- },
- end: {
- line: 1,
- column: 20
- }
- }
- },
- {
- type: "ExpressionStatement",
- expression: {
- type: "Identifier",
- name: "there",
- loc: {
- start: {
- line: 2,
- column: 0
- },
- end: {
- line: 2,
- column: 5
- }
- }
- },
- loc: {
- start: {
- line: 2,
- column: 0
- },
- end: {
- line: 2,
- column: 6
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 13
- },
- end: {
- line: 2,
- column: 8
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 2,
- column: 8
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 2,
- column: 8
- }
- }
-});
-
-test("while (true) { break // Comment\nthere; }", {
- type: "Program",
- body: [
- {
- type: "WhileStatement",
- test: {
- type: "Literal",
- value: true,
- loc: {
- start: {
- line: 1,
- column: 7
- },
- end: {
- line: 1,
- column: 11
- }
- }
- },
- body: {
- type: "BlockStatement",
- body: [
- {
- type: "BreakStatement",
- label: null,
- loc: {
- start: {
- line: 1,
- column: 15
- },
- end: {
- line: 1,
- column: 20
- }
- }
- },
- {
- type: "ExpressionStatement",
- expression: {
- type: "Identifier",
- name: "there",
- loc: {
- start: {
- line: 2,
- column: 0
- },
- end: {
- line: 2,
- column: 5
- }
- }
- },
- loc: {
- start: {
- line: 2,
- column: 0
- },
- end: {
- line: 2,
- column: 6
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 13
- },
- end: {
- line: 2,
- column: 8
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 2,
- column: 8
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 2,
- column: 8
- }
- }
-});
-
-test("while (true) { break /* Multiline\nComment */there; }", {
- type: "Program",
- body: [
- {
- type: "WhileStatement",
- test: {
- type: "Literal",
- value: true,
- loc: {
- start: {
- line: 1,
- column: 7
- },
- end: {
- line: 1,
- column: 11
- }
- }
- },
- body: {
- type: "BlockStatement",
- body: [
- {
- type: "BreakStatement",
- label: null,
- loc: {
- start: {
- line: 1,
- column: 15
- },
- end: {
- line: 1,
- column: 20
- }
- }
- },
- {
- type: "ExpressionStatement",
- expression: {
- type: "Identifier",
- name: "there",
- loc: {
- start: {
- line: 2,
- column: 10
- },
- end: {
- line: 2,
- column: 15
- }
- }
- },
- loc: {
- start: {
- line: 2,
- column: 10
- },
- end: {
- line: 2,
- column: 16
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 13
- },
- end: {
- line: 2,
- column: 18
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 2,
- column: 18
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 2,
- column: 18
- }
- }
-});
-
-test("(function(){ return\nx; })", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "FunctionExpression",
- id: null,
- params: [],
- body: {
- type: "BlockStatement",
- body: [
- {
- type: "ReturnStatement",
- argument: null,
- loc: {
- start: {
- line: 1,
- column: 13
- },
- end: {
- line: 1,
- column: 19
- }
- }
- },
- {
- type: "ExpressionStatement",
- expression: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 2,
- column: 0
- },
- end: {
- line: 2,
- column: 1
- }
- }
- },
- loc: {
- start: {
- line: 2,
- column: 0
- },
- end: {
- line: 2,
- column: 2
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 11
- },
- end: {
- line: 2,
- column: 4
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 1
- },
- end: {
- line: 2,
- column: 4
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 2,
- column: 5
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 2,
- column: 5
- }
- }
-});
-
-test("(function(){ return // Comment\nx; })", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "FunctionExpression",
- id: null,
- params: [],
- body: {
- type: "BlockStatement",
- body: [
- {
- type: "ReturnStatement",
- argument: null,
- loc: {
- start: {
- line: 1,
- column: 13
- },
- end: {
- line: 1,
- column: 19
- }
- }
- },
- {
- type: "ExpressionStatement",
- expression: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 2,
- column: 0
- },
- end: {
- line: 2,
- column: 1
- }
- }
- },
- loc: {
- start: {
- line: 2,
- column: 0
- },
- end: {
- line: 2,
- column: 2
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 11
- },
- end: {
- line: 2,
- column: 4
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 1
- },
- end: {
- line: 2,
- column: 4
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 2,
- column: 5
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 2,
- column: 5
- }
- }
-});
-
-test("(function(){ return/* Multiline\nComment */x; })", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "FunctionExpression",
- id: null,
- params: [],
- body: {
- type: "BlockStatement",
- body: [
- {
- type: "ReturnStatement",
- argument: null,
- loc: {
- start: {
- line: 1,
- column: 13
- },
- end: {
- line: 1,
- column: 19
- }
- }
- },
- {
- type: "ExpressionStatement",
- expression: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 2,
- column: 10
- },
- end: {
- line: 2,
- column: 11
- }
- }
- },
- loc: {
- start: {
- line: 2,
- column: 10
- },
- end: {
- line: 2,
- column: 12
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 11
- },
- end: {
- line: 2,
- column: 14
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 1
- },
- end: {
- line: 2,
- column: 14
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 2,
- column: 15
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 2,
- column: 15
- }
- }
-});
-
-test("{ throw error\nerror; }", {
- type: "Program",
- body: [
- {
- type: "BlockStatement",
- body: [
- {
- type: "ThrowStatement",
- argument: {
- type: "Identifier",
- name: "error",
- loc: {
- start: {
- line: 1,
- column: 8
- },
- end: {
- line: 1,
- column: 13
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 2
- },
- end: {
- line: 1,
- column: 13
- }
- }
- },
- {
- type: "ExpressionStatement",
- expression: {
- type: "Identifier",
- name: "error",
- loc: {
- start: {
- line: 2,
- column: 0
- },
- end: {
- line: 2,
- column: 5
- }
- }
- },
- loc: {
- start: {
- line: 2,
- column: 0
- },
- end: {
- line: 2,
- column: 6
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 2,
- column: 8
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 2,
- column: 8
- }
- }
-});
-
-test("{ throw error// Comment\nerror; }", {
- type: "Program",
- body: [
- {
- type: "BlockStatement",
- body: [
- {
- type: "ThrowStatement",
- argument: {
- type: "Identifier",
- name: "error",
- loc: {
- start: {
- line: 1,
- column: 8
- },
- end: {
- line: 1,
- column: 13
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 2
- },
- end: {
- line: 1,
- column: 13
- }
- }
- },
- {
- type: "ExpressionStatement",
- expression: {
- type: "Identifier",
- name: "error",
- loc: {
- start: {
- line: 2,
- column: 0
- },
- end: {
- line: 2,
- column: 5
- }
- }
- },
- loc: {
- start: {
- line: 2,
- column: 0
- },
- end: {
- line: 2,
- column: 6
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 2,
- column: 8
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 2,
- column: 8
- }
- }
-});
-
-test("{ throw error/* Multiline\nComment */error; }", {
- type: "Program",
- body: [
- {
- type: "BlockStatement",
- body: [
- {
- type: "ThrowStatement",
- argument: {
- type: "Identifier",
- name: "error",
- loc: {
- start: {
- line: 1,
- column: 8
- },
- end: {
- line: 1,
- column: 13
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 2
- },
- end: {
- line: 1,
- column: 13
- }
- }
- },
- {
- type: "ExpressionStatement",
- expression: {
- type: "Identifier",
- name: "error",
- loc: {
- start: {
- line: 2,
- column: 10
- },
- end: {
- line: 2,
- column: 15
- }
- }
- },
- loc: {
- start: {
- line: 2,
- column: 10
- },
- end: {
- line: 2,
- column: 16
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 2,
- column: 18
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 2,
- column: 18
- }
- }
-});
-
-test("", {
- type: "Program",
- body: [],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 0
- }
- }
-});
-
-test("foo: if (true) break foo;", {
- type: "Program",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 25
- }
- },
- body: [
- {
- type: "LabeledStatement",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 25
- }
- },
- body: {
- type: "IfStatement",
- loc: {
- start: {
- line: 1,
- column: 5
- },
- end: {
- line: 1,
- column: 25
- }
- },
- test: {
- type: "Literal",
- loc: {
- start: {
- line: 1,
- column: 9
- },
- end: {
- line: 1,
- column: 13
- }
- },
- value: true
- },
- consequent: {
- type: "BreakStatement",
- loc: {
- start: {
- line: 1,
- column: 15
- },
- end: {
- line: 1,
- column: 25
- }
- },
- label: {
- type: "Identifier",
- loc: {
- start: {
- line: 1,
- column: 21
- },
- end: {
- line: 1,
- column: 24
- }
- },
- name: "foo"
- }
- },
- alternate: null
- },
- label: {
- type: "Identifier",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 3
- }
- },
- name: "foo"
- }
- }
- ]
-});
-
-test("(function () {\n 'use strict';\n '\0';\n}())", {
- type: "Program",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 4,
- column: 4
- }
- },
- body: [
- {
- type: "ExpressionStatement",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 4,
- column: 4
- }
- },
- expression: {
- type: "CallExpression",
- loc: {
- start: {
- line: 1,
- column: 1
- },
- end: {
- line: 4,
- column: 3
- }
- },
- callee: {
- type: "FunctionExpression",
- loc: {
- start: {
- line: 1,
- column: 1
- },
- end: {
- line: 4,
- column: 1
- }
- },
- id: null,
- params: [],
- body: {
- type: "BlockStatement",
- loc: {
- start: {
- line: 1,
- column: 13
- },
- end: {
- line: 4,
- column: 1
- }
- },
- body: [
- {
- type: "ExpressionStatement",
- loc: {
- start: {
- line: 2,
- column: 1
- },
- end: {
- line: 2,
- column: 14
- }
- },
- expression: {
- type: "Literal",
- loc: {
- start: {
- line: 2,
- column: 1
- },
- end: {
- line: 2,
- column: 13
- }
- },
- value: "use strict"
- }
- },
- {
- type: "ExpressionStatement",
- loc: {
- start: {
- line: 3,
- column: 1
- },
- end: {
- line: 3,
- column: 5
- }
- },
- expression: {
- type: "Literal",
- loc: {
- start: {
- line: 3,
- column: 1
- },
- end: {
- line: 3,
- column: 4
- }
- },
- value: "\u0000"
- }
- }
- ]
- }
- },
- arguments: [],
- }
- }
- ]
-});
-
-test("123..toString(10)", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "CallExpression",
- callee: {
- type: "MemberExpression",
- object: {
- type: "Literal",
- value: 123
- },
- property: {
- type: "Identifier",
- name: "toString"
- },
- computed: false,
- },
- arguments: [
- {
- type: "Literal",
- value: 10
- }
- ],
- }
- }
- ]
-});
-
-test("123.+2", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "BinaryExpression",
- left: {
- type: "Literal",
- value: 123
- },
- operator: "+",
- right: {
- type: "Literal",
- value: 2
- },
- }
- }
- ]
-});
-
-test("a\u2028b", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "Identifier",
- name: "a"
- }
- },
- {
- type: "ExpressionStatement",
- expression: {
- type: "Identifier",
- name: "b"
- }
- }
- ]
-});
-
-test("'a\\u0026b'", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "Literal",
- value: "a\u0026b"
- }
- }
- ]
-});
-
-test("foo: 10; foo: 20;", {
- type: "Program",
- body: [
- {
- type: "LabeledStatement",
- body: {
- type: "ExpressionStatement",
- expression: {
- type: "Literal",
- value: 10,
- raw: "10"
- }
- },
- label: {
- type: "Identifier",
- name: "foo"
- }
- },
- {
- type: "LabeledStatement",
- body: {
- type: "ExpressionStatement",
- expression: {
- type: "Literal",
- value: 20,
- raw: "20"
- }
- },
- label: {
- type: "Identifier",
- name: "foo"
- }
- }
- ]
-});
-
-test("if(1)/ foo/", {
- type: "Program",
- body: [
- {
- type: "IfStatement",
- test: {
- type: "Literal",
- value: 1,
- raw: "1"
- },
- consequent: {
- type: "ExpressionStatement",
- expression: {
- type: "Literal",
- raw: "/ foo/"
- }
- },
- alternate: null
- }
- ]
-});
-
-test("price_9̶9̶_89", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "Identifier",
- name: "price_9̶9̶_89",
- }
- }
- ]
-});
-
-// option tests
-
-test("var a = 1;", {
- type: "Program",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 10
- },
- source: "test.js"
- },
- body: [
- {
- type: "VariableDeclaration",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 10
- },
- source: "test.js"
- },
- declarations: [
- {
- type: "VariableDeclarator",
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 9
- },
- source: "test.js"
- },
- id: {
- type: "Identifier",
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 5
- },
- source: "test.js"
- },
- name: "a"
- },
- init: {
- type: "Literal",
- loc: {
- start: {
- line: 1,
- column: 8
- },
- end: {
- line: 1,
- column: 9
- },
- source: "test.js"
- },
- value: 1,
- raw: "1"
- }
- }
- ],
- kind: "var"
- }
- ]
-}, {
- locations: true,
- sourceFile: "test.js"
-});
-
-test("a.in / b", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "BinaryExpression",
- left: {
- type: "MemberExpression",
- object: {
- type: "Identifier",
- name: "a"
- },
- property: {
- type: "Identifier",
- name: "in"
- },
- computed: false
- },
- operator: "/",
- right: {
- type: "Identifier",
- name: "b"
- }
- }
- }
- ]
-});
-
-// A number of slash-disambiguation corner cases
-test("return {} / 2", {}, {allowReturnOutsideFunction: true});
-test("return\n{}\n/foo/", {}, {allowReturnOutsideFunction: true});
-test("+{} / 2", {});
-test("{}\n/foo/", {});
-test("x++\n{}\n/foo/", {});
-test("{{}\n/foo/}", {});
-test("while (1) /foo/", {});
-test("(1) / 2", {});
-test("({a: [1]}+[]) / 2", {});
-test("{[1]}\n/foo/", {});
-test("switch(a) { case 1: {}\n/foo/ }", {});
-test("({1: {} / 2})", {});
-test("+x++ / 2", {});
-test("foo.in\n{}\n/foo/", {});
-
-test("{}/=/", {
- type: "Program",
- body: [
- {
- type: "BlockStatement",
- body: []
- },
- {
- type: "ExpressionStatement",
- expression: {
- type: "Literal",
- raw: "/=/"
- }
- }
- ]
-});
-
-test("foo 10;\n --> nothing", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "AssignmentExpression",
- operator: "=",
- left: {
- type: "Identifier",
- name: "x"
- },
- right: {
- type: "BinaryExpression",
- left: {
- type: "UpdateExpression",
- operator: "--",
- prefix: false,
- argument: {
- type: "Identifier",
- name: "y"
- }
- },
- operator: ">",
- right: {
- type: "Literal",
- value: 10
- }
- }
- }
- }
- ]
-});
-
-test("'use strict';\nobject.static();", {
- type: "Program",
- body: [
- {
- type: "ExpressionStatement",
- expression: {
- type: "Literal",
- value: "use strict",
- raw: "'use strict'"
- }
- },
- {
- type: "ExpressionStatement",
- expression: {
- type: "CallExpression",
- callee: {
- type: "MemberExpression",
- object: {
- type: "Identifier",
- name: "object"
- },
- property: {
- type: "Identifier",
- name: "static"
- },
- computed: false
- },
- arguments: []
- }
- }
- ]
-});
-
-// Failure tests
-
-testFail("{",
- "Unexpected token (1:1)");
-
-testFail("}",
- "Unexpected token (1:0)");
-
-testFail("3ea",
- "Invalid number (1:0)");
-
-testFail("3in []",
- "Identifier directly after number (1:1)");
-
-testFail("3e",
- "Invalid number (1:0)");
-
-testFail("3e+",
- "Invalid number (1:0)");
-
-testFail("3e-",
- "Invalid number (1:0)");
-
-testFail("3x",
- "Identifier directly after number (1:1)");
-
-testFail("3x0",
- "Identifier directly after number (1:1)");
-
-testFail("0x",
- "Expected number in radix 16 (1:2)");
-
-testFail("09",
- "Invalid number (1:0)");
-
-testFail("018",
- "Invalid number (1:0)");
-
-testFail("01a",
- "Identifier directly after number (1:2)");
-
-testFail("3in[]",
- "Identifier directly after number (1:1)");
-
-testFail("0x3in[]",
- "Identifier directly after number (1:3)");
-
-testFail("\"Hello\nWorld\"",
- "Unterminated string constant (1:0)");
-
-testFail("x\\",
- "Expecting Unicode escape sequence \\uXXXX (1:2)");
-
-testFail("x\\u005c",
- "Invalid Unicode escape (1:1)");
-
-testFail("x\\u002a",
- "Invalid Unicode escape (1:1)");
-
-testFail("/",
- "Unterminated regular expression (1:1)");
-
-testFail("/test",
- "Unterminated regular expression (1:1)");
-
-testFail("var x = /[a-z]/\\ux",
- "Bad character escape sequence (1:8)");
-
-testFail("3 = 4",
- "Assigning to rvalue (1:0)");
-
-testFail("func() = 4",
- "Assigning to rvalue (1:0)");
-
-testFail("(1 + 1) = 10",
- "Assigning to rvalue (1:1)");
-
-testFail("1++",
- "Assigning to rvalue (1:0)");
-
-testFail("1--",
- "Assigning to rvalue (1:0)");
-
-testFail("++1",
- "Assigning to rvalue (1:2)");
-
-testFail("--1",
- "Assigning to rvalue (1:2)");
-
-testFail("for((1 + 1) in list) process(x);",
- "Assigning to rvalue (1:5)");
-
-testFail("[",
- "Unexpected token (1:1)");
-
-testFail("[,",
- "Unexpected token (1:2)");
-
-testFail("1 + {",
- "Unexpected token (1:5)");
-
-testFail("1 + { t:t ",
- "Unexpected token (1:10)");
-
-testFail("1 + { t:t,",
- "Unexpected token (1:10)");
-
-testFail("var x = /\n/",
- "Unterminated regular expression (1:9)");
-
-testFail("var x = \"\n",
- "Unterminated string constant (1:8)");
-
-testFail("var if = 42",
- "Unexpected token (1:4)");
-
-testFail("i + 2 = 42",
- "Assigning to rvalue (1:0)");
-
-testFail("+i = 42",
- "Assigning to rvalue (1:0)");
-
-testFail("1 + (",
- "Unexpected token (1:5)");
-
-testFail("\n\n\n{",
- "Unexpected token (4:1)");
-
-testFail("\n/* Some multiline\ncomment */\n)",
- "Unexpected token (4:0)");
-
-testFail("{ set 1 }",
- "Unexpected token (1:6)");
-
-testFail("{ get 2 }",
- "Unexpected token (1:6)");
-
-testFail("({ set: s(if) { } })",
- "Unexpected token (1:10)");
-
-testFail("({ set s(.) { } })",
- "Unexpected token (1:9)");
-
-testFail("({ set: s() { } })",
- "Unexpected token (1:12)");
-
-testFail("({ set: s(a, b) { } })",
- "Unexpected token (1:16)");
-
-testFail("({ get: g(d) { } })",
- "Unexpected token (1:13)");
-
-testFail("({ get i() { }, i: 42 })",
- "Redefinition of property (1:16)");
-
-testFail("({ i: 42, get i() { } })",
- "Redefinition of property (1:14)");
-
-testFail("({ set i(x) { }, i: 42 })",
- "Redefinition of property (1:17)");
-
-testFail("({ i: 42, set i(x) { } })",
- "Redefinition of property (1:14)");
-
-testFail("({ get i() { }, get i() { } })",
- "Redefinition of property (1:20)");
-
-testFail("({ set i(x) { }, set i(x) { } })",
- "Redefinition of property (1:21)");
-
-testFail("function t(...) { }",
- "Unexpected token (1:11)");
-
-testFail("function t(...) { }",
- "Unexpected token (1:14)",
- { ecmaVersion: 6 });
-
-testFail("function t(...rest, b) { }",
- "Unexpected token (1:18)",
- { ecmaVersion: 6 });
-
-testFail("function t(if) { }",
- "Unexpected token (1:11)");
-
-testFail("function t(true) { }",
- "Unexpected token (1:11)");
-
-testFail("function t(false) { }",
- "Unexpected token (1:11)");
-
-testFail("function t(null) { }",
- "Unexpected token (1:11)");
-
-testFail("function null() { }",
- "Unexpected token (1:9)");
-
-testFail("function true() { }",
- "Unexpected token (1:9)");
-
-testFail("function false() { }",
- "Unexpected token (1:9)");
-
-testFail("function if() { }",
- "Unexpected token (1:9)");
-
-testFail("a b;",
- "Unexpected token (1:2)");
-
-testFail("if.a;",
- "Unexpected token (1:2)");
-
-testFail("a if;",
- "Unexpected token (1:2)");
-
-testFail("a class;",
- "Unexpected token (1:2)");
-
-testFail("break\n",
- "Unsyntactic break (1:0)");
-
-testFail("break 1;",
- "Unexpected token (1:6)");
-
-testFail("continue\n",
- "Unsyntactic continue (1:0)");
-
-testFail("continue 2;",
- "Unexpected token (1:9)");
-
-testFail("throw",
- "Unexpected token (1:5)");
-
-testFail("throw;",
- "Unexpected token (1:5)");
-
-testFail("for (var i, i2 in {});",
- "Unexpected token (1:15)");
-
-testFail("for ((i in {}));",
- "Unexpected token (1:14)");
-
-testFail("for (i + 1 in {});",
- "Assigning to rvalue (1:5)");
-
-testFail("for (+i in {});",
- "Assigning to rvalue (1:5)");
-
-testFail("if(false)",
- "Unexpected token (1:9)");
-
-testFail("if(false) doThis(); else",
- "Unexpected token (1:24)");
-
-testFail("do",
- "Unexpected token (1:2)");
-
-testFail("while(false)",
- "Unexpected token (1:12)");
-
-testFail("for(;;)",
- "Unexpected token (1:7)");
-
-testFail("with(x)",
- "Unexpected token (1:7)");
-
-testFail("try { }",
- "Missing catch or finally clause (1:0)");
-
-testFail("‿ = 10",
- "Unexpected character '‿' (1:0)");
-
-testFail("if(true) let a = 1;",
- "Unexpected token (1:13)");
-
-testFail("switch (c) { default: default: }",
- "Multiple default clauses (1:22)");
-
-testFail("new X().\"s\"",
- "Unexpected token (1:8)");
-
-testFail("/*",
- "Unterminated comment (1:0)");
-
-testFail("/*\n\n\n",
- "Unterminated comment (1:0)");
-
-testFail("/**",
- "Unterminated comment (1:0)");
-
-testFail("/*\n\n*",
- "Unterminated comment (1:0)");
-
-testFail("/*hello",
- "Unterminated comment (1:0)");
-
-testFail("/*hello *",
- "Unterminated comment (1:0)");
-
-testFail("\n]",
- "Unexpected token (2:0)");
-
-testFail("\r]",
- "Unexpected token (2:0)");
-
-testFail("\r\n]",
- "Unexpected token (2:0)");
-
-testFail("\n\r]",
- "Unexpected token (3:0)");
-
-testFail("//\r\n]",
- "Unexpected token (2:0)");
-
-testFail("//\n\r]",
- "Unexpected token (3:0)");
-
-testFail("/a\\\n/",
- "Unterminated regular expression (1:1)");
-
-testFail("//\r \n]",
- "Unexpected token (3:0)");
-
-testFail("/*\r\n*/]",
- "Unexpected token (2:2)");
-
-testFail("/*\n\r*/]",
- "Unexpected token (3:2)");
-
-testFail("/*\r \n*/]",
- "Unexpected token (3:2)");
-
-testFail("\\\\",
- "Expecting Unicode escape sequence \\uXXXX (1:1)");
-
-testFail("\\u005c",
- "Invalid Unicode escape (1:0)");
-
-testFail("\\x",
- "Expecting Unicode escape sequence \\uXXXX (1:1)");
-
-testFail("\\u0000",
- "Invalid Unicode escape (1:0)");
-
-testFail(" = []",
- "Unexpected character '' (1:0)");
-
-testFail(" = []",
- "Unexpected character '' (1:0)");
-
-testFail("\"\\",
- "Unterminated string constant (1:0)");
-
-testFail("\"\\u",
- "Bad character escape sequence (1:0)");
-
-testFail("return",
- "'return' outside of function (1:0)");
-
-testFail("break",
- "Unsyntactic break (1:0)");
-
-testFail("continue",
- "Unsyntactic continue (1:0)");
-
-testFail("switch (x) { default: continue; }",
- "Unsyntactic continue (1:22)");
-
-testFail("do { x } *",
- "Unexpected token (1:9)");
-
-testFail("while (true) { break x; }",
- "Unsyntactic break (1:15)");
-
-testFail("while (true) { continue x; }",
- "Unsyntactic continue (1:15)");
-
-testFail("x: while (true) { (function () { break x; }); }",
- "Unsyntactic break (1:33)");
-
-testFail("x: while (true) { (function () { continue x; }); }",
- "Unsyntactic continue (1:33)");
-
-testFail("x: while (true) { (function () { break; }); }",
- "Unsyntactic break (1:33)");
-
-testFail("x: while (true) { (function () { continue; }); }",
- "Unsyntactic continue (1:33)");
-
-testFail("x: while (true) { x: while (true) { } }",
- "Label 'x' is already declared (1:18)");
-
-testFail("(function () { 'use strict'; delete i; }())",
- "Deleting local variable in strict mode (1:29)");
-
-testFail("(function () { 'use strict'; with (i); }())",
- "'with' in strict mode (1:29)");
-
-testFail("function hello() {'use strict'; ({ i: 42, i: 42 }) }",
- "Redefinition of property (1:42)");
-
-testFail("function hello() {'use strict'; ({ hasOwnProperty: 42, hasOwnProperty: 42 }) }",
- "Redefinition of property (1:55)");
-
-testFail("function hello() {'use strict'; var eval = 10; }",
- "Binding eval in strict mode (1:36)");
-
-testFail("function hello() {'use strict'; var arguments = 10; }",
- "Binding arguments in strict mode (1:36)");
-
-testFail("function hello() {'use strict'; try { } catch (eval) { } }",
- "Binding eval in strict mode (1:47)");
-
-testFail("function hello() {'use strict'; try { } catch (arguments) { } }",
- "Binding arguments in strict mode (1:47)");
-
-testFail("function hello() {'use strict'; eval = 10; }",
- "Assigning to eval in strict mode (1:32)");
-
-testFail("function hello() {'use strict'; arguments = 10; }",
- "Assigning to arguments in strict mode (1:32)");
-
-testFail("function hello() {'use strict'; ++eval; }",
- "Assigning to eval in strict mode (1:34)");
-
-testFail("function hello() {'use strict'; --eval; }",
- "Assigning to eval in strict mode (1:34)");
-
-testFail("function hello() {'use strict'; ++arguments; }",
- "Assigning to arguments in strict mode (1:34)");
-
-testFail("function hello() {'use strict'; --arguments; }",
- "Assigning to arguments in strict mode (1:34)");
-
-testFail("function hello() {'use strict'; eval++; }",
- "Assigning to eval in strict mode (1:32)");
-
-testFail("function hello() {'use strict'; eval--; }",
- "Assigning to eval in strict mode (1:32)");
-
-testFail("function hello() {'use strict'; arguments++; }",
- "Assigning to arguments in strict mode (1:32)");
-
-testFail("function hello() {'use strict'; arguments--; }",
- "Assigning to arguments in strict mode (1:32)");
-
-testFail("function hello() {'use strict'; function eval() { } }",
- "Binding eval in strict mode (1:41)");
-
-testFail("function hello() {'use strict'; function arguments() { } }",
- "Binding arguments in strict mode (1:41)");
-
-testFail("function eval() {'use strict'; }",
- "Binding eval in strict mode (1:9)");
-
-testFail("function arguments() {'use strict'; }",
- "Binding arguments in strict mode (1:9)");
-
-testFail("function hello() {'use strict'; (function eval() { }()) }",
- "Binding eval in strict mode (1:42)");
-
-testFail("function hello() {'use strict'; (function arguments() { }()) }",
- "Binding arguments in strict mode (1:42)");
-
-testFail("(function eval() {'use strict'; })()",
- "Binding eval in strict mode (1:10)");
-
-testFail("(function arguments() {'use strict'; })()",
- "Binding arguments in strict mode (1:10)");
-
-testFail("function hello() {'use strict'; ({ s: function eval() { } }); }",
- "Binding eval in strict mode (1:47)");
-
-testFail("(function package() {'use strict'; })()",
- "Binding package in strict mode (1:10)");
-
-testFail("function hello() {'use strict'; ({ i: 10, set s(eval) { } }); }",
- "Binding eval in strict mode (1:48)");
-
-testFail("function hello() {'use strict'; ({ set s(eval) { } }); }",
- "Binding eval in strict mode (1:41)");
-
-testFail("function hello() {'use strict'; ({ s: function s(eval) { } }); }",
- "Binding eval in strict mode (1:49)");
-
-testFail("function hello(eval) {'use strict';}",
- "Binding eval in strict mode (1:15)");
-
-testFail("function hello(arguments) {'use strict';}",
- "Binding arguments in strict mode (1:15)");
-
-testFail("function hello() { 'use strict'; function inner(eval) {} }",
- "Binding eval in strict mode (1:48)");
-
-testFail("function hello() { 'use strict'; function inner(arguments) {} }",
- "Binding arguments in strict mode (1:48)");
-
-testFail("function hello() { 'use strict'; \"\\1\"; }",
- "Octal literal in strict mode (1:34)");
-
-testFail("function hello() { 'use strict'; 021; }",
- "Invalid number (1:33)");
-
-testFail("function hello() { 'use strict'; ({ \"\\1\": 42 }); }",
- "Octal literal in strict mode (1:37)");
-
-testFail("function hello() { 'use strict'; ({ 021: 42 }); }",
- "Invalid number (1:36)");
-
-testFail("function hello() { \"use strict\"; function inner() { \"octal directive\\1\"; } }",
- "Octal literal in strict mode (1:68)");
-
-testFail("function hello() { \"use strict\"; var implements; }",
- "The keyword 'implements' is reserved (1:37)");
-
-testFail("function hello() { \"use strict\"; var interface; }",
- "The keyword 'interface' is reserved (1:37)");
-
-testFail("function hello() { \"use strict\"; var package; }",
- "The keyword 'package' is reserved (1:37)");
-
-testFail("function hello() { \"use strict\"; var private; }",
- "The keyword 'private' is reserved (1:37)");
-
-testFail("function hello() { \"use strict\"; var protected; }",
- "The keyword 'protected' is reserved (1:37)");
-
-testFail("function hello() { \"use strict\"; var public; }",
- "The keyword 'public' is reserved (1:37)");
-
-testFail("function hello() { \"use strict\"; var static; }",
- "The keyword 'static' is reserved (1:37)");
-
-testFail("function hello(static) { \"use strict\"; }",
- "Binding static in strict mode (1:15)");
-
-testFail("function static() { \"use strict\"; }",
- "Binding static in strict mode (1:9)");
-
-testFail("\"use strict\"; function static() { }",
- "The keyword 'static' is reserved (1:23)");
-
-testFail("function a(t, t) { \"use strict\"; }",
- "Argument name clash in strict mode (1:14)");
-
-testFail("function a(eval) { \"use strict\"; }",
- "Binding eval in strict mode (1:11)");
-
-testFail("function a(package) { \"use strict\"; }",
- "Binding package in strict mode (1:11)");
-
-testFail("function a() { \"use strict\"; function b(t, t) { }; }",
- "Argument name clash in strict mode (1:43)");
-
-testFail("(function a(t, t) { \"use strict\"; })",
- "Argument name clash in strict mode (1:15)");
-
-testFail("function a() { \"use strict\"; (function b(t, t) { }); }",
- "Argument name clash in strict mode (1:44)");
-
-testFail("(function a(eval) { \"use strict\"; })",
- "Binding eval in strict mode (1:12)");
-
-testFail("(function a(package) { \"use strict\"; })",
- "Binding package in strict mode (1:12)");
-
-testFail("\"use strict\";function foo(){\"use strict\";}function bar(){var v = 015}",
- "Invalid number (1:65)");
-
-testFail("var this = 10;", "Unexpected token (1:4)");
-
-testFail("throw\n10;", "Illegal newline after throw (1:5)");
-
-
-// ECMA < 6 mode should work as before
-
-testFail("const a;", "Unexpected token (1:6)");
-
-testFail("let x;", "Unexpected token (1:4)");
-
-testFail("const a = 1;", "Unexpected token (1:6)");
-
-testFail("let a = 1;", "Unexpected token (1:4)");
-
-testFail("for(const x = 0;;);", "Unexpected token (1:10)");
-
-testFail("for(let x = 0;;);", "Unexpected token (1:8)");
-
-test("let++", {
- type: "Program",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 5
- }
- },
- body: [
- {
- type: "ExpressionStatement",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 5
- }
- },
- expression: {
- type: "UpdateExpression",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 5
- }
- },
- operator: "++",
- prefix: false,
- argument: {
- type: "Identifier",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 3
- }
- },
- name: "let"
- }
- }
- }
- ]
-});
-
-// ECMA 6 support
-
-test("let x", {
- type: "Program",
- body: [
- {
- type: "VariableDeclaration",
- declarations: [
- {
- type: "VariableDeclarator",
- id: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 5
- }
- }
- },
- init: null,
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 5
- }
- }
- }
- ],
- kind: "let",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 5
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 5
- }
- }
-}, {ecmaVersion: 6, locations: true});
-
-test("let x, y;", {
- type: "Program",
- body: [
- {
- type: "VariableDeclaration",
- declarations: [
- {
- type: "VariableDeclarator",
- id: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 5
- }
- }
- },
- init: null,
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 5
- }
- }
- },
- {
- type: "VariableDeclarator",
- id: {
- type: "Identifier",
- name: "y",
- loc: {
- start: {
- line: 1,
- column: 7
- },
- end: {
- line: 1,
- column: 8
- }
- }
- },
- init: null,
- loc: {
- start: {
- line: 1,
- column: 7
- },
- end: {
- line: 1,
- column: 8
- }
- }
- }
- ],
- kind: "let",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 9
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 9
- }
- }
-}, {ecmaVersion: 6, locations: true});
-
-test("let x = 42", {
- type: "Program",
- body: [
- {
- type: "VariableDeclaration",
- declarations: [
- {
- type: "VariableDeclarator",
- id: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 5
- }
- }
- },
- init: {
- type: "Literal",
- value: 42,
- loc: {
- start: {
- line: 1,
- column: 8
- },
- end: {
- line: 1,
- column: 10
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 10
- }
- }
- }
- ],
- kind: "let",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 10
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 10
- }
- }
-}, {ecmaVersion: 6, locations: true});
-
-test("let eval = 42, arguments = 42", {
- type: "Program",
- body: [
- {
- type: "VariableDeclaration",
- declarations: [
- {
- type: "VariableDeclarator",
- id: {
- type: "Identifier",
- name: "eval",
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 8
- }
- }
- },
- init: {
- type: "Literal",
- value: 42,
- loc: {
- start: {
- line: 1,
- column: 11
- },
- end: {
- line: 1,
- column: 13
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 13
- }
- }
- },
- {
- type: "VariableDeclarator",
- id: {
- type: "Identifier",
- name: "arguments",
- loc: {
- start: {
- line: 1,
- column: 15
- },
- end: {
- line: 1,
- column: 24
- }
- }
- },
- init: {
- type: "Literal",
- value: 42,
- loc: {
- start: {
- line: 1,
- column: 27
- },
- end: {
- line: 1,
- column: 29
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 15
- },
- end: {
- line: 1,
- column: 29
- }
- }
- }
- ],
- kind: "let",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 29
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 29
- }
- }
-}, {ecmaVersion: 6, locations: true});
-
-test("let x = 14, y = 3, z = 1977", {
- type: "Program",
- body: [
- {
- type: "VariableDeclaration",
- declarations: [
- {
- type: "VariableDeclarator",
- id: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 5
- }
- }
- },
- init: {
- type: "Literal",
- value: 14,
- loc: {
- start: {
- line: 1,
- column: 8
- },
- end: {
- line: 1,
- column: 10
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 10
- }
- }
- },
- {
- type: "VariableDeclarator",
- id: {
- type: "Identifier",
- name: "y",
- loc: {
- start: {
- line: 1,
- column: 12
- },
- end: {
- line: 1,
- column: 13
- }
- }
- },
- init: {
- type: "Literal",
- value: 3,
- loc: {
- start: {
- line: 1,
- column: 16
- },
- end: {
- line: 1,
- column: 17
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 12
- },
- end: {
- line: 1,
- column: 17
- }
- }
- },
- {
- type: "VariableDeclarator",
- id: {
- type: "Identifier",
- name: "z",
- loc: {
- start: {
- line: 1,
- column: 19
- },
- end: {
- line: 1,
- column: 20
- }
- }
- },
- init: {
- type: "Literal",
- value: 1977,
- loc: {
- start: {
- line: 1,
- column: 23
- },
- end: {
- line: 1,
- column: 27
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 19
- },
- end: {
- line: 1,
- column: 27
- }
- }
- }
- ],
- kind: "let",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 27
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 27
- }
- }
-}, {ecmaVersion: 6, locations: true});
-
-test("for(let x = 0;;);", {
- type: "Program",
- body: [
- {
- type: "ForStatement",
- init: {
- type: "VariableDeclaration",
- declarations: [
- {
- type: "VariableDeclarator",
- id: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 8
- },
- end: {
- line: 1,
- column: 9
- }
- }
- },
- init: {
- type: "Literal",
- value: 0,
- loc: {
- start: {
- line: 1,
- column: 12
- },
- end: {
- line: 1,
- column: 13
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 8
- },
- end: {
- line: 1,
- column: 13
- }
- }
- }
- ],
- kind: "let",
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 13
- }
- }
- },
- test: null,
- update: null,
- body: {
- type: "EmptyStatement",
- loc: {
- start: {
- line: 1,
- column: 16
- },
- end: {
- line: 1,
- column: 17
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 17
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 17
- }
- }
-}, {ecmaVersion: 6, locations: true});
-
-test("for(let x = 0, y = 1;;);", {
- type: "Program",
- body: [
- {
- type: "ForStatement",
- init: {
- type: "VariableDeclaration",
- declarations: [
- {
- type: "VariableDeclarator",
- id: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 8
- },
- end: {
- line: 1,
- column: 9
- }
- }
- },
- init: {
- type: "Literal",
- value: 0,
- loc: {
- start: {
- line: 1,
- column: 12
- },
- end: {
- line: 1,
- column: 13
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 8
- },
- end: {
- line: 1,
- column: 13
- }
- }
- },
- {
- type: "VariableDeclarator",
- id: {
- type: "Identifier",
- name: "y",
- loc: {
- start: {
- line: 1,
- column: 15
- },
- end: {
- line: 1,
- column: 16
- }
- }
- },
- init: {
- type: "Literal",
- value: 1,
- loc: {
- start: {
- line: 1,
- column: 19
- },
- end: {
- line: 1,
- column: 20
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 15
- },
- end: {
- line: 1,
- column: 20
- }
- }
- }
- ],
- kind: "let",
- loc: {
- start: {
- line: 1,
- column: 4
- },
- end: {
- line: 1,
- column: 20
- }
- }
- },
- test: null,
- update: null,
- body: {
- type: "EmptyStatement",
- loc: {
- start: {
- line: 1,
- column: 23
- },
- end: {
- line: 1,
- column: 24
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 24
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 24
- }
- }
-}, {ecmaVersion: 6, locations: true});
-
-test("for (let x in list) process(x);", {
- type: "Program",
- body: [
- {
- type: "ForInStatement",
- left: {
- type: "VariableDeclaration",
- declarations: [
- {
- type: "VariableDeclarator",
- id: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 9
- },
- end: {
- line: 1,
- column: 10
- }
- }
- },
- init: null,
- loc: {
- start: {
- line: 1,
- column: 9
- },
- end: {
- line: 1,
- column: 10
- }
- }
- }
- ],
- kind: "let",
- loc: {
- start: {
- line: 1,
- column: 5
- },
- end: {
- line: 1,
- column: 10
- }
- }
- },
- right: {
- type: "Identifier",
- name: "list",
- loc: {
- start: {
- line: 1,
- column: 14
- },
- end: {
- line: 1,
- column: 18
- }
- }
- },
- body: {
- type: "ExpressionStatement",
- expression: {
- type: "CallExpression",
- callee: {
- type: "Identifier",
- name: "process",
- loc: {
- start: {
- line: 1,
- column: 20
- },
- end: {
- line: 1,
- column: 27
- }
- }
- },
- arguments: [
- {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 28
- },
- end: {
- line: 1,
- column: 29
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 20
- },
- end: {
- line: 1,
- column: 30
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 20
- },
- end: {
- line: 1,
- column: 31
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 31
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 31
- }
- }
-}, {ecmaVersion: 6, locations: true});
-
-test("const x = 42", {
- type: "Program",
- body: [
- {
- type: "VariableDeclaration",
- declarations: [
- {
- type: "VariableDeclarator",
- id: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 6
- },
- end: {
- line: 1,
- column: 7
- }
- }
- },
- init: {
- type: "Literal",
- value: 42,
- loc: {
- start: {
- line: 1,
- column: 10
- },
- end: {
- line: 1,
- column: 12
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 6
- },
- end: {
- line: 1,
- column: 12
- }
- }
- }
- ],
- kind: "const",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 12
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 12
- }
- }
-}, {ecmaVersion: 6, locations: true});
-
-test("const eval = 42, arguments = 42", {
- type: "Program",
- body: [
- {
- type: "VariableDeclaration",
- declarations: [
- {
- type: "VariableDeclarator",
- id: {
- type: "Identifier",
- name: "eval",
- loc: {
- start: {
- line: 1,
- column: 6
- },
- end: {
- line: 1,
- column: 10
- }
- }
- },
- init: {
- type: "Literal",
- value: 42,
- loc: {
- start: {
- line: 1,
- column: 13
- },
- end: {
- line: 1,
- column: 15
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 6
- },
- end: {
- line: 1,
- column: 15
- }
- }
- },
- {
- type: "VariableDeclarator",
- id: {
- type: "Identifier",
- name: "arguments",
- loc: {
- start: {
- line: 1,
- column: 17
- },
- end: {
- line: 1,
- column: 26
- }
- }
- },
- init: {
- type: "Literal",
- value: 42,
- loc: {
- start: {
- line: 1,
- column: 29
- },
- end: {
- line: 1,
- column: 31
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 17
- },
- end: {
- line: 1,
- column: 31
- }
- }
- }
- ],
- kind: "const",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 31
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 31
- }
- }
-}, {ecmaVersion: 6, locations: true});
-
-test("const x = 14, y = 3, z = 1977", {
- type: "Program",
- body: [
- {
- type: "VariableDeclaration",
- declarations: [
- {
- type: "VariableDeclarator",
- id: {
- type: "Identifier",
- name: "x",
- loc: {
- start: {
- line: 1,
- column: 6
- },
- end: {
- line: 1,
- column: 7
- }
- }
- },
- init: {
- type: "Literal",
- value: 14,
- loc: {
- start: {
- line: 1,
- column: 10
- },
- end: {
- line: 1,
- column: 12
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 6
- },
- end: {
- line: 1,
- column: 12
- }
- }
- },
- {
- type: "VariableDeclarator",
- id: {
- type: "Identifier",
- name: "y",
- loc: {
- start: {
- line: 1,
- column: 14
- },
- end: {
- line: 1,
- column: 15
- }
- }
- },
- init: {
- type: "Literal",
- value: 3,
- loc: {
- start: {
- line: 1,
- column: 18
- },
- end: {
- line: 1,
- column: 19
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 14
- },
- end: {
- line: 1,
- column: 19
- }
- }
- },
- {
- type: "VariableDeclarator",
- id: {
- type: "Identifier",
- name: "z",
- loc: {
- start: {
- line: 1,
- column: 21
- },
- end: {
- line: 1,
- column: 22
- }
- }
- },
- init: {
- type: "Literal",
- value: 1977,
- loc: {
- start: {
- line: 1,
- column: 25
- },
- end: {
- line: 1,
- column: 29
- }
- }
- },
- loc: {
- start: {
- line: 1,
- column: 21
- },
- end: {
- line: 1,
- column: 29
- }
- }
- }
- ],
- kind: "const",
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 29
- }
- }
- }
- ],
- loc: {
- start: {
- line: 1,
- column: 0
- },
- end: {
- line: 1,
- column: 29
- }
- }
-}, {ecmaVersion: 6, locations: true});
-
-testFail("const a;", "Unexpected token (1:7)", {ecmaVersion: 6});
-
-test("for(const x = 0;;);", {
- type: "Program",
- body: [{
- type: "ForStatement",
- init: {
- type: "VariableDeclaration",
- declarations: [{
- type: "VariableDeclarator",
- id: {
- type: "Identifier",
- name: "x",
- range: [10, 11]
- },
- init: {
- type: "Literal",
- value: 0,
- range: [14, 15]
- },
- range: [10, 15]
- }],
- kind: "const",
- range: [4, 15]
- },
- test: null,
- update: null,
- body: {
- type: "EmptyStatement",
- range: [18, 19]
- },
- range: [0, 19]
- }],
- range: [0, 19]
-}, {ecmaVersion: 6, ranges: true});
-
-testFail("for(x of a);", "Unexpected token (1:6)");
-
-testFail("for(var x of a);", "Unexpected token (1:10)");
-
-test(" HTML comment", {}, {
- locations: true,
- onComment: [{
- type: "Line",
- value: " HTML comment",
- loc: {
- start: { line: 2, column: 0 },
- end: { line: 2, column: 16 }
- }
- }]
-});
-
-var tokTypes = acorn.tokTypes;
-
-test('var x = (1 + 2)', {}, {
- locations: true,
- loose: false,
- onToken: [
- {
- type: tokTypes._var,
- value: "var",
- loc: {
- start: {line: 1, column: 0},
- end: {line: 1, column: 3}
- }
- },
- {
- type: tokTypes.name,
- value: "x",
- loc: {
- start: {line: 1, column: 4},
- end: {line: 1, column: 5}
- }
- },
- {
- type: tokTypes.eq,
- value: "=",
- loc: {
- start: {line: 1, column: 6},
- end: {line: 1, column: 7}
- }
- },
- {
- type: tokTypes.parenL,
- value: undefined,
- loc: {
- start: {line: 1, column: 8},
- end: {line: 1, column: 9}
- }
- },
- {
- type: tokTypes.num,
- value: 1,
- loc: {
- start: {line: 1, column: 9},
- end: {line: 1, column: 10}
- }
- },
- {
- type: {binop: 9, prefix: true, beforeExpr: true},
- value: "+",
- loc: {
- start: {line: 1, column: 11},
- end: {line: 1, column: 12}
- }
- },
- {
- type: tokTypes.num,
- value: 2,
- loc: {
- start: {line: 1, column: 13},
- end: {line: 1, column: 14}
- }
- },
- {
- type: tokTypes.parenR,
- value: undefined,
- loc: {
- start: {line: 1, column: 14},
- end: {line: 1, column: 15}
- }
- },
- {
- type: tokTypes.eof,
- value: undefined,
- loc: {
- start: {line: 1, column: 15},
- end: {line: 1, column: 15}
- }
- }
- ]
-});
-
-test("function f(f) { 'use strict'; }", {});
-
-// https://github.com/marijnh/acorn/issues/180
-test("#!/usr/bin/node\n;", {}, {
- allowHashBang: true,
- onComment: [{
- type: "Line",
- value: "/usr/bin/node",
- start: 0,
- end: 15
- }]
-});
-
-// https://github.com/marijnh/acorn/issues/204
-test("(function () {} / 1)", {
- type: "Program",
- body: [{
- type: "ExpressionStatement",
- expression: {
- type: "BinaryExpression",
- left: {
- type: "FunctionExpression",
- id: null,
- params: [],
- body: {
- type: "BlockStatement",
- body: []
- }
- },
- operator: "/",
- right: {type: "Literal", value: 1}
- }
- }]
-});
-
-test("function f() {} / 1 /", {
- type: "Program",
- body: [
- {
- type: "FunctionDeclaration",
- id: {type: "Identifier", name: "f"},
- params: [],
- body: {
- type: "BlockStatement",
- body: []
- }
- },
- {
- type: "ExpressionStatement",
- expression: {
- type: "Literal",
- regex: {pattern: " 1 ", flags: ""},
- value: / 1 /
- }
- }
- ]
-});
-
-var semicolons = []
-testAssert("var x\nreturn\n10", function() {
- var result = semicolons.join(" ");
- semicolons.length = 0;
- if (result != "5 12 15")
- return "Unexpected result for onInsertedSemicolon: " + result;
-}, {onInsertedSemicolon: function(pos) { semicolons.push(pos); },
- allowReturnOutsideFunction: true,
- loose: false})
-
-var trailingCommas = []
-testAssert("[1,2,] + {foo: 1,}", function() {
- var result = trailingCommas.join(" ");
- trailingCommas.length = 0;
- if (result != "4 16")
- return "Unexpected result for onTrailingComma: " + result;
-}, {onTrailingComma: function(pos) { trailingCommas.push(pos); },
- loose: false})