File: test-combining.R

package info (click to toggle)
r-cran-promises 1.2.0.1%2Bdfsg-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm
  • size: 2,420 kB
  • sloc: cpp: 45; sh: 13; makefile: 2
file content (24 lines) | stat: -rw-r--r-- 709 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
library(testthat)

source("common.R")

describe("promise_all", {
  it("preserves element ordering", {
    a <- resolve_later(1, 0.5)
    b <- resolve_later(2, 0.3)
    c <- resolve_later(3, 0.1)

    x <- promise_all(.list = list(a=a, b=b, c=c))
    expect_identical(extract(x), list(a=1, b=2, c=3))
  })

  it("Handles NULLs correctly", {
    x <- promise_all(promise_resolve(NULL), promise_resolve(NULL),
                     promise_resolve(NULL))
    expect_identical(extract(x), list(NULL, NULL, NULL))

    x <- promise_all(a = promise_resolve(NULL), b = promise_resolve(NULL),
                     c = promise_resolve(NULL))
    expect_identical(extract(x), list(a = NULL, b = NULL, c = NULL))
  })
})