tests/testthat/test-sequence.R

test_that("async_sequence", {

  add1 <- function(n) { n ; delay(10/1000)$then(function(value) n + 1) }
  mul3 <- function(n) { n ; delay(10/1000)$then(function(value) n * 3) }

  add1mul3 <- async_sequence(add1, mul3)
  result <- synchronise(add1mul3(4))

  expect_equal(result, 15)
})
gaborcsardi/async documentation built on Nov. 20, 2024, 4:51 p.m.