phase29ab(p3): fix PromoteDecision contract and add negative smokes

This commit is contained in:
2025-12-28 10:57:55 +09:00
parent 280a5a8187
commit 84e1cd7c7b
8 changed files with 184 additions and 30 deletions

View File

@ -0,0 +1,40 @@
#!/bin/bash
# Phase 29ab P3: Pattern2 LoopBodyLocal seg Freeze (VM backend)
# Tests: read-only violation must fail-fast with joinir freeze tag
source "$(dirname "$0")/../../../lib/test_runner.sh"
export SMOKES_USE_PYVM=0
require_env || exit 2
INPUT="$NYASH_ROOT/apps/tests/phase29ab_pattern2_seg_freeze_min.hako"
RUN_TIMEOUT_SECS=${RUN_TIMEOUT_SECS:-10}
set +e
OUTPUT=$(timeout "$RUN_TIMEOUT_SECS" env NYASH_DISABLE_PLUGINS=1 HAKO_JOINIR_STRICT=1 "$NYASH_BIN" "$INPUT" 2>&1)
EXIT_CODE=$?
set -e
if [ "$EXIT_CODE" -eq 124 ]; then
test_fail "phase29ab_pattern2_seg_freeze_min_vm: hakorune timed out (>${RUN_TIMEOUT_SECS}s)"
exit 1
fi
if [ "$EXIT_CODE" -eq 0 ]; then
echo "[FAIL] Expected JoinIR freeze error, got exit 0"
echo "[INFO] Output:"
echo "$OUTPUT" | tail -n 40 || true
test_fail "phase29ab_pattern2_seg_freeze_min_vm: Unexpected success"
exit 1
fi
if echo "$OUTPUT" | grep -q "\[joinir/freeze\]"; then
test_pass "phase29ab_pattern2_seg_freeze_min_vm: joinir freeze detected"
exit 0
else
echo "[FAIL] Expected joinir freeze tag in output"
echo "[INFO] Exit code: $EXIT_CODE"
echo "[INFO] Output:"
echo "$OUTPUT" | tail -n 60 || true
test_fail "phase29ab_pattern2_seg_freeze_min_vm: Missing joinir freeze tag"
exit 1
fi

View File

@ -0,0 +1,34 @@
#!/bin/bash
# Phase 29ab P3: Pattern2 promotion NotApplicable (VM backend)
# Tests: no LoopBodyLocal in condition -> continue, output should be 2
source "$(dirname "$0")/../../../lib/test_runner.sh"
export SMOKES_USE_PYVM=0
require_env || exit 2
INPUT="$NYASH_ROOT/apps/tests/phase29ab_pattern2_seg_notapplicable_min.hako"
RUN_TIMEOUT_SECS=${RUN_TIMEOUT_SECS:-10}
set +e
OUTPUT=$(timeout "$RUN_TIMEOUT_SECS" env NYASH_DISABLE_PLUGINS=1 HAKO_JOINIR_STRICT=1 "$NYASH_BIN" "$INPUT" 2>&1)
EXIT_CODE=$?
set -e
if [ "$EXIT_CODE" -eq 124 ]; then
test_fail "phase29ab_pattern2_seg_notapplicable_min_vm: hakorune timed out (>${RUN_TIMEOUT_SECS}s)"
exit 1
fi
OUTPUT_CLEAN=$(echo "$OUTPUT" | filter_noise)
if echo "$OUTPUT_CLEAN" | grep -q "^2$" || echo "$OUTPUT" | grep -q "^RC: 2$"; then
test_pass "phase29ab_pattern2_seg_notapplicable_min_vm: promotion not applicable (output: 2)"
exit 0
else
echo "[FAIL] Unexpected output (expected: 2)"
echo "[INFO] Exit code: $EXIT_CODE"
echo "[INFO] Output (clean):"
echo "$OUTPUT_CLEAN" | tail -n 20 || true
test_fail "phase29ab_pattern2_seg_notapplicable_min_vm: Unexpected output"
exit 1
fi