From 4a6775717051d96e7942c53f8d010b967673f206 Mon Sep 17 00:00:00 2001 From: tomoaki Date: Sun, 28 Dec 2025 15:41:34 +0900 Subject: [PATCH] phase29ab(p7): add pattern6 reverse+matchscan negative smokes --- ...29ab_pattern6_matchscan_firstfail_min.hako | 18 +++++++++ ...se29ab_pattern6_reverse_firstfail_min.hako | 19 +++++++++ ...9ab_pattern6_matchscan_firstfail_min_vm.sh | 40 +++++++++++++++++++ ...e29ab_pattern6_reverse_firstfail_min_vm.sh | 40 +++++++++++++++++++ 4 files changed, 117 insertions(+) create mode 100644 apps/tests/phase29ab_pattern6_matchscan_firstfail_min.hako create mode 100644 apps/tests/phase29ab_pattern6_reverse_firstfail_min.hako create mode 100644 tools/smokes/v2/profiles/integration/apps/phase29ab_pattern6_matchscan_firstfail_min_vm.sh create mode 100644 tools/smokes/v2/profiles/integration/apps/phase29ab_pattern6_reverse_firstfail_min_vm.sh diff --git a/apps/tests/phase29ab_pattern6_matchscan_firstfail_min.hako b/apps/tests/phase29ab_pattern6_matchscan_firstfail_min.hako new file mode 100644 index 00000000..533d7a04 --- /dev/null +++ b/apps/tests/phase29ab_pattern6_matchscan_firstfail_min.hako @@ -0,0 +1,18 @@ +// Phase 29ab P7: Pattern6 match scan first-fail (missing step) +// Expect: JoinIR freeze (missing step update) + +static box Main { + find_missing_step(s, ch) { + local i = 0 + loop(i < s.length()) { + if s.substring(i, i + 1) == ch { + return i + } + } + return -1 + } + + main() { + return Main.find_missing_step("abc", "b") + } +} diff --git a/apps/tests/phase29ab_pattern6_reverse_firstfail_min.hako b/apps/tests/phase29ab_pattern6_reverse_firstfail_min.hako new file mode 100644 index 00000000..265f1f9b --- /dev/null +++ b/apps/tests/phase29ab_pattern6_reverse_firstfail_min.hako @@ -0,0 +1,19 @@ +// Phase 29ab P7: Pattern6 reverse scan first-fail (step contract violation) +// Expect: JoinIR freeze (reverse step must be i = i - 1) + +static box Main { + last_index_bad_step(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_bad_step("abc", "b") + } +} diff --git a/tools/smokes/v2/profiles/integration/apps/phase29ab_pattern6_matchscan_firstfail_min_vm.sh b/tools/smokes/v2/profiles/integration/apps/phase29ab_pattern6_matchscan_firstfail_min_vm.sh new file mode 100644 index 00000000..0af50220 --- /dev/null +++ b/tools/smokes/v2/profiles/integration/apps/phase29ab_pattern6_matchscan_firstfail_min_vm.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# Phase 29ab P7: Pattern6 match scan first-fail (contract violation) +# Tests: missing step update must fail-fast + +source "$(dirname "$0")/../../../lib/test_runner.sh" +export SMOKES_USE_PYVM=0 +require_env || exit 2 + +INPUT="$NYASH_ROOT/apps/tests/phase29ab_pattern6_matchscan_firstfail_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_firstfail_min_vm: hakorune timed out (>${RUN_TIMEOUT_SECS}s)" + exit 1 +fi + +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 + +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 diff --git a/tools/smokes/v2/profiles/integration/apps/phase29ab_pattern6_reverse_firstfail_min_vm.sh b/tools/smokes/v2/profiles/integration/apps/phase29ab_pattern6_reverse_firstfail_min_vm.sh new file mode 100644 index 00000000..bb63e644 --- /dev/null +++ b/tools/smokes/v2/profiles/integration/apps/phase29ab_pattern6_reverse_firstfail_min_vm.sh @@ -0,0 +1,40 @@ +#!/bin/bash +# Phase 29ab P7: Pattern6 reverse scan first-fail (contract violation) +# Tests: reverse scan step mismatch must fail-fast + +source "$(dirname "$0")/../../../lib/test_runner.sh" +export SMOKES_USE_PYVM=0 +require_env || exit 2 + +INPUT="$NYASH_ROOT/apps/tests/phase29ab_pattern6_reverse_firstfail_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_firstfail_min_vm: hakorune timed out (>${RUN_TIMEOUT_SECS}s)" + exit 1 +fi + +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 + +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