[esnext] Async function toString support
BUG=v8:4483 Review-Url: https://codereview.chromium.org/1973193002 Cr-Commit-Position: refs/heads/master@{#36265}
This commit is contained in:
parent
690922c959
commit
4afe89a7da
@ -12192,10 +12192,16 @@ Handle<String> JSFunction::ToString(Handle<JSFunction> function) {
|
||||
IncrementalStringBuilder builder(isolate);
|
||||
if (!shared_info->is_arrow()) {
|
||||
if (shared_info->is_concise_method()) {
|
||||
if (shared_info->is_generator()) builder.AppendCharacter('*');
|
||||
if (shared_info->is_generator()) {
|
||||
builder.AppendCharacter('*');
|
||||
} else if (shared_info->is_async()) {
|
||||
builder.AppendCString("async ");
|
||||
}
|
||||
} else {
|
||||
if (shared_info->is_generator()) {
|
||||
builder.AppendCString("function* ");
|
||||
} else if (shared_info->is_async()) {
|
||||
builder.AppendCString("async function ");
|
||||
} else {
|
||||
builder.AppendCString("function ");
|
||||
}
|
||||
|
@ -336,3 +336,12 @@ var resumeAfterThrowNewEval = new AsyncFunction("value", `
|
||||
log = [];
|
||||
assertEqualsAsync(6, () => resumeAfterThrowNewEval(5));
|
||||
assertEquals("start:5 resume:throw1 resume:throw2", log.join(" "));
|
||||
|
||||
async function foo() {}
|
||||
assertEquals("async function foo() {}", foo.toString());
|
||||
assertEquals("async function () {}", async function() {}.toString());
|
||||
assertEquals("async x => x", (async x => x).toString());
|
||||
assertEquals("async x => { return x }", (async x => { return x }).toString());
|
||||
class AsyncMethod { async foo() { } }
|
||||
assertEquals("async foo() { }", Function.prototype.toString.call(AsyncMethod.prototype.foo));
|
||||
assertEquals("async foo() { }", Function.prototype.toString.call({async foo() { }}.foo));
|
||||
|
Loading…
Reference in New Issue
Block a user