add temporary test

This commit is contained in:
lcnr/Bastian Kauschke 2019-01-14 21:04:29 +01:00
parent 4e611c318e
commit 6e08f579a6

View File

@ -86,3 +86,25 @@ fn spawn_local_runs() -> impl Future<Item = (), Error = JsValue> {
}
})
}
/// 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<Item = (), Error = JsValue> {
let (tx, rx) = oneshot::channel::<u32>();
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())
}
})
}