summaryrefslogtreecommitdiffstats
path: root/vendor/js-sys/tests/wasm/EvalError.rs
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 12:41:41 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-05-04 12:41:41 +0000
commit10ee2acdd26a7f1298c6f6d6b7af9b469fe29b87 (patch)
treebdffd5d80c26cf4a7a518281a204be1ace85b4c1 /vendor/js-sys/tests/wasm/EvalError.rs
parentReleasing progress-linux version 1.70.0+dfsg1-9~progress7.99u1. (diff)
downloadrustc-10ee2acdd26a7f1298c6f6d6b7af9b469fe29b87.tar.xz
rustc-10ee2acdd26a7f1298c6f6d6b7af9b469fe29b87.zip
Merging upstream version 1.70.0+dfsg2.
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'vendor/js-sys/tests/wasm/EvalError.rs')
-rw-r--r--vendor/js-sys/tests/wasm/EvalError.rs62
1 files changed, 62 insertions, 0 deletions
diff --git a/vendor/js-sys/tests/wasm/EvalError.rs b/vendor/js-sys/tests/wasm/EvalError.rs
new file mode 100644
index 000000000..52abe06ca
--- /dev/null
+++ b/vendor/js-sys/tests/wasm/EvalError.rs
@@ -0,0 +1,62 @@
+use js_sys::*;
+use wasm_bindgen::JsCast;
+use wasm_bindgen::JsValue;
+use wasm_bindgen_test::*;
+
+// Note: This error is not thrown any more, so there are no tests that will generate this error.
+// Instead we just have to manually construct it
+
+#[wasm_bindgen_test]
+fn new() {
+ let error = EvalError::new("some message");
+ let base_error: &Error = error.dyn_ref().unwrap();
+ assert_eq!(JsValue::from(base_error.message()), "some message");
+}
+
+#[wasm_bindgen_test]
+fn set_message() {
+ let error = EvalError::new("test");
+ let base_error: &Error = error.dyn_ref().unwrap();
+ base_error.set_message("another");
+ assert_eq!(JsValue::from(base_error.message()), "another");
+}
+
+#[wasm_bindgen_test]
+fn name() {
+ let error = EvalError::new("test");
+ let base_error: &Error = error.dyn_ref().unwrap();
+ assert_eq!(JsValue::from(base_error.name()), "EvalError");
+}
+
+#[wasm_bindgen_test]
+fn set_name() {
+ let error = EvalError::new("test");
+ let base_error: &Error = error.dyn_ref().unwrap();
+ base_error.set_name("different");
+ assert_eq!(JsValue::from(base_error.name()), "different");
+}
+
+#[wasm_bindgen_test]
+fn to_string() {
+ let error = EvalError::new("error message 1");
+ let base_error: &Error = error.dyn_ref().unwrap();
+ assert_eq!(
+ JsValue::from(base_error.to_string()),
+ "EvalError: error message 1"
+ );
+ base_error.set_name("error_name_1");
+ assert_eq!(
+ JsValue::from(base_error.to_string()),
+ "error_name_1: error message 1"
+ );
+}
+
+#[wasm_bindgen_test]
+fn evalerror_inheritance() {
+ let error = EvalError::new("some message");
+ assert!(error.is_instance_of::<EvalError>());
+ assert!(error.is_instance_of::<Error>());
+ assert!(error.is_instance_of::<Object>());
+ let _: &Error = error.as_ref();
+ let _: &Object = error.as_ref();
+}