From e59eec884ad2f9728d4d51774ddab497c806e4f1 Mon Sep 17 00:00:00 2001 From: pjh456 <147148383@qq.com> Date: Fri, 11 Sep 2026 12:44:48 +0000 Subject: [PATCH] =?UTF-8?q?test:=20=E8=A1=A5=20do-while=20continue=20?= =?UTF-8?q?=E5=88=A4=E5=88=AB=E6=80=A7=E9=92=89=E2=80=94=E2=80=94continue?= =?UTF-8?q?=20=E9=A1=BB=E7=9B=B4=E8=BE=BE=E6=9D=A1=E4=BB=B6=E4=BD=8D?= =?UTF-8?q?=E7=BD=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 既有钉修复前后同值(r=4)不判别 continue 目标位置:新钉 i 到 3 触发 continue,条件直达时 3<3 为假即退得 3,continue 错指体首会跳过条件多跑一轮得 4。 --- crates/oxide_vm/tests/control_flow_tests.rs | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/crates/oxide_vm/tests/control_flow_tests.rs b/crates/oxide_vm/tests/control_flow_tests.rs index f9c098b2..841e1f95 100644 --- a/crates/oxide_vm/tests/control_flow_tests.rs +++ b/crates/oxide_vm/tests/control_flow_tests.rs @@ -157,6 +157,13 @@ fn eval_do_while_continue() { ); } +#[test] +fn eval_do_while_continue_jumps_to_condition() { + // continue 直达条件位置:i 到 3 后 continue,条件 3<3 为假即退,结果 3; + // 若 continue 重入体首(跳过条件求值)会多跑一轮得 4。 + assert_eq!(eval("var i = 0; do { i = i + 1; if (i == 3) continue; } while (i < 3); i"), "3"); +} + #[test] fn eval_for_in_enumerates_keys() { assert_eq!(eval("var n=0; for (k in {a:1,b:2}) { n=n+1; } n"), "2");