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/.
11 Function doUnitTest
as String
14 doUnitTest
= TestUtil
.GetResult()
17 Sub DEV_TST
: MsgBox doUnitTesT
: End Sub
24 Dim get_foo_count
As Integer
26 Function get_foo
As foo
27 get_foo_count
= get_foo_count
+ 1
31 Sub with_in_another_procedure
32 On Local
Error GoTo errorHandler
33 ' tdf#162962 "End With" clears the internal variable; it used to fail,
34 ' when several module's procedures used With blocks, using Option Explicit
35 Dim foo_var
As New foo
38 TestUtil
.AssertEqual(.n
, 6, ".n")
39 End With ' Here (or in similar places in other tests) a "Variable Not Defined" error was generated
43 TestUtil
.ReportErrorHandler("with_in_another_procedure", Err
, Error$, Erl
)
47 On Local
Error GoTo errorHandler
53 fields
= "n = " & .n
& " s = " & .s
55 ' get_foo must be called only once; before the fix, it failed with
56 ' Number of calls to get_foo returned 4, expected 1
57 TestUtil
.AssertEqual(get_foo_count
, 1, "Number of calls to get_foo")
58 ' Before the fix, each use of . resulted in creation of a new 'foo' object,
59 ' and previous assignments didn't reflect in the result; it failed with
60 ' Field values returned n = 0 s = , expected n = 5 s = bar
61 TestUtil
.AssertEqual(fields
, "n = 5 s = bar", "Field values")
63 ' Make sure that With works with the original object, modifies it, and does not destroy
64 Dim foo_var
As New foo
69 fields
= "n = " & foo_var
.n
& " s = " & foo_var
.s
70 TestUtil
.AssertEqual(fields
, "n = 6 s = baz", "Field values of foo_var")
72 ' tdf#163219: make sure that assigning the variable in the block works
74 TestUtil
.Assert(foo_var Is
Nothing, "foo_var Is Nothing")
80 TestUtil
.AssertEqual(foo_var
.n
, 7, "foo_var.n")
81 TestUtil
.AssertEqual(foo_var
.s
, "something", "foo_var.s")
83 ' tdf#162935: Test an UNO struct - it used to copy into the With variable, not used by ref
84 Dim uno_struct
As New com
.sun
.star
.table
.CellRangeAddress
92 TestUtil
.AssertEqual(uno_struct
.Sheet
, 1, "uno_struct.Sheet")
93 TestUtil
.AssertEqual(uno_struct
.StartColumn
, 2, "uno_struct.StartColumn")
94 TestUtil
.AssertEqual(uno_struct
.StartRow
, 3, "uno_struct.StartRow")
95 TestUtil
.AssertEqual(uno_struct
.EndColumn
, 4, "uno_struct.EndColumn")
96 TestUtil
.AssertEqual(uno_struct
.EndRow
, 5, "uno_struct.EndRow")
98 with_in_another_procedure() ' test tdf#162962
102 TestUtil
.ReportErrorHandler("test_with", Err
, Error$, Erl
)