|
1 | 1 | use wasm_bindgen::prelude::*;
|
2 | 2 | use wasm_bindgen_test::*;
|
| 3 | +use std::f64::NAN; |
3 | 4 | use js_sys::*;
|
4 | 5 |
|
5 | 6 | #[wasm_bindgen]
|
@@ -48,6 +49,25 @@ fn to_string() {
|
48 | 49 | assert_eq!(foo_42().to_string(), "[object Object]");
|
49 | 50 | }
|
50 | 51 |
|
| 52 | +#[wasm_bindgen_test] |
| 53 | +fn is() { |
| 54 | + let object = JsValue::from(Object::new()); |
| 55 | + assert!(Object::is(&object, &object)); |
| 56 | + assert!(Object::is(&JsValue::undefined(), &JsValue::undefined())); |
| 57 | + assert!(Object::is(&JsValue::null(), &JsValue::null())); |
| 58 | + assert!(Object::is(&JsValue::TRUE, &JsValue::TRUE)); |
| 59 | + assert!(Object::is(&JsValue::FALSE, &JsValue::FALSE)); |
| 60 | + assert!(Object::is(&"foo".into(), &"foo".into())); |
| 61 | + assert!(Object::is(&JsValue::from(42), &JsValue::from(42))); |
| 62 | + assert!(Object::is(&JsValue::from(NAN), &JsValue::from(NAN))); |
| 63 | + |
| 64 | + let another_object = JsValue::from(Object::new()); |
| 65 | + assert!(!Object::is(&object, &another_object)); |
| 66 | + assert!(!Object::is(&JsValue::TRUE, &JsValue::FALSE)); |
| 67 | + assert!(!Object::is(&"foo".into(), &"bar".into())); |
| 68 | + assert!(!Object::is(&JsValue::from(23), &JsValue::from(42))); |
| 69 | +} |
| 70 | + |
51 | 71 | #[wasm_bindgen_test]
|
52 | 72 | fn is_extensible() {
|
53 | 73 | let object = Object::new();
|
|
0 commit comments