mirror of
https://github.com/pjh456/OxideJS.git
synced 2026-10-23 18:21:13 +08:00
test: 类编译断言更新为新属性描述符字节码布局
This commit is contained in:
@@ -565,7 +565,7 @@ fn compile_class_expression_emits_constructor_value() {
|
||||
module
|
||||
.bytecode
|
||||
.iter()
|
||||
.filter(|&&i| opcode::opcode(i) == OpCode::SET_PROP)
|
||||
.filter(|&&i| opcode::opcode(i) == OpCode::DEFINE_PROP_ATTRS)
|
||||
.count()
|
||||
>= 3,
|
||||
"class expression should wire method/constructor/prototype properties"
|
||||
@@ -594,7 +594,9 @@ fn compile_large_pure_expression_reuses_temp_registers() {
|
||||
|
||||
#[test]
|
||||
fn compile_builtin_globals_are_registered_lazily() {
|
||||
let module = compile_source("Object; Array; Math; JSON");
|
||||
// 数组字面量内全部 4 个引用均为活代码(结果即脚本值),DCE 不可删;
|
||||
// 未被引用的其它内置全局不得占用槽位。
|
||||
let module = compile_source("[Object, Array, Math, JSON]");
|
||||
assert_eq!(module.builtin_reg_map.len(), 4, "only referenced builtins should allocate registers");
|
||||
}
|
||||
|
||||
|
||||
@@ -277,7 +277,7 @@ fn compile_class_declaration_emits_constructor_and_prototype_setup() {
|
||||
module
|
||||
.bytecode
|
||||
.iter()
|
||||
.filter(|&&i| opcode::opcode(i) == OpCode::SET_PROP)
|
||||
.filter(|&&i| opcode::opcode(i) == OpCode::DEFINE_PROP_ATTRS)
|
||||
.count()
|
||||
>= 3,
|
||||
"class should assign method, constructor, and prototype properties"
|
||||
@@ -304,8 +304,11 @@ fn compile_class_declaration_default_constructor_creates_submodule() {
|
||||
fn compile_class_instance_getter_emits_define_accessor() {
|
||||
let module = compile_source("class A { get x() { return 1; } }");
|
||||
assert!(
|
||||
module.bytecode.iter().any(|&i| opcode::opcode(i) == OpCode::DEFINE_ACCESSOR),
|
||||
"class getter should emit DEFINE_ACCESSOR"
|
||||
module
|
||||
.bytecode
|
||||
.iter()
|
||||
.any(|&i| opcode::opcode(i) == OpCode::DEFINE_ACCESSOR_ATTRS),
|
||||
"class getter should emit DEFINE_ACCESSOR_ATTRS"
|
||||
);
|
||||
}
|
||||
|
||||
@@ -313,8 +316,11 @@ fn compile_class_instance_getter_emits_define_accessor() {
|
||||
fn compile_class_static_setter_emits_define_accessor() {
|
||||
let module = compile_source("class A { static set x(v) { this.y = v; } }");
|
||||
assert!(
|
||||
module.bytecode.iter().any(|&i| opcode::opcode(i) == OpCode::DEFINE_ACCESSOR),
|
||||
"static class setter should emit DEFINE_ACCESSOR"
|
||||
module
|
||||
.bytecode
|
||||
.iter()
|
||||
.any(|&i| opcode::opcode(i) == OpCode::DEFINE_ACCESSOR_ATTRS),
|
||||
"static class setter should emit DEFINE_ACCESSOR_ATTRS"
|
||||
);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user