2018-06-28 22:58:34 +03:00
|
|
|
#![allow(non_snake_case)]
|
|
|
|
|
|
|
|
use project;
|
|
|
|
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn entries() {
|
|
|
|
project()
|
|
|
|
.file("src/lib.rs", r#"
|
2018-07-19 16:57:18 +03:00
|
|
|
#![feature(use_extern_macros)]
|
2018-06-28 22:58:34 +03:00
|
|
|
|
|
|
|
extern crate wasm_bindgen;
|
2018-07-19 22:30:58 +03:00
|
|
|
extern crate js_sys;
|
2018-06-28 22:58:34 +03:00
|
|
|
use wasm_bindgen::prelude::*;
|
|
|
|
|
|
|
|
#[wasm_bindgen]
|
2018-07-19 22:30:58 +03:00
|
|
|
pub fn get_entries(this: &js_sys::Map) -> js_sys::MapIterator {
|
2018-06-28 22:58:34 +03:00
|
|
|
this.entries()
|
|
|
|
}
|
|
|
|
"#)
|
2018-07-05 06:37:09 +03:00
|
|
|
.file("test.js", r#"
|
2018-06-28 22:58:34 +03:00
|
|
|
import * as assert from "assert";
|
|
|
|
import * as wasm from "./out";
|
|
|
|
|
|
|
|
export function test() {
|
|
|
|
const map = new Map();
|
|
|
|
const iterator = map.entries();
|
|
|
|
const wasmIterator = wasm.get_entries(map);
|
|
|
|
map.set('foo', 'bar');
|
|
|
|
map.set('bar', 'baz');
|
|
|
|
|
|
|
|
assert.equal(iterator.toString(), wasmIterator.toString());
|
|
|
|
}
|
|
|
|
"#)
|
|
|
|
.test()
|
2018-06-28 22:59:11 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn keys() {
|
|
|
|
project()
|
|
|
|
.file("src/lib.rs", r#"
|
2018-07-19 16:57:18 +03:00
|
|
|
#![feature(use_extern_macros)]
|
2018-06-28 22:59:11 +03:00
|
|
|
|
|
|
|
extern crate wasm_bindgen;
|
2018-07-19 22:30:58 +03:00
|
|
|
extern crate js_sys;
|
2018-06-28 22:59:11 +03:00
|
|
|
use wasm_bindgen::prelude::*;
|
|
|
|
|
|
|
|
#[wasm_bindgen]
|
2018-07-19 22:30:58 +03:00
|
|
|
pub fn get_keys(this: &js_sys::Map) -> js_sys::MapIterator {
|
2018-06-28 22:59:11 +03:00
|
|
|
this.keys()
|
|
|
|
}
|
|
|
|
"#)
|
2018-07-05 06:37:09 +03:00
|
|
|
.file("test.js", r#"
|
2018-06-28 22:59:11 +03:00
|
|
|
import * as assert from "assert";
|
|
|
|
import * as wasm from "./out";
|
|
|
|
|
|
|
|
export function test() {
|
|
|
|
const map = new Map();
|
|
|
|
const iterator = map.keys();
|
|
|
|
const wasmIterator = wasm.get_keys(map);
|
|
|
|
map.set('foo', 'bar');
|
|
|
|
map.set('bar', 'baz');
|
|
|
|
|
|
|
|
assert.equal(iterator.toString(), wasmIterator.toString());
|
|
|
|
}
|
|
|
|
"#)
|
|
|
|
.test()
|
2018-06-28 23:00:02 +03:00
|
|
|
}
|
|
|
|
|
|
|
|
#[test]
|
|
|
|
fn values() {
|
|
|
|
project()
|
|
|
|
.file("src/lib.rs", r#"
|
2018-07-19 16:57:18 +03:00
|
|
|
#![feature(use_extern_macros)]
|
2018-06-28 23:00:02 +03:00
|
|
|
|
|
|
|
extern crate wasm_bindgen;
|
2018-07-19 22:30:58 +03:00
|
|
|
extern crate js_sys;
|
2018-06-28 23:00:02 +03:00
|
|
|
use wasm_bindgen::prelude::*;
|
|
|
|
|
|
|
|
#[wasm_bindgen]
|
2018-07-19 22:30:58 +03:00
|
|
|
pub fn get_values(this: &js_sys::Map) -> js_sys::MapIterator {
|
2018-06-28 23:00:02 +03:00
|
|
|
this.values()
|
|
|
|
}
|
|
|
|
"#)
|
2018-07-05 06:37:09 +03:00
|
|
|
.file("test.js", r#"
|
2018-06-28 23:00:02 +03:00
|
|
|
import * as assert from "assert";
|
|
|
|
import * as wasm from "./out";
|
|
|
|
|
|
|
|
export function test() {
|
|
|
|
const map = new Map();
|
|
|
|
const iterator = map.keys();
|
|
|
|
const wasmIterator = wasm.get_values(map);
|
|
|
|
map.set('foo', 'bar');
|
|
|
|
map.set('bar', 'baz');
|
|
|
|
|
|
|
|
assert.equal(iterator.toString(), wasmIterator.toString());
|
|
|
|
}
|
|
|
|
"#)
|
|
|
|
.test()
|
2018-07-05 06:37:09 +03:00
|
|
|
}
|