Initial Dever 0.0.1
This commit is contained in:
commit
81233d098c
1479 files changed
+163782
No files matched your search
@@ -0,0 +1,56 @@
|
||||
type ValueResult { Ready(value: Int)
|
||||
error Failed(message: Text) }
|
||||
|
||||
work(delay: Int, number: Int) (value: Int) { dever.task.sleep(delay)
|
||||
value = number }
|
||||
|
||||
fallback() (value: Int) { value = 7 }
|
||||
|
||||
bad(delay: Int) (value: Int) { dever.task.sleep(delay)
|
||||
fail(ValueResult.Failed("worker")) }
|
||||
|
||||
fallbackFault() (value: Int) { fail(ValueResult.Failed("fallback")) }
|
||||
|
||||
nothing() (value: Int?) { value = null }
|
||||
|
||||
nullableFallback() (value: Int?) { value = 9 }
|
||||
|
||||
pair(delay: Int) (first: Int, second: Text) { dever.task.sleep(delay)
|
||||
first = 4
|
||||
second = "pair" }
|
||||
|
||||
pairFallback() (first: Int, second: Text) { first = 7
|
||||
second = "fallback" }
|
||||
|
||||
empty() () {}
|
||||
|
||||
duration() (value: Int) { dever.task.sleep(0)
|
||||
value = 10000 }
|
||||
|
||||
badDuration() (value: Int) { dever.task.sleep(0)
|
||||
fail(ValueResult.Failed("argument")) }
|
||||
|
||||
timeoutFault() (value: Int) { value = timeout(run(bad(0)), 10000, fallbackFault) }
|
||||
|
||||
raceFault() (value: Int) { value = race(run(bad(0)), run(work(60000, 3))) }
|
||||
|
||||
invalidTimeout() () { timeout(run(dever.task.sleep(60000)), 0, empty) }
|
||||
|
||||
argumentFault() (value: Int) { value = timeout(run(work(60000, 3)), badDuration(), fallback) }
|
||||
|
||||
raceArgumentFault() (value: Int) { value = race(run(work(60000, 1)), run(work(badDuration(), 2))) }
|
||||
|
||||
verify() (answer: Bool) {
|
||||
ready = timeout(run(work(0, 1)), 10000, fallback)
|
||||
expired = timeout(run(work(60000, 2)), 1, fallback)
|
||||
nullable = timeout(run(nothing()), 10000, nullableFallback)
|
||||
evaluated = timeout(run(work(0, 3)), duration(), fallback)
|
||||
pair_value = timeout(run(pair(0)), 10000, pairFallback)
|
||||
pair_expired = timeout(run(pair(60000)), 1, pairFallback)
|
||||
pair_winner = race(run(pair(60000)), run(pair(0)))
|
||||
winner = race(run(work(60000, 1)), run(work(60000, 2)), run(work(0, 3)))
|
||||
timeout(run(dever.task.sleep(0)), 10000, empty)
|
||||
timeout(run(dever.task.sleep(60000)), 1, empty)
|
||||
race(run(dever.task.sleep(60000)), run(dever.task.sleep(0)))
|
||||
answer = ready == 1 and expired == 7 and nullable == null and evaluated == 3 and pair_value.first == 4 and pair_value.second == "pair" and pair_expired.first == 7 and pair_expired.second == "fallback" and pair_winner.first == 4 and pair_winner.second == "pair" and winner == 3
|
||||
}
|
||||
Reference in new issue
Block a user