mirror of
https://github.com/rust-lang/rust.git
synced 2025-06-06 20:28:33 +00:00
library/core/tests/iter documentation and cleanup
This commit is contained in:
parent
bc830a274b
commit
0c78500426
@ -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 adapters;
|
||||||
mod range;
|
mod range;
|
||||||
mod sources;
|
mod sources;
|
||||||
|
@ -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);
|
|
||||||
}
|
|
@ -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]
|
#[test]
|
||||||
fn test_iterator_rev_nth_back() {
|
fn test_iterator_rev_nth_back() {
|
||||||
let v: &[_] = &[0, 1, 2, 3, 4];
|
let v: &[_] = &[0, 1, 2, 3, 4];
|
||||||
|
@ -461,3 +461,10 @@ fn test_iterator_len() {
|
|||||||
assert_eq!(v[..10].iter().count(), 10);
|
assert_eq!(v[..10].iter().count(), 10);
|
||||||
assert_eq!(v[..0].iter().count(), 0);
|
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,5 +1,4 @@
|
|||||||
mod accum;
|
mod accum;
|
||||||
mod collect;
|
|
||||||
mod double_ended;
|
mod double_ended;
|
||||||
mod iterator;
|
mod iterator;
|
||||||
mod step;
|
mod step;
|
||||||
|
Loading…
Reference in New Issue
Block a user