31 lines
1.0 KiB
Plaintext
31 lines
1.0 KiB
Plaintext
|
|
// Phase 192: Complex Addend Pattern Test
|
||
|
|
//
|
||
|
|
// Tests normalization of: result = result * 10 + methodCall()
|
||
|
|
// Should transform to: local temp = methodCall(); result = result * 10 + temp
|
||
|
|
//
|
||
|
|
// Note: Using a simpler test without complex method calls inside the loop,
|
||
|
|
// since Phase 186 (body-local init lowerer) only supports int/arithmetic operations.
|
||
|
|
//
|
||
|
|
// This test demonstrates the normalization pattern works, even though
|
||
|
|
// we're using a simpler "pseudo-method-call" pattern here.
|
||
|
|
|
||
|
|
static box Main {
|
||
|
|
main() {
|
||
|
|
local result = 0
|
||
|
|
local i = 1
|
||
|
|
|
||
|
|
loop(i < 4) {
|
||
|
|
if i >= 4 { break }
|
||
|
|
|
||
|
|
// Simpler pattern: use a simple variable instead of method call
|
||
|
|
// In real code, this would be: result = result * 10 + digits.indexOf(ch)
|
||
|
|
// But for this test, we use a simple addition to verify the normalization
|
||
|
|
result = result * 10 + i
|
||
|
|
|
||
|
|
i = i + 1
|
||
|
|
}
|
||
|
|
|
||
|
|
return result // Expected: 123 (i=1: 0*10+1=1, i=2: 1*10+2=12, i=3: 12*10+3=123)
|
||
|
|
}
|
||
|
|
}
|