wasm-bindgen/crates/web-sys/tests/wasm/main.rs
Alex Crichton eee71de0ce
Support asynchronous tests (#600)
* Tweak the implementation of heap closures

This commit updates the implementation of the `Closure` type to internally store
an `Rc` and be suitable for dropping a `Closure` during the execution of the
closure. This is currently needed for promises but may be generally useful as
well!

* Support asynchronous tests

This commit adds support for executing tests asynchronously. This is modeled
by tests returning a `Future` instead of simply executing inline, and is
signified with `#[wasm_bindgen_test(async)]`.

Support for this is added through a new `wasm-bindgen-futures` crate which is a
binding between the `futures` crate and JS `Promise` objects.

Lots more details can be found in the details of the commit, but one of the end
results is that the `web-sys` tests are now entirely contained in the same test
suite and don't need `npm install` to be run to execute them!

* Review tweaks

* Add some bindings for `Function.call` to `js_sys`

Name them `call0`, `call1`, `call2`, ... for the number of arguments being
passed.

* Use oneshots channels with `JsFuture`

It did indeed clean up the implementation!
2018-08-01 15:52:24 -05:00

35 lines
762 B
Rust

#![feature(use_extern_macros)]
#![cfg(target_arch = "wasm32")]
extern crate futures;
extern crate js_sys;
extern crate wasm_bindgen;
extern crate wasm_bindgen_futures;
extern crate wasm_bindgen_test;
extern crate web_sys;
wasm_bindgen_test::wasm_bindgen_test_configure!(run_in_browser);
pub mod anchor_element;
pub mod body_element;
pub mod br_element;
pub mod button_element;
pub mod div_element;
pub mod element;
pub mod event;
pub mod head_element;
pub mod heading_element;
pub mod headers;
pub mod history;
pub mod hr_element;
pub mod html_element;
pub mod html_html_element;
pub mod input_element;
pub mod response;
pub mod select_element;
pub mod script_element;
pub mod span_element;
pub mod style_element;
pub mod title_element;
pub mod xpath_result;