Debian Codegraph @

basic/qa/basic_coverage/test_tdf160321_gosub_goto.bas

raw
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 Option Explicit
10
11 Function doUnitTest() As String
12 TestUtil.TestInit
13 verify_GoSub_GoTo
14 doUnitTest = TestUtil.GetResult()
15 End Function
16
17 Sub verify_GoSub_GoTo
18 On Error GoTo errorHandler
19
20 Dim iVar As Integer
21
22 ' tdf#160321 - don't execute the GoSub statement if the expression is 0
23 On 0 GoSub Sub1, Sub2
24 iVar = iVar + 1
25 TestUtil.AssertEqual(iVar, 1, "iVar incremented incorrectly")
26
27 ' tdf#160321 - check the correct functionality of the GoTo statement
28 On 1 GoTo Sub1, Sub2
29 iVar = iVar + 1
30
31 Exit Sub
32 Sub1:
33 TestUtil.AssertEqual(iVar, 1, "iVar incremented incorrectly")
34 On 2 GoTo Sub1, Sub2
35 iVar = iVar + 1
36 Exit Sub
37 Sub2:
38 TestUtil.AssertEqual(iVar, 1, "iVar incremented incorrectly")
39 Exit Sub
40 errorHandler:
41 TestUtil.ReportErrorHandler("verify_GoSub_GoTo", Err, Error$, Erl)
42 Exit Sub
43 End Sub