json: add v2 JsonDoc/JsonNode plugin with runtime provider switch; vendored yyjson + FFI; loader resolve(name)->method_id; PyVM JSON shims; smokes + CI gate; disable MiniVmPrints fallbacks by default
- plugin_loader_v2: store per-Box resolve() from TypeBox FFI; add resolve_method_id() and use in invoke_instance_method
- plugin_loader_unified: resolve_method() falls back to loader’s resolve when TOML lacks method entries
- nyash.toml: register JsonDocBox/JsonNodeBox methods (birth/parse/root/error; kind/get/size/at/str/int/bool)
- plugins/nyash-json-plugin:
* serde/yyjson provider switch via env NYASH_JSON_PROVIDER (default serde)
* vendored yyjson (c/yyjson) + shim; parse/root/get/size/at/str/int/bool implemented for yyjson
* TLV void returns aligned to tag=9
- PyVM: add minimal JsonDocBox/JsonNodeBox shims in ops_box.py (for dev path)
- tests/smokes: add jsonbox_{parse_ok,parse_err,nested,collect_prints}; wire two into min-gate CI
- tools: collect_prints_mixed now uses JSON-based app
- MiniVmPrints: move BinaryOp and fallback heuristics behind a dev toggle (default OFF)
- CURRENT_TASK.md: updated with provider policy and fallback stance
This commit is contained in:
31
tools/test/smoke/selfhost/collect_prints_mixed.sh
Normal file
31
tools/test/smoke/selfhost/collect_prints_mixed.sh
Normal file
@ -0,0 +1,31 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
ROOT_DIR=$(cd "$(dirname "$0")/../../../.." && pwd)
|
||||
|
||||
echo "[smoke] collect_prints mixed order ..." >&2
|
||||
|
||||
pushd "$ROOT_DIR" >/dev/null
|
||||
|
||||
cargo build --release -q
|
||||
|
||||
export NYASH_ENABLE_USING=1
|
||||
export NYASH_VM_USE_PY=1
|
||||
BIN=./target/release/nyash
|
||||
# Use JSON Box based app to avoid reliance on MiniVmPrints fallbacks
|
||||
APP=apps/tests/jsonbox_collect_prints_smoke.nyash
|
||||
|
||||
out=$("$BIN" --backend vm "$APP")
|
||||
|
||||
expected=$'A\nB\n7\n1\n7\n5'
|
||||
|
||||
if [[ "$out" != "$expected" ]]; then
|
||||
echo "[smoke] FAIL: unexpected output" >&2
|
||||
echo "--- got ---" >&2
|
||||
printf '%s\n' "$out" >&2
|
||||
echo "--- exp ---" >&2
|
||||
printf '%s\n' "$expected" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "[smoke] OK: collect_prints mixed order" >&2
|
||||
popd >/dev/null
|
||||
31
tools/test/smoke/selfhost/jsonbox_collect_prints.sh
Normal file
31
tools/test/smoke/selfhost/jsonbox_collect_prints.sh
Normal file
@ -0,0 +1,31 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
ROOT_DIR=$(cd "$(dirname "$0")/../../../.." && pwd)
|
||||
|
||||
echo "[smoke] jsonbox collect_prints ..." >&2
|
||||
|
||||
pushd "$ROOT_DIR" >/dev/null
|
||||
|
||||
cargo build --release -q --manifest-path plugins/nyash-json-plugin/Cargo.toml
|
||||
|
||||
export NYASH_VM_USE_PY=1
|
||||
export NYASH_LOAD_NY_PLUGINS=1
|
||||
unset NYASH_DISABLE_PLUGINS || true
|
||||
|
||||
BIN=./target/release/nyash
|
||||
APP=apps/tests/jsonbox_collect_prints_smoke.nyash
|
||||
|
||||
out=$("$BIN" --backend vm "$APP")
|
||||
expected=$'A\nB\n7\n1\n7\n5'
|
||||
|
||||
if [[ "$out" != "$expected" ]]; then
|
||||
echo "[smoke] FAIL: unexpected output" >&2
|
||||
echo "--- got ---" >&2
|
||||
printf '%s\n' "$out" >&2
|
||||
echo "--- exp ---" >&2
|
||||
printf '%s\n' "$expected" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "[smoke] OK: jsonbox collect_prints" >&2
|
||||
popd >/dev/null
|
||||
30
tools/test/smoke/selfhost/jsonbox_nested.sh
Normal file
30
tools/test/smoke/selfhost/jsonbox_nested.sh
Normal file
@ -0,0 +1,30 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
ROOT_DIR=$(cd "$(dirname "$0")/../../../.." && pwd)
|
||||
|
||||
echo "[smoke] jsonbox nested ..." >&2
|
||||
pushd "$ROOT_DIR" >/dev/null
|
||||
|
||||
cargo build --release -q --manifest-path plugins/nyash-json-plugin/Cargo.toml
|
||||
|
||||
export NYASH_VM_USE_PY=1
|
||||
export NYASH_LOAD_NY_PLUGINS=1
|
||||
|
||||
BIN=./target/release/nyash
|
||||
APP=apps/tests/jsonbox_nested.nyash
|
||||
|
||||
out=$("$BIN" --backend vm "$APP")
|
||||
expected=$'B\n7\n3\n2'
|
||||
|
||||
if [[ "$out" != "$expected" ]]; then
|
||||
echo "[smoke] FAIL: unexpected output" >&2
|
||||
echo "--- got ---" >&2
|
||||
printf '%s\n' "$out" >&2
|
||||
echo "--- exp ---" >&2
|
||||
printf '%s\n' "$expected" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "[smoke] OK: jsonbox nested" >&2
|
||||
popd >/dev/null
|
||||
|
||||
30
tools/test/smoke/selfhost/jsonbox_parse_err.sh
Normal file
30
tools/test/smoke/selfhost/jsonbox_parse_err.sh
Normal file
@ -0,0 +1,30 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
ROOT_DIR=$(cd "$(dirname "$0")/../../../.." && pwd)
|
||||
|
||||
echo "[smoke] jsonbox parse ERR ..." >&2
|
||||
pushd "$ROOT_DIR" >/dev/null
|
||||
|
||||
cargo build --release -q --manifest-path plugins/nyash-json-plugin/Cargo.toml
|
||||
|
||||
export NYASH_VM_USE_PY=1
|
||||
export NYASH_LOAD_NY_PLUGINS=1
|
||||
|
||||
BIN=./target/release/nyash
|
||||
APP=apps/tests/jsonbox_parse_err.nyash
|
||||
|
||||
out=$("$BIN" --backend vm "$APP")
|
||||
expected=$'ERR'
|
||||
|
||||
if [[ "$out" != "$expected" ]]; then
|
||||
echo "[smoke] FAIL: unexpected output" >&2
|
||||
echo "--- got ---" >&2
|
||||
printf '%s\n' "$out" >&2
|
||||
echo "--- exp ---" >&2
|
||||
printf '%s\n' "$expected" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "[smoke] OK: jsonbox parse ERR" >&2
|
||||
popd >/dev/null
|
||||
|
||||
30
tools/test/smoke/selfhost/jsonbox_parse_ok.sh
Normal file
30
tools/test/smoke/selfhost/jsonbox_parse_ok.sh
Normal file
@ -0,0 +1,30 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
ROOT_DIR=$(cd "$(dirname "$0")/../../../.." && pwd)
|
||||
|
||||
echo "[smoke] jsonbox parse OK ..." >&2
|
||||
pushd "$ROOT_DIR" >/dev/null
|
||||
|
||||
cargo build --release -q --manifest-path plugins/nyash-json-plugin/Cargo.toml
|
||||
|
||||
export NYASH_VM_USE_PY=1
|
||||
export NYASH_LOAD_NY_PLUGINS=1
|
||||
|
||||
BIN=./target/release/nyash
|
||||
APP=apps/tests/jsonbox_parse_ok.nyash
|
||||
|
||||
out=$("$BIN" --backend vm "$APP")
|
||||
expected=$'Program'
|
||||
|
||||
if [[ "$out" != "$expected" ]]; then
|
||||
echo "[smoke] FAIL: unexpected output" >&2
|
||||
echo "--- got ---" >&2
|
||||
printf '%s\n' "$out" >&2
|
||||
echo "--- exp ---" >&2
|
||||
printf '%s\n' "$expected" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
echo "[smoke] OK: jsonbox parse OK" >&2
|
||||
popd >/dev/null
|
||||
|
||||
Reference in New Issue
Block a user