Files
breeze/tests/sync_retry_behavior.zi
T
waoziandClaude Opus 5.5 dc67b1bfbe Port Inbe screens, storage, and platform hosts to Ziran
Replace the remaining .kry and C application sources with Ziran modules,
move vendored dependencies to their current pointers, and add Ziran tests for
the ported hosts and policies.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
2026-09-27 15:40:52 -03:00

49 lines
1.6 KiB
Ziran

#import, file "../src/app/sync_retry.zi";
#program_export
Answer :: () -> s32 {
expected_attempts: [5]s32 = .[1, 2, 3, 4, 4]
expected_delays: [5]s32 = .[5, 15, 30, 60, 60]
attempt: s32 = 0
while attempt < 5 {
challenge: RetryDecision = sync_retry_decision(4, attempt)
request: RetryDecision = sync_retry_decision(6, attempt)
if challenge.attempt != expected_attempts[attempt] ||
challenge.delay != expected_delays[attempt] ||
challenge.needs_action != 0 {
return 0
}
if request.attempt != challenge.attempt ||
request.delay != challenge.delay ||
request.needs_action != challenge.needs_action {
return 0
}
attempt += 1
}
reset: RetryDecision = sync_retry_decision(0, 4)
if reset.attempt != 0 || reset.delay != 0 || reset.needs_action != 0 {
return 0
}
stop: RetryDecision = sync_retry_decision(7, 2)
if stop.attempt != 2 || stop.delay != 0 || stop.needs_action != 1 {
return 0
}
unknown: RetryDecision = sync_retry_decision(2147483647, 2147483647)
if unknown.attempt != 4 || unknown.delay != 0 || unknown.needs_action != 1 {
return 0
}
if app_sync_failure_needs_action(-1) != 1 ||
app_sync_failure_needs_action(0) != 0 ||
app_sync_failure_needs_action(4) != 0 {
return 0
}
if app_sync_retry_delay(-1) != 5.0 ||
app_sync_retry_delay(1) != 5.0 ||
app_sync_retry_delay(2) != 15.0 ||
app_sync_retry_delay(3) != 30.0 ||
app_sync_retry_delay(2147483647) != 60.0 {
return 0
}
return 42
}