2012-03-03 01:21:36 +01:00
|
|
|
' Gambas class file
|
|
|
|
|
|
|
|
Inherits Test
|
|
|
|
|
2012-03-17 18:18:54 +01:00
|
|
|
Public Function getComplexTypeString(p As Variant) As String
|
|
|
|
Dim result As String
|
2012-03-03 01:21:36 +01:00
|
|
|
|
2012-03-17 18:18:54 +01:00
|
|
|
result = Me.getTypeString(p)
|
|
|
|
|
|
|
|
If result = "Unknown" Then
|
|
|
|
If result Is Complex Then
|
|
|
|
result = "Complex"
|
|
|
|
Endif
|
|
|
|
Endif
|
|
|
|
|
|
|
|
Return result
|
|
|
|
|
|
|
|
End
|
|
|
|
|
|
|
|
|
|
|
|
Public Sub IsComplexEqual(result As Variant, expected As Variant) As Boolean
|
|
|
|
|
|
|
|
If result Is Complex Or expected Is Complex Then
|
|
|
|
'We have objects that need special processing
|
|
|
|
If Me.IsEqual(result, expected) Then
|
|
|
|
Me.Result = result.ToString()
|
|
|
|
Me.ResType = "Complext"
|
|
|
|
Me.Expected = expected.ToString()
|
|
|
|
Me.ExpType = "Complex"
|
|
|
|
Else
|
|
|
|
Me.AddError(Me.ValueError(result.ToString, expected.ToString))
|
|
|
|
Me.hasError = True
|
|
|
|
Endif
|
2012-03-03 01:21:36 +01:00
|
|
|
Else
|
2012-03-17 18:18:54 +01:00
|
|
|
Me.hasError = Me.IsEqual(result, expected)
|
2012-03-03 01:21:36 +01:00
|
|
|
Endif
|
|
|
|
|
2012-03-17 18:18:54 +01:00
|
|
|
Return Me.hasError
|
|
|
|
|
2012-03-03 01:21:36 +01:00
|
|
|
End
|
|
|
|
|
|
|
|
|
|
|
|
Public Sub Run(func As String, result As Variant, expected As Variant, Optional note As String) As Boolean
|
|
|
|
Dim err As Boolean = False
|
|
|
|
|
|
|
|
Me.Name = func
|
|
|
|
Me.Note = note
|
|
|
|
|
|
|
|
Me.Expected = expected
|
|
|
|
Me.ExpType = Me.getTypeString(expected)
|
|
|
|
|
|
|
|
|
|
|
|
Me.Result = result
|
|
|
|
Me.ResType = Me.getTypeString(result)
|
|
|
|
|
|
|
|
If TypeOf(result) <> gb.Object And TypeOf(expected) <> gb.Object Then
|
|
|
|
' Not an object so run parent code
|
|
|
|
If TypeOf(result) <> TypeOf(expected) Then
|
|
|
|
Me.AddError(Me.TypeError(Me.ResType, Me.ExpType))
|
|
|
|
err = True
|
|
|
|
Else
|
|
|
|
If result <> expected Then
|
|
|
|
Me.AddError(Me.ValueError(Me.Result, Me.Expected))
|
|
|
|
err = True
|
|
|
|
Endif
|
|
|
|
Endif
|
|
|
|
Else
|
|
|
|
'We have objects that need special processing
|
|
|
|
If TypeOf(result) <> TypeOf(expected) Then
|
|
|
|
Me.AddError(Me.TypeError(Me.ResType, Me.ExpType))
|
|
|
|
err = True
|
|
|
|
Else
|
|
|
|
If result Is Complex And expected Is Complex Then
|
2012-03-17 18:18:54 +01:00
|
|
|
If Me.IsEqual(result, expected) Then
|
2012-03-03 01:21:36 +01:00
|
|
|
Me.Result = result.ToString()
|
|
|
|
Me.ResType = "Complex Object"
|
|
|
|
Me.Expected = expected.ToString()
|
|
|
|
Me.ExpType = "Complex Object"
|
|
|
|
Else
|
|
|
|
Me.AddError(Me.ValueError(result.ToString, expected.ToString))
|
|
|
|
err = True
|
|
|
|
Endif
|
|
|
|
Endif
|
|
|
|
Endif
|
|
|
|
|
|
|
|
Endif
|
|
|
|
|
|
|
|
Return Me.hasError
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
End
|
|
|
|
|
|
|
|
|