mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-07-31 03:51:56 +00:00
add binding for join
This commit is contained in:
@@ -76,4 +76,36 @@ fn last_index_of() {
|
||||
}
|
||||
"#)
|
||||
.test()
|
||||
}
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn join() {
|
||||
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 join_array(this: &js::Array, delimiter: &str) -> String {
|
||||
this.join(delimiter)
|
||||
}
|
||||
|
||||
"#)
|
||||
.file("test.ts", r#"
|
||||
import * as assert from "assert";
|
||||
import * as wasm from "./out";
|
||||
|
||||
export function test() {
|
||||
let characters = ["a", "c", "x", "n"];
|
||||
let stringValue = wasm.join_array(characters, ", ");
|
||||
|
||||
assert.equal("a, c, x, n", stringValue);
|
||||
let withForwardSlash = wasm.join_array(characters, "/");
|
||||
assert.equal("a/c/x/n", withForwardSlash);
|
||||
}
|
||||
"#)
|
||||
.test()
|
||||
}
|
||||
|
Reference in New Issue
Block a user