-
Notifications
You must be signed in to change notification settings - Fork 13k
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
Inner function cannot be tested #36629
Comments
But why though ? Do you want to be able to test things inner to your function ? How about an assert_test! that would compile / trigger only when in test mode ? Just an idea. |
Because this is convenient for testing nested functions. Currently I'd have to move the fn outside to be able to test it separately. |
@Cobrand Yeah, something like this will be great:
|
I'm just arguing against my own idea here, but that would require either :
My code is horrible so it doesn't have that much tests, is it possible to run tests in release mode ? If that is the case, the second option is a no-no I guess. |
The problem with this is that the test harness needs to access the inner functions, which it can't do because you can't name them. |
I'm marking as a diagnostics issue so that we print a warning in this case at least. |
Add lint warning for inner function marked as `#[test]` Fix #36629.
Why was the #51450 PR accepted, while the RFC is still unmerged? I disagree with the approach taken (a new lint), we should either (rust-lang/rfcs#2471 (comment)):
|
This comment was marked as spam.
This comment was marked as spam.
…trochenkov Make test harness lint about unnnameable tests. Implementation of rust-lang#113734 (comment) About the options suggested in rust-lang#36629 (comment): adding this case to unused_attribute was just more complicated. I'll try to understand a bit more what you had in mind in rust-lang/rfcs#2471 (comment) This was just simpler to do in a standalone PR. I'll remove the corresponding changes from rust-lang#113734 later. r? `@petrochenkov`
Make test harness lint about unnnameable tests. Implementation of rust-lang/rust#113734 (comment) About the options suggested in rust-lang/rust#36629 (comment): adding this case to unused_attribute was just more complicated. I'll try to understand a bit more what you had in mind in rust-lang/rfcs#2471 (comment) This was just simpler to do in a standalone PR. I'll remove the corresponding changes from rust-lang/rust#113734 later. r? `@petrochenkov`
I really would like to be able to this:
The text was updated successfully, but these errors were encountered: