[Pkg-cli-apps-commits] [fsharp] 51/60: Improve error message when VerifySeqsEqual fails

Christopher Halse Rogers raof-guest at moszumanska.debian.org
Sun Sep 14 08:13:42 UTC 2014


This is an automated email from the git hooks/post-receive script.

raof-guest pushed a commit to branch master
in repository fsharp.

commit 8deafc3be2e6eb05504e0a218065e2e1d9667d1a
Author: Patrick McDonald <paddymcdonald at gmail.com>
Date:   Wed Aug 27 00:27:20 2014 +0100

    Improve error message when VerifySeqsEqual fails
---
 src/fsharp/FSharp.Core.Unittests/LibraryTestFx.fs | 12 +++++-------
 1 file changed, 5 insertions(+), 7 deletions(-)

diff --git a/src/fsharp/FSharp.Core.Unittests/LibraryTestFx.fs b/src/fsharp/FSharp.Core.Unittests/LibraryTestFx.fs
index 3fde252..02ebe39 100644
--- a/src/fsharp/FSharp.Core.Unittests/LibraryTestFx.fs
+++ b/src/fsharp/FSharp.Core.Unittests/LibraryTestFx.fs
@@ -57,13 +57,11 @@ let CheckThrowsFormatException       f = CheckThrowsExn<FormatException>
 
 // Verifies two sequences are equal (same length, equiv elements)
 let VerifySeqsEqual seq1 seq2 =
-    if Seq.length seq1 <> Seq.length seq2 then Assert.Fail()
-    
-    let zippedElements = Seq.zip seq1 seq2
-    if zippedElements |> Seq.forall (fun (a, b) -> a = b) 
-    then ()
-    else Assert.Fail()
-    
+    Assert.AreEqual(Seq.length seq1, Seq.length seq2, "Sequences are different lengths.")
+
+    Seq.zip seq1 seq2
+    |> Seq.iteri (fun i (a, b) -> if a <> b then Assert.Fail("Sequences are different in position {0}\n  Expected: {1}\n  But was: {2}", i, a, b))
+
 let sleep(n : int32) =        
 #if FX_NO_THREAD
     async { do! Async.Sleep(n) } |> Async.RunSynchronously

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-cli-apps/packages/fsharp.git



More information about the Pkg-cli-apps-commits mailing list