diff options
author | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 12:41:41 +0000 |
---|---|---|
committer | Daniel Baumann <daniel.baumann@progress-linux.org> | 2024-05-04 12:41:41 +0000 |
commit | 10ee2acdd26a7f1298c6f6d6b7af9b469fe29b87 (patch) | |
tree | bdffd5d80c26cf4a7a518281a204be1ace85b4c1 /vendor/wasm-bindgen/tests/wasm/futures.js | |
parent | Releasing progress-linux version 1.70.0+dfsg1-9~progress7.99u1. (diff) | |
download | rustc-10ee2acdd26a7f1298c6f6d6b7af9b469fe29b87.tar.xz rustc-10ee2acdd26a7f1298c6f6d6b7af9b469fe29b87.zip |
Merging upstream version 1.70.0+dfsg2.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/wasm-bindgen/tests/wasm/futures.js')
-rw-r--r-- | vendor/wasm-bindgen/tests/wasm/futures.js | 44 |
1 files changed, 44 insertions, 0 deletions
diff --git a/vendor/wasm-bindgen/tests/wasm/futures.js b/vendor/wasm-bindgen/tests/wasm/futures.js new file mode 100644 index 000000000..5f4564bac --- /dev/null +++ b/vendor/wasm-bindgen/tests/wasm/futures.js @@ -0,0 +1,44 @@ +const assert = require('assert'); +const wasm = require('wasm-bindgen-test'); + +exports.call_exports = async function() { + await wasm.async_do_nothing(); + assert.strictEqual(1, await wasm.async_return_1()); + assert.strictEqual(2, await wasm.async_return_2()); + await wasm.async_nothing_again(); + assert.strictEqual(3, await wasm.async_return_3()); + assert.strictEqual(4, await wasm.async_return_4()); + assert.strictEqual(5, (await wasm.async_return_5()).val); + assert.strictEqual(6, (await wasm.async_return_6()).val); + await assert.rejects(wasm.async_throw_7(), /7/); + await assert.rejects(wasm.async_throw_custom(), /\[object Object\]/); + await assert.rejects(wasm.async_throw_message(), /async message/); + await assert.rejects(wasm.async_throw_jserror(), /async message/); + await assert.rejects(wasm.async_throw_custom_error(), /custom error/); + assert.strictEqual("Hi, Jim!", await wasm.async_take_reference("Jim")); + const foo = await new wasm.AsyncStruct(); + assert.strictEqual(42, await foo.method()); +}; + +exports.call_promise = async function() { + return "ok"; +} + +exports.call_promise_ok = async function() { + return "ok"; +} + +exports.call_promise_err = async function() { + throw "error"; +} + +exports.call_promise_unit = async function() { + console.log("asdfasdf"); +} + +exports.call_promise_ok_unit = async function() { +} + +exports.call_promise_err_unit = async function() { + throw "error"; +} |