mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-04-25 14:12:13 +00:00
This commit defaults all crates in-tree to use `std::future` by default and none of them support the crates.io `futures` 0.1 crate any more. This is a breaking change for `wasm-bindgen-futures` and `wasm-bindgen-test` so they've both received a major version bump to reflect the new defaults. Historical versions of these crates should continue to work if necessary, but they won't receive any more maintenance after this is merged. The movement here liberally uses `async`/`await` to remove the need for using any combinators on the `Future` trait. As a result many of the crates now rely on a much more recent version of the compiler, especially to run tests. The `wasm-bindgen-futures` crate was updated to remove all of its futures-related dependencies and purely use `std::future`, hopefully improving its compatibility by not having any version compat considerations over time. The implementations of the executors here are relatively simple and only delve slightly into the `RawWaker` business since there are no other stable APIs in `std::task` for wrapping these. This commit also adds support for: #[wasm_bindgen_test] async fn foo() { // ... } where previously you needed to pass `(async)` now that's inferred because it's an `async fn`. Closes #1558 Closes #1695
35 lines
820 B
Rust
35 lines
820 B
Rust
use std::time::Duration;
|
|
use sample::Timeout;
|
|
use wasm_bindgen_test::*;
|
|
|
|
#[wasm_bindgen_test]
|
|
fn pass() {
|
|
console_log!("DO NOT SEE ME");
|
|
}
|
|
|
|
#[wasm_bindgen_test]
|
|
async fn pass_after_2s() {
|
|
console_log!("immediate log");
|
|
Timeout::new(Duration::new(1, 0)).await;
|
|
console_log!("log after 1s");
|
|
Timeout::new(Duration::new(1, 0)).await;
|
|
console_log!("log at end");
|
|
}
|
|
|
|
#[wasm_bindgen_test]
|
|
fn fail() {
|
|
console_log!("helpful messsage, please see me");
|
|
panic!("this is a failing test");
|
|
}
|
|
|
|
#[wasm_bindgen_test]
|
|
async fn fail_after_3s() {
|
|
console_log!("immediate log");
|
|
Timeout::new(Duration::new(1, 0)).await;
|
|
console_log!("log after 1s");
|
|
Timeout::new(Duration::new(1, 0)).await;
|
|
console_log!("log after 2s");
|
|
Timeout::new(Duration::new(1, 0)).await;
|
|
panic!("end");
|
|
}
|