[Pkg-javascript-commits] [node-esprima] 07/09: New upstream version 3.1.0+ds
Julien Puydt
julien.puydt at laposte.net
Sat Oct 15 17:29:11 UTC 2016
This is an automated email from the git hooks/post-receive script.
jpuydt-guest pushed a commit to branch master
in repository node-esprima.
commit 7367461953f389328e8e7863048774eec3ae136f
Author: Julien Puydt <julien.puydt at laposte.net>
Date: Sat Oct 15 19:19:10 2016 +0200
New upstream version 3.1.0+ds
---
.travis.yml | 5 +-
ChangeLog | 8 +
README.md | 20 +-
circle.yml | 2 -
package.json | 22 +-
src/esprima.ts | 7 +-
src/messages.ts | 3 +-
src/parser.ts | 95 ++--
test/api-tests.js | 9 +-
test/benchmark-parser.js | 26 +-
test/benchmark-tokenizer.js | 26 +-
test/browser-tests.js | 2 +-
test/configure-sauce-labs.js | 4 +-
test/downstream.js | 46 +-
.../ES6/arrow-function/migrated_0008.tree.json | 1 -
.../ES6/arrow-function/migrated_0013.tree.json | 1 -
.../ES6/arrow-function/migrated_0014.tree.json | 1 -
.../array-pattern/nested-assignment.tree.json | 2 -
.../object-pattern-assignment.tree.json | 1 -
.../export-default-named-class.js | 1 +
.../export-default-named-class.tree.json | 201 ++++++++
.../export-named-keyword-as-specifier.js | 1 +
.../export-named-keyword-as-specifier.tree.json} | 227 ++++-----
.../export-named-keyword-specifier.js | 1 +
.../export-named-keyword-specifier.tree.json | 186 +++++++
.../ES6/for-of/invalid-assign-for-of.failure.json | 1 +
test/fixtures/ES6/for-of/invalid-assign-for-of.js | 1 +
...invalid-proto-identifier-shorthand.failure.json | 1 -
.../invalid-proto-literal-shorthand.failure.json | 1 -
...invalid-proto-shorthand-identifier.failure.json | 1 -
.../invalid-proto-shorthand-literal.failure.json | 1 -
.../invalid-proto-shorthands.failure.json | 1 -
...-shorthand.js => proto-identifier-shorthand.js} | 0
.../proto-identifier-shorthand.tree.json} | 237 ++++-----
...ral-shorthand.js => proto-literal-shorthand.js} | 0
.../proto-literal-shorthand.tree.json} | 240 +++++-----
.../proto-shorthand-assignments.js | 1 +
.../proto-shorthand-assignments.tree.json | 532 +++++++++++++++++++++
...identifier.js => proto-shorthand-identifier.js} | 0
.../proto-shorthand-identifier.tree.json} | 237 ++++-----
...thand-literal.js => proto-shorthand-literal.js} | 0
.../proto-shorthand-literal.tree.json} | 238 ++++-----
...lid-proto-shorthands.js => proto-shorthands.js} | 0
.../proto-shorthands.tree.json} | 229 ++++-----
.../yield/yield-arrow-parameter-default.tree.json | 1 -
.../yield/yield-generator-arrow-default.tree.json | 1 -
.../invalid-var-init-forin1.failure.json | 1 +
.../for-statement/invalid-var-init-forin1.js | 1 +
.../invalid-var-init-forin2.failure.json | 1 +
.../for-statement/invalid-var-init-forin2.js | 1 +
.../invalid-var-init-forin3.failure.json | 1 +
.../for-statement/invalid-var-init-forin3.js | 1 +
.../invalid-var-init-forin4.failure.json | 1 +
.../for-statement/invalid-var-init-forin4.js | 1 +
.../invalid-var-init-forin5.failure.json | 1 +
.../for-statement/invalid-var-init-forin5.js | 1 +
.../iteration/invalid-assign-for-in.failure.json | 1 +
.../statement/iteration/invalid-assign-for-in.js | 1 +
test/hostile-environment-tests.js | 2 +-
test/profile.js | 1 -
test/regression-tests.js | 1 -
test/tsfmt.json | 14 +
test/unit-tests.js | 12 +-
63 files changed, 1784 insertions(+), 879 deletions(-)
diff --git a/.travis.yml b/.travis.yml
index c3501f6..5b7cd9a 100644
--- a/.travis.yml
+++ b/.travis.yml
@@ -2,9 +2,6 @@ sudo: false
language: node_js
script: "npm run travis"
node_js:
- - iojs
- - "0.12"
- - "0.10"
- "4"
- - "5"
- "6"
+ - "node"
diff --git a/ChangeLog b/ChangeLog
index c53b304..02bf00d 100644
--- a/ChangeLog
+++ b/ChangeLog
@@ -1,3 +1,11 @@
+2016-10-09: Version 3.1.0
+
+ * Do not implicitly collect comments when comment attachment is specified (issue 1553)
+ * Fix incorrect handling of duplicated proto shorthand fields (issue 1485)
+ * Prohibit initialization in some variants of for statements (issue 1309, 1561)
+ * Fix incorrect parsing of export specifier (issue 1578)
+ * Fix ESTree compatibility for assignment pattern (issue 1575)
+
2016-09-03: Version 3.0.0
* Support ES2016 exponentiation expression (issue 1490)
diff --git a/README.md b/README.md
index 61315f9..e59d083 100644
--- a/README.md
+++ b/README.md
@@ -20,25 +20,21 @@ with the help of [many contributors](https://github.com/jquery/esprima/contribut
### API
-Esprima can be used to perform [lexical analysis](https://en.wikipedia.org/wiki/Lexical_analysis) (tokenization) or [syntactic analysis](https://en.wikipedia.org/wiki/Parsing) (parsing) of a JavaScript programs.
+Esprima can be used to perform [lexical analysis](https://en.wikipedia.org/wiki/Lexical_analysis) (tokenization) or [syntactic analysis](https://en.wikipedia.org/wiki/Parsing) (parsing) of a JavaScript program.
-A simple example:
+A simple example on Node.js REPL:
```javascript
-var esprima = require('esprima');
-var code = 'const answer = 42';
-var tokens = esprima.tokenize(code);
-var ast = esprima.parse(code);
-```
-which gives a list of [tokens](https://en.wikipedia.org/wiki/Lexical_analysis#Token):
-```javascript
+> var esprima = require('esprima');
+> var program = 'const answer = 42';
+
+> esprima.tokenize(program);
[ { type: 'Keyword', value: 'const' },
{ type: 'Identifier', value: 'answer' },
{ type: 'Punctuator', value: '=' },
{ type: 'Numeric', value: '42' } ]
-```
-and an [abstract syntax tree](https://en.wikipedia.org/wiki/Abstract_syntax_tree):
-```javascript
+
+> esprima.parse(program);
{ type: 'Program',
body:
[ { type: 'VariableDeclaration',
diff --git a/circle.yml b/circle.yml
index 59e0930..16a955f 100644
--- a/circle.yml
+++ b/circle.yml
@@ -1,7 +1,5 @@
machine:
node:
- version:
- 0.12.0
environment:
NO_WATCH_TESTS: 1
diff --git a/package.json b/package.json
index d3b7b72..312d309 100644
--- a/package.json
+++ b/package.json
@@ -7,13 +7,13 @@
"esparse": "./bin/esparse.js",
"esvalidate": "./bin/esvalidate.js"
},
- "version": "3.0.0",
+ "version": "3.1.0",
"files": [
"bin",
"dist/esprima.js"
],
"engines": {
- "node": ">=0.10.0"
+ "node": ">=4"
},
"author": {
"name": "Ariya Hidayat",
@@ -38,26 +38,25 @@
"codecov.io": "~0.1.6",
"escomplex-js": "1.2.0",
"everything.js": "~1.0.3",
- "glob": "~7.0.0",
+ "glob": "~7.1.0",
"istanbul": "~0.4.0",
- "jscs": "~3.0.3",
"json-diff": "~0.3.1",
- "karma": "~1.2.0",
+ "karma": "~1.3.0",
"karma-chrome-launcher": "~2.0.0",
"karma-detect-browsers": "~2.1.0",
"karma-firefox-launcher": "~1.0.0",
"karma-ie-launcher": "~1.0.0",
- "karma-mocha": "~1.1.1",
+ "karma-mocha": "~1.2.0",
"karma-safari-launcher": "~1.0.0",
"karma-sauce-launcher": "~1.0.0",
"lodash": "~3.10.1",
- "mocha": "~3.0.2",
+ "mocha": "~3.1.0",
"node-tick-processor": "~0.0.2",
"regenerate": "~1.3.1",
"temp": "~0.8.3",
"tslint": "~3.15.1",
"typescript": "~1.8.10",
- "typescript-formatter": "~1.2.0",
+ "typescript-formatter": "~2.3.0",
"unicode-8.0.0": "~0.7.0",
"webpack": "~1.13.2"
},
@@ -72,8 +71,8 @@
"scripts": {
"check-version": "node test/check-version.js",
"tslint": "tslint src/*.ts",
- "code-style": "tsfmt --verify src/*.ts && jscs -p crockford test/*.js",
- "format-code": "tsfmt -r src/*.ts",
+ "code-style": "tsfmt --verify src/*.ts && tsfmt --verify test/*.js",
+ "format-code": "tsfmt -r src/*.ts && tsfmt -r test/*.js",
"complexity": "node test/check-complexity.js",
"static-analysis": "npm run check-version && npm run tslint && npm run code-style && npm run complexity",
"hostile-env-tests": "node test/hostile-environment-tests.js",
@@ -87,6 +86,7 @@
"saucelabs-evergreen": "cd test && karma start saucelabs-evergreen.conf.js",
"saucelabs-safari": "cd test && karma start saucelabs-safari.conf.js",
"saucelabs-ie": "cd test && karma start saucelabs-ie.conf.js",
+ "saucelabs": "npm run saucelabs-evergreen && npm run saucelabs-ie && npm run saucelabs-safari",
"analyze-coverage": "istanbul cover test/unit-tests.js",
"check-coverage": "istanbul check-coverage --statement 100 --branch 100 --function 100",
"dynamic-analysis": "npm run analyze-coverage && npm run check-coverage",
@@ -102,7 +102,7 @@
"travis": "npm test",
"circleci": "npm test && npm run codecov && npm run downstream",
"appveyor": "npm run compile && npm run all-tests && npm run browser-tests",
- "droneio": "npm test && npm run saucelabs-evergreen && npm run saucelabs-ie && npm run saucelabs-safari",
+ "droneio": "npm run compile && npm run all-tests && npm run saucelabs",
"generate-regex": "node tools/generate-identifier-regex.js",
"generate-xhtml-entities": "node tools/generate-xhtml-entities.js"
}
diff --git a/src/esprima.ts b/src/esprima.ts
index f9d1a4c..90ad1a1 100644
--- a/src/esprima.ts
+++ b/src/esprima.ts
@@ -39,8 +39,9 @@ export function parse(code, options, delegate) {
};
let parserDelegate = (typeof delegate === 'function') ? proxyDelegate : null;
+ let collectComment = false;
if (options) {
- const collectComment = (typeof options.comment === 'boolean' && options.comment);
+ collectComment = (typeof options.comment === 'boolean' && options.comment);
const attachComment = (typeof options.attachComment === 'boolean' && options.attachComment);
if (collectComment || attachComment) {
commentHandler = new CommentHandler();
@@ -59,7 +60,7 @@ export function parse(code, options, delegate) {
const ast = <any>(parser.parseProgram());
- if (parser.config.comment) {
+ if (collectComment) {
ast.comments = commentHandler.comments;
}
if (parser.config.tokens) {
@@ -103,4 +104,4 @@ export function tokenize(code: string, options, delegate) {
export { Syntax } from './syntax';
// Sync with *.json manifests.
-export const version = '3.0.0';
+export const version = '3.1.0';
diff --git a/src/messages.ts b/src/messages.ts
index 19d82c5..32f2cad 100644
--- a/src/messages.ts
+++ b/src/messages.ts
@@ -46,5 +46,6 @@ export const Messages = {
InvalidModuleSpecifier: 'Unexpected token',
IllegalImportDeclaration: 'Unexpected token',
IllegalExportDeclaration: 'Unexpected token',
- DuplicateBinding: 'Duplicate binding %0'
+ DuplicateBinding: 'Duplicate binding %0',
+ ForInOfLoopInitializer: '%0 loop variable declaration may not have an initializer'
};
diff --git a/src/parser.ts b/src/parser.ts
index 4f05608..3f7ebe0 100644
--- a/src/parser.ts
+++ b/src/parser.ts
@@ -1,5 +1,5 @@
import { assert } from './assert';
-import { Messages} from './messages';
+import { Messages } from './messages';
import { ErrorHandler } from './error-handler';
import { Token, TokenName } from './token';
@@ -655,7 +655,7 @@ export class Parser {
case Token.Keyword:
if (!this.context.strict && this.context.allowYield && this.matchKeyword('yield')) {
- expr = this.parseNonComputedProperty();
+ expr = this.parseIdentifierName();
} else if (!this.context.strict && this.matchKeyword('let')) {
expr = this.finalize(node, new Node.Identifier(this.nextToken().value));
} else {
@@ -794,16 +794,6 @@ export class Parser {
(key.type === Syntax.Literal && key.value === value);
}
- checkDuplicatedProto(key, hasProto) {
- if (this.isPropertyKey(key, '__proto__')) {
- if (hasProto.value) {
- this.tolerateError(Messages.DuplicateProtoProperty);
- } else {
- hasProto.value = true;
- }
- }
- }
-
parseObjectProperty(hasProto): Node.Property {
const node = this.createNode();
const token = this.lookahead;
@@ -854,8 +844,11 @@ export class Parser {
kind = 'init';
if (this.match(':')) {
- if (!computed) {
- this.checkDuplicatedProto(key, hasProto);
+ if (!computed && this.isPropertyKey(key, '__proto__')) {
+ if (hasProto.value) {
+ this.tolerateError(Messages.DuplicateProtoProperty);
+ }
+ hasProto.value = true;
}
this.nextToken();
value = this.inheritCoverGrammar(this.parseAssignmentExpression);
@@ -866,7 +859,6 @@ export class Parser {
} else if (token.type === Token.Identifier) {
const id = this.finalize(node, new Node.Identifier(token.value));
- this.checkDuplicatedProto(key, hasProto);
if (this.match('=')) {
this.context.firstCoverInitializedNameError = this.lookahead;
this.nextToken();
@@ -978,6 +970,7 @@ export class Parser {
break;
case Syntax.AssignmentExpression:
expr.type = Syntax.AssignmentPattern;
+ delete expr.operator;
this.reinterpretExpressionAsPattern(expr.left);
break;
default:
@@ -1124,7 +1117,7 @@ export class Parser {
token.type === Token.NullLiteral;
}
- parseNonComputedProperty(): Node.Identifier {
+ parseIdentifierName(): Node.Identifier {
const node = this.createNode();
const token = this.nextToken();
if (!this.isIdentifierName(token)) {
@@ -1136,14 +1129,14 @@ export class Parser {
parseNewExpression(): Node.MetaProperty | Node.NewExpression {
const node = this.createNode();
- const id = this.parseNonComputedProperty();
+ const id = this.parseIdentifierName();
assert(id.name === 'new', 'New expression must start with `new`');
let expr;
if (this.match('.')) {
this.nextToken();
if (this.lookahead.type === Token.Identifier && this.context.inFunctionBody && this.lookahead.value === 'target') {
- const property = this.parseNonComputedProperty();
+ const property = this.parseIdentifierName();
expr = new Node.MetaProperty(id, property);
} else {
this.throwUnexpectedToken(this.lookahead);
@@ -1181,7 +1174,7 @@ export class Parser {
this.context.isBindingElement = false;
this.context.isAssignmentTarget = true;
this.expect('.');
- const property = this.parseNonComputedProperty();
+ const property = this.parseIdentifierName();
expr = this.finalize(this.startNode(startToken), new Node.StaticMemberExpression(expr, property));
} else if (this.match('(')) {
@@ -1242,7 +1235,7 @@ export class Parser {
this.context.isBindingElement = false;
this.context.isAssignmentTarget = true;
this.expect('.');
- const property = this.parseNonComputedProperty();
+ const property = this.parseIdentifierName();
expr = this.finalize(node, new Node.StaticMemberExpression(expr, property));
} else if (this.lookahead.type === Token.Template && this.lookahead.head) {
@@ -1304,15 +1297,8 @@ export class Parser {
parseUnaryExpression(): Node.Expression {
let expr;
- if (this.match('+') || this.match('-') || this.match('~') || this.match('!')) {
- const node = this.startNode(this.lookahead);
- const token = this.nextToken();
- expr = this.inheritCoverGrammar(this.parseUnaryExpression);
- expr = this.finalize(node, new Node.UnaryExpression(token.value, expr));
- this.context.isAssignmentTarget = false;
- this.context.isBindingElement = false;
-
- } else if (this.matchKeyword('delete') || this.matchKeyword('void') || this.matchKeyword('typeof')) {
+ if (this.match('+') || this.match('-') || this.match('~') || this.match('!') ||
+ this.matchKeyword('delete') || this.matchKeyword('void') || this.matchKeyword('typeof')) {
const node = this.startNode(this.lookahead);
const token = this.nextToken();
expr = this.inheritCoverGrammar(this.parseUnaryExpression);
@@ -1322,7 +1308,6 @@ export class Parser {
}
this.context.isAssignmentTarget = false;
this.context.isBindingElement = false;
-
} else {
expr = this.parseUpdateExpression();
}
@@ -1346,13 +1331,14 @@ export class Parser {
return expr;
}
- // ECMA-262 12.6 Multiplicative Operators
- // ECMA-262 12.7 Additive Operators
- // ECMA-262 12.8 Bitwise Shift Operators
- // ECMA-262 12.9 Relational Operators
- // ECMA-262 12.10 Equality Operators
- // ECMA-262 12.11 Binary Bitwise Operators
- // ECMA-262 12.12 Binary Logical Operators
+ // ECMA-262 12.6 Exponentiation Operators
+ // ECMA-262 12.7 Multiplicative Operators
+ // ECMA-262 12.8 Additive Operators
+ // ECMA-262 12.9 Bitwise Shift Operators
+ // ECMA-262 12.10 Relational Operators
+ // ECMA-262 12.11 Equality Operators
+ // ECMA-262 12.12 Binary Bitwise Operators
+ // ECMA-262 12.13 Binary Logical Operators
binaryPrecedence(token): number {
const op = token.value;
@@ -1424,7 +1410,7 @@ export class Parser {
return expr;
}
- // ECMA-262 12.13 Conditional Operator
+ // ECMA-262 12.14 Conditional Operator
parseConditionalExpression(): Node.Expression {
const startToken = this.lookahead;
@@ -1449,7 +1435,7 @@ export class Parser {
return expr;
}
- // ECMA-262 12.14 Assignment Operators
+ // ECMA-262 12.15 Assignment Operators
checkPatternParam(options, param) {
switch (param.type) {
@@ -1616,7 +1602,7 @@ export class Parser {
return expr;
}
- // ECMA-262 12.15 Comma Operator
+ // ECMA-262 12.16 Comma Operator
parseExpression(): Node.Expression | Node.SequenceExpression {
const startToken = this.lookahead;
@@ -2078,6 +2064,10 @@ export class Parser {
this.context.allowIn = previousAllowIn;
if (declarations.length === 1 && this.matchKeyword('in')) {
+ const decl = declarations[0];
+ if (decl.init && (decl.id.type === Syntax.ArrayPattern || decl.id.type === Syntax.ObjectPattern || this.context.strict)) {
+ this.tolerateError(Messages.ForInOfLoopInitializer, 'for-in');
+ }
init = this.finalize(init, new Node.VariableDeclaration(declarations, 'var'));
this.nextToken();
left = init;
@@ -2136,7 +2126,7 @@ export class Parser {
this.context.allowIn = previousAllowIn;
if (this.matchKeyword('in')) {
- if (!this.context.isAssignmentTarget) {
+ if (!this.context.isAssignmentTarget || init.type === Syntax.AssignmentExpression) {
this.tolerateError(Messages.InvalidLHSInForIn);
}
@@ -2146,7 +2136,7 @@ export class Parser {
right = this.parseExpression();
init = null;
} else if (this.matchContextualKeyword('of')) {
- if (!this.context.isAssignmentTarget) {
+ if (!this.context.isAssignmentTarget || init.type === Syntax.AssignmentExpression) {
this.tolerateError(Messages.InvalidLHSInForLoop);
}
@@ -2753,7 +2743,7 @@ export class Parser {
if (!this.match('(')) {
const token = this.lookahead;
- id = (!this.context.strict && !isGenerator && this.matchKeyword('yield')) ? this.parseNonComputedProperty() : this.parseVariableIdentifier();
+ id = (!this.context.strict && !isGenerator && this.matchKeyword('yield')) ? this.parseIdentifierName() : this.parseVariableIdentifier();
if (this.context.strict) {
if (this.scanner.isRestrictedWord(token.value)) {
this.tolerateUnexpectedToken(token, Messages.StrictFunctionName);
@@ -2919,7 +2909,7 @@ export class Parser {
return this.finalize(node, new Node.FunctionExpression(null, params.params, method, isGenerator));
}
- // ECMA-262 14.4 Yield expression
+ // ECMA-262 14.4 Generator Function Definitions
parseYieldExpression(): Node.YieldExpression {
const node = this.createNode();
@@ -3057,14 +3047,14 @@ export class Parser {
return this.finalize(node, new Node.ClassBody(elementList));
}
- parseClassDeclaration(): Node.ClassDeclaration {
+ parseClassDeclaration(identifierIsOptional?: boolean): Node.ClassDeclaration {
const node = this.createNode();
const previousStrict = this.context.strict;
this.context.strict = true;
this.expectKeyword('class');
- let id = this.parseVariableIdentifier();
+ const id = (identifierIsOptional && (this.lookahead.type !== Token.Identifier)) ? null : this.parseVariableIdentifier();
let superClass = null;
if (this.matchKeyword('extends')) {
this.nextToken();
@@ -3125,7 +3115,7 @@ export class Parser {
const node = this.createNode();
let local;
- const imported = this.parseNonComputedProperty();
+ const imported = this.parseIdentifierName();
if (this.matchContextualKeyword('as')) {
this.nextToken();
local = this.parseVariableIdentifier();
@@ -3154,7 +3144,7 @@ export class Parser {
// import <foo> ...;
parseImportDefaultSpecifier(): Node.ImportDefaultSpecifier {
const node = this.createNode();
- const local = this.parseNonComputedProperty();
+ const local = this.parseIdentifierName();
return this.finalize(node, new Node.ImportDefaultSpecifier(local));
}
@@ -3167,7 +3157,7 @@ export class Parser {
this.throwError(Messages.NoAsAfterImportNamespace);
}
this.nextToken();
- const local = this.parseNonComputedProperty();
+ const local = this.parseIdentifierName();
return this.finalize(node, new Node.ImportNamespaceSpecifier(local));
}
@@ -3228,11 +3218,11 @@ export class Parser {
parseExportSpecifier(): Node.ExportSpecifier {
const node = this.createNode();
- const local = this.matchKeyword('default') ? this.parseNonComputedProperty() : this.parseVariableIdentifier();
+ const local = this.parseIdentifierName();
let exported = local;
if (this.matchContextualKeyword('as')) {
this.nextToken();
- exported = this.parseNonComputedProperty();
+ exported = this.parseIdentifierName();
}
return this.finalize(node, new Node.ExportSpecifier(local, exported));
@@ -3257,8 +3247,7 @@ export class Parser {
exportDeclaration = this.finalize(node, new Node.ExportDefaultDeclaration(declaration));
} else if (this.matchKeyword('class')) {
// export default class foo {}
- let declaration = this.parseClassExpression();
- declaration.type = Syntax.ClassDeclaration;
+ const declaration = this.parseClassDeclaration(true);
exportDeclaration = this.finalize(node, new Node.ExportDefaultDeclaration(declaration));
} else {
if (this.matchContextualKeyword('from')) {
diff --git a/test/api-tests.js b/test/api-tests.js
index 5c8b740..3c8060d 100644
--- a/test/api-tests.js
+++ b/test/api-tests.js
@@ -196,7 +196,7 @@ describe('esprima.parse', function () {
it('should be able to attach comments', function () {
var ast, statement, expression, comments;
- ast = esprima.parse('/* universe */ 42', { attachComment: true});
+ ast = esprima.parse('/* universe */ 42', { attachComment: true });
statement = ast.body[0];
expression = statement.expression;
comments = statement.leadingComments;
@@ -205,6 +205,11 @@ describe('esprima.parse', function () {
assert.deepEqual(statement.leadingComments, [{ type: 'Block', value: ' universe ', range: [0, 14] }]);
});
+ it('should not implicity collect comments when comment attachment is specified', function () {
+ var ast = esprima.parse('/* universe */ 42', { attachComment: true });
+ assert.equal(ast.comments, undefined);
+ });
+
it('should include the list of tokens when specified', function () {
var ast = esprima.parse('x = 1', { tokens: true });
assert.deepEqual(ast.tokens.length, 3);
@@ -250,7 +255,7 @@ describe('esprima.parse', function () {
assert.deepEqual(expression.type, 'JSXElement');
assert.deepEqual(expression.openingElement.type, 'JSXOpeningElement');
- assert.deepEqual(expression.openingElement.name, { type: 'JSXIdentifier', name: 'title'});
+ assert.deepEqual(expression.openingElement.name, { type: 'JSXIdentifier', name: 'title' });
assert.deepEqual(expression.closingElement, null);
});
diff --git a/test/benchmark-parser.js b/test/benchmark-parser.js
index 9583ab2..766e723 100644
--- a/test/benchmark-parser.js
+++ b/test/benchmark-parser.js
@@ -66,20 +66,20 @@ function runParserTests(tests) {
var syntax = esprima.parse(source, { range: true, loc: true });
tree.push(syntax.body.length);
}, {
- 'onComplete': function (event) {
- var result;
- if (typeof gc === 'function') {
- gc();
+ 'onComplete': function (event) {
+ var result;
+ if (typeof gc === 'function') {
+ gc();
+ }
+ result = pad(this.name, 20);
+ result += pad(kb(size) + ' KiB', 12);
+ result += pad((1000 * this.stats.mean).toFixed(2), 10);
+ result += ' ms \xb1 ' + this.stats.rme.toFixed(2) + '%';
+ log(result);
+ totalTime += this.stats.mean;
+ totalRme += this.stats.mean * this.stats.rme * this.stats.rme;
}
- result = pad(this.name, 20);
- result += pad(kb(size) + ' KiB', 12);
- result += pad((1000 * this.stats.mean).toFixed(2), 10);
- result += ' ms \xb1 ' + this.stats.rme.toFixed(2) + '%';
- log(result);
- totalTime += this.stats.mean;
- totalRme += this.stats.mean * this.stats.rme * this.stats.rme;
- }
- });
+ });
}, new Benchmark.Suite()).on('complete', function () {
log(' ------------------------');
log(pad(kb(totalSize) + ' KiB', 32) +
diff --git a/test/benchmark-tokenizer.js b/test/benchmark-tokenizer.js
index a1b84a7..2bd5474 100644
--- a/test/benchmark-tokenizer.js
+++ b/test/benchmark-tokenizer.js
@@ -66,20 +66,20 @@ function runTokenizerTests(tests) {
var tokens = esprima.tokenize(source, { range: true, loc: true });
buffer.push(tokens.length);
}, {
- 'onComplete': function (event) {
- var result;
- if (typeof gc === 'function') {
- gc();
+ 'onComplete': function (event) {
+ var result;
+ if (typeof gc === 'function') {
+ gc();
+ }
+ result = pad(this.name, 20);
+ result += pad(kb(size) + ' KiB', 12);
+ result += pad((1000 * this.stats.mean).toFixed(2), 10);
+ result += ' ms \xb1 ' + this.stats.rme.toFixed(2) + '%';
+ log(result);
+ totalTime += this.stats.mean;
+ totalRme += this.stats.mean * this.stats.rme * this.stats.rme;
}
- result = pad(this.name, 20);
- result += pad(kb(size) + ' KiB', 12);
- result += pad((1000 * this.stats.mean).toFixed(2), 10);
- result += ' ms \xb1 ' + this.stats.rme.toFixed(2) + '%';
- log(result);
- totalTime += this.stats.mean;
- totalRme += this.stats.mean * this.stats.rme * this.stats.rme;
- }
- });
+ });
}, new Benchmark.Suite()).on('complete', function () {
log(' ------------------------');
log(pad(kb(totalSize) + ' KiB', 32) +
diff --git a/test/browser-tests.js b/test/browser-tests.js
index 3a753cf..9201868 100644
--- a/test/browser-tests.js
+++ b/test/browser-tests.js
@@ -76,7 +76,7 @@ function browserRunner(cases) {
source = ''
}
- return testCase.key + " - " + source + testCaseCase;
+ return testCase.key + " - " + source + testCaseCase;
}
function describeTests(tree, path) {
diff --git a/test/configure-sauce-labs.js b/test/configure-sauce-labs.js
index 917239c..573cfb0 100644
--- a/test/configure-sauce-labs.js
+++ b/test/configure-sauce-labs.js
@@ -34,8 +34,8 @@ module.exports = function (config, name, launchers) {
singleRun: true,
captureTimeout: 2 * 60 * 1000,
browserNoActivityTimeout: 3 * 60 * 1000,
- browserDisconnectTimeout : 3 * 60 * 1000,
- browserDisconnectTolerance : 2,
+ browserDisconnectTimeout: 3 * 60 * 1000,
+ browserDisconnectTolerance: 2,
sauceLabs: {
testName: name,
diff --git a/test/downstream.js b/test/downstream.js
index b9ef16b..37429a4 100644
--- a/test/downstream.js
+++ b/test/downstream.js
@@ -35,6 +35,24 @@ function copy_file(source, target) {
fs.writeFileSync(target, fs.readFileSync(source));
}
+function workaroundRecastTest() {
+ var filename = 'test/es6tests.js', lines, i, line;
+
+ console.log();
+ console.log('Applying a workaround...');
+ lines = fs.readFileSync(filename, 'utf-8').split('\n');
+ for (i = 0; i < lines.length; ++i) {
+ line = lines[i];
+ if (line.indexOf('const variables must have an initializer') > 0) {
+ console.log('-- Patching', filename);
+ lines.splice(i, 5);
+ fs.writeFileSync(filename, lines.join('\n'));
+ break;
+ }
+ }
+ execute('git diff');
+}
+
function test_project(project, repo) {
console.log();
console.log('==========', project);
@@ -48,6 +66,10 @@ function test_project(project, repo) {
execute('git log -n1 > commit.top');
console.log(fs.readFileSync('commit.top', 'utf-8'));
+ if (project === 'recast') {
+ workaroundRecastTest();
+ }
+
console.log();
execute('npm install');
@@ -66,19 +88,7 @@ function test_project(project, repo) {
}
function test_downstream(projects) {
- var nodejs_version = 'v0.12',
- downstream_path;
-
- if (typeof child_process.execSync !== 'function') {
- console.error('This only works with Node.js that support execSync');
- process.exit(0);
- }
- if (process.version.indexOf(nodejs_version) !== 0) {
- console.error('This is intended to run only with Node.js', nodejs_version);
- process.exit(0);
- }
-
- downstream_path = temp.mkdirSync('downstream');
+ var downstream_path = temp.mkdirSync('downstream');
console.log('Running the tests in', downstream_path);
if (!fs.existsSync(downstream_path)) {
@@ -92,6 +102,11 @@ function test_downstream(projects) {
}
+if (typeof child_process.execSync !== 'function') {
+ console.error('This only works with Node.js that support execSync');
+ process.exit(0);
+}
+
test_downstream({
'escope': 'https://github.com/estools/escope.git',
'esmangle': 'https://github.com/estools/esmangle.git',
@@ -99,8 +114,9 @@ test_downstream({
// 'js2coffee': 'https://github.com/js2coffee/js2coffee.git',
'redeyed': 'https://github.com/thlorenz/redeyed.git',
'jsfmt': 'https://github.com/rdio/jsfmt.git',
+ 'assetgraph': 'https://github.com/assetgraph/assetgraph.git',
'recast': 'https://github.com/benjamn/recast.git',
'rocambole': 'https://github.com/millermedeiros/rocambole.git',
- 'documentjs': 'https://github.com/bitovi/documentjs.git',
- 'istanbul': 'https://github.com/gotwarlost/istanbul.git'
+ 'documentjs': 'https://github.com/bitovi/documentjs.git'
+ // 'istanbul': 'https://github.com/gotwarlost/istanbul.git'
});
diff --git a/test/fixtures/ES6/arrow-function/migrated_0008.tree.json b/test/fixtures/ES6/arrow-function/migrated_0008.tree.json
index bb438eb..d053742 100644
--- a/test/fixtures/ES6/arrow-function/migrated_0008.tree.json
+++ b/test/fixtures/ES6/arrow-function/migrated_0008.tree.json
@@ -9,7 +9,6 @@
"params": [
{
"type": "AssignmentPattern",
- "operator": "=",
"left": {
"type": "Identifier",
"name": "x",
diff --git a/test/fixtures/ES6/arrow-function/migrated_0013.tree.json b/test/fixtures/ES6/arrow-function/migrated_0013.tree.json
index 614b73e..13f5aff 100644
--- a/test/fixtures/ES6/arrow-function/migrated_0013.tree.json
+++ b/test/fixtures/ES6/arrow-function/migrated_0013.tree.json
@@ -9,7 +9,6 @@
"params": [
{
"type": "AssignmentPattern",
- "operator": "=",
"left": {
"type": "Identifier",
"name": "eval",
diff --git a/test/fixtures/ES6/arrow-function/migrated_0014.tree.json b/test/fixtures/ES6/arrow-function/migrated_0014.tree.json
index 0887497..4c45198 100644
--- a/test/fixtures/ES6/arrow-function/migrated_0014.tree.json
+++ b/test/fixtures/ES6/arrow-function/migrated_0014.tree.json
@@ -27,7 +27,6 @@
},
{
"type": "AssignmentPattern",
- "operator": "=",
"left": {
"type": "Identifier",
"name": "a",
diff --git a/test/fixtures/ES6/destructuring-assignment/array-pattern/nested-assignment.tree.json b/test/fixtures/ES6/destructuring-assignment/array-pattern/nested-assignment.tree.json
index da89763..069003b 100644
--- a/test/fixtures/ES6/destructuring-assignment/array-pattern/nested-assignment.tree.json
+++ b/test/fixtures/ES6/destructuring-assignment/array-pattern/nested-assignment.tree.json
@@ -85,7 +85,6 @@
}
},
"type": "AssignmentPattern",
- "operator": "=",
"left": {
"range": [
3,
@@ -140,7 +139,6 @@
}
},
"type": "AssignmentPattern",
- "operator": "=",
"left": {
"range": [
7,
diff --git a/test/fixtures/ES6/destructuring-assignment/object-pattern/object-pattern-assignment.tree.json b/test/fixtures/ES6/destructuring-assignment/object-pattern/object-pattern-assignment.tree.json
index 7eaee82..80cd432 100644
--- a/test/fixtures/ES6/destructuring-assignment/object-pattern/object-pattern-assignment.tree.json
+++ b/test/fixtures/ES6/destructuring-assignment/object-pattern/object-pattern-assignment.tree.json
@@ -216,7 +216,6 @@
}
},
"type": "AssignmentPattern",
- "operator": "=",
"left": {
"range": [
25,
diff --git a/test/fixtures/ES6/export-declaration/export-default-named-class.js b/test/fixtures/ES6/export-declaration/export-default-named-class.js
new file mode 100644
index 0000000..1329e40
--- /dev/null
+++ b/test/fixtures/ES6/export-declaration/export-default-named-class.js
@@ -0,0 +1 @@
+export default class foo {}
diff --git a/test/fixtures/ES6/export-declaration/export-default-named-class.tree.json b/test/fixtures/ES6/export-declaration/export-default-named-class.tree.json
new file mode 100644
index 0000000..98fa196
--- /dev/null
+++ b/test/fixtures/ES6/export-declaration/export-default-named-class.tree.json
@@ -0,0 +1,201 @@
+{
+ "type": "Program",
+ "body": [
+ {
+ "range": [
+ 0,
+ 27
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 0
+ },
+ "end": {
+ "line": 1,
+ "column": 27
+ }
+ },
+ "type": "ExportDefaultDeclaration",
+ "declaration": {
+ "range": [
+ 15,
+ 27
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 15
+ },
+ "end": {
+ "line": 1,
+ "column": 27
+ }
+ },
+ "type": "ClassDeclaration",
+ "id": {
+ "range": [
+ 21,
+ 24
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 21
+ },
+ "end": {
+ "line": 1,
+ "column": 24
+ }
+ },
+ "type": "Identifier",
+ "name": "foo"
+ },
+ "superClass": null,
+ "body": {
+ "range": [
+ 25,
+ 27
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 25
+ },
+ "end": {
+ "line": 1,
+ "column": 27
+ }
+ },
+ "type": "ClassBody",
+ "body": []
+ }
+ }
+ }
+ ],
+ "sourceType": "module",
+ "tokens": [
+ {
+ "type": "Keyword",
+ "value": "export",
+ "range": [
+ 0,
+ 6
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 0
+ },
+ "end": {
+ "line": 1,
+ "column": 6
+ }
+ }
+ },
+ {
+ "type": "Keyword",
+ "value": "default",
+ "range": [
+ 7,
+ 14
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 7
+ },
+ "end": {
+ "line": 1,
+ "column": 14
+ }
+ }
+ },
+ {
+ "type": "Keyword",
+ "value": "class",
+ "range": [
+ 15,
+ 20
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 15
+ },
+ "end": {
+ "line": 1,
+ "column": 20
+ }
+ }
+ },
+ {
+ "type": "Identifier",
+ "value": "foo",
+ "range": [
+ 21,
+ 24
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 21
+ },
+ "end": {
+ "line": 1,
+ "column": 24
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": "{",
+ "range": [
+ 25,
+ 26
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 25
+ },
+ "end": {
+ "line": 1,
+ "column": 26
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": "}",
+ "range": [
+ 26,
+ 27
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 26
+ },
+ "end": {
+ "line": 1,
+ "column": 27
+ }
+ }
+ }
+ ],
+ "range": [
+ 0,
+ 27
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 0
+ },
+ "end": {
+ "line": 1,
+ "column": 27
+ }
+ }
+}
diff --git a/test/fixtures/ES6/export-declaration/export-named-keyword-as-specifier.js b/test/fixtures/ES6/export-declaration/export-named-keyword-as-specifier.js
new file mode 100644
index 0000000..479869b
--- /dev/null
+++ b/test/fixtures/ES6/export-declaration/export-named-keyword-as-specifier.js
@@ -0,0 +1 @@
+export {try as bar};
diff --git a/test/fixtures/ES6/arrow-function/migrated_0013.tree.json b/test/fixtures/ES6/export-declaration/export-named-keyword-as-specifier.tree.json
similarity index 50%
copy from test/fixtures/ES6/arrow-function/migrated_0013.tree.json
copy to test/fixtures/ES6/export-declaration/export-named-keyword-as-specifier.tree.json
index 614b73e..e882389 100644
--- a/test/fixtures/ES6/arrow-function/migrated_0013.tree.json
+++ b/test/fixtures/ES6/export-declaration/export-named-keyword-as-specifier.tree.json
@@ -2,106 +2,67 @@
"type": "Program",
"body": [
{
- "type": "ExpressionStatement",
- "expression": {
- "type": "ArrowFunctionExpression",
- "id": null,
- "params": [
- {
- "type": "AssignmentPattern",
- "operator": "=",
- "left": {
- "type": "Identifier",
- "name": "eval",
- "range": [
- 1,
- 5
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 1
- },
- "end": {
- "line": 1,
- "column": 5
- }
- }
- },
- "right": {
- "type": "Literal",
- "value": 10,
- "raw": "10",
- "range": [
- 8,
- 10
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 8
- },
- "end": {
- "line": 1,
- "column": 10
- }
+ "type": "ExportNamedDeclaration",
+ "declaration": null,
+ "specifiers": [
+ {
+ "type": "ExportSpecifier",
+ "exported": {
+ "type": "Identifier",
+ "name": "bar",
+ "range": [
+ 15,
+ 18
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 15
+ },
+ "end": {
+ "line": 1,
+ "column": 18
}
- },
+ }
+ },
+ "local": {
+ "type": "Identifier",
+ "name": "try",
"range": [
- 1,
- 10
+ 8,
+ 11
],
"loc": {
"start": {
"line": 1,
- "column": 1
+ "column": 8
},
"end": {
"line": 1,
- "column": 10
+ "column": 11
}
}
- }
- ],
- "body": {
- "type": "Literal",
- "value": 42,
- "raw": "42",
+ },
"range": [
- 15,
- 17
+ 8,
+ 18
],
"loc": {
"start": {
"line": 1,
- "column": 15
+ "column": 8
},
"end": {
"line": 1,
- "column": 17
+ "column": 18
}
}
- },
- "generator": false,
- "expression": true,
- "range": [
- 0,
- 17
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 0
- },
- "end": {
- "line": 1,
- "column": 17
- }
}
- },
+ ],
+ "source": null,
"range": [
0,
- 17
+ 20
],
"loc": {
"start": {
@@ -110,33 +71,19 @@
},
"end": {
"line": 1,
- "column": 17
+ "column": 20
}
}
}
],
- "sourceType": "script",
- "range": [
- 0,
- 17
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 0
- },
- "end": {
- "line": 1,
- "column": 17
- }
- },
+ "sourceType": "module",
"tokens": [
{
- "type": "Punctuator",
- "value": "(",
+ "type": "Keyword",
+ "value": "export",
"range": [
0,
- 1
+ 6
],
"loc": {
"start": {
@@ -145,117 +92,131 @@
},
"end": {
"line": 1,
- "column": 1
+ "column": 6
}
}
},
{
- "type": "Identifier",
- "value": "eval",
+ "type": "Punctuator",
+ "value": "{",
"range": [
- 1,
- 5
+ 7,
+ 8
],
"loc": {
"start": {
"line": 1,
- "column": 1
+ "column": 7
},
"end": {
"line": 1,
- "column": 5
+ "column": 8
}
}
},
{
- "type": "Punctuator",
- "value": "=",
+ "type": "Keyword",
+ "value": "try",
"range": [
- 6,
- 7
+ 8,
+ 11
],
"loc": {
"start": {
"line": 1,
- "column": 6
+ "column": 8
},
"end": {
"line": 1,
- "column": 7
+ "column": 11
}
}
},
{
- "type": "Numeric",
- "value": "10",
+ "type": "Identifier",
+ "value": "as",
"range": [
- 8,
- 10
+ 12,
+ 14
],
"loc": {
"start": {
"line": 1,
- "column": 8
+ "column": 12
},
"end": {
"line": 1,
- "column": 10
+ "column": 14
}
}
},
{
- "type": "Punctuator",
- "value": ")",
+ "type": "Identifier",
+ "value": "bar",
"range": [
- 10,
- 11
+ 15,
+ 18
],
"loc": {
"start": {
"line": 1,
- "column": 10
+ "column": 15
},
"end": {
"line": 1,
- "column": 11
+ "column": 18
}
}
},
{
"type": "Punctuator",
- "value": "=>",
+ "value": "}",
"range": [
- 12,
- 14
+ 18,
+ 19
],
"loc": {
"start": {
"line": 1,
- "column": 12
+ "column": 18
},
"end": {
"line": 1,
- "column": 14
+ "column": 19
}
}
},
{
- "type": "Numeric",
- "value": "42",
+ "type": "Punctuator",
+ "value": ";",
"range": [
- 15,
- 17
+ 19,
+ 20
],
"loc": {
"start": {
"line": 1,
- "column": 15
+ "column": 19
},
"end": {
"line": 1,
- "column": 17
+ "column": 20
}
}
}
- ]
-}
\ No newline at end of file
+ ],
+ "range": [
+ 0,
+ 20
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 0
+ },
+ "end": {
+ "line": 1,
+ "column": 20
+ }
+ }
+}
diff --git a/test/fixtures/ES6/export-declaration/export-named-keyword-specifier.js b/test/fixtures/ES6/export-declaration/export-named-keyword-specifier.js
new file mode 100644
index 0000000..17ce121
--- /dev/null
+++ b/test/fixtures/ES6/export-declaration/export-named-keyword-specifier.js
@@ -0,0 +1 @@
+export {try};
diff --git a/test/fixtures/ES6/export-declaration/export-named-keyword-specifier.tree.json b/test/fixtures/ES6/export-declaration/export-named-keyword-specifier.tree.json
new file mode 100644
index 0000000..fe0be5a
--- /dev/null
+++ b/test/fixtures/ES6/export-declaration/export-named-keyword-specifier.tree.json
@@ -0,0 +1,186 @@
+{
+ "type": "Program",
+ "body": [
+ {
+ "type": "ExportNamedDeclaration",
+ "declaration": null,
+ "specifiers": [
+ {
+ "type": "ExportSpecifier",
+ "exported": {
+ "type": "Identifier",
+ "name": "try",
+ "range": [
+ 8,
+ 11
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 8
+ },
+ "end": {
+ "line": 1,
+ "column": 11
+ }
+ }
+ },
+ "local": {
+ "type": "Identifier",
+ "name": "try",
+ "range": [
+ 8,
+ 11
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 8
+ },
+ "end": {
+ "line": 1,
+ "column": 11
+ }
+ }
+ },
+ "range": [
+ 8,
+ 11
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 8
+ },
+ "end": {
+ "line": 1,
+ "column": 11
+ }
+ }
+ }
+ ],
+ "source": null,
+ "range": [
+ 0,
+ 13
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 0
+ },
+ "end": {
+ "line": 1,
+ "column": 13
+ }
+ }
+ }
+ ],
+ "sourceType": "module",
+ "tokens": [
+ {
+ "type": "Keyword",
+ "value": "export",
+ "range": [
+ 0,
+ 6
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 0
+ },
+ "end": {
+ "line": 1,
+ "column": 6
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": "{",
+ "range": [
+ 7,
+ 8
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 7
+ },
+ "end": {
+ "line": 1,
+ "column": 8
+ }
+ }
+ },
+ {
+ "type": "Keyword",
+ "value": "try",
+ "range": [
+ 8,
+ 11
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 8
+ },
+ "end": {
+ "line": 1,
+ "column": 11
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": "}",
+ "range": [
+ 11,
+ 12
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 11
+ },
+ "end": {
+ "line": 1,
+ "column": 12
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": ";",
+ "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
+ }
+ }
+}
diff --git a/test/fixtures/ES6/for-of/invalid-assign-for-of.failure.json b/test/fixtures/ES6/for-of/invalid-assign-for-of.failure.json
new file mode 100644
index 0000000..2f4e00a
--- /dev/null
+++ b/test/fixtures/ES6/for-of/invalid-assign-for-of.failure.json
@@ -0,0 +1 @@
+{"index":8,"lineNumber":1,"column":9,"message":"Error: Line 1: Invalid left-hand side in for-loop","description":"Invalid left-hand side in for-loop"}
\ No newline at end of file
diff --git a/test/fixtures/ES6/for-of/invalid-assign-for-of.js b/test/fixtures/ES6/for-of/invalid-assign-for-of.js
new file mode 100644
index 0000000..2f72130
--- /dev/null
+++ b/test/fixtures/ES6/for-of/invalid-assign-for-of.js
@@ -0,0 +1 @@
+for (x=0 of y);
diff --git a/test/fixtures/ES6/object-initialiser/invalid-proto-identifier-shorthand.failure.json b/test/fixtures/ES6/object-initialiser/invalid-proto-identifier-shorthand.failure.json
deleted file mode 100644
index 4c4fec3..0000000
--- a/test/fixtures/ES6/object-initialiser/invalid-proto-identifier-shorthand.failure.json
+++ /dev/null
@@ -1 +0,0 @@
-{"index":29,"lineNumber":1,"column":30,"message":"Error: Line 1: Duplicate __proto__ fields are not allowed in object literals","description":"Duplicate __proto__ fields are not allowed in object literals"}
\ No newline at end of file
diff --git a/test/fixtures/ES6/object-initialiser/invalid-proto-literal-shorthand.failure.json b/test/fixtures/ES6/object-initialiser/invalid-proto-literal-shorthand.failure.json
deleted file mode 100644
index 364d8fb..0000000
--- a/test/fixtures/ES6/object-initialiser/invalid-proto-literal-shorthand.failure.json
+++ /dev/null
@@ -1 +0,0 @@
-{"index":31,"lineNumber":1,"column":32,"message":"Error: Line 1: Duplicate __proto__ fields are not allowed in object literals","description":"Duplicate __proto__ fields are not allowed in object literals"}
\ No newline at end of file
diff --git a/test/fixtures/ES6/object-initialiser/invalid-proto-shorthand-identifier.failure.json b/test/fixtures/ES6/object-initialiser/invalid-proto-shorthand-identifier.failure.json
deleted file mode 100644
index 584f92b..0000000
--- a/test/fixtures/ES6/object-initialiser/invalid-proto-shorthand-identifier.failure.json
+++ /dev/null
@@ -1 +0,0 @@
-{"index":23,"lineNumber":1,"column":24,"message":"Error: Line 1: Duplicate __proto__ fields are not allowed in object literals","description":"Duplicate __proto__ fields are not allowed in object literals"}
\ No newline at end of file
diff --git a/test/fixtures/ES6/object-initialiser/invalid-proto-shorthand-literal.failure.json b/test/fixtures/ES6/object-initialiser/invalid-proto-shorthand-literal.failure.json
deleted file mode 100644
index 8e61908..0000000
--- a/test/fixtures/ES6/object-initialiser/invalid-proto-shorthand-literal.failure.json
+++ /dev/null
@@ -1 +0,0 @@
-{"index":25,"lineNumber":1,"column":26,"message":"Error: Line 1: Duplicate __proto__ fields are not allowed in object literals","description":"Duplicate __proto__ fields are not allowed in object literals"}
\ No newline at end of file
diff --git a/test/fixtures/ES6/object-initialiser/invalid-proto-shorthands.failure.json b/test/fixtures/ES6/object-initialiser/invalid-proto-shorthands.failure.json
deleted file mode 100644
index 584f92b..0000000
--- a/test/fixtures/ES6/object-initialiser/invalid-proto-shorthands.failure.json
+++ /dev/null
@@ -1 +0,0 @@
-{"index":23,"lineNumber":1,"column":24,"message":"Error: Line 1: Duplicate __proto__ fields are not allowed in object literals","description":"Duplicate __proto__ fields are not allowed in object literals"}
\ No newline at end of file
diff --git a/test/fixtures/ES6/object-initialiser/invalid-proto-identifier-shorthand.js b/test/fixtures/ES6/object-initialiser/proto-identifier-shorthand.js
similarity index 100%
rename from test/fixtures/ES6/object-initialiser/invalid-proto-identifier-shorthand.js
rename to test/fixtures/ES6/object-initialiser/proto-identifier-shorthand.js
diff --git a/test/fixtures/ES6/arrow-function/migrated_0008.tree.json b/test/fixtures/ES6/object-initialiser/proto-identifier-shorthand.tree.json
similarity index 60%
copy from test/fixtures/ES6/arrow-function/migrated_0008.tree.json
copy to test/fixtures/ES6/object-initialiser/proto-identifier-shorthand.tree.json
index bb438eb..10992f6 100644
--- a/test/fixtures/ES6/arrow-function/migrated_0008.tree.json
+++ b/test/fixtures/ES6/object-initialiser/proto-identifier-shorthand.tree.json
@@ -4,139 +4,142 @@
{
"type": "ExpressionStatement",
"expression": {
- "type": "ArrowFunctionExpression",
- "id": null,
- "params": [
+ "type": "ObjectExpression",
+ "properties": [
{
- "type": "AssignmentPattern",
- "operator": "=",
- "left": {
+ "type": "Property",
+ "key": {
"type": "Identifier",
- "name": "x",
+ "name": "__proto__",
"range": [
- 1,
- 2
+ 3,
+ 12
],
"loc": {
"start": {
"line": 1,
- "column": 1
+ "column": 3
},
"end": {
"line": 1,
- "column": 2
+ "column": 12
}
}
},
- "right": {
+ "computed": false,
+ "value": {
"type": "Literal",
- "value": 1,
- "raw": "1",
+ "value": null,
+ "raw": "null",
"range": [
- 3,
- 4
+ 14,
+ 18
],
"loc": {
"start": {
"line": 1,
- "column": 3
+ "column": 14
},
"end": {
"line": 1,
- "column": 4
+ "column": 18
}
}
},
+ "kind": "init",
+ "method": false,
+ "shorthand": false,
"range": [
- 1,
- 4
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 1
- },
- "end": {
- "line": 1,
- "column": 4
- }
- }
- }
- ],
- "body": {
- "type": "BinaryExpression",
- "operator": "*",
- "left": {
- "type": "Identifier",
- "name": "x",
- "range": [
- 9,
- 10
+ 3,
+ 18
],
"loc": {
"start": {
"line": 1,
- "column": 9
+ "column": 3
},
"end": {
"line": 1,
- "column": 10
+ "column": 18
}
}
},
- "right": {
- "type": "Identifier",
- "name": "x",
+ {
+ "type": "Property",
+ "key": {
+ "type": "Identifier",
+ "name": "__proto__",
+ "range": [
+ 20,
+ 29
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 20
+ },
+ "end": {
+ "line": 1,
+ "column": 29
+ }
+ }
+ },
+ "computed": false,
+ "value": {
+ "type": "Identifier",
+ "name": "__proto__",
+ "range": [
+ 20,
+ 29
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 20
+ },
+ "end": {
+ "line": 1,
+ "column": 29
+ }
+ }
+ },
+ "kind": "init",
+ "method": false,
+ "shorthand": true,
"range": [
- 13,
- 14
+ 20,
+ 29
],
"loc": {
"start": {
"line": 1,
- "column": 13
+ "column": 20
},
"end": {
"line": 1,
- "column": 14
+ "column": 29
}
}
- },
- "range": [
- 9,
- 14
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 9
- },
- "end": {
- "line": 1,
- "column": 14
- }
}
- },
- "generator": false,
- "expression": true,
+ ],
"range": [
- 0,
- 14
+ 1,
+ 31
],
"loc": {
"start": {
"line": 1,
- "column": 0
+ "column": 1
},
"end": {
"line": 1,
- "column": 14
+ "column": 31
}
}
},
"range": [
0,
- 14
+ 32
],
"loc": {
"start": {
@@ -145,7 +148,7 @@
},
"end": {
"line": 1,
- "column": 14
+ "column": 32
}
}
}
@@ -153,7 +156,7 @@
"sourceType": "script",
"range": [
0,
- 14
+ 32
],
"loc": {
"start": {
@@ -162,7 +165,7 @@
},
"end": {
"line": 1,
- "column": 14
+ "column": 32
}
},
"tokens": [
@@ -185,8 +188,8 @@
}
},
{
- "type": "Identifier",
- "value": "x",
+ "type": "Punctuator",
+ "value": "{",
"range": [
1,
2
@@ -203,128 +206,128 @@
}
},
{
- "type": "Punctuator",
- "value": "=",
+ "type": "Identifier",
+ "value": "__proto__",
"range": [
- 2,
- 3
+ 3,
+ 12
],
"loc": {
"start": {
"line": 1,
- "column": 2
+ "column": 3
},
"end": {
"line": 1,
- "column": 3
+ "column": 12
}
}
},
{
- "type": "Numeric",
- "value": "1",
+ "type": "Punctuator",
+ "value": ":",
"range": [
- 3,
- 4
+ 12,
+ 13
],
"loc": {
"start": {
"line": 1,
- "column": 3
+ "column": 12
},
"end": {
"line": 1,
- "column": 4
+ "column": 13
}
}
},
{
- "type": "Punctuator",
- "value": ")",
+ "type": "Null",
+ "value": "null",
"range": [
- 4,
- 5
+ 14,
+ 18
],
"loc": {
"start": {
"line": 1,
- "column": 4
+ "column": 14
},
"end": {
"line": 1,
- "column": 5
+ "column": 18
}
}
},
{
"type": "Punctuator",
- "value": "=>",
+ "value": ",",
"range": [
- 6,
- 8
+ 18,
+ 19
],
"loc": {
"start": {
"line": 1,
- "column": 6
+ "column": 18
},
"end": {
"line": 1,
- "column": 8
+ "column": 19
}
}
},
{
"type": "Identifier",
- "value": "x",
+ "value": "__proto__",
"range": [
- 9,
- 10
+ 20,
+ 29
],
"loc": {
"start": {
"line": 1,
- "column": 9
+ "column": 20
},
"end": {
"line": 1,
- "column": 10
+ "column": 29
}
}
},
{
"type": "Punctuator",
- "value": "*",
+ "value": "}",
"range": [
- 11,
- 12
+ 30,
+ 31
],
"loc": {
"start": {
"line": 1,
- "column": 11
+ "column": 30
},
"end": {
"line": 1,
- "column": 12
+ "column": 31
}
}
},
{
- "type": "Identifier",
- "value": "x",
+ "type": "Punctuator",
+ "value": ")",
"range": [
- 13,
- 14
+ 31,
+ 32
],
"loc": {
"start": {
"line": 1,
- "column": 13
+ "column": 31
},
"end": {
"line": 1,
- "column": 14
+ "column": 32
}
}
}
diff --git a/test/fixtures/ES6/object-initialiser/invalid-proto-literal-shorthand.js b/test/fixtures/ES6/object-initialiser/proto-literal-shorthand.js
similarity index 100%
rename from test/fixtures/ES6/object-initialiser/invalid-proto-literal-shorthand.js
rename to test/fixtures/ES6/object-initialiser/proto-literal-shorthand.js
diff --git a/test/fixtures/ES6/arrow-function/migrated_0008.tree.json b/test/fixtures/ES6/object-initialiser/proto-literal-shorthand.tree.json
similarity index 59%
copy from test/fixtures/ES6/arrow-function/migrated_0008.tree.json
copy to test/fixtures/ES6/object-initialiser/proto-literal-shorthand.tree.json
index bb438eb..362b239 100644
--- a/test/fixtures/ES6/arrow-function/migrated_0008.tree.json
+++ b/test/fixtures/ES6/object-initialiser/proto-literal-shorthand.tree.json
@@ -4,139 +4,143 @@
{
"type": "ExpressionStatement",
"expression": {
- "type": "ArrowFunctionExpression",
- "id": null,
- "params": [
+ "type": "ObjectExpression",
+ "properties": [
{
- "type": "AssignmentPattern",
- "operator": "=",
- "left": {
- "type": "Identifier",
- "name": "x",
+ "type": "Property",
+ "key": {
+ "type": "Literal",
+ "value": "__proto__",
+ "raw": "\"__proto__\"",
"range": [
- 1,
- 2
+ 3,
+ 14
],
"loc": {
"start": {
"line": 1,
- "column": 1
+ "column": 3
},
"end": {
"line": 1,
- "column": 2
+ "column": 14
}
}
},
- "right": {
+ "computed": false,
+ "value": {
"type": "Literal",
- "value": 1,
- "raw": "1",
+ "value": null,
+ "raw": "null",
"range": [
- 3,
- 4
+ 16,
+ 20
],
"loc": {
"start": {
"line": 1,
- "column": 3
+ "column": 16
},
"end": {
"line": 1,
- "column": 4
+ "column": 20
}
}
},
+ "kind": "init",
+ "method": false,
+ "shorthand": false,
"range": [
- 1,
- 4
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 1
- },
- "end": {
- "line": 1,
- "column": 4
- }
- }
- }
- ],
- "body": {
- "type": "BinaryExpression",
- "operator": "*",
- "left": {
- "type": "Identifier",
- "name": "x",
- "range": [
- 9,
- 10
+ 3,
+ 20
],
"loc": {
"start": {
"line": 1,
- "column": 9
+ "column": 3
},
"end": {
"line": 1,
- "column": 10
+ "column": 20
}
}
},
- "right": {
- "type": "Identifier",
- "name": "x",
+ {
+ "type": "Property",
+ "key": {
+ "type": "Identifier",
+ "name": "__proto__",
+ "range": [
+ 22,
+ 31
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 22
+ },
+ "end": {
+ "line": 1,
+ "column": 31
+ }
+ }
+ },
+ "computed": false,
+ "value": {
+ "type": "Identifier",
+ "name": "__proto__",
+ "range": [
+ 22,
+ 31
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 22
+ },
+ "end": {
+ "line": 1,
+ "column": 31
+ }
+ }
+ },
+ "kind": "init",
+ "method": false,
+ "shorthand": true,
"range": [
- 13,
- 14
+ 22,
+ 31
],
"loc": {
"start": {
"line": 1,
- "column": 13
+ "column": 22
},
"end": {
"line": 1,
- "column": 14
+ "column": 31
}
}
- },
- "range": [
- 9,
- 14
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 9
- },
- "end": {
- "line": 1,
- "column": 14
- }
}
- },
- "generator": false,
- "expression": true,
+ ],
"range": [
- 0,
- 14
+ 1,
+ 33
],
"loc": {
"start": {
"line": 1,
- "column": 0
+ "column": 1
},
"end": {
"line": 1,
- "column": 14
+ "column": 33
}
}
},
"range": [
0,
- 14
+ 34
],
"loc": {
"start": {
@@ -145,7 +149,7 @@
},
"end": {
"line": 1,
- "column": 14
+ "column": 34
}
}
}
@@ -153,7 +157,7 @@
"sourceType": "script",
"range": [
0,
- 14
+ 34
],
"loc": {
"start": {
@@ -162,7 +166,7 @@
},
"end": {
"line": 1,
- "column": 14
+ "column": 34
}
},
"tokens": [
@@ -185,8 +189,8 @@
}
},
{
- "type": "Identifier",
- "value": "x",
+ "type": "Punctuator",
+ "value": "{",
"range": [
1,
2
@@ -203,128 +207,128 @@
}
},
{
- "type": "Punctuator",
- "value": "=",
+ "type": "String",
+ "value": "\"__proto__\"",
"range": [
- 2,
- 3
+ 3,
+ 14
],
"loc": {
"start": {
"line": 1,
- "column": 2
+ "column": 3
},
"end": {
"line": 1,
- "column": 3
+ "column": 14
}
}
},
{
- "type": "Numeric",
- "value": "1",
+ "type": "Punctuator",
+ "value": ":",
"range": [
- 3,
- 4
+ 14,
+ 15
],
"loc": {
"start": {
"line": 1,
- "column": 3
+ "column": 14
},
"end": {
"line": 1,
- "column": 4
+ "column": 15
}
}
},
{
- "type": "Punctuator",
- "value": ")",
+ "type": "Null",
+ "value": "null",
"range": [
- 4,
- 5
+ 16,
+ 20
],
"loc": {
"start": {
"line": 1,
- "column": 4
+ "column": 16
},
"end": {
"line": 1,
- "column": 5
+ "column": 20
}
}
},
{
"type": "Punctuator",
- "value": "=>",
+ "value": ",",
"range": [
- 6,
- 8
+ 20,
+ 21
],
"loc": {
"start": {
"line": 1,
- "column": 6
+ "column": 20
},
"end": {
"line": 1,
- "column": 8
+ "column": 21
}
}
},
{
"type": "Identifier",
- "value": "x",
+ "value": "__proto__",
"range": [
- 9,
- 10
+ 22,
+ 31
],
"loc": {
"start": {
"line": 1,
- "column": 9
+ "column": 22
},
"end": {
"line": 1,
- "column": 10
+ "column": 31
}
}
},
{
"type": "Punctuator",
- "value": "*",
+ "value": "}",
"range": [
- 11,
- 12
+ 32,
+ 33
],
"loc": {
"start": {
"line": 1,
- "column": 11
+ "column": 32
},
"end": {
"line": 1,
- "column": 12
+ "column": 33
}
}
},
{
- "type": "Identifier",
- "value": "x",
+ "type": "Punctuator",
+ "value": ")",
"range": [
- 13,
- 14
+ 33,
+ 34
],
"loc": {
"start": {
"line": 1,
- "column": 13
+ "column": 33
},
"end": {
"line": 1,
- "column": 14
+ "column": 34
}
}
}
diff --git a/test/fixtures/ES6/object-initialiser/proto-shorthand-assignments.js b/test/fixtures/ES6/object-initialiser/proto-shorthand-assignments.js
new file mode 100644
index 0000000..85f4e54
--- /dev/null
+++ b/test/fixtures/ES6/object-initialiser/proto-shorthand-assignments.js
@@ -0,0 +1 @@
+({__proto__ = 0, __proto__ = 0} = {})
diff --git a/test/fixtures/ES6/object-initialiser/proto-shorthand-assignments.tree.json b/test/fixtures/ES6/object-initialiser/proto-shorthand-assignments.tree.json
new file mode 100644
index 0000000..e1676f5
--- /dev/null
+++ b/test/fixtures/ES6/object-initialiser/proto-shorthand-assignments.tree.json
@@ -0,0 +1,532 @@
+{
+ "type": "Program",
+ "body": [
+ {
+ "type": "ExpressionStatement",
+ "expression": {
+ "type": "AssignmentExpression",
+ "operator": "=",
+ "left": {
+ "type": "ObjectPattern",
+ "properties": [
+ {
+ "type": "Property",
+ "key": {
+ "type": "Identifier",
+ "name": "__proto__",
+ "range": [
+ 2,
+ 11
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 2
+ },
+ "end": {
+ "line": 1,
+ "column": 11
+ }
+ }
+ },
+ "computed": false,
+ "value": {
+ "type": "AssignmentPattern",
+ "left": {
+ "type": "Identifier",
+ "name": "__proto__",
+ "range": [
+ 2,
+ 11
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 2
+ },
+ "end": {
+ "line": 1,
+ "column": 11
+ }
+ }
+ },
+ "right": {
+ "type": "Literal",
+ "value": 0,
+ "raw": "0",
+ "range": [
+ 14,
+ 15
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 14
+ },
+ "end": {
+ "line": 1,
+ "column": 15
+ }
+ }
+ },
+ "range": [
+ 2,
+ 15
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 2
+ },
+ "end": {
+ "line": 1,
+ "column": 15
+ }
+ }
+ },
+ "kind": "init",
+ "method": false,
+ "shorthand": true,
+ "range": [
+ 2,
+ 15
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 2
+ },
+ "end": {
+ "line": 1,
+ "column": 15
+ }
+ }
+ },
+ {
+ "type": "Property",
+ "key": {
+ "type": "Identifier",
+ "name": "__proto__",
+ "range": [
+ 17,
+ 26
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 17
+ },
+ "end": {
+ "line": 1,
+ "column": 26
+ }
+ }
+ },
+ "computed": false,
+ "value": {
+ "type": "AssignmentPattern",
+ "left": {
+ "type": "Identifier",
+ "name": "__proto__",
+ "range": [
+ 17,
+ 26
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 17
+ },
+ "end": {
+ "line": 1,
+ "column": 26
+ }
+ }
+ },
+ "right": {
+ "type": "Literal",
+ "value": 0,
+ "raw": "0",
+ "range": [
+ 29,
+ 30
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 29
+ },
+ "end": {
+ "line": 1,
+ "column": 30
+ }
+ }
+ },
+ "range": [
+ 17,
+ 30
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 17
+ },
+ "end": {
+ "line": 1,
+ "column": 30
+ }
+ }
+ },
+ "kind": "init",
+ "method": false,
+ "shorthand": true,
+ "range": [
+ 17,
+ 30
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 17
+ },
+ "end": {
+ "line": 1,
+ "column": 30
+ }
+ }
+ }
+ ],
+ "range": [
+ 1,
+ 31
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 1
+ },
+ "end": {
+ "line": 1,
+ "column": 31
+ }
+ }
+ },
+ "right": {
+ "type": "ObjectExpression",
+ "properties": [],
+ "range": [
+ 34,
+ 36
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 34
+ },
+ "end": {
+ "line": 1,
+ "column": 36
+ }
+ }
+ },
+ "range": [
+ 1,
+ 36
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 1
+ },
+ "end": {
+ "line": 1,
+ "column": 36
+ }
+ }
+ },
+ "range": [
+ 0,
+ 37
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 0
+ },
+ "end": {
+ "line": 1,
+ "column": 37
+ }
+ }
+ }
+ ],
+ "sourceType": "script",
+ "range": [
+ 0,
+ 37
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 0
+ },
+ "end": {
+ "line": 1,
+ "column": 37
+ }
+ },
+ "tokens": [
+ {
+ "type": "Punctuator",
+ "value": "(",
+ "range": [
+ 0,
+ 1
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 0
+ },
+ "end": {
+ "line": 1,
+ "column": 1
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": "{",
+ "range": [
+ 1,
+ 2
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 1
+ },
+ "end": {
+ "line": 1,
+ "column": 2
+ }
+ }
+ },
+ {
+ "type": "Identifier",
+ "value": "__proto__",
+ "range": [
+ 2,
+ 11
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 2
+ },
+ "end": {
+ "line": 1,
+ "column": 11
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": "=",
+ "range": [
+ 12,
+ 13
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 12
+ },
+ "end": {
+ "line": 1,
+ "column": 13
+ }
+ }
+ },
+ {
+ "type": "Numeric",
+ "value": "0",
+ "range": [
+ 14,
+ 15
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 14
+ },
+ "end": {
+ "line": 1,
+ "column": 15
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": ",",
+ "range": [
+ 15,
+ 16
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 15
+ },
+ "end": {
+ "line": 1,
+ "column": 16
+ }
+ }
+ },
+ {
+ "type": "Identifier",
+ "value": "__proto__",
+ "range": [
+ 17,
+ 26
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 17
+ },
+ "end": {
+ "line": 1,
+ "column": 26
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": "=",
+ "range": [
+ 27,
+ 28
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 27
+ },
+ "end": {
+ "line": 1,
+ "column": 28
+ }
+ }
+ },
+ {
+ "type": "Numeric",
+ "value": "0",
+ "range": [
+ 29,
+ 30
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 29
+ },
+ "end": {
+ "line": 1,
+ "column": 30
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": "}",
+ "range": [
+ 30,
+ 31
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 30
+ },
+ "end": {
+ "line": 1,
+ "column": 31
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": "=",
+ "range": [
+ 32,
+ 33
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 32
+ },
+ "end": {
+ "line": 1,
+ "column": 33
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": "{",
+ "range": [
+ 34,
+ 35
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 34
+ },
+ "end": {
+ "line": 1,
+ "column": 35
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": "}",
+ "range": [
+ 35,
+ 36
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 35
+ },
+ "end": {
+ "line": 1,
+ "column": 36
+ }
+ }
+ },
+ {
+ "type": "Punctuator",
+ "value": ")",
+ "range": [
+ 36,
+ 37
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 36
+ },
+ "end": {
+ "line": 1,
+ "column": 37
+ }
+ }
+ }
+ ]
+}
\ No newline at end of file
diff --git a/test/fixtures/ES6/object-initialiser/invalid-proto-shorthand-identifier.js b/test/fixtures/ES6/object-initialiser/proto-shorthand-identifier.js
similarity index 100%
rename from test/fixtures/ES6/object-initialiser/invalid-proto-shorthand-identifier.js
rename to test/fixtures/ES6/object-initialiser/proto-shorthand-identifier.js
diff --git a/test/fixtures/ES6/arrow-function/migrated_0008.tree.json b/test/fixtures/ES6/object-initialiser/proto-shorthand-identifier.tree.json
similarity index 60%
copy from test/fixtures/ES6/arrow-function/migrated_0008.tree.json
copy to test/fixtures/ES6/object-initialiser/proto-shorthand-identifier.tree.json
index bb438eb..b599242 100644
--- a/test/fixtures/ES6/arrow-function/migrated_0008.tree.json
+++ b/test/fixtures/ES6/object-initialiser/proto-shorthand-identifier.tree.json
@@ -4,37 +4,35 @@
{
"type": "ExpressionStatement",
"expression": {
- "type": "ArrowFunctionExpression",
- "id": null,
- "params": [
+ "type": "ObjectExpression",
+ "properties": [
{
- "type": "AssignmentPattern",
- "operator": "=",
- "left": {
+ "type": "Property",
+ "key": {
"type": "Identifier",
- "name": "x",
+ "name": "__proto__",
"range": [
- 1,
- 2
+ 3,
+ 12
],
"loc": {
"start": {
"line": 1,
- "column": 1
+ "column": 3
},
"end": {
"line": 1,
- "column": 2
+ "column": 12
}
}
},
- "right": {
- "type": "Literal",
- "value": 1,
- "raw": "1",
+ "computed": false,
+ "value": {
+ "type": "Identifier",
+ "name": "__proto__",
"range": [
3,
- 4
+ 12
],
"loc": {
"start": {
@@ -43,100 +41,105 @@
},
"end": {
"line": 1,
- "column": 4
+ "column": 12
}
}
},
+ "kind": "init",
+ "method": false,
+ "shorthand": true,
"range": [
- 1,
- 4
+ 3,
+ 12
],
"loc": {
"start": {
"line": 1,
- "column": 1
+ "column": 3
},
"end": {
"line": 1,
- "column": 4
- }
- }
- }
- ],
- "body": {
- "type": "BinaryExpression",
- "operator": "*",
- "left": {
- "type": "Identifier",
- "name": "x",
- "range": [
- 9,
- 10
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 9
- },
- "end": {
- "line": 1,
- "column": 10
+ "column": 12
}
}
},
- "right": {
- "type": "Identifier",
- "name": "x",
+ {
+ "type": "Property",
+ "key": {
+ "type": "Identifier",
+ "name": "__proto__",
+ "range": [
+ 14,
+ 23
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 14
+ },
+ "end": {
+ "line": 1,
+ "column": 23
+ }
+ }
+ },
+ "computed": false,
+ "value": {
+ "type": "Literal",
+ "value": null,
+ "raw": "null",
+ "range": [
+ 25,
+ 29
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 25
+ },
+ "end": {
+ "line": 1,
+ "column": 29
+ }
+ }
+ },
+ "kind": "init",
+ "method": false,
+ "shorthand": false,
"range": [
- 13,
- 14
+ 14,
+ 29
],
"loc": {
"start": {
"line": 1,
- "column": 13
+ "column": 14
},
"end": {
"line": 1,
- "column": 14
+ "column": 29
}
}
- },
- "range": [
- 9,
- 14
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 9
- },
- "end": {
- "line": 1,
- "column": 14
- }
}
- },
- "generator": false,
- "expression": true,
+ ],
"range": [
- 0,
- 14
+ 1,
+ 31
],
"loc": {
"start": {
"line": 1,
- "column": 0
+ "column": 1
},
"end": {
"line": 1,
- "column": 14
+ "column": 31
}
}
},
"range": [
0,
- 14
+ 32
],
"loc": {
"start": {
@@ -145,7 +148,7 @@
},
"end": {
"line": 1,
- "column": 14
+ "column": 32
}
}
}
@@ -153,7 +156,7 @@
"sourceType": "script",
"range": [
0,
- 14
+ 32
],
"loc": {
"start": {
@@ -162,7 +165,7 @@
},
"end": {
"line": 1,
- "column": 14
+ "column": 32
}
},
"tokens": [
@@ -185,8 +188,8 @@
}
},
{
- "type": "Identifier",
- "value": "x",
+ "type": "Punctuator",
+ "value": "{",
"range": [
1,
2
@@ -203,128 +206,128 @@
}
},
{
- "type": "Punctuator",
- "value": "=",
+ "type": "Identifier",
+ "value": "__proto__",
"range": [
- 2,
- 3
+ 3,
+ 12
],
"loc": {
"start": {
"line": 1,
- "column": 2
+ "column": 3
},
"end": {
"line": 1,
- "column": 3
+ "column": 12
}
}
},
{
- "type": "Numeric",
- "value": "1",
+ "type": "Punctuator",
+ "value": ",",
"range": [
- 3,
- 4
+ 12,
+ 13
],
"loc": {
"start": {
"line": 1,
- "column": 3
+ "column": 12
},
"end": {
"line": 1,
- "column": 4
+ "column": 13
}
}
},
{
- "type": "Punctuator",
- "value": ")",
+ "type": "Identifier",
+ "value": "__proto__",
"range": [
- 4,
- 5
+ 14,
+ 23
],
"loc": {
"start": {
"line": 1,
- "column": 4
+ "column": 14
},
"end": {
"line": 1,
- "column": 5
+ "column": 23
}
}
},
{
"type": "Punctuator",
- "value": "=>",
+ "value": ":",
"range": [
- 6,
- 8
+ 23,
+ 24
],
"loc": {
"start": {
"line": 1,
- "column": 6
+ "column": 23
},
"end": {
"line": 1,
- "column": 8
+ "column": 24
}
}
},
{
- "type": "Identifier",
- "value": "x",
+ "type": "Null",
+ "value": "null",
"range": [
- 9,
- 10
+ 25,
+ 29
],
"loc": {
"start": {
"line": 1,
- "column": 9
+ "column": 25
},
"end": {
"line": 1,
- "column": 10
+ "column": 29
}
}
},
{
"type": "Punctuator",
- "value": "*",
+ "value": "}",
"range": [
- 11,
- 12
+ 30,
+ 31
],
"loc": {
"start": {
"line": 1,
- "column": 11
+ "column": 30
},
"end": {
"line": 1,
- "column": 12
+ "column": 31
}
}
},
{
- "type": "Identifier",
- "value": "x",
+ "type": "Punctuator",
+ "value": ")",
"range": [
- 13,
- 14
+ 31,
+ 32
],
"loc": {
"start": {
"line": 1,
- "column": 13
+ "column": 31
},
"end": {
"line": 1,
- "column": 14
+ "column": 32
}
}
}
diff --git a/test/fixtures/ES6/object-initialiser/invalid-proto-shorthand-literal.js b/test/fixtures/ES6/object-initialiser/proto-shorthand-literal.js
similarity index 100%
rename from test/fixtures/ES6/object-initialiser/invalid-proto-shorthand-literal.js
rename to test/fixtures/ES6/object-initialiser/proto-shorthand-literal.js
diff --git a/test/fixtures/ES6/arrow-function/migrated_0008.tree.json b/test/fixtures/ES6/object-initialiser/proto-shorthand-literal.tree.json
similarity index 60%
copy from test/fixtures/ES6/arrow-function/migrated_0008.tree.json
copy to test/fixtures/ES6/object-initialiser/proto-shorthand-literal.tree.json
index bb438eb..b6aa4c8 100644
--- a/test/fixtures/ES6/arrow-function/migrated_0008.tree.json
+++ b/test/fixtures/ES6/object-initialiser/proto-shorthand-literal.tree.json
@@ -4,37 +4,35 @@
{
"type": "ExpressionStatement",
"expression": {
- "type": "ArrowFunctionExpression",
- "id": null,
- "params": [
+ "type": "ObjectExpression",
+ "properties": [
{
- "type": "AssignmentPattern",
- "operator": "=",
- "left": {
+ "type": "Property",
+ "key": {
"type": "Identifier",
- "name": "x",
+ "name": "__proto__",
"range": [
- 1,
- 2
+ 3,
+ 12
],
"loc": {
"start": {
"line": 1,
- "column": 1
+ "column": 3
},
"end": {
"line": 1,
- "column": 2
+ "column": 12
}
}
},
- "right": {
- "type": "Literal",
- "value": 1,
- "raw": "1",
+ "computed": false,
+ "value": {
+ "type": "Identifier",
+ "name": "__proto__",
"range": [
3,
- 4
+ 12
],
"loc": {
"start": {
@@ -43,100 +41,106 @@
},
"end": {
"line": 1,
- "column": 4
+ "column": 12
}
}
},
+ "kind": "init",
+ "method": false,
+ "shorthand": true,
"range": [
- 1,
- 4
+ 3,
+ 12
],
"loc": {
"start": {
"line": 1,
- "column": 1
+ "column": 3
},
"end": {
"line": 1,
- "column": 4
- }
- }
- }
- ],
- "body": {
- "type": "BinaryExpression",
- "operator": "*",
- "left": {
- "type": "Identifier",
- "name": "x",
- "range": [
- 9,
- 10
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 9
- },
- "end": {
- "line": 1,
- "column": 10
+ "column": 12
}
}
},
- "right": {
- "type": "Identifier",
- "name": "x",
+ {
+ "type": "Property",
+ "key": {
+ "type": "Literal",
+ "value": "__proto__",
+ "raw": "\"__proto__\"",
+ "range": [
+ 14,
+ 25
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 14
+ },
+ "end": {
+ "line": 1,
+ "column": 25
+ }
+ }
+ },
+ "computed": false,
+ "value": {
+ "type": "Literal",
+ "value": null,
+ "raw": "null",
+ "range": [
+ 27,
+ 31
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 27
+ },
+ "end": {
+ "line": 1,
+ "column": 31
+ }
+ }
+ },
+ "kind": "init",
+ "method": false,
+ "shorthand": false,
"range": [
- 13,
- 14
+ 14,
+ 31
],
"loc": {
"start": {
"line": 1,
- "column": 13
+ "column": 14
},
"end": {
"line": 1,
- "column": 14
+ "column": 31
}
}
- },
- "range": [
- 9,
- 14
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 9
- },
- "end": {
- "line": 1,
- "column": 14
- }
}
- },
- "generator": false,
- "expression": true,
+ ],
"range": [
- 0,
- 14
+ 1,
+ 33
],
"loc": {
"start": {
"line": 1,
- "column": 0
+ "column": 1
},
"end": {
"line": 1,
- "column": 14
+ "column": 33
}
}
},
"range": [
0,
- 14
+ 34
],
"loc": {
"start": {
@@ -145,7 +149,7 @@
},
"end": {
"line": 1,
- "column": 14
+ "column": 34
}
}
}
@@ -153,7 +157,7 @@
"sourceType": "script",
"range": [
0,
- 14
+ 34
],
"loc": {
"start": {
@@ -162,7 +166,7 @@
},
"end": {
"line": 1,
- "column": 14
+ "column": 34
}
},
"tokens": [
@@ -185,8 +189,8 @@
}
},
{
- "type": "Identifier",
- "value": "x",
+ "type": "Punctuator",
+ "value": "{",
"range": [
1,
2
@@ -203,128 +207,128 @@
}
},
{
- "type": "Punctuator",
- "value": "=",
+ "type": "Identifier",
+ "value": "__proto__",
"range": [
- 2,
- 3
+ 3,
+ 12
],
"loc": {
"start": {
"line": 1,
- "column": 2
+ "column": 3
},
"end": {
"line": 1,
- "column": 3
+ "column": 12
}
}
},
{
- "type": "Numeric",
- "value": "1",
+ "type": "Punctuator",
+ "value": ",",
"range": [
- 3,
- 4
+ 12,
+ 13
],
"loc": {
"start": {
"line": 1,
- "column": 3
+ "column": 12
},
"end": {
"line": 1,
- "column": 4
+ "column": 13
}
}
},
{
- "type": "Punctuator",
- "value": ")",
+ "type": "String",
+ "value": "\"__proto__\"",
"range": [
- 4,
- 5
+ 14,
+ 25
],
"loc": {
"start": {
"line": 1,
- "column": 4
+ "column": 14
},
"end": {
"line": 1,
- "column": 5
+ "column": 25
}
}
},
{
"type": "Punctuator",
- "value": "=>",
+ "value": ":",
"range": [
- 6,
- 8
+ 25,
+ 26
],
"loc": {
"start": {
"line": 1,
- "column": 6
+ "column": 25
},
"end": {
"line": 1,
- "column": 8
+ "column": 26
}
}
},
{
- "type": "Identifier",
- "value": "x",
+ "type": "Null",
+ "value": "null",
"range": [
- 9,
- 10
+ 27,
+ 31
],
"loc": {
"start": {
"line": 1,
- "column": 9
+ "column": 27
},
"end": {
"line": 1,
- "column": 10
+ "column": 31
}
}
},
{
"type": "Punctuator",
- "value": "*",
+ "value": "}",
"range": [
- 11,
- 12
+ 32,
+ 33
],
"loc": {
"start": {
"line": 1,
- "column": 11
+ "column": 32
},
"end": {
"line": 1,
- "column": 12
+ "column": 33
}
}
},
{
- "type": "Identifier",
- "value": "x",
+ "type": "Punctuator",
+ "value": ")",
"range": [
- 13,
- 14
+ 33,
+ 34
],
"loc": {
"start": {
"line": 1,
- "column": 13
+ "column": 33
},
"end": {
"line": 1,
- "column": 14
+ "column": 34
}
}
}
diff --git a/test/fixtures/ES6/object-initialiser/invalid-proto-shorthands.js b/test/fixtures/ES6/object-initialiser/proto-shorthands.js
similarity index 100%
rename from test/fixtures/ES6/object-initialiser/invalid-proto-shorthands.js
rename to test/fixtures/ES6/object-initialiser/proto-shorthands.js
diff --git a/test/fixtures/ES6/arrow-function/migrated_0014.tree.json b/test/fixtures/ES6/object-initialiser/proto-shorthands.tree.json
similarity index 57%
copy from test/fixtures/ES6/arrow-function/migrated_0014.tree.json
copy to test/fixtures/ES6/object-initialiser/proto-shorthands.tree.json
index 0887497..88c8d84 100644
--- a/test/fixtures/ES6/arrow-function/migrated_0014.tree.json
+++ b/test/fixtures/ES6/object-initialiser/proto-shorthands.tree.json
@@ -4,122 +4,141 @@
{
"type": "ExpressionStatement",
"expression": {
- "type": "ArrowFunctionExpression",
- "id": null,
- "params": [
+ "type": "ObjectExpression",
+ "properties": [
{
- "type": "Identifier",
- "name": "eval",
+ "type": "Property",
+ "key": {
+ "type": "Identifier",
+ "name": "__proto__",
+ "range": [
+ 3,
+ 12
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 3
+ },
+ "end": {
+ "line": 1,
+ "column": 12
+ }
+ }
+ },
+ "computed": false,
+ "value": {
+ "type": "Identifier",
+ "name": "__proto__",
+ "range": [
+ 3,
+ 12
+ ],
+ "loc": {
+ "start": {
+ "line": 1,
+ "column": 3
+ },
+ "end": {
+ "line": 1,
+ "column": 12
+ }
+ }
+ },
+ "kind": "init",
+ "method": false,
+ "shorthand": true,
"range": [
- 1,
- 5
+ 3,
+ 12
],
"loc": {
"start": {
"line": 1,
- "column": 1
+ "column": 3
},
"end": {
"line": 1,
- "column": 5
+ "column": 12
}
}
},
{
- "type": "AssignmentPattern",
- "operator": "=",
- "left": {
+ "type": "Property",
+ "key": {
"type": "Identifier",
- "name": "a",
+ "name": "__proto__",
"range": [
- 7,
- 8
+ 14,
+ 23
],
"loc": {
"start": {
"line": 1,
- "column": 7
+ "column": 14
},
"end": {
"line": 1,
- "column": 8
+ "column": 23
}
}
},
- "right": {
- "type": "Literal",
- "value": 10,
- "raw": "10",
+ "computed": false,
+ "value": {
+ "type": "Identifier",
+ "name": "__proto__",
"range": [
- 11,
- 13
+ 14,
+ 23
],
"loc": {
"start": {
"line": 1,
- "column": 11
+ "column": 14
},
"end": {
"line": 1,
- "column": 13
+ "column": 23
}
}
},
+ "kind": "init",
+ "method": false,
+ "shorthand": true,
"range": [
- 7,
- 13
+ 14,
+ 23
],
"loc": {
"start": {
"line": 1,
- "column": 7
+ "column": 14
},
"end": {
"line": 1,
- "column": 13
+ "column": 23
}
}
}
],
- "body": {
- "type": "Literal",
- "value": 42,
- "raw": "42",
- "range": [
- 18,
- 20
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 18
- },
- "end": {
- "line": 1,
- "column": 20
- }
- }
- },
- "generator": false,
- "expression": true,
"range": [
- 0,
- 20
+ 1,
+ 25
],
"loc": {
"start": {
"line": 1,
- "column": 0
+ "column": 1
},
"end": {
"line": 1,
- "column": 20
+ "column": 25
}
}
},
"range": [
0,
- 20
+ 26
],
"loc": {
"start": {
@@ -128,7 +147,7 @@
},
"end": {
"line": 1,
- "column": 20
+ "column": 26
}
}
}
@@ -136,7 +155,7 @@
"sourceType": "script",
"range": [
0,
- 20
+ 26
],
"loc": {
"start": {
@@ -145,7 +164,7 @@
},
"end": {
"line": 1,
- "column": 20
+ "column": 26
}
},
"tokens": [
@@ -168,11 +187,11 @@
}
},
{
- "type": "Identifier",
- "value": "eval",
+ "type": "Punctuator",
+ "value": "{",
"range": [
1,
- 5
+ 2
],
"loc": {
"start": {
@@ -181,75 +200,39 @@
},
"end": {
"line": 1,
- "column": 5
- }
- }
- },
- {
- "type": "Punctuator",
- "value": ",",
- "range": [
- 5,
- 6
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 5
- },
- "end": {
- "line": 1,
- "column": 6
+ "column": 2
}
}
},
{
"type": "Identifier",
- "value": "a",
+ "value": "__proto__",
"range": [
- 7,
- 8
+ 3,
+ 12
],
"loc": {
"start": {
"line": 1,
- "column": 7
+ "column": 3
},
"end": {
"line": 1,
- "column": 8
+ "column": 12
}
}
},
{
"type": "Punctuator",
- "value": "=",
- "range": [
- 9,
- 10
- ],
- "loc": {
- "start": {
- "line": 1,
- "column": 9
- },
- "end": {
- "line": 1,
- "column": 10
- }
- }
- },
- {
- "type": "Numeric",
- "value": "10",
+ "value": ",",
"range": [
- 11,
+ 12,
13
],
"loc": {
"start": {
"line": 1,
- "column": 11
+ "column": 12
},
"end": {
"line": 1,
@@ -258,56 +241,56 @@
}
},
{
- "type": "Punctuator",
- "value": ")",
+ "type": "Identifier",
+ "value": "__proto__",
"range": [
- 13,
- 14
+ 14,
+ 23
],
"loc": {
"start": {
"line": 1,
- "column": 13
+ "column": 14
},
"end": {
"line": 1,
- "column": 14
+ "column": 23
}
}
},
{
"type": "Punctuator",
- "value": "=>",
+ "value": "}",
"range": [
- 15,
- 17
+ 24,
+ 25
],
"loc": {
"start": {
"line": 1,
- "column": 15
+ "column": 24
},
"end": {
"line": 1,
- "column": 17
+ "column": 25
}
}
},
{
- "type": "Numeric",
- "value": "42",
+ "type": "Punctuator",
+ "value": ")",
"range": [
- 18,
- 20
+ 25,
+ 26
],
"loc": {
"start": {
"line": 1,
- "column": 18
+ "column": 25
},
"end": {
"line": 1,
- "column": 20
+ "column": 26
}
}
}
diff --git a/test/fixtures/ES6/yield/yield-arrow-parameter-default.tree.json b/test/fixtures/ES6/yield/yield-arrow-parameter-default.tree.json
index 40531d3..9766a51 100644
--- a/test/fixtures/ES6/yield/yield-arrow-parameter-default.tree.json
+++ b/test/fixtures/ES6/yield/yield-arrow-parameter-default.tree.json
@@ -9,7 +9,6 @@
"params": [
{
"type": "AssignmentPattern",
- "operator": "=",
"left": {
"type": "Identifier",
"name": "x",
diff --git a/test/fixtures/ES6/yield/yield-generator-arrow-default.tree.json b/test/fixtures/ES6/yield/yield-generator-arrow-default.tree.json
index f2f6cf4..d8f819a 100644
--- a/test/fixtures/ES6/yield/yield-generator-arrow-default.tree.json
+++ b/test/fixtures/ES6/yield/yield-generator-arrow-default.tree.json
@@ -33,7 +33,6 @@
"params": [
{
"type": "AssignmentPattern",
- "operator": "=",
"left": {
"type": "Identifier",
"name": "x",
diff --git a/test/fixtures/es2017/for-statement/invalid-var-init-forin1.failure.json b/test/fixtures/es2017/for-statement/invalid-var-init-forin1.failure.json
new file mode 100644
index 0000000..db29861
--- /dev/null
+++ b/test/fixtures/es2017/for-statement/invalid-var-init-forin1.failure.json
@@ -0,0 +1 @@
+{"index":26,"lineNumber":1,"column":27,"message":"Error: Line 1: for-in loop variable declaration may not have an initializer","description":"for-in loop variable declaration may not have an initializer"}
\ No newline at end of file
diff --git a/test/fixtures/es2017/for-statement/invalid-var-init-forin1.js b/test/fixtures/es2017/for-statement/invalid-var-init-forin1.js
new file mode 100644
index 0000000..a06f428
--- /dev/null
+++ b/test/fixtures/es2017/for-statement/invalid-var-init-forin1.js
@@ -0,0 +1 @@
+"use strict"; for (var i=0 in j);
diff --git a/test/fixtures/es2017/for-statement/invalid-var-init-forin2.failure.json b/test/fixtures/es2017/for-statement/invalid-var-init-forin2.failure.json
new file mode 100644
index 0000000..65c635f
--- /dev/null
+++ b/test/fixtures/es2017/for-statement/invalid-var-init-forin2.failure.json
@@ -0,0 +1 @@
+{"index":14,"lineNumber":1,"column":15,"message":"Error: Line 1: for-in loop variable declaration may not have an initializer","description":"for-in loop variable declaration may not have an initializer"}
\ No newline at end of file
diff --git a/test/fixtures/es2017/for-statement/invalid-var-init-forin2.js b/test/fixtures/es2017/for-statement/invalid-var-init-forin2.js
new file mode 100644
index 0000000..df7751c
--- /dev/null
+++ b/test/fixtures/es2017/for-statement/invalid-var-init-forin2.js
@@ -0,0 +1 @@
+for (var {x}=0 in y);
diff --git a/test/fixtures/es2017/for-statement/invalid-var-init-forin3.failure.json b/test/fixtures/es2017/for-statement/invalid-var-init-forin3.failure.json
new file mode 100644
index 0000000..a1ce7ad
--- /dev/null
+++ b/test/fixtures/es2017/for-statement/invalid-var-init-forin3.failure.json
@@ -0,0 +1 @@
+{"index":28,"lineNumber":1,"column":29,"message":"Error: Line 1: for-in loop variable declaration may not have an initializer","description":"for-in loop variable declaration may not have an initializer"}
\ No newline at end of file
diff --git a/test/fixtures/es2017/for-statement/invalid-var-init-forin3.js b/test/fixtures/es2017/for-statement/invalid-var-init-forin3.js
new file mode 100644
index 0000000..a7a6d20
--- /dev/null
+++ b/test/fixtures/es2017/for-statement/invalid-var-init-forin3.js
@@ -0,0 +1 @@
+"use strict"; for (var {x}=0 in y);
diff --git a/test/fixtures/es2017/for-statement/invalid-var-init-forin4.failure.json b/test/fixtures/es2017/for-statement/invalid-var-init-forin4.failure.json
new file mode 100644
index 0000000..65c635f
--- /dev/null
+++ b/test/fixtures/es2017/for-statement/invalid-var-init-forin4.failure.json
@@ -0,0 +1 @@
+{"index":14,"lineNumber":1,"column":15,"message":"Error: Line 1: for-in loop variable declaration may not have an initializer","description":"for-in loop variable declaration may not have an initializer"}
\ No newline at end of file
diff --git a/test/fixtures/es2017/for-statement/invalid-var-init-forin4.js b/test/fixtures/es2017/for-statement/invalid-var-init-forin4.js
new file mode 100644
index 0000000..a948d37
--- /dev/null
+++ b/test/fixtures/es2017/for-statement/invalid-var-init-forin4.js
@@ -0,0 +1 @@
+for (var [p]=0 in q);
diff --git a/test/fixtures/es2017/for-statement/invalid-var-init-forin5.failure.json b/test/fixtures/es2017/for-statement/invalid-var-init-forin5.failure.json
new file mode 100644
index 0000000..a1ce7ad
--- /dev/null
+++ b/test/fixtures/es2017/for-statement/invalid-var-init-forin5.failure.json
@@ -0,0 +1 @@
+{"index":28,"lineNumber":1,"column":29,"message":"Error: Line 1: for-in loop variable declaration may not have an initializer","description":"for-in loop variable declaration may not have an initializer"}
\ No newline at end of file
diff --git a/test/fixtures/es2017/for-statement/invalid-var-init-forin5.js b/test/fixtures/es2017/for-statement/invalid-var-init-forin5.js
new file mode 100644
index 0000000..9299d7f
--- /dev/null
+++ b/test/fixtures/es2017/for-statement/invalid-var-init-forin5.js
@@ -0,0 +1 @@
+"use strict"; for (var [p]=1 in q);
diff --git a/test/fixtures/statement/iteration/invalid-assign-for-in.failure.json b/test/fixtures/statement/iteration/invalid-assign-for-in.failure.json
new file mode 100644
index 0000000..8d05182
--- /dev/null
+++ b/test/fixtures/statement/iteration/invalid-assign-for-in.failure.json
@@ -0,0 +1 @@
+{"index":8,"lineNumber":1,"column":9,"message":"Error: Line 1: Invalid left-hand side in for-in","description":"Invalid left-hand side in for-in"}
\ No newline at end of file
diff --git a/test/fixtures/statement/iteration/invalid-assign-for-in.js b/test/fixtures/statement/iteration/invalid-assign-for-in.js
new file mode 100644
index 0000000..15da094
--- /dev/null
+++ b/test/fixtures/statement/iteration/invalid-assign-for-in.js
@@ -0,0 +1 @@
+for (x=0 in y);
diff --git a/test/hostile-environment-tests.js b/test/hostile-environment-tests.js
index ba2c94a..a328279 100644
--- a/test/hostile-environment-tests.js
+++ b/test/hostile-environment-tests.js
@@ -40,7 +40,7 @@ Object.defineProperty = defineProperty;
if (typeof Object.defineProperty === 'function') {
Object.defineProperty(Object.prototype, '$a', {
- get: function () {},
+ get: function () { },
configurable: true
});
try {
diff --git a/test/profile.js b/test/profile.js
index 352bfcc..d9430c5 100644
--- a/test/profile.js
+++ b/test/profile.js
@@ -55,4 +55,3 @@ fixture.forEach(function (name) {
process.exit(1);
}
});
-
diff --git a/test/regression-tests.js b/test/regression-tests.js
index 6d21633..b8c5170 100644
--- a/test/regression-tests.js
+++ b/test/regression-tests.js
@@ -144,4 +144,3 @@ fixture.forEach(function (name) {
process.exit(1);
}
});
-
diff --git a/test/tsfmt.json b/test/tsfmt.json
new file mode 100644
index 0000000..d5fd8f0
--- /dev/null
+++ b/test/tsfmt.json
@@ -0,0 +1,14 @@
+{
+ "indentSize": 4,
+ "tabSize": 4,
+ "insertSpaceAfterCommaDelimiter": true,
+ "insertSpaceAfterSemicolonInForStatements": true,
+ "insertSpaceBeforeAndAfterBinaryOperators": true,
+ "insertSpaceAfterKeywordsInControlFlowStatements": true,
+ "insertSpaceAfterFunctionKeywordForAnonymousFunctions": true,
+ "insertSpaceAfterOpeningAndBeforeClosingNonemptyParenthesis": false,
+ "insertSpaceAfterOpeningAndBeforeClosingNonemptyBrackets": false,
+ "insertSpaceAfterOpeningAndBeforeClosingTemplateStringBraces": false,
+ "placeOpenBraceOnNewLineForFunctions": false,
+ "placeOpenBraceOnNewLineForControlBlocks": false
+}
diff --git a/test/unit-tests.js b/test/unit-tests.js
index cea8ad8..f608ba0 100644
--- a/test/unit-tests.js
+++ b/test/unit-tests.js
@@ -35,7 +35,7 @@ var esprima = require('../'),
result,
failures = [],
cases = {},
- context = {source: '', result: null},
+ context = { source: '', result: null },
tick = new Date(),
testCase,
header;
@@ -111,13 +111,13 @@ if (failures.length) {
actualObject = JSON.parse(failure.actual);
console.error(failure.source + ': Expected\n ' +
- failure.expected.split('\n').join('\n ') +
- '\nto match\n ' + failure.actual + '\nDiff:\n' +
- diff(expectedObject, actualObject));
+ failure.expected.split('\n').join('\n ') +
+ '\nto match\n ' + failure.actual + '\nDiff:\n' +
+ diff(expectedObject, actualObject));
} catch (ex) {
console.error(failure.source + ': Expected\n ' +
- failure.expected.split('\n').join('\n ') +
- '\nto match\n ' + failure.actual);
+ failure.expected.split('\n').join('\n ') +
+ '\nto match\n ' + failure.actual);
}
});
} else {
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-esprima.git
More information about the Pkg-javascript-commits
mailing list