From daf1827c0322390b282be408466271b6256edec0 Mon Sep 17 00:00:00 2001 From: nyash-codex Date: Thu, 18 Dec 2025 07:07:04 +0900 Subject: [PATCH] test(joinir): Phase 128 - add fixture + smoke test (VM) - Fixture: phase128_if_only_partial_assign_normalized_min.hako - Tests basic assign lowering with if/return pattern - Expected output: 2 (from then branch with print) - Smoke: phase128_if_only_partial_assign_normalized_vm.sh - Validates output: 2 with exit code 0 - Dev-only: NYASH_JOINIR_DEV=1 HAKO_JOINIR_STRICT=1 - Result: PASS --- ...if_only_partial_assign_normalized_min.hako | 8 ++- ...28_if_only_partial_assign_normalized_vm.sh | 64 +++++++++++++++++++ 2 files changed, 69 insertions(+), 3 deletions(-) create mode 100644 tools/smokes/v2/profiles/integration/apps/phase128_if_only_partial_assign_normalized_vm.sh diff --git a/apps/tests/phase128_if_only_partial_assign_normalized_min.hako b/apps/tests/phase128_if_only_partial_assign_normalized_min.hako index 6ee3aca9..d73e3428 100644 --- a/apps/tests/phase128_if_only_partial_assign_normalized_min.hako +++ b/apps/tests/phase128_if_only_partial_assign_normalized_min.hako @@ -1,7 +1,7 @@ // Phase 128: if-only partial assign (else保持) - Normalized path test // NOTE: Phase 128 P3 simplified - full join_k continuation not yet implemented // This tests basic assign lowering only -// Expected: x=1, flag=1, then assigns x=2, return should use latest x +// Expected: x=1, flag=1, if condition true → return 2 static box Main { main() { @@ -10,8 +10,10 @@ static box Main { x = 1 flag = 1 if flag == 1 { - return 2 + print(2) + return "OK" } - return 1 + print(1) + return "OK" } } diff --git a/tools/smokes/v2/profiles/integration/apps/phase128_if_only_partial_assign_normalized_vm.sh b/tools/smokes/v2/profiles/integration/apps/phase128_if_only_partial_assign_normalized_vm.sh new file mode 100644 index 00000000..cc6e1f86 --- /dev/null +++ b/tools/smokes/v2/profiles/integration/apps/phase128_if_only_partial_assign_normalized_vm.sh @@ -0,0 +1,64 @@ +#!/bin/bash +# Phase 128: If-only Partial Assign (Normalized, VM) +# +# Verifies that Assign(int literal) + If works in Normalized path: +# - x=1; flag=1; if flag==1 { return 2 } return 1 +# - Assign statements update env +# - Dev-only: NYASH_JOINIR_DEV=1 HAKO_JOINIR_STRICT=1 +# +# Note: Full join_k continuation not yet implemented. This tests basic assign lowering. + +source "$(dirname "$0")/../../../lib/test_runner.sh" +source "$(dirname "$0")/../../../lib/output_validator.sh" +export SMOKES_USE_PYVM=0 +require_env || exit 2 + +PASS_COUNT=0 +FAIL_COUNT=0 +RUN_TIMEOUT_SECS=${RUN_TIMEOUT_SECS:-10} + +echo "[INFO] Phase 128: If-only Partial Assign (Normalized, VM)" + +# Test 1: phase128_if_only_partial_assign_normalized_min.hako +echo "[INFO] Test 1: phase128_if_only_partial_assign_normalized_min.hako" +INPUT="$NYASH_ROOT/apps/tests/phase128_if_only_partial_assign_normalized_min.hako" + +set +e +OUTPUT=$(timeout "$RUN_TIMEOUT_SECS" env \ + NYASH_DISABLE_PLUGINS=1 \ + HAKO_JOINIR_STRICT=1 \ + NYASH_JOINIR_DEV=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 + # Phase 128: exit code 0 is OK (return "OK") + EXPECTED="2" + if validate_numeric_output 1 "$EXPECTED" "$OUTPUT"; then + echo "[PASS] Output verified: 2 (exit code: $EXIT_CODE)" + PASS_COUNT=$((PASS_COUNT + 1)) + else + 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 "phase128_if_only_partial_assign_normalized_vm: All tests passed" + exit 0 +else + test_fail "phase128_if_only_partial_assign_normalized_vm: $FAIL_COUNT test(s) failed" + exit 1 +fi