mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-06-26 11:11:34 +00:00
add binding for fill
This commit is contained in:
@ -138,4 +138,34 @@ fn slice() {
|
||||
}
|
||||
"#)
|
||||
.test()
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn fill() {
|
||||
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 fill_with(this: &js::Array, value: JsValue, start: u32, end: u32) -> js::Array {
|
||||
this.fill(value, start, end)
|
||||
}
|
||||
"#)
|
||||
.file("test.ts", r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
|
||||
export function test() {
|
||||
let characters = ["a", "c", "x", "n", 1, "8"];
|
||||
let subset = wasm.fill_with(characters, 0, 0, 3);
|
||||
|
||||
assert.equal(subset[0], 0);
|
||||
assert.equal(subset[4], 1);
|
||||
}
|
||||
"#)
|
||||
.test()
|
||||
}
|
Reference in New Issue
Block a user