#!/bin/bash
# Using alias resolution (selfhost.shared.common.string_helpers) basic call
set -euo pipefail

SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"; if ROOT_GIT=$(git -C "$SCRIPT_DIR" rev-parse --show-toplevel 2>/dev/null); then ROOT="$ROOT_GIT"; else ROOT="$(cd "$SCRIPT_DIR/../../../../../../../../.." && pwd)"; fi
source "$ROOT/tools/smokes/v2/lib/test_runner.sh"; require_env || exit 2

code=$(cat <<'HCODE'
using selfhost.shared.common.string_helpers as StringHelpers
static box Main { method main(args) {
  // alias 解決 + 静的メソッドの呼び出し（戻り値は捨てる）
  local s = StringHelpers.int_to_str(7)
  return 0
} }
HCODE
)

set +e
out=$(NYASH_USING_AST=1 run_nyash_vm -c "$code" 2>&1)
rc=$?
set -e

if [ "$rc" -eq 0 ]; then
  echo "[PASS] using_alias_string_helpers_canary_vm"
  exit 0
fi
echo "[FAIL] using_alias_string_helpers_canary_vm (rc=$rc)" >&2
printf '%s\n' "$out" | sed -n '1,120p' >&2
exit 1

