mirror of
https://github.com/pjh456/OxideJS.git
synced 2026-10-23 18:21:13 +08:00
fix: 修复 switch case 标签冲突与大 switch 寄存器回绕
This commit is contained in:
@@ -256,3 +256,16 @@ fn eval_break_in_switch_in_loop() {
|
||||
"2"
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn eval_large_adjacent_switches_do_not_collide_labels() {
|
||||
let mut source = String::from("var r=0;switch(256){");
|
||||
for i in 0..=256 {
|
||||
source.push_str(&format!("case {i}:"));
|
||||
if i == 256 {
|
||||
source.push_str("r=1;break;");
|
||||
}
|
||||
}
|
||||
source.push_str("}switch(0){case 0:r=r+1;break;}r");
|
||||
assert_eq!(eval(&source), "2");
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user