Struct wasm_bindgen_test::__rt::Context
source · [−]pub struct Context { /* private fields */ }
Expand description
Runtime test harness support instantiated in JS.
The node.js entry script instantiates a Context
here which is used to
drive test execution.
Implementations
sourceimpl Context
impl Context
sourcepub fn new() -> Context
pub fn new() -> Context
Creates a new context ready to run tests.
A Context
is the main structure through which test execution is
coordinated, and this will collect output and results for all executed
tests.
sourcepub fn args(&mut self, args: Vec<JsValue>)
pub fn args(&mut self, args: Vec<JsValue>)
Inform this context about runtime arguments passed to the test harness.
Eventually this will be used to support flags, but for now it’s just used to support test filters.
sourcepub fn run(&self, tests: Vec<JsValue>) -> Promise
pub fn run(&self, tests: Vec<JsValue>) -> Promise
Executes a list of tests, returning a promise representing their eventual completion.
This is the main entry point for executing tests. All the tests passed
in are the JS Function
object that was plucked off the
WebAssembly.Instance
exports list.
The promise returned resolves to either true
if all tests passed or
false
if at least one test failed.
sourceimpl Context
impl Context
sourcepub fn execute_sync<T: Termination>(
&self,
name: &str,
f: impl 'static + FnOnce() -> T
)
pub fn execute_sync<T: Termination>(
&self,
name: &str,
f: impl 'static + FnOnce() -> T
)
Entry point for a synchronous test in wasm. The #[wasm_bindgen_test]
macro generates invocations of this method.
sourcepub fn execute_async<F>(&self, name: &str, f: impl FnOnce() -> F + 'static)where
F: Future + 'static,
F::Output: Termination,
pub fn execute_async<F>(&self, name: &str, f: impl FnOnce() -> F + 'static)where
F: Future + 'static,
F::Output: Termination,
Entry point for an asynchronous in wasm. The
#[wasm_bindgen_test(async)]
macro generates invocations of this
method.
Trait Implementations
sourceimpl FromWasmAbi for Context
impl FromWasmAbi for Context
sourceimpl IntoWasmAbi for Context
impl IntoWasmAbi for Context
sourceimpl OptionFromWasmAbi for Context
impl OptionFromWasmAbi for Context
sourceimpl OptionIntoWasmAbi for Context
impl OptionIntoWasmAbi for Context
sourceimpl RefFromWasmAbi for Context
impl RefFromWasmAbi for Context
type Anchor = Ref<'static, Context>
type Anchor = Ref<'static, Context>
The type that holds the reference to Self
for the duration of the
invocation of the function that has an &Self
parameter. This is
required to ensure that the lifetimes don’t persist beyond one function
call, and so that they remain anonymous. Read more
sourceunsafe fn ref_from_abi(js: Self::Abi) -> Self::Anchor
unsafe fn ref_from_abi(js: Self::Abi) -> Self::Anchor
Recover a Self::Anchor
from Self::Abi
. Read more
sourceimpl RefMutFromWasmAbi for Context
impl RefMutFromWasmAbi for Context
Auto Trait Implementations
impl !RefUnwindSafe for Context
impl !Send for Context
impl !Sync for Context
impl Unpin for Context
impl !UnwindSafe for Context
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
impl<T> ReturnWasmAbi for Twhere
T: IntoWasmAbi,
type Abi = <T as IntoWasmAbi>::Abi
type Abi = <T as IntoWasmAbi>::Abi
Same as IntoWasmAbi::Abi
sourcefn return_abi(self) -> <T as ReturnWasmAbi>::Abi
fn return_abi(self) -> <T as ReturnWasmAbi>::Abi
Same as IntoWasmAbi::into_abi
, except that it may throw and never
return in the case of Err
. Read more