json-native: token positions (line/column); escape utils BMP coverage + surrogate guard; add smokes for string escapes, nested, and error cases (AST/VM)
This commit is contained in:
@ -1,6 +1,6 @@
|
||||
# Nyash AOT-Plan (Phase 15.1) — Scripts Skeleton
|
||||
|
||||
This folder will contain Nyash scripts that analyze a project (following `using` imports) and emit `aot_plan.v1.json` per docs/design/aot-plan-v1.md.
|
||||
This folder will contain Nyash scripts that analyze a project (following `using` imports) and emit `aot_plan.v1.json` per docs/development/design/legacy/aot-plan-v1.md.
|
||||
|
||||
Phase 15.1 scope:
|
||||
- Keep scripts minimal and deterministic
|
||||
|
||||
@ -7,13 +7,13 @@ ROOT_DIR="$(cd "$(dirname "$0")/.." && pwd)"
|
||||
cd "$ROOT_DIR"
|
||||
|
||||
PAIRS=(
|
||||
"local_tests/typeop_is_as_func_poc.nyash docs/status/golden/typeop_is_as_func_poc.mir.txt"
|
||||
"local_tests/typeop_is_as_poc.nyash docs/status/golden/typeop_is_as_poc.mir.txt"
|
||||
"local_tests/extern_console_log.nyash docs/status/golden/extern_console_log.mir.txt"
|
||||
"local_tests/simple_loop_test.nyash docs/status/golden/loop_simple.mir.txt"
|
||||
"local_tests/test_vm_array_getset.nyash docs/status/golden/boxcall_array_getset.mir.txt"
|
||||
"local_tests/typeop_mixed.nyash docs/status/golden/typeop_mixed.mir.txt"
|
||||
"local_tests/loop_nested_if_test.nyash docs/status/golden/loop_nested_if.mir.txt"
|
||||
"local_tests/typeop_is_as_func_poc.nyash docs/development/testing/golden/typeop_is_as_func_poc.mir.txt"
|
||||
"local_tests/typeop_is_as_poc.nyash docs/development/testing/golden/typeop_is_as_poc.mir.txt"
|
||||
"local_tests/extern_console_log.nyash docs/development/testing/golden/extern_console_log.mir.txt"
|
||||
"local_tests/simple_loop_test.nyash docs/development/testing/golden/loop_simple.mir.txt"
|
||||
"local_tests/test_vm_array_getset.nyash docs/development/testing/golden/boxcall_array_getset.mir.txt"
|
||||
"local_tests/typeop_mixed.nyash docs/development/testing/golden/typeop_mixed.mir.txt"
|
||||
"local_tests/loop_nested_if_test.nyash docs/development/testing/golden/loop_nested_if.mir.txt"
|
||||
)
|
||||
|
||||
FAILED=0
|
||||
|
||||
@ -0,0 +1,63 @@
|
||||
#!/bin/bash
|
||||
# json_string_escapes_ast.sh - JSON string escapes roundtrip via AST using
|
||||
|
||||
source "$(dirname "$0")/../../../lib/test_runner.sh"
|
||||
require_env || exit 2
|
||||
preflight_plugins || exit 2
|
||||
|
||||
TEST_DIR="/tmp/json_string_escapes_ast_$$"
|
||||
mkdir -p "$TEST_DIR"
|
||||
cd "$TEST_DIR"
|
||||
|
||||
cat > nyash.toml << EOF
|
||||
[using.json_native]
|
||||
path = "$NYASH_ROOT/apps/lib/json_native/"
|
||||
main = "parser/parser.nyash"
|
||||
|
||||
[using.aliases]
|
||||
json = "json_native"
|
||||
EOF
|
||||
|
||||
cat > driver.nyash << 'EOF'
|
||||
using json_native as JsonParserModule
|
||||
|
||||
static box Main {
|
||||
main() {
|
||||
// input → expected stringify
|
||||
local inputs = new ArrayBox()
|
||||
local expect = new ArrayBox()
|
||||
|
||||
inputs.push("\"A\""); expect.push("\"A\"")
|
||||
inputs.push("\"\\n\" "); expect.push("\"\\n\"")
|
||||
inputs.push("\"\\t\""); expect.push("\"\\t\"")
|
||||
inputs.push("\"\\\\\""); expect.push("\"\\\\\"")
|
||||
inputs.push("\"\\\"\""); expect.push("\"\\\"\"")
|
||||
inputs.push("\"\\u0041\""); expect.push("\"A\"")
|
||||
|
||||
local i = 0
|
||||
loop(i < inputs.length()) {
|
||||
local s = inputs.get(i)
|
||||
local r = JsonParserModule.roundtrip_test(s)
|
||||
print(r)
|
||||
i = i + 1
|
||||
}
|
||||
return 0
|
||||
}
|
||||
}
|
||||
EOF
|
||||
|
||||
expected=$(cat << 'TXT'
|
||||
"A"
|
||||
"\n"
|
||||
"\t"
|
||||
"\\"
|
||||
"\""
|
||||
"A"
|
||||
TXT
|
||||
)
|
||||
|
||||
output=$("$NYASH_BIN" --backend vm driver.nyash 2>&1 | filter_noise)
|
||||
compare_outputs "$expected" "$output" "json_string_escapes_ast"
|
||||
|
||||
cd /
|
||||
rm -rf "$TEST_DIR"
|
||||
Reference in New Issue
Block a user