Skip to content

Commit

Permalink
Fixed missing space between for await with compact: true
Browse files Browse the repository at this point in the history
  • Loading branch information
sanex3339 authored and michaelficarra committed Jan 3, 2020
1 parent 124e035 commit 2360684
Show file tree
Hide file tree
Showing 2 changed files with 78 additions and 1 deletion.
2 changes: 1 addition & 1 deletion escodegen.js
Original file line number Diff line number Diff line change
Expand Up @@ -953,7 +953,7 @@
};

CodeGenerator.prototype.generateIterationForStatement = function (operator, stmt, flags) {
var result = ['for' + space + (stmt.await ? 'await' + space : '') + '('], that = this;
var result = ['for' + (stmt.await ? noEmptySpace() + 'await' : '') + space + '('], that = this;
withIndent(function () {
if (stmt.left.type === Syntax.VariableDeclaration) {
withIndent(function () {
Expand Down
77 changes: 77 additions & 0 deletions test/harmony.js
Original file line number Diff line number Diff line change
Expand Up @@ -6322,6 +6322,83 @@ data = {

},

'ES2018 for-await-of with `compact: true`': {
'async function f(){for await(const x of ait){console.log(x);}}': {
options: {
format: {
compact: true
}
},
generateFrom: {
"type": "FunctionDeclaration",
"id": {
"type": "Identifier",
"name": "f"
},
"params": [],
"body": {
"type": "BlockStatement",
"body": [
{
"type": "ForOfStatement",
"left": {
"type": "VariableDeclaration",
"declarations": [
{
"type": "VariableDeclarator",
"id": {
"type": "Identifier",
"name": "x"
},
"init": null
}
],
"kind": "const"
},
"right": {
"type": "Identifier",
"name": "ait"
},
"body": {
"type": "BlockStatement",
"body": [
{
"type": "ExpressionStatement",
"expression": {
"type": "CallExpression",
"callee": {
"type": "MemberExpression",
"object": {
"type": "Identifier",
"name": "console"
},
"property": {
"type": "Identifier",
"name": "log"
},
"computed": false
},
"arguments": [
{
"type": "Identifier",
"name": "x"
}
]
}
}
]
},
"await": true
}
]
},
"generator": false,
"async": true
}
}

},

'ES2018 async generator method': {
'class C {\n async *readLines(file) {\n while (!file.EOF) {\n yield await file.readLine();\n }\n }\n}': {
generateFrom: {
Expand Down

0 comments on commit 2360684

Please sign in to comment.