diff --git a/README.md b/README.md index cde2cac..426ae06 100644 --- a/README.md +++ b/README.md @@ -65,6 +65,19 @@ Inside `speculate! { ... }`, you can have any "Item", like `static`, `const`, } ``` + You can also declare an error type that the tests can fail with, which implicitly makes those test return `Result<(), E>`: + + ```rust + use std::fs; + speculate! { + errtype(Error) + + it "has i/o setup" { + fs::write("/some/file", "with content")?; + assert_eq!(file_reader()?, "with_content"); + } + } + ``` * `bench` - contains benchmarks. For example: diff --git a/src/lib.rs b/src/lib.rs index b73febb..01197ef 100644 --- a/src/lib.rs +++ b/src/lib.rs @@ -85,6 +85,19 @@ fn get_root_name() -> proc_macro2::Ident { /// } /// # } /// ``` +/// You can also declare an error type that the tests can fail with, which implicitly makes those test return `Result<(), E>`: +/// +/// ```rust +/// use std::fs; +/// speculate! { +/// errtype(Error) +/// +/// it "has i/o setup" { +/// fs::write("/some/file", "with content")?; +/// assert_eq!(file_reader()?, "with_content"); +/// } +/// } +/// ``` /// /// * `bench` - contains benchmarks (using [`Bencher`](https://doc.rust-lang.org/test/struct.Bencher.html)). ///