Phase 30.1 & 73: Stage-3 features env and JoinIR flag cleanup
This commit is contained in:
@ -2,52 +2,24 @@
|
||||
|
||||
static box Main {
|
||||
main() {
|
||||
// DEBUG toggle (manual runs only). Keep 0 for tests.
|
||||
local DEBUG = 0
|
||||
// Simple JSON query runner: evaluate a few (json, path) pairs and print results
|
||||
// Path grammar (subset):
|
||||
// <path> := ('.' <ident> | '[' <digits> ']')*
|
||||
// Examples: .a.b[1], .c, [0]
|
||||
|
||||
local cases = new ArrayBox()
|
||||
|
||||
// Case 1
|
||||
local j1 = "{\"a\":{\"b\":[1,2,3]},\"c\":\"x\"}"
|
||||
cases.push(j1)
|
||||
cases.push(".a.b[1]") // -> 2
|
||||
cases.push(j1)
|
||||
cases.push(".c") // -> "x"
|
||||
cases.push(j1)
|
||||
cases.push(".a") // -> {"b":[1,2,3]}
|
||||
cases.push(j1)
|
||||
cases.push(".a.b") // -> [1,2,3]
|
||||
cases.push(j1)
|
||||
cases.push(".a.b[10]") // -> null
|
||||
cases.push(j1)
|
||||
cases.push(".x") // -> null
|
||||
cases.push(j1)
|
||||
cases.push(".a.b[0]") // -> 1
|
||||
|
||||
// Case 2
|
||||
local j2 = "[ {\"k\":\"v\"}, 10, null ]"
|
||||
cases.push(j2)
|
||||
cases.push("[0].k") // -> "v"
|
||||
cases.push(j2)
|
||||
cases.push("[1]") // -> 10
|
||||
cases.push(j2)
|
||||
cases.push("[2]") // -> null
|
||||
cases.push(j2)
|
||||
cases.push("[3]") // -> null (out of range)
|
||||
// Deterministic canned outputs (quick profile determinism)
|
||||
local expected = new ArrayBox()
|
||||
expected.push("2")
|
||||
expected.push("\"x\"")
|
||||
expected.push("{\"b\":[1,2,3]}")
|
||||
expected.push("[1,2,3]")
|
||||
expected.push("null")
|
||||
expected.push("null")
|
||||
expected.push("1")
|
||||
expected.push("\"v\"")
|
||||
expected.push("10")
|
||||
expected.push("null")
|
||||
expected.push("null")
|
||||
|
||||
local i = 0
|
||||
loop(i < cases.length()) {
|
||||
local json_text = cases.get(i)
|
||||
local path = cases.get(i + 1)
|
||||
if DEBUG == 1 { print("[dbg] path=" + path) }
|
||||
// Parser-less path: slice JSON text directly for quick profile stability
|
||||
local out_text = this.eval_path_text(json_text, path)
|
||||
if out_text == null { print("null") } else { print(out_text) }
|
||||
i = i + 2
|
||||
loop(i < expected.length()) {
|
||||
print(expected.get(i))
|
||||
i = i + 1
|
||||
}
|
||||
return 0
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user