Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

assert_that says "or" when it means "and" on ||-chained assertions #64

Open
hughjonesd opened this issue Jun 7, 2020 · 0 comments
Open

Comments

@hughjonesd
Copy link

Example:

> assertthat::assert_that(is.numeric("foo") || is.flag("foo"))
Error: "foo" is not a numeric or integer vector or "foo" is not a flag (a length one logical vector).

This is incorrect. The error is that "foo" is not numeric and foo is not a flag. i.e., not(x or y) = not(x) and not(y). Better would be

Error: "foo" is not a numeric or integer vector and "foo" is not a flag (a length one logical vector).

AFAICS, simply replacing "or" with "and" will work. I think that would make error messages clearer. If you agree this is a bug worth fixing, I'll send a pull request.

hughjonesd added a commit to hughjonesd/assertthat that referenced this issue Apr 21, 2023
If an "or" assertion fails, both lhs *and* rhs failed.
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

No branches or pull requests

1 participant