about summary refs log tree commit diff
diff options
context:
space:
mode:
authorDaniel Conley <danielc030417@gmail.com>2021-01-22 17:39:17 -0500
committerDaniel Conley <danielc030417@gmail.com>2021-01-22 17:57:08 -0500
commit0c78500426c90e12d8d1da7db013e401dc48788c (patch)
tree0ab071b432adafcce362ad45c248262d77a78b1d
parentbc830a274b91d67fed39b875247163fde4f13326 (diff)
downloadrust-0c78500426c90e12d8d1da7db013e401dc48788c.tar.gz
rust-0c78500426c90e12d8d1da7db013e401dc48788c.zip
library/core/tests/iter documentation and cleanup
-rw-r--r--library/core/tests/iter/mod.rs17
-rw-r--r--library/core/tests/iter/traits/collect.rs6
-rw-r--r--library/core/tests/iter/traits/double_ended.rs13
-rw-r--r--library/core/tests/iter/traits/iterator.rs7
-rw-r--r--library/core/tests/iter/traits/mod.rs1
5 files changed, 37 insertions, 7 deletions
diff --git a/library/core/tests/iter/mod.rs b/library/core/tests/iter/mod.rs
index b88454a50c4..770b6f7601f 100644
--- a/library/core/tests/iter/mod.rs
+++ b/library/core/tests/iter/mod.rs
@@ -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;
diff --git a/library/core/tests/iter/traits/collect.rs b/library/core/tests/iter/traits/collect.rs
deleted file mode 100644
index c90ad8baeb9..00000000000
--- a/library/core/tests/iter/traits/collect.rs
+++ /dev/null
@@ -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);
-}
diff --git a/library/core/tests/iter/traits/double_ended.rs b/library/core/tests/iter/traits/double_ended.rs
index 2728be29593..947d19d3dfe 100644
--- a/library/core/tests/iter/traits/double_ended.rs
+++ b/library/core/tests/iter/traits/double_ended.rs
@@ -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];
diff --git a/library/core/tests/iter/traits/iterator.rs b/library/core/tests/iter/traits/iterator.rs
index f31686378eb..422e389e380 100644
--- a/library/core/tests/iter/traits/iterator.rs
+++ b/library/core/tests/iter/traits/iterator.rs
@@ -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);
+}
diff --git a/library/core/tests/iter/traits/mod.rs b/library/core/tests/iter/traits/mod.rs
index b00e49b0696..80619f53f25 100644
--- a/library/core/tests/iter/traits/mod.rs
+++ b/library/core/tests/iter/traits/mod.rs
@@ -1,5 +1,4 @@
 mod accum;
-mod collect;
 mod double_ended;
 mod iterator;
 mod step;