test: Phase 99 add trailing backslash escape best-effort (VM+LLVM)
末尾バックスラッシュ処理: - 現行仕様: best-effort(そのまま出力)として固定 - fixture: "hello\\" → "hello\" を出力 - VM+LLVM EXE parity完全対応 Integration smokeで検証済み 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
@ -0,0 +1,38 @@
|
||||
// Phase 99: json_loader escape with trailing backslash
|
||||
// Purpose: Exercise escape loop with incomplete escape sequence (trailing \).
|
||||
// This fixture documents current behavior: trailing \ is silently ignored.
|
||||
|
||||
static box Main {
|
||||
main() {
|
||||
// Input: "hello\" - string ending with backslash (incomplete escape)
|
||||
local s = "\"hello\\\\"
|
||||
local pos = 0
|
||||
local i = pos
|
||||
|
||||
// Skip opening quote
|
||||
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
|
||||
}
|
||||
|
||||
// Current behavior: trailing backslash is included in output
|
||||
print(out)
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user