Use js_sys::Array, generate _n methods for ergonomics

This commit is contained in:
Anton Danilkin
2018-09-11 00:37:59 +03:00
parent 14eb317509
commit 9f4ed536df
3 changed files with 53 additions and 36 deletions

View File

@ -95,7 +95,19 @@ fn optional_and_union_arguments() {
#[wasm_bindgen_test]
fn variadic() {
let f = Variadic::new().unwrap();
assert_eq!(f.sum(Box::new([1, 2, 3, 4, 5])), 15);
assert_eq!(f.sum_5(1, 2, 3, 4, 5), 15);
assert_eq!(
f.sum(
&::js_sys::Array::of5(
&JsValue::from_f64(1f64),
&JsValue::from_f64(2f64),
&JsValue::from_f64(3f64),
&JsValue::from_f64(4f64),
&JsValue::from_f64(5f64),
)
),
15
);
}
#[wasm_bindgen_test]