Skip to content

Conversation

@snystrom
Copy link

Adds required argument to expect_true() that accepts c("one", "any", "all"). I've held off implementing for expect_false until we make sure the implementation is sound for easier review. This also means the docstring is slightly out of sync between expect_true and expect_false for now (and indeed the language could be a little nicer--I expect to polish this up too once we're aligned on the approach).

When required = "any" we throw an error to avoid edges with numeric vectors that contain 1 which may be coerced to TRUE.

Fixes #1836.

Adds `required` argument to `expect_true()` that accepts `c("one", "any", "all")`. I've held off implementing for `expect_false` until we make sure the implementation is sound for easier review.

When `required = "any"` we throw an error to avoid edges with numeric vectors that contain `1` which may be coerced to `TRUE`.

Fixes r-lib#1836.
@hadley
Copy link
Member

hadley commented Oct 2, 2025

Thanks for working on this! I'll take it from here 😄

@hadley
Copy link
Member

hadley commented Oct 8, 2025

@snystrom thanks again for working on this. Unfortunately your code didn't make it into testthat since we ended up going in a slightly different direction, but this is not to say your work wasn't useful and appreciated! Sometimes you need to see a fully thought out implementation to realise it's not quite the right approach. We appreciate your work 😄

hadley added a commit that referenced this pull request Oct 8, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

all= argument for expect_true()/expect_false()

2 participants