2018-07-21 02:19:10 +03:00
|
|
|
use wasm_bindgen::prelude::*;
|
|
|
|
use wasm_bindgen_test::*;
|
|
|
|
use js_sys::*;
|
|
|
|
|
|
|
|
#[wasm_bindgen_test]
|
|
|
|
fn entries() {
|
|
|
|
let s = Set::new(&JsValue::undefined());
|
|
|
|
s.add(&1.into());
|
2018-07-26 23:48:52 +03:00
|
|
|
let iter = s.entries();
|
|
|
|
let obj = iter.next().unwrap();
|
2018-07-21 02:19:10 +03:00
|
|
|
assert!(!obj.done());
|
2018-07-26 00:33:44 +03:00
|
|
|
let array = Array::from(&obj.value());
|
2018-07-21 02:19:10 +03:00
|
|
|
assert_eq!(array.length(), 2);
|
|
|
|
array.for_each(&mut |a, _, _| {
|
|
|
|
assert_eq!(a, 1);
|
|
|
|
});
|
|
|
|
|
2018-07-26 23:48:52 +03:00
|
|
|
assert!(iter.next().unwrap().done());
|
2018-07-21 02:19:10 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#[wasm_bindgen_test]
|
|
|
|
fn keys() {
|
|
|
|
let s = Set::new(&JsValue::undefined());
|
|
|
|
s.add(&1.into());
|
2018-07-26 23:48:52 +03:00
|
|
|
let iter = s.keys();
|
|
|
|
let obj = iter.next().unwrap();
|
2018-07-21 02:19:10 +03:00
|
|
|
assert!(!obj.done());
|
|
|
|
assert_eq!(obj.value(), 1);
|
2018-07-26 23:48:52 +03:00
|
|
|
assert!(iter.next().unwrap().done());
|
2018-07-21 02:19:10 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#[wasm_bindgen_test]
|
|
|
|
fn values() {
|
|
|
|
let s = Set::new(&JsValue::undefined());
|
|
|
|
s.add(&1.into());
|
2018-07-26 23:48:52 +03:00
|
|
|
let iter = s.values();
|
|
|
|
let obj = iter.next().unwrap();
|
2018-07-21 02:19:10 +03:00
|
|
|
assert!(!obj.done());
|
|
|
|
assert_eq!(obj.value(), 1);
|
2018-07-26 23:48:52 +03:00
|
|
|
assert!(iter.next().unwrap().done());
|
2018-07-21 02:19:10 +03:00
|
|
|
}
|