From 1092816652d6da212825cc11cb9a339b9c84b97f Mon Sep 17 00:00:00 2001 From: Andrew Chin Date: Fri, 10 Aug 2018 14:33:21 -0400 Subject: [PATCH] Use Reflect::set instead of javascript helper --- crates/js-sys/tests/wasm/JSON.js | 4 ---- crates/js-sys/tests/wasm/JSON.rs | 9 +-------- 2 files changed, 1 insertion(+), 12 deletions(-) delete mode 100644 crates/js-sys/tests/wasm/JSON.js diff --git a/crates/js-sys/tests/wasm/JSON.js b/crates/js-sys/tests/wasm/JSON.js deleted file mode 100644 index 796bd200..00000000 --- a/crates/js-sys/tests/wasm/JSON.js +++ /dev/null @@ -1,4 +0,0 @@ -exports.set_in_object = function(obj, name, value) { - obj[name] = value; -}; - diff --git a/crates/js-sys/tests/wasm/JSON.rs b/crates/js-sys/tests/wasm/JSON.rs index c7f0f4bb..b1d9fd18 100644 --- a/crates/js-sys/tests/wasm/JSON.rs +++ b/crates/js-sys/tests/wasm/JSON.rs @@ -1,15 +1,8 @@ use wasm_bindgen::JsValue; use wasm_bindgen_test::*; -use wasm_bindgen::prelude::*; use wasm_bindgen::JsCast; use js_sys::*; - -#[wasm_bindgen(module = "tests/wasm/JSON.js")] -extern { - fn set_in_object(obj: &Object, name: &str, value: &JsValue); -} - #[wasm_bindgen_test] fn parse_array() { @@ -79,7 +72,7 @@ fn stringify() { fn stringify_error() { let func = Function::new_no_args("throw new Error(\"rust really rocks\")"); let obj = Object::new(); - set_in_object(&obj, "toJSON", &JsValue::from(func)); + Reflect::set(obj.as_ref(), &JsValue::from("toJSON"), func.as_ref()); let result = JSON::stringify(&JsValue::from(obj)); assert!(result.is_err());