fix: 修复 THROW 错误类型与 Error 子类构造器

This commit is contained in:
2026-06-08 23:14:02 +08:00
parent be199ca077
commit 1c68a03654
4 changed files with 136 additions and 19 deletions
@@ -137,3 +137,25 @@ fn reference_error_is_defined() {
let result = eval("typeof ReferenceError").unwrap();
assert!(result.is_string());
}
#[test]
fn error_subtype_constructors_produce_named_objects() {
assert_eq!(
format!("{}", eval("new Error('boom').name == 'Error'").unwrap()),
"true"
);
assert_eq!(
format!(
"{}",
eval("new TypeError('boom').name == 'TypeError'").unwrap()
),
"true"
);
assert_eq!(
format!(
"{}",
eval("new SyntaxError('boom').name == 'SyntaxError'").unwrap()
),
"true"
);
}