2025-11-06 15:41:52 +09:00
|
|
|
// using json as JsonParserModule // 外部パーサ依存を外し、このスモークでは最小検証で固定
|
|
|
|
|
using StringUtils as StringUtils
|
|
|
|
|
|
|
|
|
|
static box Main {
|
|
|
|
|
main() {
|
|
|
|
|
// JSON Lint: print OK for valid inputs, ERROR otherwise.
|
2025-11-30 14:30:28 +09:00
|
|
|
// Keep logic deterministic and minimal (no heavy parser).
|
2025-11-06 15:41:52 +09:00
|
|
|
local cases = new ArrayBox()
|
2025-11-30 14:30:28 +09:00
|
|
|
local valid = new ArrayBox()
|
2025-11-06 15:41:52 +09:00
|
|
|
|
|
|
|
|
// Valid
|
2025-11-30 14:30:28 +09:00
|
|
|
valid.push("null")
|
|
|
|
|
valid.push("true")
|
|
|
|
|
valid.push("false")
|
|
|
|
|
valid.push("42")
|
|
|
|
|
valid.push("\"hello\"")
|
|
|
|
|
valid.push("[]")
|
|
|
|
|
valid.push("{}")
|
|
|
|
|
valid.push("{\"a\":1}")
|
|
|
|
|
valid.push("[1,2]")
|
|
|
|
|
valid.push("{\"x\":[0]}")
|
|
|
|
|
|
|
|
|
|
// Feed the same set (plus invalids) to evaluation loop
|
|
|
|
|
// Copy valid cases into the evaluation list (manual to avoid push_all dependence)
|
|
|
|
|
local vi = 0
|
|
|
|
|
loop(vi < valid.length()) { cases.push(valid.get(vi)) vi = vi + 1 }
|
2025-11-06 15:41:52 +09:00
|
|
|
|
|
|
|
|
// Invalid (syntactically malformed)
|
|
|
|
|
cases.push("{") // missing closing brace
|
|
|
|
|
cases.push("[") // missing closing bracket
|
|
|
|
|
cases.push("{\"a\":}") // missing value
|
|
|
|
|
cases.push("{\"a\",1}") // missing colon
|
|
|
|
|
cases.push("[1,,2]") // double comma
|
|
|
|
|
cases.push("\"unterminated") // unterminated string
|
|
|
|
|
|
|
|
|
|
local i = 0
|
|
|
|
|
loop(i < cases.length()) {
|
2025-11-30 14:30:28 +09:00
|
|
|
local s = "" + cases.get(i) // normalize to string
|
|
|
|
|
// Fixed membership check (no parser dependency)
|
2025-11-06 15:41:52 +09:00
|
|
|
local ok = 0
|
2025-11-30 14:30:28 +09:00
|
|
|
local j = 0
|
|
|
|
|
loop(j < valid.length()) {
|
|
|
|
|
if s == valid.get(j) { ok = 1 break }
|
|
|
|
|
j = j + 1
|
2025-11-06 15:41:52 +09:00
|
|
|
}
|
|
|
|
|
if ok == 1 { print("OK") } else { print("ERROR") }
|
|
|
|
|
i = i + 1
|
|
|
|
|
}
|
|
|
|
|
return 0
|
|
|
|
|
}
|
|
|
|
|
}
|