forked from rust-lang/rust
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into fix-submodules
- Loading branch information
Showing
55 changed files
with
1,210 additions
and
693 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
src/doc/unstable-book/src/language-features/custom-test-frameworks.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
# `custom_test_frameworks` | ||
|
||
The tracking issue for this feature is: [#50297] | ||
|
||
[#50297]: https://github.com/rust-lang/rust/issues/50297 | ||
|
||
------------------------ | ||
|
||
The `custom_test_frameworks` feature allows the use of `#[test_case]` and `#![test_runner]`. | ||
Any function, const, or static can be annotated with `#[test_case]` causing it to be aggregated (like `#[test]`) | ||
and be passed to the test runner determined by the `#![test_runner]` crate attribute. | ||
|
||
```rust | ||
#![feature(custom_test_frameworks)] | ||
#![test_runner(my_runner)] | ||
|
||
fn my_runner(tests: &[&i32]) { | ||
for t in tests { | ||
if **t == 0 { | ||
println!("PASSED"); | ||
} else { | ||
println!("FAILED"); | ||
} | ||
} | ||
} | ||
|
||
#[test_case] | ||
const WILL_PASS: i32 = 0; | ||
|
||
#[test_case] | ||
const WILL_FAIL: i32 = 4; | ||
``` | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.