From 6e08f579a665d7d73750e3dafb0d2d2a94bb3b2a Mon Sep 17 00:00:00 2001 From: lcnr/Bastian Kauschke Date: Mon, 14 Jan 2019 21:04:29 +0100 Subject: [PATCH] add temporary test --- crates/futures/tests/tests.rs | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/crates/futures/tests/tests.rs b/crates/futures/tests/tests.rs index 7b76dfe5..e8e6bbf4 100644 --- a/crates/futures/tests/tests.rs +++ b/crates/futures/tests/tests.rs @@ -86,3 +86,25 @@ fn spawn_local_runs() -> impl Future { } }) } + +/// check that `spawn_local` does not forward the `future::err` as an unchecked rejection +#[wasm_bindgen_test(async)] +fn spawn_local_err_no_exception() -> impl Future { + let (tx, rx) = oneshot::channel::(); + let fn_box = Box::new(move || { + tx.send(42).unwrap(); + }); + // Promises should run in a deterministic order, so the `err` should be handled during the execution of this test. + spawn_local(futures::future::err::<(), ()>(())); + spawn_local(futures::future::ok::<(), ()>(()).map(|_| { + fn_box(); + })); + rx.then(|val| { + if val == Ok(42) { + Ok(()) + } else { + Err(JsValue::undefined()) + } + }) +} +