Skip to content

Commit d8c785f

Browse files
Talk about tests and benchmarks
1 parent 1075507 commit d8c785f

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

CONTRIBUTING.md

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@ then **please first file an issue** describing your proposal._
1010
To pass CI tests successfully, your code must be free of "compiler warnings" and "clippy warnings" and be "rustfmt" formatted.
1111

1212
## Write a new method/adaptor for `Itertools` trait
13+
In general, the code logic should be tested with [quickcheck](https://crates.io/crates/quickcheck) tests in `tests/quick.rs`
14+
which allow us to test properties about the code with randomly generated inputs.
15+
1316
### Behind `use_std`/`use_alloc` feature?
1417
If it needs the "std" (such as using hashes) then it should be behind the `use_std` feature,
1518
or if it requires heap allocation (such as using vectors) then it should be behind the `use_alloc` feature.
@@ -32,6 +35,8 @@ Iterators are [lazy](https://doc.rust-lang.org/std/iter/index.html#laziness):
3235
- structs of iterator adaptors should have `#[must_use = "iterator adaptors are lazy and do nothing unless consumed"]` ;
3336
- structs of iterators should have `#[must_use = "iterators are lazy and do nothing unless consumed"]`.
3437

38+
Those behaviors are **tested** in `tests/laziness.rs`.
39+
3540
## Specialize `Iterator` methods
3641
It might be more performant to specialize some methods.
3742
However, each specialization should be thoroughly tested.
@@ -63,6 +68,9 @@ Additionally,
6368

6469
An adaptor might use the inner iterator specializations for its own specializations.
6570

71+
They are **tested** in `tests/specializations.rs` and **benchmarked** in `benches/specializations.rs`
72+
(build those benchmarks is slow so you might want to temporarily remove the ones you do not want to measure).
73+
6674
## Additional implementations
6775
### The [`Debug`](https://doc.rust-lang.org/std/fmt/trait.Debug.html) implementation
6876
All our iterators should implement `Debug`.
@@ -159,6 +167,8 @@ The conditions on which it should be implemented are usually the ones from the `
159167
### When to implement [`itertools::PeekingNext`](https://docs.rs/itertools/latest/itertools/trait.PeekingNext.html)
160168
TODO
161169

170+
This is currently **tested** in `tests/test_std.rs`.
171+
162172
## About lending iterators
163173
TODO
164174

0 commit comments

Comments
 (0)