diff options
| author | Manish Goregaokar <manishsmail@gmail.com> | 2015-03-19 06:09:31 +0530 |
|---|---|---|
| committer | Manish Goregaokar <manishsmail@gmail.com> | 2015-03-19 08:49:35 +0530 |
| commit | 30718dd44be229a5c61648a4aed6711441ef7b6d (patch) | |
| tree | 7de04d6f39ac61e9216ad78ef6196686f2e72a62 | |
| parent | acc706db4bea7fe8b0cede5ba3f45ad3fff47ce9 (diff) | |
| parent | da96d22d3a8bd4ad74e797b823dd10a34d88991e (diff) | |
| download | rust-30718dd44be229a5c61648a4aed6711441ef7b6d.tar.gz rust-30718dd44be229a5c61648a4aed6711441ef7b6d.zip | |
Rollup merge of #23490 - jooert:master, r=steveklabnik
Update documentation to reflect #21824. r? @steveklabnik
| -rw-r--r-- | src/doc/reference.md | 2 | ||||
| -rw-r--r-- | src/doc/trpl/functions.md | 2 | ||||
| -rw-r--r-- | src/doc/trpl/testing.md | 14 |
3 files changed, 9 insertions, 9 deletions
diff --git a/src/doc/reference.md b/src/doc/reference.md index 3fae49bfc6d..92573d79217 100644 --- a/src/doc/reference.md +++ b/src/doc/reference.md @@ -2068,7 +2068,7 @@ type int8_t = i8; item](#language-items) for more details. - `test` - indicates that this function is a test function, to only be compiled in case of `--test`. -- `should_fail` - indicates that this test function should panic, inverting the success condition. +- `should_panic` - indicates that this test function should panic, inverting the success condition. - `cold` - The function is unlikely to be executed, so optimize it (and calls to it) differently. diff --git a/src/doc/trpl/functions.md b/src/doc/trpl/functions.md index ca1385fde9c..8e8ee8d63d6 100644 --- a/src/doc/trpl/functions.md +++ b/src/doc/trpl/functions.md @@ -179,7 +179,7 @@ Because this function will cause a crash, it will never return, and so it has the type '`!`', which is read "diverges." A diverging function can be used as any type: -```should_fail +```should_panic # fn diverges() -> ! { # panic!("This function never returns!"); # } diff --git a/src/doc/trpl/testing.md b/src/doc/trpl/testing.md index 537e100d7d8..72e9ec9f750 100644 --- a/src/doc/trpl/testing.md +++ b/src/doc/trpl/testing.md @@ -129,11 +129,11 @@ $ echo $? This is useful if you want to integrate `cargo test` into other tooling. -We can invert our test's failure with another attribute: `should_fail`: +We can invert our test's failure with another attribute: `should_panic`: ```rust #[test] -#[should_fail] +#[should_panic] fn it_works() { assert!(false); } @@ -163,13 +163,13 @@ equality: ```rust #[test] -#[should_fail] +#[should_panic] fn it_works() { assert_eq!("Hello", "world"); } ``` -Does this test pass or fail? Because of the `should_fail` attribute, it +Does this test pass or fail? Because of the `should_panic` attribute, it passes: ```bash @@ -189,15 +189,15 @@ running 0 tests test result: ok. 0 passed; 0 failed; 0 ignored; 0 measured ``` -`should_fail` tests can be fragile, as it's hard to guarantee that the test +`should_panic` tests can be fragile, as it's hard to guarantee that the test didn't fail for an unexpected reason. To help with this, an optional `expected` -parameter can be added to the `should_fail` attribute. The test harness will +parameter can be added to the `should_panic` attribute. The test harness will make sure that the failure message contains the provided text. A safer version of the example above would be: ``` #[test] -#[should_fail(expected = "assertion failed")] +#[should_panic(expected = "assertion failed")] fn it_works() { assert_eq!("Hello", "world"); } |
