diff --git a/apps/tests/phase117_if_only_nested_if_call_merge_min.hako b/apps/tests/phase117_if_only_nested_if_call_merge_min.hako new file mode 100644 index 00000000..f3373de3 --- /dev/null +++ b/apps/tests/phase117_if_only_nested_if_call_merge_min.hako @@ -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" + } +} diff --git a/tools/smokes/v2/profiles/integration/apps/phase117_if_only_nested_if_call_merge_llvm_exe.sh b/tools/smokes/v2/profiles/integration/apps/phase117_if_only_nested_if_call_merge_llvm_exe.sh new file mode 100644 index 00000000..a90d19ee --- /dev/null +++ b/tools/smokes/v2/profiles/integration/apps/phase117_if_only_nested_if_call_merge_llvm_exe.sh @@ -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 diff --git a/tools/smokes/v2/profiles/integration/apps/phase117_if_only_nested_if_call_merge_vm.sh b/tools/smokes/v2/profiles/integration/apps/phase117_if_only_nested_if_call_merge_vm.sh new file mode 100644 index 00000000..1e8364c9 --- /dev/null +++ b/tools/smokes/v2/profiles/integration/apps/phase117_if_only_nested_if_call_merge_vm.sh @@ -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"