feat: 支持访问器描述符与 get/set 语法

This commit is contained in:
爱特每羊队
2026-06-09 16:22:24 +08:00
parent 044c8a4303
commit ed0864d01f
13 changed files with 457 additions and 77 deletions
@@ -72,6 +72,24 @@ fn compile_multiple_stmts() {
assert!(load_count >= 3);
}
#[test]
fn compile_object_literal_getter_emits_define_accessor() {
let module = compile_source("var o = { get x() { return 1; } };");
assert!(
module.bytecode.iter().any(|&i| opcode::opcode(i) == OpCode::DEFINE_ACCESSOR),
"object literal getter should emit DEFINE_ACCESSOR"
);
}
#[test]
fn compile_object_literal_setter_emits_define_accessor() {
let module = compile_source("var o = { set x(v) { this.y = v; } };");
assert!(
module.bytecode.iter().any(|&i| opcode::opcode(i) == OpCode::DEFINE_ACCESSOR),
"object literal setter should emit DEFINE_ACCESSOR"
);
}
#[test]
fn compile_binary_ops() {
let tests = [