Proper HOST↔JoinIR ValueId separation for condition variables: - Add ConditionEnv struct (name → JoinIR-local ValueId mapping) - Add ConditionBinding struct (HOST/JoinIR ValueId pairs) - Modify condition_to_joinir to use ConditionEnv instead of builder.variable_map - Update Pattern2 lowerer to build ConditionEnv and ConditionBindings - Extend JoinInlineBoundary with condition_bindings field - Update BoundaryInjector to inject Copy instructions for condition variables This fixes the undefined ValueId errors where HOST ValueIds were being used directly in JoinIR instructions. Programs now execute (RC: 0), though loop variable exit values still need Phase 172 work. Key invariants established: 1. JoinIR uses ONLY JoinIR-local ValueIds 2. HOST↔JoinIR bridging is ONLY through JoinInlineBoundary 3. condition_to_joinir NEVER accesses builder.variable_map 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <noreply@anthropic.com>
72 lines
1.9 KiB
Plaintext
72 lines
1.9 KiB
Plaintext
// 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
|
|
}
|
|
}
|