diff --git a/apps/tests/phase116_if_only_keep_plus_call_min.hako b/apps/tests/phase116_if_only_keep_plus_call_min.hako new file mode 100644 index 00000000..b2ac3a96 --- /dev/null +++ b/apps/tests/phase116_if_only_keep_plus_call_min.hako @@ -0,0 +1,23 @@ +// Phase 116: if-only keep+call merge parity +// Test one side keeps original value, other side calls function + +static box Main { + f(x) { + return x + 1 + } + + g(flag) { + local v + v = 10 + if flag == 1 { + v = me.f(1) + } + print(v) + } + + main() { + me.g(0) + me.g(1) + return "OK" + } +} diff --git a/tools/smokes/v2/profiles/integration/apps/phase116_if_only_keep_plus_call_llvm_exe.sh b/tools/smokes/v2/profiles/integration/apps/phase116_if_only_keep_plus_call_llvm_exe.sh new file mode 100644 index 00000000..881cfb88 --- /dev/null +++ b/tools/smokes/v2/profiles/integration/apps/phase116_if_only_keep_plus_call_llvm_exe.sh @@ -0,0 +1,38 @@ +#!/bin/bash +# Phase 116: if-only keep+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/phase116_if_only_keep_plus_call_plugin_build.log" +llvm_exe_ensure_plugins_or_fail || exit 1 + +INPUT_HAKO="$NYASH_ROOT/apps/tests/phase116_if_only_keep_plus_call_min.hako" +OUTPUT_EXE="$NYASH_ROOT/tmp/phase116_if_only_keep_plus_call_llvm_exe" + +EXPECTED=$'10\n2' +EXPECTED_LINES=2 +LLVM_BUILD_LOG="/tmp/phase116_if_only_keep_plus_call_build.log" +if llvm_exe_build_and_run_numeric_smoke; then + test_pass "phase116_if_only_keep_plus_call_llvm_exe: output matches expected (10\\n2)" +else + exit 1 +fi diff --git a/tools/smokes/v2/profiles/integration/apps/phase116_if_only_keep_plus_call_vm.sh b/tools/smokes/v2/profiles/integration/apps/phase116_if_only_keep_plus_call_vm.sh new file mode 100644 index 00000000..66be4be7 --- /dev/null +++ b/tools/smokes/v2/profiles/integration/apps/phase116_if_only_keep_plus_call_vm.sh @@ -0,0 +1,55 @@ +#!/bin/bash +# Phase 116: if-only keep+call merge parity (VM) +# +# Verifies that if-only with one side keeping original value and other side calling works correctly. + +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} + +INPUT="$NYASH_ROOT/apps/tests/phase116_if_only_keep_plus_call_min.hako" + +echo "[INFO] Phase 116: if-only keep+call merge parity (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 + echo "[FAIL] hakorune timed out (>${RUN_TIMEOUT_SECS}s)" + FAIL_COUNT=$((FAIL_COUNT + 1)) +elif [ "$EXIT_CODE" -eq 0 ]; then + EXPECTED=$'10\n2' + if validate_numeric_output 2 "$EXPECTED" "$OUTPUT"; then + echo "[PASS] Output verified: 10\\n2" + 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 "phase116_if_only_keep_plus_call_vm: All tests passed" + exit 0 +else + test_fail "phase116_if_only_keep_plus_call_vm: $FAIL_COUNT test(s) failed" + exit 1 +fi