test(joinir): Fix phase212 test to use Main box pattern
Changed IfSumTest to Main box with main(args) to match entry point convention. Removed print() calls that aren't needed for RC test. 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
@ -1,15 +1,14 @@
|
||||
// Phase 212: Pattern 1 + Pattern 3 (IfPHI) test - if-sum implementation
|
||||
// Phase 212: Pattern 3 (IfPHI) test - if-sum implementation
|
||||
// Tests: Loop with conditional update inside if block
|
||||
// Target: selfhost if-sum pattern (e.g., FuncScannerBox._sum_def_count)
|
||||
//
|
||||
// Expected behavior:
|
||||
// Array [null-equivalent, "a", "b"] → sum counts non-empty strings
|
||||
// Empty string "" treated as null-equivalent → skip
|
||||
// "a", "b" are valid → sum = 2
|
||||
// Simulated array [null-equivalent, "a", "b"] → sum counts non-empty strings
|
||||
// i=0 → skip, i=1,2 → count
|
||||
//
|
||||
// Expected result: 2 (count of valid items)
|
||||
// Expected result: RC=2 (count of valid items)
|
||||
|
||||
static box IfSumTest {
|
||||
static box Main {
|
||||
sum_def_count(defs) {
|
||||
local sum
|
||||
sum = 0
|
||||
@ -19,10 +18,6 @@ static box IfSumTest {
|
||||
len = 3
|
||||
|
||||
loop(i < len) {
|
||||
// ArrayBox.get equivalent (simplified: use index directly)
|
||||
// In real code: local item = defs.get(i)
|
||||
// For Phase 212: simulate with positional check
|
||||
|
||||
// Simulate: [empty, "a", "b"]
|
||||
// i=0 → empty (skip)
|
||||
// i=1 → "a" (count)
|
||||
@ -31,9 +26,9 @@ static box IfSumTest {
|
||||
if i > 0 {
|
||||
// Conditional update: sum = sum + 1
|
||||
sum = sum + 1
|
||||
print(sum) // ← Force if to stay in MIR
|
||||
} else {
|
||||
print(0) // ← Ensure else branch exists
|
||||
// Else branch (do nothing)
|
||||
sum = sum + 0
|
||||
}
|
||||
|
||||
i = i + 1
|
||||
@ -42,11 +37,10 @@ static box IfSumTest {
|
||||
return sum
|
||||
}
|
||||
|
||||
main() {
|
||||
// Array: [empty, "a", "b"] → sum=2
|
||||
// (simplified without actual ArrayBox for Phase 212)
|
||||
main(args) {
|
||||
// Simulated array [empty, "a", "b"] → sum=2
|
||||
local result
|
||||
result = IfSumTest.sum_def_count(0) // dummy arg
|
||||
result = Main.sum_def_count(0) // dummy arg
|
||||
return result
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user