JS: Add test

This commit is contained in:
Asger F
2022-06-20 12:59:29 +02:00
parent a0d3a6b5b1
commit 835c9bb0b9
2 changed files with 33 additions and 0 deletions

View File

@@ -34,6 +34,7 @@ from Locatable loc, File f, int l, string name, string msg
where
expected(loc, f, l, name) and
not actual(_, f, l, name) and
name != "none" and
msg = "Failed to track " + name + " here."
or
actual(loc, f, l, name) and

View File

@@ -0,0 +1,32 @@
const lib = require('testlib');
function foo() {
return lib.foo(); // name: raw-await-source
}
async function test() {
const x = await foo();
const y = await x;
const z = await y;
z; // track: raw-await-source
}
async function exceptionThrower() {
throw {}; // name: raw-await-err
}
async function exceptionReThrower() {
const x = await exceptionThrower();
const y = x.catch(err => {
err; // track: none
});
return y;
}
async function exceptionCatcher() {
try {
await exceptionThrower();
} catch (err) {
err; // track: raw-await-err
}
}