Bug 1354212: Fix source representation for async generators created through AsyncGenerator intrinsic. r=arai

This commit is contained in:
André Bargull 2017-04-07 16:02:11 +02:00
parent f2c723fa8a
commit b719cb0993
8 changed files with 64 additions and 2 deletions

View File

@ -2500,7 +2500,7 @@ Parser<FullParseHandler>::standaloneFunction(HandleFunction fun,
if (!tokenStream.getToken(&tt))
return null();
if (generatorKind == StarGenerator && asyncKind == SyncFunction) {
if (generatorKind == StarGenerator) {
MOZ_ASSERT(tt == TOK_MUL);
if (!tokenStream.getToken(&tt))
return null();

View File

@ -1677,7 +1677,7 @@ FunctionConstructor(JSContext* cx, const CallArgs& args, GeneratorKind generator
}
if (!sb.append("function"))
return false;
if (isStarGenerator && !isAsync) {
if (isStarGenerator) {
if (!sb.append('*'))
return false;
}

View File

@ -0,0 +1,18 @@
// Copyright 2017 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: pending
description: >
Function.prototype.toString on an async generator created with the
AsyncGenerator constructor.
features: [async-iteration]
---*/
async function* f() {}
var AsyncGenerator = f.constructor;
var g = /* before */AsyncGenerator("a", " /* a */ b, c /* b */ //", "/* c */ ; /* d */ //")/* after */;
assert.sameValue(g.toString(), "async function* anonymous(a, /* a */ b, c /* b */ //\n) {\n/* c */ ; /* d */ //\n}");
reportCompare(0, 0);

View File

@ -0,0 +1,14 @@
// Copyright 2017 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: pending
description: Function.prototype.toString on an async generator declaration
features: [async-iteration]
---*/
/* before */async /* a */ function /* b */ * /* c */ f /* d */ ( /* e */ x /* f */ , /* g */ y /* h */ ) /* i */ { /* j */ ; /* k */ ; /* l */ }/* after */
assert.sameValue(f.toString(), "async /* a */ function /* b */ * /* c */ f /* d */ ( /* e */ x /* f */ , /* g */ y /* h */ ) /* i */ { /* j */ ; /* k */ ; /* l */ }");
reportCompare(0, 0);

View File

@ -0,0 +1,14 @@
// Copyright 2017 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: pending
description: Function.prototype.toString on an async generator expression
features: [async-iteration]
---*/
let f = /* before */async /* a */ function /* b */ * /* c */ f /* d */ ( /* e */ x /* f */ , /* g */ y /* h */ ) /* i */ { /* j */ ; /* k */ ; /* l */ }/* after */;
assert.sameValue(f.toString(), "async /* a */ function /* b */ * /* c */ f /* d */ ( /* e */ x /* f */ , /* g */ y /* h */ ) /* i */ { /* j */ ; /* k */ ; /* l */ }");
reportCompare(0, 0);

View File

@ -0,0 +1,16 @@
// Copyright 2017 André Bargull. All rights reserved.
// This code is governed by the BSD license found in the LICENSE file.
/*---
esid: pending
description: Function.prototype.toString on an async generator method
features: [async-iteration]
---*/
let f = { /* before */async /* a */ * /* b */ f /* c */ ( /* d */ ) /* e */ { /* f */ }/* after */ }.f;
let g = { /* before */async /* a */ * /* b */ [ /* c */ "g" /* d */ ] /* e */ ( /* f */ ) /* g */ { /* h */ }/* after */ }.g;
assert.sameValue(f.toString(), "async /* a */ * /* b */ f /* c */ ( /* d */ ) /* e */ { /* f */ }");
assert.sameValue(g.toString(), "async /* a */ * /* b */ [ /* c */ \"g\" /* d */ ] /* e */ ( /* f */ ) /* g */ { /* h */ }");
reportCompare(0, 0);