gambas-source-code/gb.gsl/Test/test/.src/TestComplex.class
Randall Morgan 5da2463da1 Just updating source while working
[GB.GSL]
* NEW: Updating development code.

git-svn-id: svn://localhost/gambas/trunk@4559 867c0c6c-44f3-4631-809d-bfa615b0a4ec
2012-03-17 17:18:54 +00:00

94 lines
2.1 KiB
Text

' Gambas class file
Inherits Test
Public Function getComplexTypeString(p As Variant) As String
Dim result As String
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
Else
Me.hasError = Me.IsEqual(result, expected)
Endif
Return Me.hasError
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
If Me.IsEqual(result, expected) Then
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