-
Notifications
You must be signed in to change notification settings - Fork 13.6k
Closed
Labels
A-testsuiteArea: The testsuite used to check the correctness of rustcArea: The testsuite used to check the correctness of rustcC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.
Description
It would be nice if we could implement test cases directly on a type that they test. This is especially useful when generating code (and test cases) with macros.
In the example below, the expected result would be Unit::my_important_test
when testing.
struct Unit;
impl Unit {
#[test]
fn my_important_test() { /* ... */ }
}
Alternatively one can just create a non_camel_case module sharing the same identifier as the struct
. But this looks off for that exact reason. And abuses the bug as reported in #29185.
#[cfg(test)] #[allow(non_camel_case)]
mod Unit {
#[test]
fn my_important_test() { /* ... */ }
}
Metadata
Metadata
Assignees
Labels
A-testsuiteArea: The testsuite used to check the correctness of rustcArea: The testsuite used to check the correctness of rustcC-enhancementCategory: An issue proposing an enhancement or a PR with one.Category: An issue proposing an enhancement or a PR with one.