Debian Codegraph @

tests/testthat/test-ordering.R

raw
1 test_that("promise resolution order matches expectations", {
2 # See discussion in #151 - this is just the current behaviour. There may be
3 # grounds for change if we find a legitimate reason for doing so.
4 y <- 0L
5 p1 <- promise_resolve(1) |> then(\(x) y <<- y + 1) |> then(\(x) y <<- y / 2)
6 p2 <- promise_resolve(2) |> then(\(x) y <<- y + 3) |> then(\(x) y <<- y * 2)
7 later::run_now()
8 expect_equal(y, 4)
9 later::run_now()
10 expect_equal(y, 4)
11 })