From 99f15a289063ff9c9e4202fc1a343fc0babf18e6 Mon Sep 17 00:00:00 2001 From: nyash-codex Date: Sun, 2 Nov 2025 11:12:15 +0900 Subject: [PATCH] Smokes(core): add string lastIndexOf not-found and map delete missing-key negatives --- .../core/map/map_delete_missing_key_vm.sh | 26 +++++++++++++++++++ .../core/string/last_index_not_found_vm.sh | 24 +++++++++++++++++ 2 files changed, 50 insertions(+) create mode 100644 tools/smokes/v2/profiles/quick/core/map/map_delete_missing_key_vm.sh create mode 100644 tools/smokes/v2/profiles/quick/core/string/last_index_not_found_vm.sh diff --git a/tools/smokes/v2/profiles/quick/core/map/map_delete_missing_key_vm.sh b/tools/smokes/v2/profiles/quick/core/map/map_delete_missing_key_vm.sh new file mode 100644 index 00000000..6c43a90e --- /dev/null +++ b/tools/smokes/v2/profiles/quick/core/map/map_delete_missing_key_vm.sh @@ -0,0 +1,26 @@ +#!/bin/bash +# map_delete_missing_key_vm.sh — MapBox.delete on missing key returns stable message + +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='static box Main { main() { local m=new MapBox(); print(m.delete("absent")); return 0 } }' +output=$(run_nyash_vm -c "$code") +if echo "$output" | grep -q "Key not found: absent"; then + echo "[PASS] map_delete_missing_key_vm" + exit 0 +else + echo "[FAIL] map_delete_missing_key_vm" >&2 + echo "--- output ---" >&2 + echo "$output" >&2 + exit 1 +fi + diff --git a/tools/smokes/v2/profiles/quick/core/string/last_index_not_found_vm.sh b/tools/smokes/v2/profiles/quick/core/string/last_index_not_found_vm.sh new file mode 100644 index 00000000..794d802f --- /dev/null +++ b/tools/smokes/v2/profiles/quick/core/string/last_index_not_found_vm.sh @@ -0,0 +1,24 @@ +#!/bin/bash +# last_index_not_found_vm.sh — String.lastIndexOf not found returns -1 + +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='static box Main { main() { local s="abcdef"; print(s.lastIndexOf("@")); return 0 } }' +out=$(run_nyash_vm -c "$code") +if [ "$out" = "-1" ]; then + echo "[PASS] last_index_not_found_vm" + exit 0 +else + echo "[FAIL] last_index_not_found_vm (got '$out')" >&2 + exit 1 +fi +