about summary refs log tree commit diff
path: root/src/libcore/tests
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2018-11-20 00:02:33 +0000
committerbors <bors@rust-lang.org>2018-11-20 00:02:33 +0000
commit31fa30145e15d57a17de8029e8950c60d28d6c8f (patch)
tree112430e63c6c229aa4da57a608c465f725bf45a7 /src/libcore/tests
parent5aff30734b0e1056b1003459fbb27af199f51822 (diff)
parent6357021294614deebbcb3a1c9fbb64bb9aaa1a43 (diff)
downloadrust-31fa30145e15d57a17de8029e8950c60d28d6c8f.tar.gz
rust-31fa30145e15d57a17de8029e8950c60d28d6c8f.zip
Auto merge of #56049 - newpavlov:revert_51601, r=sfackler
Revert #51601

Closes: #55985

Specialization of `StepBy<Range(Inclusive)>` results in an incorrectly behaving code when `step_by` is combined with `skip` or `nth`.

If this will get merged we probably should reopen issues previously closed by #51601 (if there was any).
Diffstat (limited to 'src/libcore/tests')
-rw-r--r--src/libcore/tests/iter.rs7
1 files changed, 7 insertions, 0 deletions
diff --git a/src/libcore/tests/iter.rs b/src/libcore/tests/iter.rs
index 2476c07cbd9..ec09071b3d0 100644
--- a/src/libcore/tests/iter.rs
+++ b/src/libcore/tests/iter.rs
@@ -1619,6 +1619,13 @@ fn test_range_step() {
 }
 
 #[test]
+fn test_step_by_skip() {
+    assert_eq!((0..640).step_by(128).skip(1).collect::<Vec<_>>(), [128, 256, 384, 512]);
+    assert_eq!((0..=50).step_by(10).nth(3), Some(30));
+    assert_eq!((200..=255u8).step_by(10).nth(3), Some(230));
+}
+
+#[test]
 fn test_range_inclusive_step() {
     assert_eq!((0..=50).step_by(10).collect::<Vec<_>>(), [0, 10, 20, 30, 40, 50]);
     assert_eq!((0..=5).step_by(1).collect::<Vec<_>>(), [0, 1, 2, 3, 4, 5]);