Skip to content

Update a test for suspending import returning non-Promise value #58

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Feb 5, 2025
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions test/js-api/js-promise-integration/js-promise-integration.any.js
Original file line number Diff line number Diff line change
Expand Up @@ -168,27 +168,27 @@ promise_test(async () => {
let builder = new WasmModuleBuilder();
let AbeforeB = recordAbeforeB();
import42_index = builder.addImport('m', 'import42', kSig_i_i);
importSetA_index = builder.addImport('m', 'setA', kSig_v_v);
importSetB_index = builder.addImport('m', 'setB', kSig_v_v);
builder.addFunction("test", kSig_i_i)
.addBody([
kExprLocalGet, 0,
kExprCallFunction, import42_index, // suspend?
kExprCallFunction, importSetA_index
kExprCallFunction, importSetB_index
]).exportFunc();
let import42 = WebAssembly.Suspending(()=>42);
let instance = builder.instantiate({m: {import42: import42,
setA:AbeforeB.setA}});
setB:AbeforeB.setB}});

let wrapped_export = WebAssembly.promising(instance.exports.test);

let exported_promise = wrapped_export();
AbeforeB.setB();
AbeforeB.setA();

assert_equals(await exported_promise, 42);
// AbeforeB.showAbeforeB();

assert_true(AbeforeB.isAbeforeB());
}, "Do not suspend if the import's return value is not a Promise");
}, "Do suspend even if the import's return value is not a Promise by wrapping it with Promise.resolve");

test(t => {
console.log("Throw after the first suspension");
Expand Down
Loading