Skip to content
Snippets Groups Projects
Commit bbbaba0e authored by Cheng Shao's avatar Cheng Shao :beach:
Browse files

testsuite: add test for wasm promise.throwTo() logic

This commit adds a test case to test the wasm backend
promise.throwTo() logic.

(cherry picked from commit 7f80455e)
parent 2162cb15
No related branches found
No related tags found
No related merge requests found
......@@ -11,6 +11,8 @@ setTestOpts([
extra_ways(['compacting_gc', 'nonmoving', 'sanity'])
])
test('cancel', [], compile_and_run, ['-optl-Wl,--export=setTimeout'])
test('gameover', [], compile_and_run, ['-optl-Wl,--export=testJSException,--export=testHSException'])
test('http', [], compile_and_run, ['-optl-Wl,--export=main'])
......
module Test where
import Control.Exception
foreign import javascript safe "new Promise(res => setTimeout(res, $1))"
js_setTimeout :: Int -> IO ()
setTimeout :: Int -> IO ()
setTimeout t = evaluate =<< js_setTimeout t
foreign export javascript "setTimeout"
setTimeout :: Int -> IO ()
export default async (__exports) => {
const test = new Promise((res) => {
const p = __exports.setTimeout(114514);
p.throwTo("1919810");
p.catch((err) => {
console.log(`${err}`.split("\n")[0]);
res();
});
});
await test;
process.exit();
};
RuntimeError: JSException "1919810"
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment