// Phase 166: JsonParserBox 単体テスト - Object parsing // Goal: Validate JsonParserBox can parse simple JSON objects through JoinIR using "tools/hako_shared/json_parser.hako" with JsonParserBox static box Main { main(args) { print("=== JsonParserBox Object Parsing Tests ===") // Test 1: Simple object with string values print("Test 1: Simple object {\"name\": \"Alice\", \"age\": \"30\"}") local json1 = "{\"name\": \"Alice\", \"age\": \"30\"}" local result1 = JsonParserBox.parse(json1) if result1 == null { print(" FAIL: parse returned null") return 1 } // Check if it's a MapBox by calling get() local name = result1.get("name") if name == "Alice" { print(" PASS: got name='Alice'") } else { print(" FAIL: expected name='Alice'") return 1 } local age = result1.get("age") if age == "30" { print(" PASS: got age='30'") } else { print(" FAIL: expected age='30'") return 1 } // Test 2: Object with number values print("Test 2: Object with numbers {\"x\": 10, \"y\": 20}") local json2 = "{\"x\": 10, \"y\": 20}" local result2 = JsonParserBox.parse(json2) if result2 == null { print(" FAIL: parse returned null") return 1 } local x = result2.get("x") if x == 10 { print(" PASS: got x=10") } else { print(" FAIL: expected x=10") return 1 } local y = result2.get("y") if y == 20 { print(" PASS: got y=20") } else { print(" FAIL: expected y=20") return 1 } // Test 3: Empty object print("Test 3: Empty object {}") local json3 = "{}" local result3 = JsonParserBox.parse(json3) if result3 == null { print(" FAIL: parse returned null") return 1 } // Empty object should be a MapBox with no keys print(" PASS: empty object parsed") print("=== All Object Tests PASSED ===") return 0 } }