test: strengthen phase96 next_non_ws fixture

This commit is contained in:
nyash-codex
2025-12-17 01:35:43 +09:00
parent ba87afd35c
commit db4453eb3c
3 changed files with 18 additions and 12 deletions

View File

@ -2,15 +2,14 @@
// Purpose: Trim系の実ループを fixtures/smoke で押さえる。 // Purpose: Trim系の実ループを fixtures/smoke で押さえる。
static box Main { static box Main {
main() { next_non_ws(s) {
// Input mirrors MiniJsonLoader.next_non_ws
local s = "hi"
local i = 0 local i = 0
local n = s.length() local n = s.length()
loop(i < n) { loop(i < n) {
local ch = s.substring(i, i + 1) 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 i = i + 1
} else { } else {
break break
@ -18,10 +17,15 @@ static box Main {
} }
if i < n { if i < n {
print(i) return i
} else {
print(-1)
} }
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" return "OK"
} }
} }

View File

@ -1,3 +1,3 @@
- Phase 96: MiniJsonLoader の next_non_ws ループを Trim policy/SSOT で固定。 - Phase 96: MiniJsonLoader の next_non_ws ループを Trim policy/SSOT で固定。
- フィクスチャ: apps/tests/phase96_json_loader_next_non_ws_min.hako現状は -1 出力で最小固定) - フィクスチャ: 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.shVM, strict - smoke: tools/smokes/v2/profiles/integration/apps/phase96_json_loader_next_non_ws_vm.shVM, strict、出力一致チェック

View File

@ -27,11 +27,13 @@ if [ "$EXIT_CODE" -eq 124 ]; then
echo "[FAIL] hakorune timed out (>${RUN_TIMEOUT_SECS}s)" echo "[FAIL] hakorune timed out (>${RUN_TIMEOUT_SECS}s)"
FAIL_COUNT=$((FAIL_COUNT + 1)) FAIL_COUNT=$((FAIL_COUNT + 1))
elif [ "$EXIT_CODE" -eq 0 ]; then elif [ "$EXIT_CODE" -eq 0 ]; then
if echo "$OUTPUT" | grep -q '^-1$'; then EXPECTED=$'0\n0'
echo "[PASS] Output verified: -1" 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)) PASS_COUNT=$((PASS_COUNT + 1))
else else
echo "[FAIL] Unexpected output (expected line: -1)" echo "[FAIL] Unexpected output (expected lines: 0 then 0)"
echo "[INFO] output (tail):" echo "[INFO] output (tail):"
echo "$OUTPUT" | tail -n 50 || true echo "$OUTPUT" | tail -n 50 || true
FAIL_COUNT=$((FAIL_COUNT + 1)) FAIL_COUNT=$((FAIL_COUNT + 1))