test(joinir): Phase 131 loop(true) break-once fixture + VM/LLVM smokes

Add minimal fixture and smoke tests for loop(true) break-once pattern:

**Fixture**:
- apps/tests/phase131_loop_true_break_once_min.hako
  - Pattern: x=0; loop(true) { x=1; break }; return x
  - Expected: return value 1 (exit code 1)

**Smokes**:
- tools/smokes/v2/profiles/integration/apps/phase131_loop_true_break_once_vm.sh
  - VM backend test with dev-only flags
- tools/smokes/v2/profiles/integration/apps/phase131_loop_true_break_once_llvm_exe.sh
  - LLVM EXE backend test with plugin gating

**Note**: Smokes currently fail (execution path not yet wired).
Structure implementation only - follow-up phase will wire execution.

Related: Phase 131 P0 (Normalized shadow structure)
This commit is contained in:
nyash-codex
2025-12-18 09:36:25 +09:00
parent 353b8022af
commit 38d3c98822
3 changed files with 120 additions and 0 deletions

View File

@ -0,0 +1,24 @@
// Phase 131 P0: loop(true) break-once minimal fixture
//
// Purpose: Test loop(true) { <assign>* ; break } in Normalized shadow
// Expected output: 1
//
// Structure:
// x = 0 // pre-loop init
// loop(true) { // condition is Bool literal true
// x = 1 // body assignment
// break // break at end
// }
// return x // return updated value
static box Main {
main() {
local x
x = 0
loop(true) {
x = 1
break
}
return x
}
}

View File

@ -0,0 +1,35 @@
#!/bin/bash
# Phase 131 P0: loop(true) break-once (LLVM EXE parity)
# Pattern: loop(true) { x = 1; break } → return x (should be 1)
source "$(dirname "$0")/../../../lib/test_runner.sh"
source "$(dirname "$0")/../../../lib/llvm_exe_runner.sh"
export SMOKES_USE_PYVM=0
require_env || exit 2
llvm_exe_preflight_or_skip || exit 0
# Phase 131: minimal plugin set (StringBox, ConsoleBox, IntegerBox only)
STRINGBOX_SO="$NYASH_ROOT/plugins/nyash-string-plugin/libnyash_string_plugin.so"
CONSOLEBOX_SO="$NYASH_ROOT/plugins/nyash-console-plugin/libnyash_console_plugin.so"
INTEGERBOX_SO="$NYASH_ROOT/plugins/nyash-integer-plugin/libnyash_integer_plugin.so"
LLVM_REQUIRED_PLUGINS=(
"StringBox|$STRINGBOX_SO|nyash-string-plugin"
"ConsoleBox|$CONSOLEBOX_SO|nyash-console-plugin"
"IntegerBox|$INTEGERBOX_SO|nyash-integer-plugin"
)
LLVM_PLUGIN_BUILD_LOG="/tmp/phase131_loop_true_break_once_plugin_build.log"
llvm_exe_ensure_plugins_or_fail || exit 1
INPUT_HAKO="$NYASH_ROOT/apps/tests/phase131_loop_true_break_once_min.hako"
OUTPUT_EXE="$NYASH_ROOT/tmp/phase131_loop_true_break_once_llvm_exe"
EXPECTED=$'1'
EXPECTED_LINES=1
LLVM_BUILD_LOG="/tmp/phase131_loop_true_break_once_build.log"
if llvm_exe_build_and_run_numeric_smoke; then
test_pass "phase131_loop_true_break_once_llvm_exe: output matches expected (1)"
else
exit 1
fi

View File

@ -0,0 +1,61 @@
#!/bin/bash
# Phase 131 P0: loop(true) break-once (Normalized shadow, VM)
#
# Verifies that loop(true) { <assign>* ; break } works in Normalized:
# - x = 0 → loop(true) { x = 1; break } → return x → 1
# - Dev-only: NYASH_JOINIR_DEV=1 HAKO_JOINIR_STRICT=1
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 131 P0: loop(true) break-once (Normalized shadow, VM)"
# Test 1: phase131_loop_true_break_once_min.hako
echo "[INFO] Test 1: phase131_loop_true_break_once_min.hako"
INPUT="$NYASH_ROOT/apps/tests/phase131_loop_true_break_once_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 1 ]; then
# Phase 131: expected output is exit code 1 (return value)
EXPECTED=$'1'
if validate_numeric_output 1 "$EXPECTED" "$OUTPUT"; then
echo "[PASS] Output verified: 1 (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 (expected 1)"
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 "phase131_loop_true_break_once_vm: All tests passed"
exit 0
else
test_fail "phase131_loop_true_break_once_vm: $FAIL_COUNT test(s) failed"
exit 1
fi