Files
hakorune/tools/selfhost/json_parser_string_min.hako
nyash-codex e30116f53d feat(joinir): Phase 171-fix ConditionEnv/ConditionBinding architecture
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>
2025-12-07 01:45:03 +09:00

55 lines
1.4 KiB
Plaintext

// Phase 166: JsonParserBox 単体テスト - String parsing
// Goal: Validate JsonParserBox can parse simple JSON strings through JoinIR
using "tools/hako_shared/json_parser.hako" with JsonParserBox
static box Main {
main(args) {
print("=== JsonParserBox String Parsing Tests ===")
// Test 1: Simple string
print("Test 1: Simple string")
local json1 = "\"hello\""
local result1 = JsonParserBox.parse(json1)
if result1 == null {
print(" FAIL: parse returned null")
return 1
}
if result1 == "hello" {
print(" PASS: got 'hello'")
} else {
print(" FAIL: expected 'hello', got different value")
return 1
}
// Test 2: String with escape sequences
print("Test 2: String with escapes (\\n, \\t)")
local json2 = "\"line1\\nline2\""
local result2 = JsonParserBox.parse(json2)
if result2 == null {
print(" FAIL: parse returned null")
return 1
}
// Result should contain newline
print(" PASS: escape sequences parsed")
// Test 3: Empty string
print("Test 3: Empty string")
local json3 = "\"\""
local result3 = JsonParserBox.parse(json3)
if result3 == null {
print(" FAIL: parse returned null")
return 1
}
if result3 == "" {
print(" PASS: got empty string")
} else {
print(" FAIL: expected empty string")
return 1
}
print("=== All String Tests PASSED ===")
return 0
}
}