test: add phase95 json_loader escape fixture
This commit is contained in:
34
apps/tests/phase95_json_loader_escape_min.hako
Normal file
34
apps/tests/phase95_json_loader_escape_min.hako
Normal file
@ -0,0 +1,34 @@
|
||||
// Phase 95: json_loader escape loop (minimal)
|
||||
// Purpose: Fixture extracted from MiniJsonLoader.read_quoted_from to exercise
|
||||
// Phase 94 derived body-local + conditional skip in JoinIR.
|
||||
|
||||
static box Main {
|
||||
main() {
|
||||
// Input mirrors the json_loader escape case
|
||||
local s = "\"hello\\\" world\""
|
||||
local pos = 0
|
||||
local i = pos
|
||||
if s.substring(i, i + 1) != "\"" { return "NG" }
|
||||
i = i + 1
|
||||
local out = ""
|
||||
local n = s.length()
|
||||
|
||||
loop(i < n) {
|
||||
local ch = s.substring(i, i + 1)
|
||||
if ch == "\"" { break }
|
||||
|
||||
if ch == "\\" {
|
||||
i = i + 1
|
||||
if i < n {
|
||||
ch = s.substring(i, i + 1)
|
||||
}
|
||||
}
|
||||
|
||||
out = out + ch
|
||||
i = i + 1
|
||||
}
|
||||
|
||||
print(out)
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user