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>
77 lines
2.0 KiB
Plaintext
77 lines
2.0 KiB
Plaintext
// Phase 166: JsonParserBox 単体テスト - Array parsing
|
|
// Goal: Validate JsonParserBox can parse simple JSON arrays through JoinIR
|
|
|
|
using "tools/hako_shared/json_parser.hako" with JsonParserBox
|
|
|
|
static box Main {
|
|
main(args) {
|
|
print("=== JsonParserBox Array Parsing Tests ===")
|
|
|
|
// Test 1: Simple array with numbers
|
|
print("Test 1: Simple number array [1, 2, 3]")
|
|
local json1 = "[1, 2, 3]"
|
|
local result1 = JsonParserBox.parse(json1)
|
|
if result1 == null {
|
|
print(" FAIL: parse returned null")
|
|
return 1
|
|
}
|
|
// Check if it's an ArrayBox by calling size()
|
|
local size1 = result1.size()
|
|
if size1 == 3 {
|
|
print(" PASS: array has 3 elements")
|
|
local elem0 = result1.get(0)
|
|
if elem0 == 1 {
|
|
print(" PASS: first element is 1")
|
|
} else {
|
|
print(" FAIL: first element should be 1")
|
|
return 1
|
|
}
|
|
} else {
|
|
print(" FAIL: array should have 3 elements")
|
|
return 1
|
|
}
|
|
|
|
// Test 2: Array with strings
|
|
print("Test 2: String array [\"hello\", \"world\"]")
|
|
local json2 = "[\"hello\", \"world\"]"
|
|
local result2 = JsonParserBox.parse(json2)
|
|
if result2 == null {
|
|
print(" FAIL: parse returned null")
|
|
return 1
|
|
}
|
|
local size2 = result2.size()
|
|
if size2 == 2 {
|
|
print(" PASS: array has 2 elements")
|
|
local elem0 = result2.get(0)
|
|
if elem0 == "hello" {
|
|
print(" PASS: first element is 'hello'")
|
|
} else {
|
|
print(" FAIL: first element should be 'hello'")
|
|
return 1
|
|
}
|
|
} else {
|
|
print(" FAIL: array should have 2 elements")
|
|
return 1
|
|
}
|
|
|
|
// Test 3: Empty array
|
|
print("Test 3: Empty array []")
|
|
local json3 = "[]"
|
|
local result3 = JsonParserBox.parse(json3)
|
|
if result3 == null {
|
|
print(" FAIL: parse returned null")
|
|
return 1
|
|
}
|
|
local size3 = result3.size()
|
|
if size3 == 0 {
|
|
print(" PASS: array is empty")
|
|
} else {
|
|
print(" FAIL: array should be empty")
|
|
return 1
|
|
}
|
|
|
|
print("=== All Array Tests PASSED ===")
|
|
return 0
|
|
}
|
|
}
|