Patchwork rust: adapted hg-core tests for iteration over Result

login
register
mail settings
Submitter Georges Racinet
Date Dec. 12, 2018, 12:58 p.m.
Message ID <7255a67d19ac54af8008.1544619490@purity.tombe.racinet.fr>
Download mbox | patch
Permalink /patch/37120/
State Accepted
Headers show

Comments

Georges Racinet - Dec. 12, 2018, 12:58 p.m.
# HG changeset patch
# User Georges Racinet <gracinet@anybox.fr>
# Date 1544544797 -3600
#      Tue Dec 11 17:13:17 2018 +0100
# Node ID 7255a67d19ac54af80085ebfc9b62a684532aabe
# Parent  76d8b20139a3b8b5835c7262216b97275845b582
# EXP-Topic rustancestors-tests
rust: adapted hg-core tests for iteration over Result

Now AncestorsIterator iters on Result<Revision, GraphError>
Yuya Nishihara - Dec. 12, 2018, 1:47 p.m.
On Wed, 12 Dec 2018 13:58:10 +0100, Georges Racinet wrote:
> # HG changeset patch
> # User Georges Racinet <gracinet@anybox.fr>
> # Date 1544544797 -3600
> #      Tue Dec 11 17:13:17 2018 +0100
> # Node ID 7255a67d19ac54af80085ebfc9b62a684532aabe
> # Parent  76d8b20139a3b8b5835c7262216b97275845b582
> # EXP-Topic rustancestors-tests
> rust: adapted hg-core tests for iteration over Result

Queued, thanks for fixing my mistake.

Patch

diff -r 76d8b20139a3 -r 7255a67d19ac rust/hg-core/src/ancestors.rs
--- a/rust/hg-core/src/ancestors.rs	Tue Dec 11 22:23:39 2018 +0900
+++ b/rust/hg-core/src/ancestors.rs	Tue Dec 11 17:13:17 2018 +0100
@@ -173,6 +173,7 @@ 
     ) -> Vec<Revision> {
         AncestorsIterator::new(graph, initrevs, stoprev, inclusive)
             .unwrap()
+            .map(|res| res.unwrap())
             .collect()
     }
 
@@ -218,12 +219,12 @@ 
     fn test_contains() {
         let mut lazy =
             AncestorsIterator::new(Stub, vec![10, 1], 0, true).unwrap();
-        assert!(lazy.contains(1));
-        assert!(!lazy.contains(3));
+        assert!(lazy.contains(1).unwrap());
+        assert!(!lazy.contains(3).unwrap());
 
         let mut lazy =
             AncestorsIterator::new(Stub, vec![0], 0, false).unwrap();
-        assert!(!lazy.contains(NULL_REVISION));
+        assert!(!lazy.contains(NULL_REVISION).unwrap());
     }
 
     /// A corrupted Graph, supporting error handling tests
@@ -255,7 +256,6 @@ 
         // inclusive=false looks up initrev's parents right away
         let mut iter =
             AncestorsIterator::new(Corrupted, vec![1], 0, false).unwrap();
-        assert_eq!(iter.next(), Some(0));
-        assert_eq!(iter.next(), None);
+        assert_eq!(iter.next(), Some(Err(GraphError::ParentOutOfRange(0))));
     }
 }