| 1 |
' |
| 2 |
' This file is part of the LibreOffice project. |
| 3 |
' |
| 4 |
' This Source Code Form is subject to the terms of the Mozilla Public |
| 5 |
' License, v. 2.0. If a copy of the MPL was not distributed with this |
| 6 |
' file, You can obtain one at http://mozilla.org/MPL/2.0/. |
| 7 |
' |
| 8 |
|
| 9 |
Function doUnitTest as String |
| 10 |
Dim n As Integer, i |
| 11 |
Dim a(3) |
| 12 |
n = 0 |
| 13 |
For Each i In a |
| 14 |
n = n + 1 |
| 15 |
Next i |
| 16 |
If n <> 4 Then |
| 17 |
doUnitTest = "For Each over array failed" |
| 18 |
Exit Function |
| 19 |
End If |
| 20 |
|
| 21 |
If TestInvalidForEachWithErrorHandler <> "13 91 14 " Then |
| 22 |
doUnitTest = "For Each doesn't generate proper errors on bad arguments" |
| 23 |
Exit Function |
| 24 |
End If |
| 25 |
|
| 26 |
doUnitTest = "OK" |
| 27 |
End Function |
| 28 |
|
| 29 |
Function TestInvalidForEachWithErrorHandler |
| 30 |
Dim s As String |
| 31 |
On Error Goto ErrHandler |
| 32 |
' This For Each is given a bad iterable; it must generate first error ("Data type mismatch") for b; |
| 33 |
For Each a In b |
| 34 |
' Then proceed here (Resume Next from ErrHandler), and generate "Object variable not set" for c; |
| 35 |
c.d |
| 36 |
' Then proceed here (Resume Next from ErrHandler), and generate "Invalid parameter" at Next. |
| 37 |
Next |
| 38 |
TestInvalidForEachWithErrorHandler = s |
| 39 |
Exit Function |
| 40 |
ErrHandler: |
| 41 |
s = s & Err & " " |
| 42 |
Resume Next |
| 43 |
End Function |