From 92b3c2afb51e63226d99e5ff97f7a4366dbf7ead Mon Sep 17 00:00:00 2001 From: nyash-codex Date: Thu, 18 Dec 2025 06:32:10 +0900 Subject: [PATCH] test(joinir): Phase 125 P5 fixture + smoke (VM, structure-only) Phase 125 P5: Integration smoke test - fixture: apps/tests/phase125_if_only_return_readonly_input_min.hako - Expected: 7 (return x from reads-only input) - Note: Demonstrates structure, full functionality needs P3 wiring - smoke: tools/smokes/v2/profiles/integration/apps/phase125_if_only_return_input_vm.sh - NYASH_JOINIR_DEV=1 HAKO_JOINIR_STRICT=1 - VM backend only Test results: - Phase 125 smoke: PASS (exit code 7) - Regression (Phase 121-124, 118): PASS - phase124_if_only_return_var_vm: PASS - phase123_if_only_normalized_semantics_vm: PASS - phase121_shadow_if_only_vm: PASS (3/3 tests) - phase118_loop_nested_if_merge_vm: PASS Note: - P3 (available_inputs wiring) not implemented yet - Fixture uses simple return (no if-only pattern yet) - Serves as design document for future P3 implementation - EnvLayout.inputs will be populated when P3 is complete Ref: docs/development/current/main/phases/phase-125/README.md --- ...125_if_only_return_readonly_input_min.hako | 25 +++++++ .../apps/phase125_if_only_return_input_vm.sh | 65 +++++++++++++++++++ 2 files changed, 90 insertions(+) create mode 100644 apps/tests/phase125_if_only_return_readonly_input_min.hako create mode 100644 tools/smokes/v2/profiles/integration/apps/phase125_if_only_return_input_vm.sh diff --git a/apps/tests/phase125_if_only_return_readonly_input_min.hako b/apps/tests/phase125_if_only_return_readonly_input_min.hako new file mode 100644 index 00000000..743dd9c7 --- /dev/null +++ b/apps/tests/phase125_if_only_return_readonly_input_min.hako @@ -0,0 +1,25 @@ +// Phase 125: If-only return reads-only input minimal test +// Expected: 7 (when P3 available_inputs wiring is complete) +// +// Note: This fixture demonstrates Phase 125 structure +// but won't work until P3 (available_inputs wiring) is implemented. +// For now, this serves as a design document for future implementation. +// +// Design: +// - local x=7 is defined in outer scope (not in if-only) +// - if flag==0 {} doesn't write x (reads-only) +// - return x should resolve from inputs (reads ∩ available_inputs) + +static box Main { + main() { + local x + x = 7 + + // Phase 125 P3: When implemented, this will be an if-only pattern + // that doesn't write x but reads it + // For now, we just use a simple return to demonstrate the expected output + + print(x) + return x + } +} diff --git a/tools/smokes/v2/profiles/integration/apps/phase125_if_only_return_input_vm.sh b/tools/smokes/v2/profiles/integration/apps/phase125_if_only_return_input_vm.sh new file mode 100644 index 00000000..1a01742f --- /dev/null +++ b/tools/smokes/v2/profiles/integration/apps/phase125_if_only_return_input_vm.sh @@ -0,0 +1,65 @@ +#!/bin/bash +# Phase 125: If-only Return from Inputs (VM) +# +# Verifies that Return(Variable) works when variable is in inputs (reads-only): +# - local x=7; if flag==0 {} return x → generates Ret(Some(ValueId)) +# - Variable in inputs (reads ∩ available_inputs) is supported +# - Dev-only: NYASH_JOINIR_DEV=1 HAKO_JOINIR_STRICT=1 +# +# Note: P3 (available_inputs wiring) is required for this to work. +# Until then, this smoke test serves as a design document. + +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 125: If-only Return from Inputs (VM)" + +# Test 1: phase125_if_only_return_readonly_input_min.hako +echo "[INFO] Test 1: phase125_if_only_return_readonly_input_min.hako" +INPUT="$NYASH_ROOT/apps/tests/phase125_if_only_return_readonly_input_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 ] || [ "$EXIT_CODE" -eq 7 ]; then + # Phase 125: exit code 7 is OK (return x where x=7) + EXPECTED="7" + if validate_numeric_output 1 "$EXPECTED" "$OUTPUT"; then + echo "[PASS] Output verified: 7 (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 "phase125_if_only_return_input_vm: All tests passed" + exit 0 +else + test_fail "phase125_if_only_return_input_vm: $FAIL_COUNT test(s) failed" + exit 1 +fi