phase29ad(p0): split pattern6 ok vs contract fixtures
This commit is contained in:
@ -1,5 +1,5 @@
|
||||
// Phase 29ac P2: Pattern6 match scan OK minimal
|
||||
// Expect: find_missing_step("abc", "b") -> 1
|
||||
// Phase 29ad P0: Pattern6 match scan contract violation
|
||||
// Expect: JoinIR freeze (step update missing)
|
||||
|
||||
static box Main {
|
||||
find_missing_step(s, ch) {
|
||||
@ -8,7 +8,6 @@ static box Main {
|
||||
if s.substring(i, i + 1) == ch {
|
||||
return i
|
||||
}
|
||||
i = i + 1
|
||||
}
|
||||
return -1
|
||||
}
|
||||
|
||||
19
apps/tests/phase29ab_pattern6_matchscan_ok_min.hako
Normal file
19
apps/tests/phase29ab_pattern6_matchscan_ok_min.hako
Normal file
@ -0,0 +1,19 @@
|
||||
// Phase 29ac P2: Pattern6 match scan OK minimal
|
||||
// Expect: find_ok("abc", "b") -> 1
|
||||
|
||||
static box Main {
|
||||
find_ok(s, ch) {
|
||||
local i = 0
|
||||
loop(i < s.length()) {
|
||||
if s.substring(i, i + 1) == ch {
|
||||
return i
|
||||
}
|
||||
i = i + 1
|
||||
}
|
||||
return -1
|
||||
}
|
||||
|
||||
main() {
|
||||
return Main.find_ok("abc", "b")
|
||||
}
|
||||
}
|
||||
@ -1,5 +1,5 @@
|
||||
// Phase 29ac P1: Pattern6 reverse scan OK minimal
|
||||
// Expect: last_index_bad_step("abc", "b") -> 1
|
||||
// Phase 29ad P0: Pattern6 reverse scan contract violation
|
||||
// Expect: JoinIR freeze (reverse step must be i = i - 1)
|
||||
|
||||
static box Main {
|
||||
last_index_bad_step(s, ch) {
|
||||
@ -8,7 +8,7 @@ static box Main {
|
||||
if s.substring(i, i + 1) == ch {
|
||||
return i
|
||||
}
|
||||
i = i - 1
|
||||
i = i - 2
|
||||
}
|
||||
return -1
|
||||
}
|
||||
|
||||
19
apps/tests/phase29ab_pattern6_reverse_ok_min.hako
Normal file
19
apps/tests/phase29ab_pattern6_reverse_ok_min.hako
Normal file
@ -0,0 +1,19 @@
|
||||
// Phase 29ac P1: Pattern6 reverse scan OK minimal
|
||||
// Expect: last_index_ok("abc", "b") -> 1
|
||||
|
||||
static box Main {
|
||||
last_index_ok(s, ch) {
|
||||
local i = s.length() - 1
|
||||
loop(i >= 0) {
|
||||
if s.substring(i, i + 1) == ch {
|
||||
return i
|
||||
}
|
||||
i = i - 1
|
||||
}
|
||||
return -1
|
||||
}
|
||||
|
||||
main() {
|
||||
return Main.last_index_ok("abc", "b")
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user