test(joinir): Phase 118 loop+if merge parity smokes

This commit is contained in:
nyash-codex
2025-12-18 03:43:10 +09:00
parent 1080dee58f
commit 8fb393b5e8
6 changed files with 196 additions and 0 deletions

View File

@ -0,0 +1,38 @@
#!/bin/bash
# Phase 118: loop + if-else merge parity (LLVM EXE)
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 97/98/100 SSOT: plugin dlopen check → build only if needed → dlopen recheck.
FILEBOX_SO="$NYASH_ROOT/plugins/nyash-filebox-plugin/libnyash_filebox_plugin.so"
MAPBOX_SO="$NYASH_ROOT/plugins/nyash-map-plugin/libnyash_map_plugin.so"
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=(
"FileBox|$FILEBOX_SO|nyash-filebox-plugin"
"MapBox|$MAPBOX_SO|nyash-map-plugin"
"StringBox|$STRINGBOX_SO|nyash-string-plugin"
"ConsoleBox|$CONSOLEBOX_SO|nyash-console-plugin"
"IntegerBox|$INTEGERBOX_SO|nyash-integer-plugin"
)
LLVM_PLUGIN_BUILD_LOG="/tmp/phase118_loop_nested_if_merge_plugin_build.log"
llvm_exe_ensure_plugins_or_fail || exit 1
INPUT_HAKO="$NYASH_ROOT/apps/tests/phase118_loop_nested_if_merge_min.hako"
OUTPUT_EXE="$NYASH_ROOT/tmp/phase118_loop_nested_if_merge_llvm_exe"
EXPECTED='2'
EXPECTED_LINES=1
LLVM_BUILD_LOG="/tmp/phase118_loop_nested_if_merge_build.log"
if llvm_exe_build_and_run_numeric_smoke; then
test_pass "phase118_loop_nested_if_merge_llvm_exe: output matches expected (2)"
else
exit 1
fi

View File

@ -0,0 +1,21 @@
#!/usr/bin/env bash
set -euo pipefail
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
source "$SCRIPT_DIR/../../../lib/output_validator.sh"
FIXTURE="apps/tests/phase118_loop_nested_if_merge_min.hako"
echo "[phase118_loop_nested_if_merge_vm] Testing loop + if-else merge parity (VM)..."
# VM execution with STRICT mode
OUTPUT=$(NYASH_DISABLE_PLUGINS=1 HAKO_JOINIR_STRICT=1 ./target/release/hakorune --backend vm "$FIXTURE" 2>&1) || {
echo "❌ VM execution failed"
echo "$OUTPUT"
exit 1
}
# Validate: expect 1 line with value 2
validate_numeric_output 1 "2" "$OUTPUT"
echo "✅ [phase118_loop_nested_if_merge_vm] PASS"

View File

@ -0,0 +1,39 @@
#!/bin/bash
# Phase 118: Pattern3 carrier merge regression (LLVM EXE)
source "$(dirname "$0")/../../../lib/test_runner.sh"
source "$(dirname "$0")/../../../lib/llvm_exe_runner.sh"
source "$(dirname "$0")/../../../lib/output_validator.sh"
export SMOKES_USE_PYVM=0
require_env || exit 2
llvm_exe_preflight_or_skip || exit 0
FILEBOX_SO="$NYASH_ROOT/plugins/nyash-filebox-plugin/libnyash_filebox_plugin.so"
MAPBOX_SO="$NYASH_ROOT/plugins/nyash-map-plugin/libnyash_map_plugin.so"
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=(
"FileBox|$FILEBOX_SO|nyash-filebox-plugin"
"MapBox|$MAPBOX_SO|nyash-map-plugin"
"StringBox|$STRINGBOX_SO|nyash-string-plugin"
"ConsoleBox|$CONSOLEBOX_SO|nyash-console-plugin"
"IntegerBox|$INTEGERBOX_SO|nyash-integer-plugin"
)
LLVM_PLUGIN_BUILD_LOG="/tmp/phase118_pattern3_if_sum_plugin_build.log"
llvm_exe_ensure_plugins_or_fail || exit 1
INPUT_HAKO="$NYASH_ROOT/apps/tests/phase118_pattern3_if_sum_min.hako"
OUTPUT_EXE="$NYASH_ROOT/tmp/phase118_pattern3_if_sum_llvm_exe"
EXPECTED='12'
EXPECTED_LINES=1
LLVM_BUILD_LOG="/tmp/phase118_pattern3_if_sum_build.log"
if llvm_exe_build_and_run_numeric_smoke; then
test_pass "phase118_pattern3_if_sum_llvm_exe: output matches expected (12)"
else
exit 1
fi

View File

@ -0,0 +1,46 @@
#!/bin/bash
# Phase 118: Pattern3 carrier merge regression (VM)
source "$(dirname "$0")/../../../lib/test_runner.sh"
source "$(dirname "$0")/../../../lib/output_validator.sh"
export SMOKES_USE_PYVM=0
require_env || exit 2
RUN_TIMEOUT_SECS=${RUN_TIMEOUT_SECS:-10}
INPUT="$NYASH_ROOT/apps/tests/phase118_pattern3_if_sum_min.hako"
EXPECTED="12"
echo "[INFO] Phase 118: Pattern3 if-sum carrier merge (VM) - $INPUT"
set +e
OUTPUT=$(timeout "$RUN_TIMEOUT_SECS" env \
NYASH_DISABLE_PLUGINS=1 \
HAKO_JOINIR_STRICT=1 \
"$NYASH_BIN" --backend vm "$INPUT" 2>&1)
EXIT_CODE=$?
set -e
if [ "$EXIT_CODE" -eq 124 ]; then
test_fail "phase118_pattern3_if_sum_vm: hakorune timed out (>${RUN_TIMEOUT_SECS}s)"
exit 1
fi
if [ "$EXIT_CODE" -ne 0 ]; then
echo "[FAIL] hakorune failed with exit code $EXIT_CODE"
echo "[INFO] output (tail):"
echo "$OUTPUT" | tail -n 80 || true
test_fail "phase118_pattern3_if_sum_vm: execution failed"
exit 1
fi
if validate_numeric_output 1 "$EXPECTED" "$OUTPUT"; then
test_pass "phase118_pattern3_if_sum_vm: output matches expected (12)"
exit 0
fi
echo "[INFO] output (tail):"
echo "$OUTPUT" | tail -n 80 || true
test_fail "phase118_pattern3_if_sum_vm: output mismatch"
exit 1