mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-06-26 03:01:33 +00:00
Adding in support for async iterators (#1895)
* Adding in support for async iterators * Adding in some unit tests for asyncIterator * Fixing unit tests * Fixing UI tests
This commit is contained in:
@ -1,12 +1,14 @@
|
||||
use js_sys::*;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen_test::*;
|
||||
use wasm_bindgen_futures::JsFuture;
|
||||
|
||||
#[wasm_bindgen(module = "tests/wasm/Symbol.js")]
|
||||
extern "C" {
|
||||
fn test_has_instance(sym: &Symbol);
|
||||
fn test_is_concat_spreadable(sym: &Symbol);
|
||||
fn test_iterator(sym: &Symbol);
|
||||
fn test_async_iterator(sym: &Symbol) -> Promise;
|
||||
fn test_match(sym: &Symbol);
|
||||
fn test_replace(sym: &Symbol);
|
||||
fn test_search(sym: &Symbol);
|
||||
@ -37,6 +39,11 @@ fn iterator() {
|
||||
test_iterator(&Symbol::iterator());
|
||||
}
|
||||
|
||||
#[wasm_bindgen_test]
|
||||
async fn async_iterator() {
|
||||
JsFuture::from(test_async_iterator(&Symbol::async_iterator())).await.unwrap_throw();
|
||||
}
|
||||
|
||||
#[wasm_bindgen_test]
|
||||
fn match_() {
|
||||
test_match(&Symbol::match_());
|
||||
@ -89,12 +96,14 @@ fn key_for() {
|
||||
let sym = Symbol::for_("foo");
|
||||
assert_eq!(Symbol::key_for(&sym), "foo");
|
||||
assert!(Symbol::key_for(&Symbol::iterator()).is_undefined());
|
||||
assert!(Symbol::key_for(&Symbol::async_iterator()).is_undefined());
|
||||
assert!(Symbol::key_for(&gensym(JsValue::undefined())).is_undefined());
|
||||
}
|
||||
|
||||
#[wasm_bindgen_test]
|
||||
fn to_string() {
|
||||
assert_eq!(Symbol::iterator().to_string(), "Symbol(Symbol.iterator)");
|
||||
assert_eq!(Symbol::async_iterator().to_string(), "Symbol(Symbol.asyncIterator)");
|
||||
assert_eq!(Symbol::for_("foo").to_string(), "Symbol(foo)");
|
||||
assert_eq!(gensym("desc".into()).to_string(), "Symbol(desc)");
|
||||
}
|
||||
|
Reference in New Issue
Block a user