mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-06-13 04:51:23 +00:00
js-sys: Add bindings to Object.assign
This commit is contained in:
@ -36,6 +36,33 @@ fn new() {
|
||||
assert!(JsValue::from(Object::new()).is_object());
|
||||
}
|
||||
|
||||
|
||||
#[wasm_bindgen_test]
|
||||
fn assign() {
|
||||
let a = JsValue::from("a");
|
||||
let b = JsValue::from("b");
|
||||
let c = JsValue::from("c");
|
||||
|
||||
let target = Object::new();
|
||||
Reflect::set(target.as_ref(), a.as_ref(), a.as_ref());
|
||||
|
||||
let src1 = Object::new();
|
||||
Reflect::set(src1.as_ref(), &a, &c);
|
||||
|
||||
let src2 = Object::new();
|
||||
Reflect::set(src2.as_ref(), &b, &b);
|
||||
|
||||
let src3 = Object::new();
|
||||
Reflect::set(src3.as_ref(), &c, &c);
|
||||
|
||||
let res = Object::assign3(&target, &src1, &src2, &src3);
|
||||
|
||||
assert!(Object::is(target.as_ref(), res.as_ref()));
|
||||
assert_eq!(Reflect::get(target.as_ref(), &a), c);
|
||||
assert_eq!(Reflect::get(target.as_ref(), &b), b);
|
||||
assert_eq!(Reflect::get(target.as_ref(), &c), c);
|
||||
}
|
||||
|
||||
#[wasm_bindgen_test]
|
||||
fn has_own_property() {
|
||||
assert!(foo_42().has_own_property(&"foo".into()));
|
||||
|
Reference in New Issue
Block a user