docs(tests): clarify compiler scenarios and capability helper ownership
This commit is contained in:
@@ -325,6 +325,7 @@ fn declared_field_checks_cover_construction_inheritance_writes_and_gc() {
|
||||
.unwrap();
|
||||
vm.release(roots.object).unwrap();
|
||||
vm.release(roots.type_type).unwrap();
|
||||
// 一次模块声明建立继承字段、名义对象字段及未知注解三种约束,真正的构造/写入在后面分别触发。
|
||||
execute(
|
||||
&mut vm,
|
||||
globals,
|
||||
@@ -336,6 +337,7 @@ class Unknown { value: Missing }
|
||||
"#,
|
||||
ParseMode::Module,
|
||||
);
|
||||
// 每份交互源码只提交一条语句:先登记 Child 实例,再让 Holder 的字段持有同一实例。
|
||||
// Interactive intentionally accepts one complete statement per source unit.
|
||||
execute(
|
||||
&mut vm,
|
||||
@@ -381,6 +383,7 @@ class Unknown { value: Missing }
|
||||
assert!(vm.del_attr(value, "count").is_err());
|
||||
vm.set_attr(value, "count", Value::Number(10.into()))
|
||||
.unwrap();
|
||||
// 用同名新类替换全局 Base,旧 value 的名义类型图仍保留最初的 Base 身份。
|
||||
execute(&mut vm, globals, "class Base {}", ParseMode::Interactive);
|
||||
// 其他名义类型名称在声明环境中动态解析;Base 重定义后 Holder 的字段约束应按新身份检查。
|
||||
// Other nominal names resolve dynamically in the declaring environment.
|
||||
@@ -446,6 +449,7 @@ class Seed: Link {}
|
||||
vm.set_attr(seed, "next", Value::Object(seed)).unwrap();
|
||||
vm.dict_set(globals, Value::Text("old".into()), Value::Object(seed))
|
||||
.unwrap();
|
||||
// 新 Link 采用不同字段布局,只替换环境绑定;seed 及其 next 的原声明身份应不受影响。
|
||||
execute(
|
||||
&mut vm,
|
||||
globals,
|
||||
|
||||
@@ -33,7 +33,7 @@ fn module(vm: &mut Vm, compiled: &CompiledCode) -> (ObjectRef, ObjectRef) {
|
||||
|
||||
/// 测试按名称从环境借用函数句柄;不 retain,调用者须保持 globals 或其他拥有图存活。
|
||||
fn function(vm: &Vm, globals: ObjectRef, name: &str) -> ObjectRef {
|
||||
// 环境键命中必须是函数对象;这里只借用,不新取得外部根。
|
||||
// 环境键必须命中对象句柄;此辅助函数不再下转型证明函数类别,实际可调用性由后续 VM 调用验证。
|
||||
let Some(Value::Object(function)) = vm.dict_get(globals, &Value::Text(name.into())).unwrap()
|
||||
else {
|
||||
panic!("missing function {name}")
|
||||
@@ -357,7 +357,7 @@ fn argument_and_recursion_failures_unwind_vm_frames_and_keep_traceback() {
|
||||
}
|
||||
|
||||
#[test]
|
||||
/// 由 Rust 测试框架调用:编译选项只声明合法名字,不注入 VM 值;空环境执行仍报告 NameNotFound。
|
||||
/// 由 Rust 测试框架调用:编译选项只登记可见名字,不注入 VM 值;空环境执行仍报告 NameNotFound。
|
||||
fn declared_host_names_are_checked_again_at_runtime() {
|
||||
// 当前用例的源码或带来源快照,下面按指定模式解析/编译。
|
||||
let source = EndorReader::from_text("<host>", "missing");
|
||||
@@ -669,7 +669,7 @@ fn source_control_flow_and_exact_arithmetic_execute_real_bytecode() {
|
||||
fn control_flow_definite_initialization_large_jumps_and_loop_budgets() {
|
||||
// 拼接较长 if/while 体,迫使条件出口和回边跨越扩展编码距离。
|
||||
let mut body = String::from("function main(): Number { i=0 while i<2 { if i==0 {");
|
||||
// 重复运行同一函数三次,每次归还结果,以对象数验证代码复用。
|
||||
// 追加三百条不改变 i 的赋值,仅增大跳转跨越的代码宽度;真正的循环推进在后面单独追加。
|
||||
for _ in 0..300 {
|
||||
body.push_str("i=i+0 ");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user