@@ -10,6 +10,11 @@ extern "C" {
10
10
#[ wasm_bindgen( method, setter, structural) ]
11
11
fn set_foo ( this : & Foo42 , val : JsValue ) ;
12
12
13
+ #[ wasm_bindgen( js_name = prototype, js_namespace = Object ) ]
14
+ static OBJECT_PROTOTYPE : JsValue ;
15
+ #[ wasm_bindgen( js_name = prototype, js_namespace = Array ) ]
16
+ static ARRAY_PROTOTYPE : JsValue ;
17
+
13
18
type DefinePropertyAttrs ;
14
19
#[ wasm_bindgen( method, setter, structural) ]
15
20
fn set_value ( this : & DefinePropertyAttrs , val : & JsValue ) ;
@@ -105,6 +110,19 @@ fn define_properties() {
105
110
assert ! ( foo. has_own_property( & "car" . into( ) ) ) ;
106
111
}
107
112
113
+ #[ wasm_bindgen_test]
114
+ fn entries ( ) {
115
+ let entries = Object :: entries ( & foo_42 ( ) ) ;
116
+ assert_eq ! ( entries. length( ) , 1 ) ;
117
+ entries. for_each ( & mut |x, _, _| {
118
+ assert ! ( x. is_object( ) ) ;
119
+ let array: Array = x. into ( ) ;
120
+ assert_eq ! ( array. shift( ) , "foo" ) ;
121
+ assert_eq ! ( array. shift( ) , 42 ) ;
122
+ assert_eq ! ( array. length( ) , 0 ) ;
123
+ } ) ;
124
+ }
125
+
108
126
#[ wasm_bindgen_test]
109
127
fn get_own_property_descriptor ( ) {
110
128
let foo = foo_42 ( ) ;
@@ -122,6 +140,29 @@ fn get_own_property_descriptors() {
122
140
assert_eq ! ( PropertyDescriptor :: from( foo_desc) . value( ) , 42 ) ;
123
141
}
124
142
143
+ #[ wasm_bindgen_test]
144
+ fn get_own_property_names ( ) {
145
+ let names = Object :: get_own_property_names ( & foo_42 ( ) ) ;
146
+ assert_eq ! ( names. length( ) , 1 ) ;
147
+ names. for_each ( & mut |x, _, _| {
148
+ assert_eq ! ( x, "foo" ) ;
149
+ } ) ;
150
+ }
151
+
152
+ #[ wasm_bindgen_test]
153
+ fn get_own_property_symbols ( ) {
154
+ let symbols = Object :: get_own_property_symbols ( & map_with_symbol_key ( ) ) ;
155
+ assert_eq ! ( symbols. length( ) , 1 ) ;
156
+ }
157
+
158
+ #[ wasm_bindgen_test]
159
+ fn get_prototype_of ( ) {
160
+ let proto = JsValue :: from ( Object :: get_prototype_of ( & Object :: new ( ) . into ( ) ) ) ;
161
+ assert_eq ! ( proto, * OBJECT_PROTOTYPE ) ;
162
+ let proto = JsValue :: from ( Object :: get_prototype_of ( & Array :: new ( ) . into ( ) ) ) ;
163
+ assert_eq ! ( proto, * ARRAY_PROTOTYPE ) ;
164
+ }
165
+
125
166
#[ wasm_bindgen_test]
126
167
fn has_own_property ( ) {
127
168
assert ! ( foo_42( ) . has_own_property( & "foo" . into( ) ) ) ;
0 commit comments