feat: 支持访问器描述符与 get/set 语法
This commit is contained in:
@@ -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 = [
|
||||
|
||||
Reference in New Issue
Block a user