mirror of
https://github.com/fluencelabs/wasm-bindgen
synced 2025-06-12 04:21:21 +00:00
js-sys: Add bindings for Object.create
This commit is contained in:
@ -1,17 +1,18 @@
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen_test::*;
|
||||
use std::f64::NAN;
|
||||
use js_sys::*;
|
||||
use std::f64::NAN;
|
||||
use wasm_bindgen::prelude::*;
|
||||
use wasm_bindgen::JsCast;
|
||||
use wasm_bindgen_test::*;
|
||||
|
||||
#[wasm_bindgen]
|
||||
extern {
|
||||
extern "C" {
|
||||
type Foo42;
|
||||
#[wasm_bindgen(method, setter, structural)]
|
||||
fn set_foo(this: &Foo42, val: JsValue);
|
||||
}
|
||||
|
||||
#[wasm_bindgen(module = "tests/wasm/Object.js")]
|
||||
extern {
|
||||
extern "C" {
|
||||
fn map_with_symbol_key() -> Object;
|
||||
fn symbol_key() -> JsValue;
|
||||
|
||||
@ -36,7 +37,6 @@ fn new() {
|
||||
assert!(JsValue::from(Object::new()).is_object());
|
||||
}
|
||||
|
||||
|
||||
#[wasm_bindgen_test]
|
||||
fn assign() {
|
||||
let a = JsValue::from("a");
|
||||
@ -63,6 +63,16 @@ fn assign() {
|
||||
assert_eq!(Reflect::get(target.as_ref(), &c), c);
|
||||
}
|
||||
|
||||
#[wasm_bindgen_test]
|
||||
fn create() {
|
||||
let array_proto = eval("Array.prototype")
|
||||
.unwrap()
|
||||
.dyn_into::<Object>()
|
||||
.unwrap();
|
||||
let my_array = Object::create(&array_proto);
|
||||
assert!(my_array.is_instance_of::<Array>());
|
||||
}
|
||||
|
||||
#[wasm_bindgen_test]
|
||||
fn has_own_property() {
|
||||
assert!(foo_42().has_own_property(&"foo".into()));
|
||||
|
Reference in New Issue
Block a user