Merge pull request #1230 from fitzgen/multiple-futures-same-promise

futures: Add a test for creating multiple futures from the same promise
This commit is contained in:
Alex Crichton 2019-02-04 20:57:35 +01:00 committed by GitHub
commit a0c8514e66
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

7
crates/futures/tests/tests.rs Normal file → Executable file
View File

@ -108,3 +108,10 @@ fn spawn_local_err_no_exception() -> impl Future<Item = (), Error = JsValue> {
})
}
#[wasm_bindgen_test(async)]
fn can_create_multiple_futures_from_same_promise() -> impl Future<Item = (), Error = JsValue> {
let promise = js_sys::Promise::resolve(&JsValue::null());
let a = JsFuture::from(promise.clone());
let b = JsFuture::from(promise);
futures::future::join_all(vec![a, b]).map(|_| ())
}