test(joinir): Phase 182-5 Add P1/P2 pattern verification tests
Phase 182-5 Test Results: ✅ Pattern1 (Simple) - phase182_p1_match_literal.hako PASSES ✅ Pattern2 (Break) - phase182_p2_break_integer.hako PASSES Verification: - P1 routes correctly to Pattern1_Minimal - P2 routes correctly to Pattern2_WithBreak - Both execute successfully with integer operations - _match_literal logic verified (string matching with early return) Blockers for actual JsonParser loops (_parse_number, _atoi): 1. LoopBodyLocal variables (ch, digit_pos, pos) trigger promotion requirement - Current system only handles Trim-specific carrier promotion - P2 should allow purely local temp variables (not promoted to carriers) 2. String operation filter (Phase 178) - Conservatively rejects string concat: num_str = num_str + ch - Need gradual enablement for JsonParser use cases Next steps (Phase 182-6): - Document blockers and workaround strategies - Recommend LoopBodyLocal handling improvements for Phase 183+
This commit is contained in:
31
apps/tests/phase182_p1_match_literal.hako
Normal file
31
apps/tests/phase182_p1_match_literal.hako
Normal file
@ -0,0 +1,31 @@
|
||||
// Phase 162: Test _match_literal from JsonParserBox (Pattern1 + return)
|
||||
// Target: JsonParserBox._match_literal - Pattern1 (Simple) with return in loop
|
||||
|
||||
static box Main {
|
||||
main(args) {
|
||||
// Simulate _match_literal logic
|
||||
local s = "null value"
|
||||
local pos = 0
|
||||
local literal = "null"
|
||||
|
||||
local len = literal.length()
|
||||
if pos + len > s.length() {
|
||||
print("Result: FAIL (out of bounds)")
|
||||
return 0
|
||||
}
|
||||
|
||||
local i = 0
|
||||
loop(i < len) {
|
||||
local ch_s = s.substring(pos + i, pos + i + 1)
|
||||
local ch_lit = literal.substring(i, i + 1)
|
||||
if ch_s != ch_lit {
|
||||
print("Result: NOMATCH")
|
||||
return 0
|
||||
}
|
||||
i = i + 1
|
||||
}
|
||||
|
||||
print("Result: MATCH")
|
||||
return 0
|
||||
}
|
||||
}
|
||||
29
apps/tests/phase182_p2_break_integer.hako
Normal file
29
apps/tests/phase182_p2_break_integer.hako
Normal file
@ -0,0 +1,29 @@
|
||||
// Phase 182-5: Basic Pattern2 Break test with integers only
|
||||
// No string operations, no LoopBodyLocal - pure P2 verification
|
||||
|
||||
static box Main {
|
||||
main(args) {
|
||||
// Simple integer accumulation with break (sum of 1+2 = 3)
|
||||
local result = 0
|
||||
local i = 1
|
||||
local limit = 5
|
||||
|
||||
loop(i < limit) {
|
||||
if i == 3 { break } // Stop before adding 3
|
||||
result = result + i
|
||||
i = i + 1
|
||||
}
|
||||
|
||||
// Expected: result = 1+2 = 3, i = 3
|
||||
// Simple verification without toString()
|
||||
if result == 3 {
|
||||
if i == 3 {
|
||||
print("PASS: P2 Break works correctly")
|
||||
return 0
|
||||
}
|
||||
}
|
||||
|
||||
print("FAIL: result or i incorrect")
|
||||
return 1
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user