update actor doc and add more actor based tests
This commit is contained in:
30
tests/actor_requestors.ce
Normal file
30
tests/actor_requestors.ce
Normal file
@@ -0,0 +1,30 @@
|
||||
// Test: sequence, parallel, and fallback requestor composition
|
||||
var immediate = function(callback, value) {
|
||||
callback(42)
|
||||
}
|
||||
|
||||
var add_one = function(callback, value) {
|
||||
callback(value + 1)
|
||||
}
|
||||
|
||||
var broken = function(callback, value) {
|
||||
callback(null, "broken")
|
||||
}
|
||||
|
||||
var _t = sequence([immediate, add_one])(function(result, reason) {
|
||||
if (reason != null) disrupt
|
||||
if (result != 43) disrupt
|
||||
|
||||
parallel([immediate, immediate])(function(results, reason) {
|
||||
if (reason != null) disrupt
|
||||
if (length(results) != 2) disrupt
|
||||
if (results[0] != 42) disrupt
|
||||
if (results[1] != 42) disrupt
|
||||
|
||||
fallback([broken, immediate])(function(result, reason) {
|
||||
if (reason != null) disrupt
|
||||
if (result != 42) disrupt
|
||||
$stop()
|
||||
})
|
||||
})
|
||||
})
|
||||
Reference in New Issue
Block a user