Initial Dever 0.0.1
This commit is contained in:
commit
81233d098c
1479 files changed
+163782
No files matched your search
@@ -0,0 +1,105 @@
|
||||
type Payload { name: Text
|
||||
values: List<Int> }
|
||||
|
||||
delayed(value: Payload) (answer: Payload) {
|
||||
dever.task.sleep(0)
|
||||
answer = value
|
||||
}
|
||||
|
||||
total(values: List<Int>) (answer: Int) pure { answer = sum(values) }
|
||||
|
||||
yes() (answer: Bool) { answer = true }
|
||||
|
||||
captured() (answer: dever.time.SleepResult) {
|
||||
answer = result(dever.task.sleep(-1))
|
||||
}
|
||||
|
||||
failed(result: dever.time.SleepResult.Done) (answer: Bool) recover("test observes invalid duration") { answer = false }
|
||||
failed(result: dever.time.SleepResult.Failed(message)) (answer: Bool) recover("test observes invalid duration") { answer = length(message) > 0 }
|
||||
|
||||
verify() (answer: Bool) {
|
||||
original = Payload { name = "雪"
|
||||
values = [1, 2, 3] }
|
||||
pending = run(delayed(original))
|
||||
total_value = parallel(total(original.values))
|
||||
received = wait(pending)
|
||||
flag = run(yes())
|
||||
skipped = false and wait(flag)
|
||||
completed = wait(flag)
|
||||
flag = run(yes())
|
||||
reused = wait(flag)
|
||||
blocking(dever.time.sleep(0))
|
||||
stop(run(dever.task.sleep(10000)))
|
||||
captured_task = run(captured())
|
||||
captured_result = wait(captured_task)
|
||||
handled = failed(captured_result)
|
||||
values = each(addOne, [1, 2])
|
||||
reduced = reduce(add, [1, 2, 3], 0)
|
||||
pair_task = run(pair(41))
|
||||
pair_value = wait(pair_task)
|
||||
resource_value = wait(run(localResource()))
|
||||
cleaned = failed(result(pendingFailure(-1)))
|
||||
branch_first = branchTask(true)
|
||||
branch_second = branchTask(false)
|
||||
answer = original == received and total_value == 6 and completed and reused and handled and cleaned and not skipped and values == [2, 3] and reduced == 6 and pair_value.first == 41 and pair_value.second == 42 and resource_value == 0 and branch_first == 6 and branch_second == 4
|
||||
}
|
||||
|
||||
pendingFailure(millis: Int) () {
|
||||
pending = run(dever.task.sleep(60000))
|
||||
dever.task.sleep(millis)
|
||||
stop(pending)
|
||||
}
|
||||
|
||||
branchTask(flag: true) (answer: Int) {
|
||||
pending = run(total([1, 2, 3]))
|
||||
answer = wait(pending)
|
||||
}
|
||||
branchTask(flag: false) (answer: Int) {
|
||||
pending = run(total([4]))
|
||||
answer = wait(pending)
|
||||
}
|
||||
|
||||
emptyStreams() (answer: List<Stream<Int>>) { answer = [] }
|
||||
|
||||
closeStream(value: Stream<Int>) () { close(value) }
|
||||
|
||||
localResource() (answer: Int) {
|
||||
values = emptyStreams()
|
||||
size = length(values)
|
||||
pending = run(yes())
|
||||
each(closeStream, values)
|
||||
values = emptyStreams()
|
||||
other_size = length(values)
|
||||
each(closeStream, values)
|
||||
dever.task.sleep(0)
|
||||
completed = wait(pending)
|
||||
answer = size + other_size
|
||||
}
|
||||
|
||||
pair(value: Int) (first: Int, second: Int) {
|
||||
dever.task.sleep(0)
|
||||
first = value
|
||||
second = value + 1
|
||||
}
|
||||
|
||||
addOne(value: Int) (answer: Int) {
|
||||
dever.task.sleep(0)
|
||||
answer = value + 1
|
||||
}
|
||||
|
||||
add(item: Int, state: Int) (answer: Int) {
|
||||
dever.task.sleep(0)
|
||||
answer = item + state
|
||||
}
|
||||
|
||||
sleepFailure() () { blocking(dever.time.sleep(-1)) }
|
||||
|
||||
increment(value: Int) (answer: Int) {
|
||||
dever.task.sleep(0)
|
||||
answer = value + 1
|
||||
}
|
||||
|
||||
faultEntry() (answer: Int) {
|
||||
pending = run(increment(9223372036854775807))
|
||||
answer = wait(pending)
|
||||
}
|
||||
Reference in new issue
Block a user