mirror of
https://github.com/rustwasm/wasm-bindgen.git
synced 2024-11-25 19:43:00 +03:00
d868ff26ef
* feat(Set): add Set.add * feat(Set): add Set.clear * feat(Set): add Set.delete * feat(Set): add Set.has * feat(Set): add Set.new * feat(Set): add Set.size * feat(Set/SetIterator): add Set.entries * feat(Set/SetIterator): add Set.keys * feat(Set/SetIterator): add Set.values
97 lines
2.4 KiB
Rust
97 lines
2.4 KiB
Rust
#![allow(non_snake_case)]
|
|
|
|
use project;
|
|
|
|
#[test]
|
|
fn entries() {
|
|
project()
|
|
.file("src/lib.rs", r#"
|
|
#![feature(proc_macro, wasm_custom_section)]
|
|
|
|
extern crate wasm_bindgen;
|
|
use wasm_bindgen::prelude::*;
|
|
use wasm_bindgen::js;
|
|
|
|
#[wasm_bindgen]
|
|
pub fn entries(this: &js::Set) -> js::SetIterator {
|
|
this.entries()
|
|
}
|
|
|
|
"#)
|
|
.file("test.ts", r#"
|
|
import * as assert from "assert";
|
|
import * as wasm from "./out";
|
|
|
|
export function test() {
|
|
let set = new Set([8, 5, 4, 3, 1, 2]);
|
|
let wasmIterator = wasm.entries(set);
|
|
let nextValue = wasmIterator.next().value;
|
|
|
|
assert.equal(nextValue[0], 8);
|
|
assert.equal(nextValue[1], 8);
|
|
}
|
|
"#)
|
|
.test()
|
|
}
|
|
|
|
#[test]
|
|
fn keys() {
|
|
project()
|
|
.file("src/lib.rs", r#"
|
|
#![feature(proc_macro, wasm_custom_section)]
|
|
|
|
extern crate wasm_bindgen;
|
|
use wasm_bindgen::prelude::*;
|
|
use wasm_bindgen::js;
|
|
|
|
#[wasm_bindgen]
|
|
pub fn keys(this: &js::Set) -> js::SetIterator {
|
|
this.keys()
|
|
}
|
|
|
|
"#)
|
|
.file("test.ts", r#"
|
|
import * as assert from "assert";
|
|
import * as wasm from "./out";
|
|
|
|
export function test() {
|
|
let set = new Set([8, 5, 4, 3, 1, 2]);
|
|
let wasmIterator = wasm.keys(set);
|
|
let nextValue = wasmIterator.next().value;
|
|
|
|
assert.equal(nextValue, 8);
|
|
}
|
|
"#)
|
|
.test()
|
|
}
|
|
|
|
#[test]
|
|
fn values() {
|
|
project()
|
|
.file("src/lib.rs", r#"
|
|
#![feature(proc_macro, wasm_custom_section)]
|
|
|
|
extern crate wasm_bindgen;
|
|
use wasm_bindgen::prelude::*;
|
|
use wasm_bindgen::js;
|
|
|
|
#[wasm_bindgen]
|
|
pub fn values(this: &js::Set) -> js::SetIterator {
|
|
this.values()
|
|
}
|
|
|
|
"#)
|
|
.file("test.ts", r#"
|
|
import * as assert from "assert";
|
|
import * as wasm from "./out";
|
|
|
|
export function test() {
|
|
let set = new Set([8, 5, 4, 3, 1, 2]);
|
|
let wasmIterator = wasm.values(set);
|
|
let nextValue = wasmIterator.next().value;
|
|
|
|
assert.equal(nextValue, 8);
|
|
}
|
|
"#)
|
|
.test()
|
|
} |