Files
core/test/rust/native/combinations.dever
T
2026-11-27 06:03:56 +00:00

154 lines
4.1 KiB
Plaintext

identity(value: Int) (out: Int) {
out = value
}
fallback() (out: Int) {
out = 42
}
noop() () {
}
pair(value: Int) (left: Int, right: Int) {
left = value
right = value + 1
}
otherPair() (left: Int, right: Int) {
left = 20
right = 22
}
flow slow(value: Int) (out: Int)
| step | kind | do |
| - | flow | dever.time.sleep(60000) |
| out | calc | value |
flow timed() (out: Int)
| step | kind | do |
| out | calc | timeout(run(slow(0)), 1, fallback) |
flow fast() (out: Int)
| step | kind | do |
| out | calc | timeout(run(identity(7)), 60000, fallback) |
flow racing() (out: Int)
| step | kind | do |
| out | calc | race(run(slow(0)), run(identity(42))) |
flow ordered() (out: Int)
| step | kind | do |
| first | calc | run(identity(42)) |
| second | calc | run(identity(0)) |
| - | flow | dever.time.sleep(1) |
| out | calc | race(first, second) |
flow multiple() (out: Int)
| step | kind | do |
| result | calc | race(run(pair(20)), run(otherPair())) |
| out | calc | result.left + result.right |
flow multiTimeout() (out: Int)
| step | kind | do |
| result | calc | timeout(run(pair(20)), 60000, otherPair) |
| out | calc | result.left + result.right |
flow grouped() ()
| step | kind | do |
| tasks | calc | group(1) |
| - | calc | run(tasks, noop()) |
| - | calc | run(tasks, dever.time.sleep(0)) |
| - | calc | wait(tasks) |
flow stopped() ()
| step | kind | do |
| tasks | calc | group(2) |
| - | calc | run(tasks, dever.time.sleep(60000)) |
| - | calc | stop(tasks) |
type Outcome {
Done(value: Int)
error Failed(value: dever.time.SleepResult)
}
rule resolve(value: Outcome) (out: Int) recover("report rejected sleep as -1")
| value | out |
| Done(number) | number |
| Failed(error) | -1 |
flow failWork() (out: Int)
| step | kind | do |
| - | flow | dever.time.sleep(-1) |
| out | calc | 0 |
flow capturedRace() (out: Int)
| step | kind | do |
| result: Outcome | calc | result(race(run(failWork()), run(slow(0)))) |
| out | rule | resolve(result) |
flow capturedTimeout() (out: Int)
| step | kind | do |
| result: Outcome | calc | result(timeout(run(failWork()), 60000, fallback)) |
| out | rule | resolve(result) |
type Submitted {
Done
error Failed(value: dever.time.SleepResult)
}
rule acknowledge(value: Submitted) () recover("caller explicitly acknowledges member failure")
| value | do |
| Done | noop() |
| Failed(error) | noop() |
flow capturedGroup() ()
| step | kind | do |
| tasks | calc | group(1) |
| - | calc | run(tasks, dever.time.sleep(-1)) |
| submission: Submitted | calc | result(run(tasks, noop())) |
| - | rule | acknowledge(submission) |
| - | calc | stop(tasks) |
flow useFallback(action: handler() (out: Int)) (out: Int)
| step | kind | do |
| out | calc | timeout(run(slow(0)), 1, action) |
flow boundFallback() (out: Int)
| step | kind | do |
| out | flow | useFallback(fallback) |
flow parallelGroups() ()
| step | kind | parallel | do |
| first | calc | create | group(1) |
| second | calc | create | group(1) |
| - | calc | submit | run(first, noop()) |
| - | calc | submit | run(second, noop()) |
| - | calc | finish | wait(first) |
| - | calc | finish | wait(second) |
flow failedFallback() (out: Int)
| step | kind | do |
| child | calc | run(identity(1)) |
| - | flow | dever.time.sleep(-1) |
| out | calc | wait(child) |
flow capturedFallback() (out: Int)
| step | kind | do |
| result: Outcome | calc | result(timeout(run(slow(0)), 1, failedFallback)) |
| out | rule | resolve(result) |
type Broken {
error Failed
}
failZero() () {
fail(Broken.Failed)
}
flow neverGroup() ()
| step | kind | do |
| tasks | calc | group(1) |
| - | calc | run(tasks, failZero()) |
| - | calc | wait(tasks) |