pyvm: split op handlers into ops_core/ops_box/ops_ctrl; add ops_flow + intrinsic; delegate vm.py without behavior change
net-plugin: modularize constants (consts.rs) and sockets (sockets.rs); remove legacy commented socket code; fix unused imports mir: move instruction unit tests to tests/mir_instruction_unit.rs (file lean-up); no semantic changes runner/pyvm: ensure using pre-strip; misc docs updates Build: cargo build ok; legacy cfg warnings remain as before
This commit is contained in:
16
tools/test/smoke/selfhost/mini_vm_if_branch.sh
Normal file
16
tools/test/smoke/selfhost/mini_vm_if_branch.sh
Normal file
@ -0,0 +1,16 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
root=$(cd "$(dirname "$0")"/../../../.. && pwd)
|
||||
bin="$root/target/release/nyash"
|
||||
prog="$root/apps/selfhost-vm/mini_vm_if_branch.nyash"
|
||||
|
||||
if [ ! -x "$bin" ]; then
|
||||
echo "nyash binary not found at $bin; build first (cargo build --release)" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
out=$(NYASH_VM_USE_PY=1 "$bin" --backend vm "$prog" 2>/dev/null)
|
||||
test "$out" = "10" || { echo "[FAIL] mini_vm_if_branch expected 10, got '$out'" >&2; exit 2; }
|
||||
echo "[OK] mini_vm_if_branch"
|
||||
exit 0
|
||||
27
tools/test/smoke/selfhost/mini_vm_if_literal_branch_smoke.sh
Normal file
27
tools/test/smoke/selfhost/mini_vm_if_literal_branch_smoke.sh
Normal file
@ -0,0 +1,27 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
root=$(cd "$(dirname "$0")"/../../../.. && pwd)
|
||||
bin="$root/target/release/nyash"
|
||||
src="$root/apps/selfhost-vm/mini_vm.nyash"
|
||||
|
||||
if [ ! -x "$bin" ]; then
|
||||
echo "nyash binary not found at $bin; build first (cargo build --release)" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
export NYASH_VM_USE_PY=1
|
||||
export NYASH_MINIVM_READ_STDIN=1
|
||||
|
||||
# cond=1 -> then prints "T" only
|
||||
json_then='{"kind":"Program","statements":[{"kind":"If","condition":{"kind":"Literal","value":{"type":"int","value":1}},"then_body":[{"kind":"Print","expression":{"kind":"Literal","value":{"type":"string","value":"T"}}}],"else_body":[{"kind":"Print","expression":{"kind":"Literal","value":{"type":"string","value":"F"}}}]}]}'
|
||||
out=$(printf '%s' "$json_then" | "$bin" --backend vm "$src" 2>&1)
|
||||
echo "$out" | rg -qx 'T' || { echo "[FAIL] then branch did not print T only" >&2; echo "$out" >&2; exit 2; }
|
||||
|
||||
# cond=0 -> else prints "F" only
|
||||
json_else='{"kind":"Program","statements":[{"kind":"If","condition":{"kind":"Literal","value":{"type":"int","value":0}},"then_body":[{"kind":"Print","expression":{"kind":"Literal","value":{"type":"string","value":"T"}}}],"else_body":[{"kind":"Print","expression":{"kind":"Literal","value":{"type":"string","value":"F"}}}]}]}'
|
||||
out=$(printf '%s' "$json_else" | "$bin" --backend vm "$src" 2>&1)
|
||||
echo "$out" | rg -qx 'F' || { echo "[FAIL] else branch did not print F only" >&2; echo "$out" >&2; exit 2; }
|
||||
|
||||
echo "[OK] mini-vm if literal branch smoke passed"
|
||||
|
||||
@ -0,0 +1,21 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
root=$(cd "$(dirname "$0")"/../../../.. && pwd)
|
||||
bin="$root/target/release/nyash"
|
||||
src="$root/apps/selfhost-vm/mini_vm.nyash"
|
||||
|
||||
if [ ! -x "$bin" ]; then
|
||||
echo "nyash binary not found at $bin; build first (cargo build --release)" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
export NYASH_VM_USE_PY=1
|
||||
export NYASH_MINIVM_READ_STDIN=1
|
||||
|
||||
# BinaryOp int + int → 46
|
||||
json1='{"kind":"Program","statements":[{"kind":"Print","expression":{"kind":"BinaryOp","operator":"+","left":{"kind":"Literal","value":{"type":"int","value":12}},"right":{"kind":"Literal","value":{"type":"int","value":34}}}}]}'
|
||||
out1=$(printf '%s' "$json1" | "$bin" --backend vm "$src" 2>&1)
|
||||
echo "$out1" | rg -qx '46' || { echo "[FAIL] BinaryOp int+int failed" >&2; echo "$out1" >&2; exit 2; }
|
||||
|
||||
echo "[OK] mini-vm binop (int) smoke passed"
|
||||
20
tools/test/smoke/selfhost/mini_vm_print_binop_int_smoke.sh
Normal file
20
tools/test/smoke/selfhost/mini_vm_print_binop_int_smoke.sh
Normal file
@ -0,0 +1,20 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
root=$(cd "$(dirname "$0")"/../../../.. && pwd)
|
||||
bin="$root/target/release/nyash"
|
||||
src="$root/apps/selfhost-vm/mini_vm.nyash"
|
||||
|
||||
if [ ! -x "$bin" ]; then
|
||||
echo "nyash binary not found at $bin; build first (cargo build --release)" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
export NYASH_VM_USE_PY=1
|
||||
# BinaryOp int + int → addition (12 + 34 = 46)
|
||||
export NYASH_MINIVM_READ_STDIN=1
|
||||
json='{"kind":"Program","statements":[{"kind":"Print","expression":{"kind":"BinaryOp","operator":"+","left":{"kind":"Literal","value":{"type":"int","value":12}},"right":{"kind":"Literal","value":{"type":"int","value":34}}}}]}'
|
||||
out=$(printf '%s' "$json" | NYASH_VM_USE_PY=1 "$bin" --backend vm "$src" 2>&1)
|
||||
echo "$out" | rg -qx '46' || { echo "[FAIL] BinaryOp int+int failed" >&2; echo "$out" >&2; exit 2; }
|
||||
|
||||
echo "[OK] mini-vm binop int+int smoke passed"
|
||||
23
tools/test/smoke/selfhost/mini_vm_print_compare_ops_smoke.sh
Normal file
23
tools/test/smoke/selfhost/mini_vm_print_compare_ops_smoke.sh
Normal file
@ -0,0 +1,23 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
root=$(cd "$(dirname "$0")"/../../../.. && pwd)
|
||||
bin="$root/target/release/nyash"
|
||||
src="$root/apps/selfhost-vm/mini_vm.nyash"
|
||||
|
||||
if [ ! -x "$bin" ]; then
|
||||
echo "nyash binary not found at $bin; build first (cargo build --release)" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
export NYASH_VM_USE_PY=1
|
||||
export NYASH_MINIVM_READ_STDIN=1
|
||||
|
||||
# Single comparison: 1 < 2 → 1
|
||||
json='{"kind":"Program","statements":[
|
||||
{"kind":"Print","expression":{"kind":"Compare","operation":"<","lhs":{"kind":"Literal","value":{"type":"int","value":1}},"rhs":{"kind":"Literal","value":{"type":"int","value":2}}}}
|
||||
]}'
|
||||
out=$(printf '%s' "$json" | "$bin" --backend vm "$src" 2>&1)
|
||||
echo "$out" | rg -qx '1' || { echo "[FAIL] Compare (<) failed" >&2; echo "$out" >&2; exit 2; }
|
||||
|
||||
echo "[OK] mini-vm compare (<) smoke passed"
|
||||
@ -0,0 +1,24 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
root=$(cd "$(dirname "$0")"/../../../.. && pwd)
|
||||
bin="$root/target/release/nyash"
|
||||
src="$root/apps/selfhost-vm/mini_vm.nyash"
|
||||
|
||||
if [ ! -x "$bin" ]; then
|
||||
echo "nyash binary not found at $bin; build first (cargo build --release)" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
export NYASH_VM_USE_PY=1
|
||||
export NYASH_MINIVM_READ_STDIN=1
|
||||
|
||||
json='{"kind":"Program","statements":[
|
||||
{"kind":"Print","expression":{"kind":"FunctionCall","name":"echo","arguments":[{"kind":"Literal","value":{"type":"string","value":"hello"}}]}},
|
||||
{"kind":"Print","expression":{"kind":"FunctionCall","name":"itoa","arguments":[{"kind":"Literal","value":{"type":"int","value":123}}]}}
|
||||
]}'
|
||||
out=$(printf '%s' "$json" | "$bin" --backend vm "$src" 2>&1)
|
||||
echo "$out" | rg -q '^hello$' || { echo "[FAIL] line1 not hello" >&2; echo "$out" >&2; exit 2; }
|
||||
echo "$out" | rg -q '^123$' || { echo "[FAIL] line2 not 123" >&2; echo "$out" >&2; exit 2; }
|
||||
echo "[OK] mini-vm print functioncall literal smoke passed"
|
||||
|
||||
18
tools/test/smoke/selfhost/mini_vm_print_literal.sh
Normal file
18
tools/test/smoke/selfhost/mini_vm_print_literal.sh
Normal file
@ -0,0 +1,18 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
root=$(cd "$(dirname "$0")"/../../../.. && pwd)
|
||||
bin="$root/target/release/nyash"
|
||||
prog="$root/apps/selfhost-vm/mini_vm.nyash"
|
||||
|
||||
if [ ! -x "$bin" ]; then
|
||||
echo "nyash binary not found at $bin; build first (cargo build --release)" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
# Minimal AST JSON with a single print of int literal 42
|
||||
json='{"kind":"Program","statements":[{"kind":"Print","expression":{"kind":"Literal","value":{"type":"int","value":42}}}]}'
|
||||
out=$(NYASH_VM_USE_PY=1 "$bin" --backend vm "$prog" -- "$json" 2>/dev/null)
|
||||
test "$out" = "42" || { echo "[FAIL] mini_vm_print_literal expected 42, got '$out'" >&2; exit 2; }
|
||||
echo "[OK] mini_vm_print_literal"
|
||||
exit 0
|
||||
21
tools/test/smoke/selfhost/mini_vm_print_multi_json_smoke.sh
Normal file
21
tools/test/smoke/selfhost/mini_vm_print_multi_json_smoke.sh
Normal file
@ -0,0 +1,21 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
root=$(cd "$(dirname "$0")"/../../../.. && pwd)
|
||||
bin="$root/target/release/nyash"
|
||||
src="$root/apps/selfhost-vm/mini_vm.nyash"
|
||||
|
||||
if [ ! -x "$bin" ]; then
|
||||
echo "nyash binary not found at $bin; build first (cargo build --release)" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
export NYASH_VM_USE_PY=1
|
||||
export NYASH_MINIVM_READ_STDIN=1
|
||||
|
||||
json='{"kind":"Program","statements":[{"kind":"Print","expression":{"kind":"Literal","value":{"type":"string","value":"hello"}}},{"kind":"Print","expression":{"kind":"Literal","value":{"type":"int","value":123}}}]}'
|
||||
out=$(printf '%s' "$json" | "$bin" --backend vm "$src" 2>&1)
|
||||
echo "$out" | rg -q '^hello$' || { echo "[FAIL] line1 not hello" >&2; echo "$out" >&2; exit 2; }
|
||||
echo "$out" | rg -q '^123$' || { echo "[FAIL] line2 not 123" >&2; echo "$out" >&2; exit 2; }
|
||||
echo "[OK] mini-vm print multi literal smoke passed"
|
||||
|
||||
20
tools/test/smoke/selfhost/mini_vm_print_string_json_smoke.sh
Normal file
20
tools/test/smoke/selfhost/mini_vm_print_string_json_smoke.sh
Normal file
@ -0,0 +1,20 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
root=$(cd "$(dirname "$0")"/../../../.. && pwd)
|
||||
bin="$root/target/release/nyash"
|
||||
src="$root/apps/selfhost-vm/mini_vm.nyash"
|
||||
|
||||
if [ ! -x "$bin" ]; then
|
||||
echo "nyash binary not found at $bin; build first (cargo build --release)" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
export NYASH_VM_USE_PY=1
|
||||
export NYASH_MINIVM_READ_STDIN=1
|
||||
|
||||
json='{"kind":"Program","statements":[{"kind":"Print","expression":{"kind":"Literal","value":{"type":"string","value":"hello"}}}]}'
|
||||
out=$(printf '%s' "$json" | "$bin" --backend vm "$src" 2>&1)
|
||||
echo "$out" | rg -q '^hello$' || { echo "[FAIL] mini-vm print string literal failed" >&2; echo "$out" >&2; exit 2; }
|
||||
echo "[OK] mini-vm print string literal smoke passed"
|
||||
|
||||
20
tools/test/smoke/selfhost/mini_vm_stdin_loader_smoke.sh
Normal file
20
tools/test/smoke/selfhost/mini_vm_stdin_loader_smoke.sh
Normal file
@ -0,0 +1,20 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
root=$(cd "$(dirname "$0")"/../../../.. && pwd)
|
||||
bin="$root/target/release/nyash"
|
||||
src="$root/apps/selfhost-vm/mini_vm.nyash"
|
||||
|
||||
if [ ! -x "$bin" ]; then
|
||||
echo "nyash binary not found at $bin; build first (cargo build --release)" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
export NYASH_VM_USE_PY=1
|
||||
export NYASH_MINIVM_READ_STDIN=1
|
||||
|
||||
json='{"kind":"Program","statements":[{"kind":"Print","expression":{"kind":"Literal","value":{"type":"int","value":123}}}]}'
|
||||
out=$(printf '%s' "$json" | "$bin" --backend vm "$src" 2>&1)
|
||||
echo "$out" | rg -q '^123$' || { echo "[FAIL] mini-vm stdin loader did not print 123" >&2; echo "$out" >&2; exit 2; }
|
||||
echo "[OK] mini-vm stdin loader smoke passed"
|
||||
|
||||
Reference in New Issue
Block a user