1
0
mirror of https://github.com/fluencelabs/wasm-bindgen synced 2025-07-26 01:21:55 +00:00
Files
.cargo
crates
backend
cli
cli-support
futures
js-sys
src
tests
wasm
Array.rs
ArrayBuffer.rs
ArrayIterator.rs
Boolean.rs
DataView.rs
Date.rs
Error.rs
Function.js
Function.rs
Generator.js
Generator.rs
Intl.rs
JsString.rs
Map.rs
MapIterator.rs
Math.rs
Number.rs
Object.js
Object.rs
Proxy.js
Proxy.rs
Reflect.js
Reflect.rs
RegExp.rs
Set.rs
SetIterator.rs
Symbol.js
Symbol.rs
TypedArray.rs
WeakMap.rs
WeakSet.rs
WebAssembly.rs
global_fns.rs
main.rs
headless.js
headless.rs
CHANGELOG.md
Cargo.toml
README.md
macro
macro-support
shared
test
test-macro
test-project-builder
typescript
web-sys
webidl
webidl-tests
examples
guide
releases
src
tests
.appveyor.yml
.eslintignore
.eslintrc
.gitattributes
.gitignore
.travis.yml
CHANGELOG.md
CONTRIBUTING.md
Cargo.toml
LICENSE-APACHE
LICENSE-MIT
README.md
package-lock.json
package.json
yarn.lock
wasm-bindgen/crates/js-sys/tests/wasm/MapIterator.rs
Nick Fitzgerald 62de3bad67 js-sys: Unify all iterators under one generic iterator type
The JS iterator protocol uses duck typing and we don't need separate
ArrayIterator and SetIterator etc types, we can have a single iterator type for
the whole protocol.
2018-07-26 13:48:52 -07:00

53 lines
1.2 KiB
Rust

use wasm_bindgen_test::*;
use js_sys::*;
#[wasm_bindgen_test]
fn entries() {
let map = Map::new();
map.set(&"uno".into(), &1.into());
let entries = map.entries();
let next = entries.next().unwrap();
assert_eq!(next.done(), false);
assert!(next.value().is_object());
assert_eq!(Reflect::get(&next.value(), &0.into()), "uno");
assert_eq!(Reflect::get(&next.value(), &1.into()), 1);
let next = entries.next().unwrap();
assert!(next.done());
assert!(next.value().is_undefined());
}
#[wasm_bindgen_test]
fn keys() {
let map = Map::new();
map.set(&"uno".into(), &1.into());
let keys = map.keys();
let next = keys.next().unwrap();
assert_eq!(next.done(), false);
assert_eq!(next.value(), "uno");
let next = keys.next().unwrap();
assert!(next.done());
assert!(next.value().is_undefined());
}
#[wasm_bindgen_test]
fn values() {
let map = Map::new();
map.set(&"uno".into(), &1.into());
let values = map.values();
let next = values.next().unwrap();
assert_eq!(next.done(), false);
assert_eq!(next.value(), 1);
let next = values.next().unwrap();
assert!(next.done());
assert!(next.value().is_undefined());
}