phase29ad(p0): split pattern6 ok vs contract fixtures

This commit is contained in:
2025-12-28 17:30:34 +09:00
parent 432a8436c7
commit 9c44e990a9
11 changed files with 171 additions and 27 deletions

View File

@ -1,5 +1,5 @@
// Phase 29ac P2: Pattern6 match scan OK minimal
// Expect: find_missing_step("abc", "b") -> 1
// Phase 29ad P0: Pattern6 match scan contract violation
// Expect: JoinIR freeze (step update missing)
static box Main {
find_missing_step(s, ch) {
@ -8,7 +8,6 @@ static box Main {
if s.substring(i, i + 1) == ch {
return i
}
i = i + 1
}
return -1
}

View File

@ -0,0 +1,19 @@
// Phase 29ac P2: Pattern6 match scan OK minimal
// Expect: find_ok("abc", "b") -> 1
static box Main {
find_ok(s, ch) {
local i = 0
loop(i < s.length()) {
if s.substring(i, i + 1) == ch {
return i
}
i = i + 1
}
return -1
}
main() {
return Main.find_ok("abc", "b")
}
}

View File

@ -1,5 +1,5 @@
// Phase 29ac P1: Pattern6 reverse scan OK minimal
// Expect: last_index_bad_step("abc", "b") -> 1
// Phase 29ad P0: Pattern6 reverse scan contract violation
// Expect: JoinIR freeze (reverse step must be i = i - 1)
static box Main {
last_index_bad_step(s, ch) {
@ -8,7 +8,7 @@ static box Main {
if s.substring(i, i + 1) == ch {
return i
}
i = i - 1
i = i - 2
}
return -1
}

View File

@ -0,0 +1,19 @@
// Phase 29ac P1: Pattern6 reverse scan OK minimal
// Expect: last_index_ok("abc", "b") -> 1
static box Main {
last_index_ok(s, ch) {
local i = s.length() - 1
loop(i >= 0) {
if s.substring(i, i + 1) == ch {
return i
}
i = i - 1
}
return -1
}
main() {
return Main.last_index_ok("abc", "b")
}
}

View File

@ -37,3 +37,22 @@ Accepted shape:
Freeze conditions:
- then/else update contracts broken (start/i updates)
- separator literal length != 1 (P0 scope)
## Fixtures (OK vs Contract)
Pattern6 OK:
- `apps/tests/phase29ab_pattern6_scan_with_init_ok_min.hako`
- `apps/tests/phase29ab_pattern6_reverse_ok_min.hako`
- `apps/tests/phase29ab_pattern6_matchscan_ok_min.hako`
Pattern6 contract:
- `apps/tests/phase29ab_pattern6_firstfail_min.hako`
- `apps/tests/phase29ab_pattern6_reverse_firstfail_min.hako`
- `apps/tests/phase29ab_pattern6_matchscan_firstfail_min.hako`
Pattern7 OK:
- `apps/tests/phase29ab_pattern7_splitscan_ok_min.hako`
- `apps/tests/phase29ac_pattern7_splitscan_nearmiss_fix_ok_min.hako`
Pattern7 contract:
- `apps/tests/phase29ab_pattern7_firstfail_min.hako`

View File

@ -43,6 +43,12 @@ Goal: Fix near-miss vs OK boundaries for Pattern2/6/7 and provide a single entry
- Pattern6 ScanWithInit OK:
- `apps/tests/phase29ab_pattern6_scan_with_init_ok_min.hako`
- `tools/smokes/v2/profiles/integration/apps/phase29ab_pattern6_scan_with_init_ok_min_vm.sh`
- Pattern6 reverse scan OK:
- `apps/tests/phase29ab_pattern6_reverse_ok_min.hako`
- `tools/smokes/v2/profiles/integration/apps/phase29ab_pattern6_reverse_ok_min_vm.sh`
- Pattern6 matchscan OK:
- `apps/tests/phase29ab_pattern6_matchscan_ok_min.hako`
- `tools/smokes/v2/profiles/integration/apps/phase29ab_pattern6_matchscan_ok_min_vm.sh`
- Pattern7 SplitScan OK:
- `apps/tests/phase29ab_pattern7_splitscan_ok_min.hako`
- `tools/smokes/v2/profiles/integration/apps/phase29ab_pattern7_splitscan_ok_min_vm.sh`

View File

@ -18,20 +18,22 @@ Goal: Convert freeze-fixed Pattern6/7 near-miss cases into PASS while keeping co
### PASS fixtures (behavioral)
- Pattern6 reverse scan OK: `apps/tests/phase29ab_pattern6_reverse_firstfail_min.hako`RC=1
- Pattern6 matchscan OK: `apps/tests/phase29ab_pattern6_matchscan_firstfail_min.hako`RC=1
- Pattern6 reverse scan OK: `apps/tests/phase29ab_pattern6_reverse_ok_min.hako`RC=1
- Pattern6 matchscan OK: `apps/tests/phase29ab_pattern6_matchscan_ok_min.hako`RC=1
- Pattern7 split-scan near-miss fixup OK: `apps/tests/phase29ac_pattern7_splitscan_nearmiss_fix_ok_min.hako`RC=3
### FAIL-Fast fixtures (contract boundary)
- Pattern6 scan-with-init contract violation: `apps/tests/phase29ab_pattern6_firstfail_min.hako`tag: `[joinir/phase29ab/pattern6/contract]`
- Pattern6 reverse scan contract violation: `apps/tests/phase29ab_pattern6_reverse_firstfail_min.hako`tag: `[joinir/phase29ab/pattern6/contract]`
- Pattern6 matchscan contract violation: `apps/tests/phase29ab_pattern6_matchscan_firstfail_min.hako`tag: `[joinir/phase29ab/pattern6/contract]`
- Pattern7 split-scan contract violation: `apps/tests/phase29ab_pattern7_firstfail_min.hako`tag: `[joinir/phase29ab/pattern7/contract]`
## Pass order (recommended)
1. **Pattern6 reverse scan**
- Plan/Normalizer: add reverse support (`i >= 0`, step `i = i - 1`).
- Smoke: `phase29ab_pattern6_reverse_firstfail_min` now OK PASS (RC=1).
- Smoke: `phase29ab_pattern6_reverse_ok_min` now OK PASS (RC=1).
2. **Pattern6 matchscan missing step**
- Freeze reason: `[joinir/phase29ab/pattern6/contract] scan-with-init contract: missing step update`
- Resolution: add explicit `i = i + 1` step in fixture (contract-aligned).

View File

@ -1,6 +1,6 @@
#!/bin/bash
# Phase 29ac P2: Pattern6 match scan OK minimal
# Tests: return index 1
# Phase 29ad P0: Pattern6 match scan contract violation
# Tests: missing step update must fail-fast
source "$(dirname "$0")/../../../lib/test_runner.sh"
export SMOKES_USE_PYVM=0
@ -19,12 +19,22 @@ if [ "$EXIT_CODE" -eq 124 ]; then
exit 1
fi
if [ "$EXIT_CODE" -eq 1 ]; then
test_pass "phase29ab_pattern6_matchscan_firstfail_min_vm: RC=1 (expected)"
exit 0
if [ "$EXIT_CODE" -eq 0 ]; then
echo "[FAIL] Expected JoinIR contract freeze error, got exit 0"
echo "[INFO] Output:"
echo "$OUTPUT" | tail -n 40 || true
test_fail "phase29ab_pattern6_matchscan_firstfail_min_vm: Unexpected success"
exit 1
fi
echo "[FAIL] Expected exit 1, got $EXIT_CODE"
echo "$OUTPUT" | tail -n 40 || true
test_fail "phase29ab_pattern6_matchscan_firstfail_min_vm: Unexpected RC"
exit 1
if echo "$OUTPUT" | grep -q "\[joinir/phase29ab/pattern6/contract\]"; then
test_pass "phase29ab_pattern6_matchscan_firstfail_min_vm: joinir contract freeze detected"
exit 0
else
echo "[FAIL] Expected joinir contract freeze tag in output"
echo "[INFO] Exit code: $EXIT_CODE"
echo "[INFO] Output:"
echo "$OUTPUT" | tail -n 60 || true
test_fail "phase29ab_pattern6_matchscan_firstfail_min_vm: Missing joinir contract freeze tag"
exit 1
fi

View File

@ -0,0 +1,30 @@
#!/bin/bash
# Phase 29ac P2: Pattern6 match scan OK minimal
# Tests: return index 1
source "$(dirname "$0")/../../../lib/test_runner.sh"
export SMOKES_USE_PYVM=0
require_env || exit 2
INPUT="$NYASH_ROOT/apps/tests/phase29ab_pattern6_matchscan_ok_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_pattern6_matchscan_ok_min_vm: hakorune timed out (>${RUN_TIMEOUT_SECS}s)"
exit 1
fi
if [ "$EXIT_CODE" -eq 1 ]; then
test_pass "phase29ab_pattern6_matchscan_ok_min_vm: RC=1 (expected)"
exit 0
fi
echo "[FAIL] Expected exit 1, got $EXIT_CODE"
echo "$OUTPUT" | tail -n 40 || true
test_fail "phase29ab_pattern6_matchscan_ok_min_vm: Unexpected RC"
exit 1

View File

@ -1,6 +1,6 @@
#!/bin/bash
# Phase 29ac P1: Pattern6 reverse scan OK minimal
# Tests: return index 1
# Phase 29ad P0: Pattern6 reverse scan contract violation
# Tests: reverse step mismatch must fail-fast
source "$(dirname "$0")/../../../lib/test_runner.sh"
export SMOKES_USE_PYVM=0
@ -19,12 +19,22 @@ if [ "$EXIT_CODE" -eq 124 ]; then
exit 1
fi
if [ "$EXIT_CODE" -eq 1 ]; then
test_pass "phase29ab_pattern6_reverse_firstfail_min_vm: RC=1 (expected)"
exit 0
if [ "$EXIT_CODE" -eq 0 ]; then
echo "[FAIL] Expected JoinIR contract freeze error, got exit 0"
echo "[INFO] Output:"
echo "$OUTPUT" | tail -n 40 || true
test_fail "phase29ab_pattern6_reverse_firstfail_min_vm: Unexpected success"
exit 1
fi
echo "[FAIL] Expected exit 1, got $EXIT_CODE"
echo "$OUTPUT" | tail -n 40 || true
test_fail "phase29ab_pattern6_reverse_firstfail_min_vm: Unexpected RC"
exit 1
if echo "$OUTPUT" | grep -q "\[joinir/phase29ab/pattern6/contract\]"; then
test_pass "phase29ab_pattern6_reverse_firstfail_min_vm: joinir contract freeze detected"
exit 0
else
echo "[FAIL] Expected joinir contract freeze tag in output"
echo "[INFO] Exit code: $EXIT_CODE"
echo "[INFO] Output:"
echo "$OUTPUT" | tail -n 60 || true
test_fail "phase29ab_pattern6_reverse_firstfail_min_vm: Missing joinir contract freeze tag"
exit 1
fi

View File

@ -0,0 +1,30 @@
#!/bin/bash
# Phase 29ac P1: Pattern6 reverse scan OK minimal
# Tests: return index 1
source "$(dirname "$0")/../../../lib/test_runner.sh"
export SMOKES_USE_PYVM=0
require_env || exit 2
INPUT="$NYASH_ROOT/apps/tests/phase29ab_pattern6_reverse_ok_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_pattern6_reverse_ok_min_vm: hakorune timed out (>${RUN_TIMEOUT_SECS}s)"
exit 1
fi
if [ "$EXIT_CODE" -eq 1 ]; then
test_pass "phase29ab_pattern6_reverse_ok_min_vm: RC=1 (expected)"
exit 0
fi
echo "[FAIL] Expected exit 1, got $EXIT_CODE"
echo "$OUTPUT" | tail -n 40 || true
test_fail "phase29ab_pattern6_reverse_ok_min_vm: Unexpected RC"
exit 1