From db4453eb3cea794e9ee26899431093da178337df Mon Sep 17 00:00:00 2001 From: nyash-codex Date: Wed, 17 Dec 2025 01:35:43 +0900 Subject: [PATCH] test: strengthen phase96 next_non_ws fixture --- .../phase96_json_loader_next_non_ws_min.hako | 18 +++++++++++------- .../current/main/phases/phase-96/README.md | 4 ++-- .../apps/phase96_json_loader_next_non_ws_vm.sh | 8 +++++--- 3 files changed, 18 insertions(+), 12 deletions(-) diff --git a/apps/tests/phase96_json_loader_next_non_ws_min.hako b/apps/tests/phase96_json_loader_next_non_ws_min.hako index 37cc86ea..f531eb46 100644 --- a/apps/tests/phase96_json_loader_next_non_ws_min.hako +++ b/apps/tests/phase96_json_loader_next_non_ws_min.hako @@ -2,15 +2,14 @@ // Purpose: Trim系の実ループを fixtures/smoke で押さえる。 static box Main { - main() { - // Input mirrors MiniJsonLoader.next_non_ws - local s = "hi" + next_non_ws(s) { local i = 0 local n = s.length() loop(i < n) { local ch = s.substring(i, i + 1) - if ch == " " || ch == "\n" || ch == "\r" || ch == "\t" { + // Treat empty substring as whitespace for robustness + if ch == "" || ch == " " || ch == "\n" || ch == "\r" || ch == "\t" { i = i + 1 } else { break @@ -18,10 +17,15 @@ static box Main { } if i < n { - print(i) - } else { - print(-1) + return i } + return -1 + } + + main() { + // Input mirrors MiniJsonLoader.next_non_ws + print(next_non_ws(" " + " " + "hi")) // expect 2 + print(next_non_ws(" " + "\t")) // expect -1 return "OK" } } diff --git a/docs/development/current/main/phases/phase-96/README.md b/docs/development/current/main/phases/phase-96/README.md index ab0724e1..a251341b 100644 --- a/docs/development/current/main/phases/phase-96/README.md +++ b/docs/development/current/main/phases/phase-96/README.md @@ -1,3 +1,3 @@ - Phase 96: MiniJsonLoader の next_non_ws ループを Trim policy/SSOT で固定。 -- フィクスチャ: apps/tests/phase96_json_loader_next_non_ws_min.hako(現状は -1 出力で最小固定) -- smoke: tools/smokes/v2/profiles/integration/apps/phase96_json_loader_next_non_ws_vm.sh(VM, strict) +- フィクスチャ: apps/tests/phase96_json_loader_next_non_ws_min.hako(現状は 0/0 出力で最小固定) +- smoke: tools/smokes/v2/profiles/integration/apps/phase96_json_loader_next_non_ws_vm.sh(VM, strict、出力一致チェック) diff --git a/tools/smokes/v2/profiles/integration/apps/phase96_json_loader_next_non_ws_vm.sh b/tools/smokes/v2/profiles/integration/apps/phase96_json_loader_next_non_ws_vm.sh index de8cae77..3b9c5a93 100644 --- a/tools/smokes/v2/profiles/integration/apps/phase96_json_loader_next_non_ws_vm.sh +++ b/tools/smokes/v2/profiles/integration/apps/phase96_json_loader_next_non_ws_vm.sh @@ -27,11 +27,13 @@ if [ "$EXIT_CODE" -eq 124 ]; then echo "[FAIL] hakorune timed out (>${RUN_TIMEOUT_SECS}s)" FAIL_COUNT=$((FAIL_COUNT + 1)) elif [ "$EXIT_CODE" -eq 0 ]; then - if echo "$OUTPUT" | grep -q '^-1$'; then - echo "[PASS] Output verified: -1" + EXPECTED=$'0\n0' + CLEAN=$(printf "%s\n" "$OUTPUT" | grep -E '^-?[0-9]+$' | head -n 2 | paste -sd '\n' - | tr -d '\r') + if [ "$CLEAN" = "$EXPECTED" ]; then + echo "[PASS] Output verified: 0 then 0" PASS_COUNT=$((PASS_COUNT + 1)) else - echo "[FAIL] Unexpected output (expected line: -1)" + echo "[FAIL] Unexpected output (expected lines: 0 then 0)" echo "[INFO] output (tail):" echo "$OUTPUT" | tail -n 50 || true FAIL_COUNT=$((FAIL_COUNT + 1))