Skip to content

Commit

Permalink
Document errtype.
Browse files Browse the repository at this point in the history
  • Loading branch information
Bittrance committed Apr 19, 2019
1 parent d03c815 commit 9356d5c
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 0 deletions.
14 changes: 14 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,20 @@ 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! {
use std::io::Error;
errtype(Error)

it "has i/o setup" {
fs::write("/some/file", "with content")?;
assert_eq!(file_reader()?, "with_content");
}
}
```
* `bench` - contains benchmarks.

For example:
Expand Down
16 changes: 16 additions & 0 deletions src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,22 @@ 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
/// #[macro_use] extern crate speculate as other_speculate;
/// # use std::fs;
/// # fn main() {}
/// # speculate! {
/// use std::io::Error;
/// 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)).
///
Expand Down

0 comments on commit 9356d5c

Please # to comment.