js-sys: Add bindings to Array.of

This commit is contained in:
Nick Fitzgerald
2018-08-10 10:29:22 -07:00
parent d390f2fe04
commit 95c55d0b4c
2 changed files with 47 additions and 0 deletions

View File

@ -126,6 +126,19 @@ fn copy_within() {
assert_eq!(to_rust(&characters)[5], JsValue::from(3));
}
#[wasm_bindgen_test]
fn of() {
let a = JsValue::from("a");
let b = JsValue::from("b");
let c = JsValue::from("c");
let arr = Array::of3(&a, &b, &c);
let vec = to_rust(&arr);
assert_eq!(vec.len(), 3);
assert_eq!(vec[0], a);
assert_eq!(vec[1], b);
assert_eq!(vec[2], c);
}
#[wasm_bindgen_test]
fn pop() {
let characters = js_array![8, 5, 4, 3, 1, 2];