library/core/tests/iter documentation and cleanup

This commit is contained in:
Daniel Conley 2021-01-22 17:39:17 -05:00
parent bc830a274b
commit 0c78500426
5 changed files with 37 additions and 7 deletions

View file

@ -1,3 +1,20 @@
//! Note
//! ----
//! You're probably viewing this file because you're adding a test (or you might
//! just be browsing, in that case, hey there!).
//!
//! The iter test suite is split into two big modules, and some miscellaneous
//! smaller modules. The two big modules are `adapters` and `traits`.
//!
//! `adapters` are for methods on `Iterator` that adapt the data inside the
//! iterator, whether it be by emitting another iterator or returning an item
//! from inside the iterator after executing a closure on each item.
//!
//! `traits` are for trait's that extend an `Iterator` (and the `Iterator`
//! trait itself, mostly containing miscellaneous methods). For the most part,
//! if a test in `traits` uses a specific adapter, then it should be moved to
//! that adapter's test file in `adapters`.
mod adapters;
mod range;
mod sources;

View file

@ -1,6 +0,0 @@
#[test]
fn test_collect() {
let a = vec![1, 2, 3, 4, 5];
let b: Vec<isize> = a.iter().cloned().collect();
assert!(a == b);
}

View file

@ -1,3 +1,16 @@
//! Note
//! ----
//! You're probably viewing this file because you're adding a test (or you might
//! just be browsing, in that case, hey there!).
//!
//! If you've made a test that happens to use one of DoubleEnded's methods, but
//! it tests another adapter or trait, you should *add it to the adapter or
//! trait's test file*.
//!
//! Some examples would be `adapters::cloned::test_cloned_try_folds` or
//! `adapters::flat_map::test_double_ended_flat_map`, which use `try_fold` and
//! `next_back`, but test their own adapter.
#[test]
fn test_iterator_rev_nth_back() {
let v: &[_] = &[0, 1, 2, 3, 4];

View file

@ -461,3 +461,10 @@ fn test_iterator_len() {
assert_eq!(v[..10].iter().count(), 10);
assert_eq!(v[..0].iter().count(), 0);
}
#[test]
fn test_collect() {
let a = vec![1, 2, 3, 4, 5];
let b: Vec<isize> = a.iter().cloned().collect();
assert!(a == b);
}

View file

@ -1,5 +1,4 @@
mod accum;
mod collect;
mod double_ended;
mod iterator;
mod step;