mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-03-16 18:20:51 +00:00
Use Reflect::set instead of javascript helper
This commit is contained in:
parent
f5203bba8a
commit
1092816652
@ -1,4 +0,0 @@
|
||||
exports.set_in_object = function(obj, name, value) {
|
||||
obj[name] = value;
|
||||
};
|
||||
|
@ -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());
|
||||
|
Loading…
x
Reference in New Issue
Block a user