| 1 |
|
| 2 |
test_that("expr() works as expected", { |
| 3 |
|
| 4 |
value <- 42 |
| 5 |
actual <- expr({ |
| 6 |
x <- !!value |
| 7 |
}) |
| 8 |
|
| 9 |
expected <- quote({ |
| 10 |
x <- 42 |
| 11 |
}) |
| 12 |
|
| 13 |
expect_identical(actual, expected) |
| 14 |
|
| 15 |
}) |
| 16 |
|
| 17 |
test_that("expr() also supports expressions", { |
| 18 |
|
| 19 |
actual <- expr({ |
| 20 |
pid <- !!Sys.getpid() |
| 21 |
}) |
| 22 |
|
| 23 |
expected <- substitute({ |
| 24 |
pid <- id |
| 25 |
}, list(id = Sys.getpid())) |
| 26 |
|
| 27 |
expect_identical(actual, expected) |
| 28 |
|
| 29 |
}) |
| 30 |
|
| 31 |
test_that("expr() repairs parse trees", { |
| 32 |
|
| 33 |
a <- TRUE; b <- FALSE |
| 34 |
actual <- expr(!!a + !!b) |
| 35 |
expected <- quote(TRUE + FALSE) |
| 36 |
expect_identical(actual, expected) |
| 37 |
|
| 38 |
}) |