r-lib / testthat

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

Is it intentional that expect_xxx functions use tidyeval semantics? #884

Closed jcheng5 closed 5 years ago

jcheng5 commented 5 years ago

In particular, I found it surprising that !! (and in rlang version 0.3.99.9003, {{...}}) are evaluated at the expect_xxx level.

> identical(rlang::expr(!!quote(!!foo)), quote(!!foo))
[1] TRUE
> expect_identical(rlang::expr(!!quote(!!foo)), quote(!!foo))
Error in enexpr(expr) : object 'foo' not found

This is relevant for the shinymeta project; in that context, it's easy to break the results by evaluating !! at the wrong moment.

hadley commented 5 years ago

Yes, because we unquoting to generate better failure messages when you're reducing duplication in tests with a for loop or function.

hadley commented 5 years ago

Closing for now, but happy to discuss if you think it's really problematic.