about summary refs log tree commit diff
path: root/src/libcore/tests
diff options
context:
space:
mode:
authorbors <bors@rust-lang.org>2019-09-09 16:33:43 +0000
committerbors <bors@rust-lang.org>2019-09-09 16:33:43 +0000
commit0b36e9dea3f2ff25b1d0df2669836c33cce89ae5 (patch)
treee5e45ef04b46bdba8f8959029e7da415a58b0983 /src/libcore/tests
parent45859b7ca764cafb14efb8c63a83d5e48dc5d016 (diff)
parentf7ee13040b66c323359c8aea139ba4d91db84376 (diff)
downloadrust-0b36e9dea3f2ff25b1d0df2669836c33cce89ae5.tar.gz
rust-0b36e9dea3f2ff25b1d0df2669836c33cce89ae5.zip
Auto merge of #64313 - Centril:rollup-7w8b67g, r=Centril
Rollup of 5 pull requests

Successful merges:

 - #63468 (Resolve attributes in several places)
 - #64121 (Override `StepBy::{try_fold, try_rfold}`)
 - #64278 (check git in bootstrap.py)
 - #64306 (Fix typo in config.toml.example)
 - #64312 (Unify escape usage)

Failed merges:

r? @ghost
Diffstat (limited to 'src/libcore/tests')
-rw-r--r--src/libcore/tests/iter.rs35
1 files changed, 35 insertions, 0 deletions
diff --git a/src/libcore/tests/iter.rs b/src/libcore/tests/iter.rs
index d7088cf891f..c9096b713f2 100644
--- a/src/libcore/tests/iter.rs
+++ b/src/libcore/tests/iter.rs
@@ -386,6 +386,23 @@ fn test_iterator_step_by_nth_overflow() {
 }
 
 #[test]
+fn test_iterator_step_by_nth_try_fold() {
+    let mut it = (0..).step_by(10);
+    assert_eq!(it.try_fold(0, i8::checked_add), None);
+    assert_eq!(it.next(), Some(60));
+    assert_eq!(it.try_fold(0, i8::checked_add), None);
+    assert_eq!(it.next(), Some(90));
+
+    let mut it = (100..).step_by(10);
+    assert_eq!(it.try_fold(50, i8::checked_add), None);
+    assert_eq!(it.next(), Some(110));
+
+    let mut it = (100..=100).step_by(10);
+    assert_eq!(it.next(), Some(100));
+    assert_eq!(it.try_fold(0, i8::checked_add), Some(0));
+}
+
+#[test]
 fn test_iterator_step_by_nth_back() {
     let mut it = (0..16).step_by(5);
     assert_eq!(it.nth_back(0), Some(15));
@@ -411,6 +428,24 @@ fn test_iterator_step_by_nth_back() {
 }
 
 #[test]
+fn test_iterator_step_by_nth_try_rfold() {
+    let mut it = (0..100).step_by(10);
+    assert_eq!(it.try_rfold(0, i8::checked_add), None);
+    assert_eq!(it.next_back(), Some(70));
+    assert_eq!(it.next(), Some(0));
+    assert_eq!(it.try_rfold(0, i8::checked_add), None);
+    assert_eq!(it.next_back(), Some(30));
+
+    let mut it = (0..100).step_by(10);
+    assert_eq!(it.try_rfold(50, i8::checked_add), None);
+    assert_eq!(it.next_back(), Some(80));
+
+    let mut it = (100..=100).step_by(10);
+    assert_eq!(it.next_back(), Some(100));
+    assert_eq!(it.try_fold(0, i8::checked_add), Some(0));
+}
+
+#[test]
 #[should_panic]
 fn test_iterator_step_by_zero() {
     let mut it = (0..).step_by(0);