Skip to content

Commit

Permalink
library/core/tests/iter documentation and cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
danii committed Jan 22, 2021
1 parent bc830a2 commit 0c78500
Show file tree
Hide file tree
Showing 5 changed files with 37 additions and 7 deletions.
17 changes: 17 additions & 0 deletions library/core/tests/iter/mod.rs
Original file line number Diff line number Diff line change
@@ -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;
Expand Down
6 changes: 0 additions & 6 deletions library/core/tests/iter/traits/collect.rs

This file was deleted.

13 changes: 13 additions & 0 deletions library/core/tests/iter/traits/double_ended.rs
Original file line number Diff line number Diff line change
@@ -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];
Expand Down
7 changes: 7 additions & 0 deletions library/core/tests/iter/traits/iterator.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}
1 change: 0 additions & 1 deletion library/core/tests/iter/traits/mod.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
mod accum;
mod collect;
mod double_ended;
mod iterator;
mod step;

0 comments on commit 0c78500

Please sign in to comment.