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

expect_warning has problem with "()" #1886

Closed
tanaphum opened this issue Oct 18, 2023 · 1 comment
Closed

expect_warning has problem with "()" #1886

tanaphum opened this issue Oct 18, 2023 · 1 comment

Comments

@tanaphum
Copy link

I found some bugs while I'm try testthat package on expect_warning().

library(testthat)

#pass
expect_warning(warning("test"),"test")
#pass
expect_warning(warning("(test)"),"(test)")
#fail
expect_warning(warning("test(test)"),"test(test)")

The error on console

> expect_warning(warning("test(test)"),"test(test)")
Error: `warning("test(test)")` did not throw the expected warning.
In addition: Warning message:
In eval_bare(quo_get_expr(.quo), quo_get_env(.quo)) : test(test)

It looks like the skip to read string after "(".

#fail
expect_warning(warning("test(test)"),"test(test)")
#pass
expect_warning(warning("test(test)"),"test")
@hadley
Copy link
Member

hadley commented Oct 23, 2023

Note that the second argument to expect_warning() is called regexp because it's a regular expression 😄 You might want to either set fixed = TRUE or try expect_snapshot() instead.

@hadley hadley closed this as completed Oct 23, 2023
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

2 participants