## 🎯 Checker/Analyzer拡張 ### ✅ 実装追加 - テストフレームワーク追加(tools/hako_check/tests/) - ルール改善(HC003グローバルassign、HC040静的箱トップレベルassign) - テストランナー(run_tests.sh) ### 🔧 Rust側修正 - AST utilities拡張(src/ast/utils.rs) - MIR lowerers新設(src/mir/lowerers/) - Parser制御フロー改善(src/parser/statements/control_flow.rs) - Tokenizer識別子処理改善(src/tokenizer/lex_ident.rs) ### 📁 主要変更 - tools/hako_check/cli.hako - CLI改善 - tools/hako_check/hako_source_checker.hako - Checker core更新 - tools/hako_check/tests/ - NEW (テストケース追加) - tools/hako_check/run_tests.sh - NEW (テストランナー) - src/mir/lowerers/ - NEW (MIR lowering utilities) 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
51 lines
1.4 KiB
Bash
51 lines
1.4 KiB
Bash
#!/usr/bin/env bash
|
|
set -euo pipefail
|
|
|
|
ROOT="$(cd "$(dirname "$0")/.." && pwd)"
|
|
BIN="${NYASH_BIN:-$ROOT/target/release/hakorune}"
|
|
|
|
if [ ! -x "$BIN" ]; then
|
|
echo "[TEST] hakorune not built: $BIN" >&2
|
|
echo "Run: cargo build --release" >&2
|
|
exit 2
|
|
fi
|
|
|
|
TARGET_DIR="$ROOT/tools/hako_check/tests"
|
|
fail=0
|
|
|
|
run_case() {
|
|
local dir="$1"
|
|
local expected="$dir/expected.json"
|
|
local input_ok="$dir/ok.hako"
|
|
local input_ng="$dir/ng.hako"
|
|
if [ ! -f "$expected" ]; then echo "[TEST] skip (no expected): $dir"; return; fi
|
|
if [ ! -f "$input_ok" ] && [ ! -f "$input_ng" ]; then echo "[TEST] skip (no inputs): $dir"; return; fi
|
|
local tmp_out="/tmp/hako_test_$$.json"
|
|
NYASH_DISABLE_NY_COMPILER=1 HAKO_DISABLE_NY_COMPILER=1 \
|
|
NYASH_PARSER_STAGE3=1 HAKO_PARSER_STAGE3=1 NYASH_PARSER_SEAM_TOLERANT=1 HAKO_PARSER_SEAM_TOLERANT=1 \
|
|
NYASH_ENABLE_USING=1 HAKO_ENABLE_USING=1 NYASH_USING_AST=1 \
|
|
"$BIN" --backend vm "$ROOT/tools/hako_check/cli.hako" -- --format json-lsp ${input_ok:+"$input_ok"} ${input_ng:+"$input_ng"} \
|
|
>"$tmp_out" 2>/dev/null || true
|
|
if ! diff -u "$expected" "$tmp_out" >/dev/null; then
|
|
echo "[TEST/FAIL] $dir" >&2
|
|
diff -u "$expected" "$tmp_out" || true
|
|
fail=$((fail+1))
|
|
else
|
|
echo "[TEST/OK] $dir"
|
|
fi
|
|
rm -f "$tmp_out"
|
|
}
|
|
|
|
for d in "$TARGET_DIR"/*; do
|
|
[ -d "$d" ] || continue
|
|
run_case "$d"
|
|
done
|
|
|
|
if [ $fail -ne 0 ]; then
|
|
echo "[TEST/SUMMARY] failures=$fail" >&2
|
|
exit 1
|
|
fi
|
|
echo "[TEST/SUMMARY] all green"
|
|
exit 0
|
|
|