From 98a188983af0388c2132906142765b50009543dd Mon Sep 17 00:00:00 2001 From: Vitosh Academy Date: Tue, 10 Nov 2015 21:35:30 +0100 Subject: [PATCH 1/2] thus, we may test functions, that return Arrays If arrays consist of equal elements, then they are equal. Hi, I am Vitosh from vitoshacademy.com --- src/SpecExpectation.cls | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/SpecExpectation.cls b/src/SpecExpectation.cls index 3f58548..16be118 100644 --- a/src/SpecExpectation.cls +++ b/src/SpecExpectation.cls @@ -47,6 +47,17 @@ Public Sub ToNotEqual(Expected As Variant) End Sub Private Function IsEqual(Actual As Variant, Expected As Variant) As Variant + Dim l_count As Long + + If IsArray(Expected) Then + For l_count = LBound(Expected) To UBound(Expected) + If Not Expected(l_count) = Actual(l_count) Then + IsEqual = False + Exit Function + End If + Next l_count + End If + If IsError(Actual) Or IsError(Expected) Then IsEqual = False ElseIf IsObject(Actual) Or IsObject(Expected) Then From c2093ca80db56eca4f5ff31ca1406facabcbd6a9 Mon Sep 17 00:00:00 2001 From: Vitosh Academy Date: Fri, 20 Nov 2015 14:20:05 +0100 Subject: [PATCH 2/2] Update SpecExpectation.cls This way the check for the Arrays works better. --- src/SpecExpectation.cls | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/src/SpecExpectation.cls b/src/SpecExpectation.cls index 16be118..bf01503 100644 --- a/src/SpecExpectation.cls +++ b/src/SpecExpectation.cls @@ -49,14 +49,15 @@ End Sub Private Function IsEqual(Actual As Variant, Expected As Variant) As Variant Dim l_count As Long - If IsArray(Expected) Then - For l_count = LBound(Expected) To UBound(Expected) - If Not Expected(l_count) = Actual(l_count) Then - IsEqual = False - Exit Function - End If - Next l_count - End If + If IsArray(Expected) Then + If UBound(Expected) <> UBound(Actual) Then IsEqual = False: Exit Function + + For l_count = LBound(Expected) To UBound(Expected) + If Not Expected(l_count) = Actual(l_count) Then IsEqual = False: Exit Function + Next l_count + + IsEqual = True + End If If IsError(Actual) Or IsError(Expected) Then IsEqual = False