mirror of
https://github.com/tc39/test262.git
synced 2025-05-03 14:30:27 +02:00
* [javascriptcore-test262-automation] changes from git@github.com:WebKit/webkit.git at sha 949e26452cfa153a7f4afe593da97e2fe9e1b706 on Tue Jul 03 2018 14:35:15 GMT-0400 (Eastern Daylight Time)
37 lines
697 B
JavaScript
37 lines
697 B
JavaScript
function assert(b) {
|
|
if (!b)
|
|
throw new Error("Bad");
|
|
}
|
|
|
|
async function* asyncIterator() {
|
|
yield 42;
|
|
}
|
|
|
|
function test1() {
|
|
let p = asyncIterator();
|
|
p.next().then((x) => {
|
|
assert(x.value === 42);
|
|
assert(x.done === false);
|
|
});
|
|
p.__proto__ = {};
|
|
assert(p.next === undefined);
|
|
}
|
|
test1();
|
|
|
|
let error = null;
|
|
async function test2() {
|
|
let p2 = asyncIterator();
|
|
p2.__proto__ = {};
|
|
try {
|
|
for await (let x of p2) {
|
|
throw new Error("Bad!");
|
|
}
|
|
}
|
|
catch(e) {
|
|
error = e;
|
|
}
|
|
}
|
|
test2();
|
|
assert(error instanceof TypeError);
|
|
assert(error.message === "undefined is not a function (near '...x of p2...')");
|