39 lines
1.0 KiB
Plaintext
39 lines
1.0 KiB
Plaintext
|
|
// Phase 92 P2-3: Simplest P5b E2E Test (no body-local variables)
|
||
|
|
//
|
||
|
|
// This test uses position-based checks instead of a 'ch' variable
|
||
|
|
// to avoid the body-local variable complexity for initial testing.
|
||
|
|
//
|
||
|
|
// Pattern: Loop with break check + conditional increment (P5b escape pattern)
|
||
|
|
//
|
||
|
|
// Expected behavior:
|
||
|
|
// - i=0: not quote (0!=4), not escape (0!=2), i=1
|
||
|
|
// - i=1: not quote (1!=4), not escape (1!=2), i=2
|
||
|
|
// - i=2: not quote (2!=4), IS escape (2==2), i=4
|
||
|
|
// - i=4: IS quote (4==4), break
|
||
|
|
// - Output: 4
|
||
|
|
|
||
|
|
static box Main {
|
||
|
|
main() {
|
||
|
|
local i = 0
|
||
|
|
local len = 10
|
||
|
|
|
||
|
|
loop(i < len) {
|
||
|
|
// Break check (simulated: position 4 is quote)
|
||
|
|
if i == 4 {
|
||
|
|
break
|
||
|
|
}
|
||
|
|
|
||
|
|
// Escape check with conditional increment (P5b pattern)
|
||
|
|
// Position 2 is escape character
|
||
|
|
if i == 2 {
|
||
|
|
i = i + 2 // Escape: skip 2
|
||
|
|
} else {
|
||
|
|
i = i + 1 // Normal: skip 1
|
||
|
|
}
|
||
|
|
}
|
||
|
|
|
||
|
|
print(i)
|
||
|
|
return 0
|
||
|
|
}
|
||
|
|
}
|