1 ' This file is part of the LibreOffice project.
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/.
10 Function doUnitTest() As String
13 doUnitTest
= TestUtil
.GetResult()
16 Sub verify_CallByName()
17 Const _Get
= 2, _Let
= 4, _Method
= 1, _Set
= 8
19 On Error GoTo errorHandler
21 ' Basic modules are Objects
22 TestUtil
.AssertEqual(CallByName(TestUtil
, "failCount", _Get
), 0, "CallByName(TestUtil, ""failCount"", _Get")
23 TestUtil
.AssertEqual(CallByName(TestUtil
, "passCount", _Get
), 1, "CallByName(TestUtil, ""passCount"", _Get")
24 TestUtil
.AssertEqual(CallByName(TestUtil
, "GetResult", _Method
), "OK", "CallByName(TestUtil, ""GetResult"", _Method")
26 ' Collection instances
27 Dim c
As New Collection
28 c
.Add(100, "1st") : c
.Add(101)
29 TestUtil
.AssertEqual(CallByName(c
,"Count", _Get
), 2, "CallByName(c,""Count"", _Get)")
31 TestUtil
.AssertEqual(CallByName(callType
:=_Get
, object:=c
, procName
:="Count"), 1, _
32 "CallByName(callType:=_Get, object:=c, procName:=""Count"")")
34 ' ClassModule instances or UNO services are 'CallByNamable' objects too!
35 ' see https://help.libreoffice.org/7.4/en-US/text/sbasic/shared/CallByName.html?DbPAR=BASIC#bm_id3150669
36 ' for more _Let and _Set examples
40 TestUtil
.ReportErrorHandler("verify_CallByName", Err
, Error$, Erl
)