test: Phase 117 if-only nested-if call merge parity (VM + LLVM EXE)

Fixture & Smoke tests for nested if-only with call merge verification.

**Fixture**:
- apps/tests/phase117_if_only_nested_if_call_merge_min.hako
- Pattern: nested if (inner: b == 1) inside outer if (a == 1), outer else
- Call merge: f(1), f(2), f(3) results merged to single variable v
- Expected output: 2, 3, 4 (f(x) = x + 1)

**VM Smoke**:
- tools/smokes/v2/profiles/integration/apps/phase117_if_only_nested_if_call_merge_vm.sh
- Execution: NYASH_DISABLE_PLUGINS=1 HAKO_JOINIR_STRICT=1
- Validation: numeric output 3 lines "2\n3\n4"

**LLVM EXE Smoke**:
- tools/smokes/v2/profiles/integration/apps/phase117_if_only_nested_if_call_merge_llvm_exe.sh
- Required plugins: FileBox, MapBox, StringBox, ConsoleBox, IntegerBox
- Validation: numeric output "2\n3\n4" (3 lines)

**Verification**:
 VM smoke: PASS
 LLVM EXE smoke: PASS
 Regression (Phase 116): PASS

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
nyash-codex
2025-12-18 02:55:02 +09:00
parent f63b5c3c64
commit bc561682f6
3 changed files with 79 additions and 0 deletions

View File

@ -0,0 +1,18 @@
static box Main {
f(x) { return x + 1 }
g(a, b) {
local v = 0
if a == 1 {
if b == 1 { v = f(1) } else { v = f(2) }
} else {
v = f(3)
}
print(v)
}
main() {
g(1, 1) // → 2 (f(1) = 1+1)
g(1, 0) // → 3 (f(2) = 2+1)
g(0, 0) // → 4 (f(3) = 3+1)
return "OK"
}
}

View File

@ -0,0 +1,38 @@
#!/bin/bash
# Phase 117: if-only nested-if + call 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/phase117_if_only_nested_if_call_merge_plugin_build.log"
llvm_exe_ensure_plugins_or_fail || exit 1
INPUT_HAKO="$NYASH_ROOT/apps/tests/phase117_if_only_nested_if_call_merge_min.hako"
OUTPUT_EXE="$NYASH_ROOT/tmp/phase117_if_only_nested_if_call_merge_llvm_exe"
EXPECTED=$'2\n3\n4'
EXPECTED_LINES=3
LLVM_BUILD_LOG="/tmp/phase117_if_only_nested_if_call_merge_build.log"
if llvm_exe_build_and_run_numeric_smoke; then
test_pass "phase117_if_only_nested_if_call_merge_llvm_exe: output matches expected (2\\n3\\n4)"
else
exit 1
fi

View File

@ -0,0 +1,23 @@
#!/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/phase117_if_only_nested_if_call_merge_min.hako"
echo "[phase117_if_only_nested_if_call_merge_vm] Testing nested if + call 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 3 lines with values 2, 3, 4
validate_numeric_output 3 "2
3
4" "$OUTPUT"
echo "✅ [phase117_if_only_nested_if_call_merge_vm] PASS"