Js sys once over (#550)

* js-sys: Return `f64` instead of `Number`

* js-sys: remove trailing whitespace

* js-sys: Ensure that all imported types derive Clone and Debug

* js-sys: Imported functions should always take JS object arguments by-ref
This commit is contained in:
Nick Fitzgerald
2018-07-25 14:33:44 -07:00
committed by Alex Crichton
parent 93933f033f
commit 61fc8d2567
18 changed files with 216 additions and 184 deletions

View File

@ -42,15 +42,15 @@ extern {
#[wasm_bindgen_test]
fn apply() {
let args = Array::new();
args.push(3.into());
args.push(&3.into());
assert_eq!(Reflect::apply(&get_char_at(), &"ponies".into(), &args).unwrap(), "i");
}
#[wasm_bindgen_test]
fn construct() {
let args = Array::new();
args.push(10.into());
args.push(10.into());
args.push(&10.into());
args.push(&10.into());
let instance = Reflect::construct(&RECTANGLE_CLASS, &args);
assert_eq!(Rectangle::from(instance).x(), 10);
}
@ -58,8 +58,8 @@ fn construct() {
#[wasm_bindgen_test]
fn construct_with_new_target() {
let args = Array::new();
args.push(10.into());
args.push(10.into());
args.push(&10.into());
args.push(&10.into());
let instance = Reflect::construct_with_new_target(
&RECTANGLE_CLASS,
&args,
@ -86,10 +86,10 @@ fn delete_property() {
assert!(r.x_jsval().is_undefined());
let array = Array::new();
array.push(1.into());
array.push(&1.into());
let obj = Object::from(JsValue::from(array));
Reflect::delete_property(&obj, &0.into());
let array = Array::from(JsValue::from(obj));
let array = Array::from(&JsValue::from(obj));
assert!(array.length() == 1);
array.for_each(&mut |x, _, _| assert!(x.is_undefined()));
}