tdf#130857 qt weld: Implement QtInstanceWidget::strip_mnemonic
[LibreOffice.git] / basic / qa / basic_coverage / test_for_each.bas
blob3d9b74c273c9ccd8c3f2264e411634956731e675
2 ' This file is part of the LibreOffice project.
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/.
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
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
26 doUnitTest = "OK"
27 End Function
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