Implement missing async function and async iterator prototypes. (#3962)
JerryScript-DCO-1.0-Signed-off-by: Zoltan Herczeg zherczeg.u-szeged@partner.samsung.com
This commit is contained in:
@@ -615,9 +615,35 @@ async function f11() {
|
||||
|
||||
f11()
|
||||
|
||||
// Test 12
|
||||
|
||||
var o12 = {}
|
||||
async function *gen12()
|
||||
{
|
||||
try {
|
||||
yield 9.5
|
||||
assert(false)
|
||||
} finally {
|
||||
successCount++
|
||||
}
|
||||
assert(false)
|
||||
}
|
||||
|
||||
async function f12()
|
||||
{
|
||||
for await (var v of gen12())
|
||||
{
|
||||
assert(v === 9.5)
|
||||
break;
|
||||
}
|
||||
successCount++
|
||||
}
|
||||
|
||||
f12()
|
||||
|
||||
// END
|
||||
|
||||
function __checkAsync() {
|
||||
assert(returnCount2 === 5)
|
||||
assert(successCount === 34)
|
||||
assert(successCount === 36)
|
||||
}
|
||||
|
||||
@@ -190,9 +190,41 @@ async function f2b() {
|
||||
|
||||
f2b();
|
||||
|
||||
// Test 3
|
||||
|
||||
var o3 = {}
|
||||
async function* gen3()
|
||||
{
|
||||
yield o3
|
||||
yield "Res"
|
||||
}
|
||||
|
||||
async function f3()
|
||||
{
|
||||
var idx = 0
|
||||
|
||||
for await (var v of gen3())
|
||||
{
|
||||
idx++
|
||||
|
||||
if (idx === 1)
|
||||
{
|
||||
assert(v === o3)
|
||||
}
|
||||
else
|
||||
{
|
||||
assert(idx === 2)
|
||||
assert(v === "Res")
|
||||
}
|
||||
}
|
||||
successCount++
|
||||
}
|
||||
|
||||
f3()
|
||||
|
||||
// END
|
||||
|
||||
function __checkAsync() {
|
||||
assert(state2 === 8)
|
||||
assert(successCount === 23)
|
||||
assert(successCount === 24)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,32 @@
|
||||
// Copyright JS Foundation and other contributors, http://js.foundation
|
||||
//
|
||||
// Licensed under the Apache License, Version 2.0 (the "License");
|
||||
// you may not use this file except in compliance with the License.
|
||||
// You may obtain a copy of the License at
|
||||
//
|
||||
// http://www.apache.org/licenses/LICENSE-2.0
|
||||
//
|
||||
// Unless required by applicable law or agreed to in writing, software
|
||||
// distributed under the License is distributed on an "AS IS" BASIS
|
||||
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
// See the License for the specific language governing permissions and
|
||||
// limitations under the License.
|
||||
|
||||
/* This test async prototype. */
|
||||
|
||||
var proto1 = Object.getPrototypeOf(async () => {})
|
||||
var proto2 = Object.getPrototypeOf(async function () {})
|
||||
|
||||
assert(proto1 === proto2)
|
||||
assert(typeof proto1 === "object")
|
||||
assert(proto1[Symbol.toStringTag] === "AsyncFunction")
|
||||
assert(typeof proto1.constructor === "function")
|
||||
assert(proto1.constructor.name === "AsyncFunction")
|
||||
|
||||
var successCount = 0
|
||||
var f = proto1.constructor("p", "assert(await p === 'Res'); successCount++")
|
||||
f(Promise.resolve("Res"))
|
||||
|
||||
function __checkAsync() {
|
||||
assert(successCount === 1)
|
||||
}
|
||||
Reference in New Issue
Block a user