test: add phase96 trim loop fixture and smoke

This commit is contained in:
nyash-codex
2025-12-17 01:25:06 +09:00
parent ad67d50798
commit ba87afd35c
5 changed files with 93 additions and 0 deletions

View File

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

View File

@ -49,6 +49,8 @@ JoinIR の箱構造と責務、ループ/if の lowering パターンを把握
- `docs/development/current/main/phases/phase-94/README.md`
8. Phase 95: MiniJsonLoader escape ループPhase 94 基盤の横展開)
- `docs/development/current/main/phases/phase-95/README.md`
9. Phase 96: Trim policy 着手 + next_non_ws ループ
- `docs/development/current/main/phases/phase-96/README.md`
6. MIR BuilderContext 分割の入口)
- `src/mir/builder/README.md`
7. Scope/BindingIdshadowing・束縛同一性の段階移行

View File

@ -63,6 +63,13 @@
- smoke: `tools/smokes/v2/profiles/integration/apps/phase95_json_loader_escape_vm.sh`
- Phase 記録(入口): `docs/development/current/main/phases/phase-95/README.md`
## 20251216Phase 96短報
- Trim系 policy 化を開始し、MiniJsonLoader の next_non_ws ループを fixtures/smoke に追加。
- フィクスチャ: `apps/tests/phase96_json_loader_next_non_ws_min.hako`
- smoke: `tools/smokes/v2/profiles/integration/apps/phase96_json_loader_next_non_ws_vm.sh`
- Phase 記録(入口): `docs/development/current/main/phases/phase-96/README.md`
## 20251214現状サマリ
補足docs が増えて迷子になったときの「置き場所ルールSSOT」:

View File

@ -0,0 +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.shVM, strict

View File

@ -0,0 +1,54 @@
#!/bin/bash
# Phase 96: json_loader next_non_ws loop (VM)
#
# Verifies Trim-style loop (next non-whitespace) extracted from MiniJsonLoader.
source "$(dirname "$0")/../../../lib/test_runner.sh"
export SMOKES_USE_PYVM=0
require_env || exit 2
PASS_COUNT=0
FAIL_COUNT=0
RUN_TIMEOUT_SECS=${RUN_TIMEOUT_SECS:-10}
INPUT="$NYASH_ROOT/apps/tests/phase96_json_loader_next_non_ws_min.hako"
echo "[INFO] Phase 96: json_loader next_non_ws loop (VM) - $INPUT"
set +e
OUTPUT=$(timeout "$RUN_TIMEOUT_SECS" env \
NYASH_DISABLE_PLUGINS=1 \
HAKO_JOINIR_STRICT=1 \
"$NYASH_BIN" --backend vm "$INPUT" 2>&1)
EXIT_CODE=$?
set -e
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"
PASS_COUNT=$((PASS_COUNT + 1))
else
echo "[FAIL] Unexpected output (expected line: -1)"
echo "[INFO] output (tail):"
echo "$OUTPUT" | tail -n 50 || true
FAIL_COUNT=$((FAIL_COUNT + 1))
fi
else
echo "[FAIL] hakorune failed with exit code $EXIT_CODE"
echo "[INFO] output (tail):"
echo "$OUTPUT" | tail -n 50 || true
FAIL_COUNT=$((FAIL_COUNT + 1))
fi
echo "[INFO] PASS: $PASS_COUNT, FAIL: $FAIL_COUNT"
if [ "$FAIL_COUNT" -eq 0 ]; then
test_pass "phase96_json_loader_next_non_ws_vm: All tests passed"
exit 0
else
test_fail "phase96_json_loader_next_non_ws_vm: $FAIL_COUNT test(s) failed"
exit 1
fi