Debian Codegraph @

basic/qa/basic_coverage/test_method_name_variable.bas

raw
1 ' This file is part of the LibreOffice project.
2 '
3 ' This Source Code Form is subject to the terms of the Mozilla Public
4 ' License, v. 2.0. If a copy of the MPL was not distributed with this
5 ' file, You can obtain one at http://mozilla.org/MPL/2.0/.
6 '
7
8 Option Explicit
9
10 Function assignVarToMethod() As Integer
11
12 ' method name used as dimension specifier
13 Dim fieldOfLongs() As Long
14 ReDim fieldOfLongs(assignVarToMethod) As Long
15
16 ' method name used as loop index
17 Dim sum As Integer
18 For assignVarToMethod = 1 To 3
19 sum = sum + assignVarToMethod
20 Next assignVarToMethod
21 assignVarToMethod = sum
22
23 End Function
24
25 Function doUnitTest() As String
26
27 doUnitTest = "FAIL"
28
29 ' tdf#85371 - check if the name of the method can be used as a variable in certain statements
30 If (assignVarToMethod() <> 6) Then Exit Function
31 ' tdf#85371 - check if an assignment to the function fails outside of the function itself
32 assignVarToMethod = 0
33 If (assignVarToMethod() <> 6) Then Exit Function
34
35 doUnitTest = "OK"
36
37 End Function