fix: 脚本顶层 var/function 声明落 globalThis(DEFINE_GLOBAL_PROP 非可配置数据属性)

This commit is contained in:
爱特每羊队
2026-08-10 03:52:17 +08:00
parent 012a8e5110
commit 4d37614e49
11 changed files with 187 additions and 13 deletions
+5 -2
View File
@@ -458,7 +458,7 @@ fn run_test_inner(
if is_async {
// 异步测试:注入 print 捕获 + $DONE(asyncTests 用 $DONE 报告结果)。
// 结果写入 globalThis 全局字符串,run() 结束后由 runner 读取并按 marker 判定。
// (顶层 var 不落 global 对象,须显式写 globalThis。)
// print 为顶层函数声明,经全局对象反射落 globalThis;此处仅初始化累加器。
append_source_chunk(
&mut code,
"async capture",
@@ -578,7 +578,10 @@ fn judge_async_result(
return TestResult::fail(
path.to_path_buf(),
dur,
format!("expected runtime error ({}), got: async complete", meta.negative.as_ref().unwrap().error_type),
format!(
"expected runtime error ({}), got: async complete",
meta.negative.as_ref().unwrap().error_type
),
);
}
return TestResult::pass(path.to_path_buf(), dur, "async ok");