File: test-f-capture.R

package info (click to toggle)
r-cran-lazyeval 0.2.2-1
  • links: PTS, VCS
  • area: main
  • in suites: bookworm, bullseye, forky, sid, trixie
  • size: 596 kB
  • sloc: ansic: 310; sh: 9; makefile: 2
file content (28 lines) | stat: -rw-r--r-- 538 bytes parent folder | download | duplicates (4)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
context("f_capture")

test_that("explicit promise makes a formula", {
  f1 <- f_capture(1 + 2 + 3)
  f2 <- ~ 1 + 2 + 3

  expect_equal(f1, f2)
})

test_that("explicit promise works several levels deep", {
  f <- function(x) g(x)
  g <- function(y) h(y)
  h <- function(z) f_capture(z)

  f1 <- f(1 + 2 + 3)
  f2 <- ~ 1 + 2 + 3

  expect_equal(f1, f2)
})

test_that("explicit dots makes a list of formulas", {
  fs <- dots_capture(x = 1 + 2, y = 2 + 3)
  f1 <- ~ 1 + 2
  f2 <- ~ 2 + 3

  expect_equal(fs$x, f1)
  expect_equal(fs$y, f2)
})