r-lib / testthat

An R 📦 to make testing 😀
https://testthat.r-lib.org
Other
891 stars 316 forks source link

Use quasiquotation #626

Closed hadley closed 7 years ago

hadley commented 7 years ago

To better support parameterised tests. Should include #524

hadley commented 7 years ago

Basic idea:

bad_sum <- function(...) 0

val1 <- 1
val2 <- 1
exp <- 3
expect_equal(bad_sum(!!val1, !!val2), !!exp)

# Should generate same failure message as 
expect_equal(bad_sum(1, 1), 3)

#> Error: bad_sum(1, 1) not equal to 3.
#> 1/1 mismatches
#> [1] 10 - 3 == 7 

This is not tidy eval, but quasiquotation + quosures in order to generate better labels.

hadley commented 7 years ago

make_label() is only exported in the dev version, so it's safe to replace.