test: Phase 107 add find_balanced_object_end fixture + smokes
This commit is contained in:
25
apps/tests/phase107_find_balanced_object_end_min.hako
Normal file
25
apps/tests/phase107_find_balanced_object_end_min.hako
Normal file
@ -0,0 +1,25 @@
|
||||
// Phase 107: real-app derived fixture from apps/libs/json_cur.hako:find_balanced_object_end
|
||||
// Expect numeric output lines: 1 then 5
|
||||
|
||||
static box Main {
|
||||
find_balanced_object_end(s, idx) {
|
||||
local n = s.length()
|
||||
if s.substring(idx, idx+1) != "{" { return -1 }
|
||||
local depth = 0
|
||||
local i = idx
|
||||
loop (i < n) {
|
||||
local ch = s.substring(i, i+1)
|
||||
if ch == "{" { depth = depth + 1 }
|
||||
if ch == "}" { depth = depth - 1 if depth == 0 { return i } }
|
||||
i = i + 1
|
||||
}
|
||||
return -1
|
||||
}
|
||||
|
||||
main() {
|
||||
print(find_balanced_object_end("{}", 0))
|
||||
print(find_balanced_object_end("{{{}}}", 0))
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
|
||||
@ -8,3 +8,6 @@ DONE:
|
||||
- fixture: `apps/tests/phase107_find_balanced_array_end_min.hako`
|
||||
- smoke(VM): `tools/smokes/v2/profiles/integration/apps/phase107_find_balanced_array_end_vm.sh`
|
||||
- smoke(LLVM EXE): `tools/smokes/v2/profiles/integration/apps/phase107_find_balanced_array_end_llvm_exe.sh`
|
||||
- fixture: `apps/tests/phase107_find_balanced_object_end_min.hako`
|
||||
- smoke(VM): `tools/smokes/v2/profiles/integration/apps/phase107_find_balanced_object_end_vm.sh`
|
||||
- smoke(LLVM EXE): `tools/smokes/v2/profiles/integration/apps/phase107_find_balanced_object_end_llvm_exe.sh`
|
||||
|
||||
@ -0,0 +1,39 @@
|
||||
#!/bin/bash
|
||||
# Phase 107: find_balanced_object_end real-app derived (LLVM EXE parity)
|
||||
|
||||
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/phase107_find_balanced_object_end_plugin_build.log"
|
||||
llvm_exe_ensure_plugins_or_fail || exit 1
|
||||
|
||||
INPUT_HAKO="$NYASH_ROOT/apps/tests/phase107_find_balanced_object_end_min.hako"
|
||||
OUTPUT_EXE="$NYASH_ROOT/tmp/phase107_find_balanced_object_end_llvm_exe"
|
||||
|
||||
EXPECTED=$'1\n5'
|
||||
EXPECTED_LINES=2
|
||||
LLVM_BUILD_LOG="/tmp/phase107_find_balanced_object_end_build.log"
|
||||
if llvm_exe_build_and_run_numeric_smoke; then
|
||||
test_pass "phase107_find_balanced_object_end_llvm_exe: output matches expected (1, 5)"
|
||||
else
|
||||
exit 1
|
||||
fi
|
||||
|
||||
@ -0,0 +1,55 @@
|
||||
#!/bin/bash
|
||||
# Phase 107: find_balanced_object_end real-app derived (VM)
|
||||
|
||||
source "$(dirname "$0")/../../../lib/test_runner.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/phase107_find_balanced_object_end_min.hako"
|
||||
|
||||
echo "[INFO] Phase 107: find_balanced_object_end json_cur derived (VM) - $INPUT"
|
||||
|
||||
set +e
|
||||
OUTPUT=$(timeout "$RUN_TIMEOUT_SECS" env \
|
||||
NYASH_DISABLE_PLUGINS=0 \
|
||||
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=$'1\n5'
|
||||
CLEAN=$(printf "%s\n" "$OUTPUT" | grep -E '^-?[0-9]+$' | head -n 2 | paste -sd '\n' - | tr -d '\r')
|
||||
if [ "$CLEAN" = "$EXPECTED" ]; then
|
||||
echo "[PASS] Output verified: 1 then 5"
|
||||
PASS_COUNT=$((PASS_COUNT + 1))
|
||||
else
|
||||
echo "[FAIL] Unexpected output (expected lines: 1 then 5)"
|
||||
echo "[INFO] output (tail):"
|
||||
echo "$OUTPUT" | tail -n 60 || 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 60 || true
|
||||
FAIL_COUNT=$((FAIL_COUNT + 1))
|
||||
fi
|
||||
|
||||
echo "[INFO] PASS: $PASS_COUNT, FAIL: $FAIL_COUNT"
|
||||
|
||||
if [ "$FAIL_COUNT" -eq 0 ]; then
|
||||
test_pass "phase107_find_balanced_object_end_vm: All tests passed"
|
||||
exit 0
|
||||
else
|
||||
test_fail "phase107_find_balanced_object_end_vm: $FAIL_COUNT test(s) failed"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
Reference in New Issue
Block a user