// 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()
    })
  })
})
