test: strengthen phase96 next_non_ws fixture
This commit is contained in:
@ -2,15 +2,14 @@
|
||||
// Purpose: Trim系の実ループを fixtures/smoke で押さえる。
|
||||
|
||||
static box Main {
|
||||
main() {
|
||||
// Input mirrors MiniJsonLoader.next_non_ws
|
||||
local s = "hi"
|
||||
next_non_ws(s) {
|
||||
local i = 0
|
||||
local n = s.length()
|
||||
|
||||
loop(i < n) {
|
||||
local ch = s.substring(i, i + 1)
|
||||
if ch == " " || ch == "\n" || ch == "\r" || ch == "\t" {
|
||||
// Treat empty substring as whitespace for robustness
|
||||
if ch == "" || ch == " " || ch == "\n" || ch == "\r" || ch == "\t" {
|
||||
i = i + 1
|
||||
} else {
|
||||
break
|
||||
@ -18,10 +17,15 @@ static box Main {
|
||||
}
|
||||
|
||||
if i < n {
|
||||
print(i)
|
||||
} else {
|
||||
print(-1)
|
||||
return i
|
||||
}
|
||||
return -1
|
||||
}
|
||||
|
||||
main() {
|
||||
// Input mirrors MiniJsonLoader.next_non_ws
|
||||
print(next_non_ws(" " + " " + "hi")) // expect 2
|
||||
print(next_non_ws(" " + "\t")) // expect -1
|
||||
return "OK"
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user