summaryrefslogtreecommitdiffstats
path: root/basic/qa/vba_tests
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:06:44 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-07 09:06:44 +0000
commited5640d8b587fbcfed7dd7967f3de04b37a76f26 (patch)
tree7a5f7c6c9d02226d7471cb3cc8fbbf631b415303 /basic/qa/vba_tests
parentInitial commit. (diff)
downloadlibreoffice-ed5640d8b587fbcfed7dd7967f3de04b37a76f26.tar.xz
libreoffice-ed5640d8b587fbcfed7dd7967f3de04b37a76f26.zip
Adding upstream version 4:7.4.7.upstream/4%7.4.7upstream
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'basic/qa/vba_tests')
-rw-r--r--basic/qa/vba_tests/Err.Raise.vb54
-rw-r--r--basic/qa/vba_tests/abs.vb29
-rw-r--r--basic/qa/vba_tests/array.vb48
-rw-r--r--basic/qa/vba_tests/asc.vb29
-rw-r--r--basic/qa/vba_tests/atn.vb30
-rw-r--r--basic/qa/vba_tests/booltypename.vb47
-rw-r--r--basic/qa/vba_tests/bytearraystring.vb36
-rw-r--r--basic/qa/vba_tests/cbool.vb40
-rw-r--r--basic/qa/vba_tests/cdate.vb28
-rw-r--r--basic/qa/vba_tests/cdbl.vb34
-rw-r--r--basic/qa/vba_tests/cdec.vb41
-rw-r--r--basic/qa/vba_tests/choose.vb31
-rw-r--r--basic/qa/vba_tests/chr.vb31
-rw-r--r--basic/qa/vba_tests/chrw.vb31
-rw-r--r--basic/qa/vba_tests/cint.vb42
-rw-r--r--basic/qa/vba_tests/clng.vb37
-rw-r--r--basic/qa/vba_tests/collection.vb75
-rw-r--r--basic/qa/vba_tests/constants.vb42
-rw-r--r--basic/qa/vba_tests/cos.vb28
-rw-r--r--basic/qa/vba_tests/csng.vb36
-rw-r--r--basic/qa/vba_tests/cstr.vb40
-rw-r--r--basic/qa/vba_tests/cvdate.vb30
-rw-r--r--basic/qa/vba_tests/cverr.vb44
-rw-r--r--basic/qa/vba_tests/data/ADODBdata.xlsbin0 -> 16384 bytes
-rw-r--r--basic/qa/vba_tests/dateadd.vb40
-rw-r--r--basic/qa/vba_tests/datediff.vb45
-rw-r--r--basic/qa/vba_tests/datepart.vb34
-rw-r--r--basic/qa/vba_tests/dateserial.vb28
-rw-r--r--basic/qa/vba_tests/datevalue.vb27
-rw-r--r--basic/qa/vba_tests/day.vb26
-rw-r--r--basic/qa/vba_tests/enum.vb52
-rw-r--r--basic/qa/vba_tests/error.vb27
-rw-r--r--basic/qa/vba_tests/error_message.vb34
-rw-r--r--basic/qa/vba_tests/exp.vb26
-rw-r--r--basic/qa/vba_tests/fix.vb28
-rw-r--r--basic/qa/vba_tests/format.vb186
-rw-r--r--basic/qa/vba_tests/formatnumber.vb31
-rw-r--r--basic/qa/vba_tests/formatpercent.vb31
-rw-r--r--basic/qa/vba_tests/hex.vb31
-rw-r--r--basic/qa/vba_tests/hour.vb28
-rw-r--r--basic/qa/vba_tests/iif.vb31
-rw-r--r--basic/qa/vba_tests/instr.vb45
-rw-r--r--basic/qa/vba_tests/instrrev.vb43
-rw-r--r--basic/qa/vba_tests/int.vb30
-rw-r--r--basic/qa/vba_tests/isarray.vb32
-rw-r--r--basic/qa/vba_tests/isdate.vb28
-rw-r--r--basic/qa/vba_tests/isempty.vb33
-rw-r--r--basic/qa/vba_tests/iserror.vb27
-rw-r--r--basic/qa/vba_tests/ismissing.vb181
-rw-r--r--basic/qa/vba_tests/isnull.vb27
-rw-r--r--basic/qa/vba_tests/isnumeric.vb32
-rw-r--r--basic/qa/vba_tests/isobject.vb31
-rw-r--r--basic/qa/vba_tests/join.vb33
-rw-r--r--basic/qa/vba_tests/lbound.vb28
-rw-r--r--basic/qa/vba_tests/lcase.vb29
-rw-r--r--basic/qa/vba_tests/left.vb28
-rw-r--r--basic/qa/vba_tests/len.vb28
-rw-r--r--basic/qa/vba_tests/log.vb28
-rw-r--r--basic/qa/vba_tests/ltrim.vb26
-rw-r--r--basic/qa/vba_tests/mid.vb28
-rw-r--r--basic/qa/vba_tests/minute.vb26
-rw-r--r--basic/qa/vba_tests/month.vb32
-rw-r--r--basic/qa/vba_tests/monthname.vb28
-rw-r--r--basic/qa/vba_tests/oct.vb28
-rw-r--r--basic/qa/vba_tests/ole_ObjAssignNoDflt.vb30
-rw-r--r--basic/qa/vba_tests/ole_ObjAssignToNothing.vb19
-rw-r--r--basic/qa/vba_tests/optional_paramters.vb208
-rw-r--r--basic/qa/vba_tests/partition.vb30
-rw-r--r--basic/qa/vba_tests/qbcolor.vb34
-rw-r--r--basic/qa/vba_tests/rate.vb31
-rw-r--r--basic/qa/vba_tests/redim_objects.vb42
-rw-r--r--basic/qa/vba_tests/replace.vb37
-rw-r--r--basic/qa/vba_tests/rgb.vb28
-rw-r--r--basic/qa/vba_tests/right.vb28
-rw-r--r--basic/qa/vba_tests/roundcompatibility.vb29
-rw-r--r--basic/qa/vba_tests/rtrim.vb26
-rw-r--r--basic/qa/vba_tests/second.vb27
-rw-r--r--basic/qa/vba_tests/sgn.vb30
-rw-r--r--basic/qa/vba_tests/sin.vb26
-rw-r--r--basic/qa/vba_tests/space.vb26
-rw-r--r--basic/qa/vba_tests/split.vb57
-rw-r--r--basic/qa/vba_tests/sqr.vb26
-rw-r--r--basic/qa/vba_tests/str.vb29
-rw-r--r--basic/qa/vba_tests/strcomp.vb34
-rw-r--r--basic/qa/vba_tests/strconv.vb55
-rw-r--r--basic/qa/vba_tests/string.vb28
-rw-r--r--basic/qa/vba_tests/stringplusdouble.vb243
-rw-r--r--basic/qa/vba_tests/strreverse.vb29
-rw-r--r--basic/qa/vba_tests/switch.vb32
-rw-r--r--basic/qa/vba_tests/tdf147089_idiv.vb31
-rwxr-xr-xbasic/qa/vba_tests/tdf147529_optional_parameters_msgbox.vb37
-rw-r--r--basic/qa/vba_tests/tdf148358_non_ascii_names.vb33
-rw-r--r--basic/qa/vba_tests/timeserial.vb35
-rw-r--r--basic/qa/vba_tests/timevalue.vb28
-rw-r--r--basic/qa/vba_tests/trim.vb26
-rw-r--r--basic/qa/vba_tests/typename.vb69
-rw-r--r--basic/qa/vba_tests/ubound.vb29
-rw-r--r--basic/qa/vba_tests/ucase.vb26
-rw-r--r--basic/qa/vba_tests/val.vb35
-rw-r--r--basic/qa/vba_tests/vartype.vb63
-rw-r--r--basic/qa/vba_tests/weekday.vb31
-rw-r--r--basic/qa/vba_tests/weekdayname.vb33
-rw-r--r--basic/qa/vba_tests/win32compat.vb47
-rw-r--r--basic/qa/vba_tests/win32compatb.vb66
-rw-r--r--basic/qa/vba_tests/year.vb27
105 files changed, 4239 insertions, 0 deletions
diff --git a/basic/qa/vba_tests/Err.Raise.vb b/basic/qa/vba_tests/Err.Raise.vb
new file mode 100644
index 000000000..d7714facb
--- /dev/null
+++ b/basic/qa/vba_tests/Err.Raise.vb
@@ -0,0 +1,54 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+Option Explicit
+
+Function doUnitTest()
+ ''' This routine is QA/…/test_vba.cxx main entry point '''
+ Const MIN_ERR = &hFFFFFFFF : Const MAX_ERR = 2^31-1
+
+ ''' Raise one-to-many User-Defined Errors as signed Int32 '''
+ TestUtil.TestInit()
+ ' test_Description | Err # | Err_Source | Err_Description
+ Call TestErrRaise("MAXimum error value", MAX_ERR, "doUnitTest.vb", "Custom Error Maximum value")
+ Call TestErrRaise("Positive custom error", 1789, "" , "User-Defined Error Number")
+ Call TestErrRaise("Negative custom error", -1793, "doUnitTest.vb", "Negative User-Defined Error Number")
+ Call TestErrRaise("MINimum error value", MIN_ERR, "" , "Custom Error Minimum value")
+
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub TestErrRaise(TestName As String, CurErrNo As Long, CurErrSource As String, CurErrDescription As String)
+ Dim origPassCount As Integer, origFailCount As Integer
+
+try: On Error Goto catch
+ Dim errorHandled As Integer
+ Err.Raise(CurErrNo, CurErrSource, CurErrDescription, "", "")
+
+ TestUtil.Assert(errorHandled = 1, TestName, "error handler did not execute!")
+ TestUtil.Assert(Erl = 0, TestName, "Erl = " & Erl)
+ TestUtil.Assert(Err = 0, TestName, "Err = " & Err)
+ TestUtil.Assert(Error = "", TestName, "Error = " & Error)
+ TestUtil.Assert(Err.Description = "", "Err.Description reset", "Err.Description = "& Err.Description)
+ TestUtil.Assert(Err.Number = 0, "Err.Number reset", "Err.Number = " & Err.Number)
+ TestUtil.Assert(Err.Source = "", "Err.Source reset", "Err.Source = " & Err.Source)
+ Exit Sub
+
+catch:
+ TestUtil.Assert(Err.Number = CurErrNo, "Err.Number failure", "Err.Number = " & Err.Number)
+ TestUtil.Assert(Err.Source = CurErrSource, "Err.Source failure", "Err.Source = " & Err.Source)
+ TestUtil.Assert(Err.Description = CurErrDescription, "Err.Description failure", "Err.Description = " & Err.Description)
+
+ TestUtil.Assert(Erl = 32, "line# failure", "Erl = " & Erl ) ' WATCH OUT for HARDCODED LINE # HERE
+ TestUtil.Assert(Err = CurErrNo, "Err# failure", "Err = " & Err)
+ TestUtil.Assert(Error = CurErrDescription, "Error description failure", "Error$ = " & Error$)
+
+ errorHandled = 1
+ Resume Next ' Err object properties reset from here …
+End Sub
diff --git a/basic/qa/vba_tests/abs.vb b/basic/qa/vba_tests/abs.vb
new file mode 100644
index 000000000..c6f1b8fff
--- /dev/null
+++ b/basic/qa/vba_tests/abs.vb
@@ -0,0 +1,29 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Rem Attribute VBA_ModuleType=VBAModule
+Option VBASupport 1
+Option Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testABS
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testABS()
+ On Error GoTo errorHandler
+
+ TestUtil.AssertEqual(Abs(-5), 5, "Abs(-5)")
+ TestUtil.AssertEqual(Abs(5), 5, "Abs(5)")
+ TestUtil.AssertEqual(Abs(-21.7), 21.7, "Abs(-21.7)")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testABS", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/vba_tests/array.vb b/basic/qa/vba_tests/array.vb
new file mode 100644
index 000000000..608974462
--- /dev/null
+++ b/basic/qa/vba_tests/array.vb
@@ -0,0 +1,48 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Rem Attribute VBA_ModuleType=VBAModule
+Option VBASupport 1
+Option Explicit
+
+Type MyType
+ ax(3) As Integer
+ bx As Double
+End Type
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testARRAY
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testARRAY()
+ On Error GoTo errorHandler
+
+ Dim a
+ a = Array(10, 20, 30)
+ TestUtil.AssertEqual(a(0), 10, "a(0)")
+ TestUtil.AssertEqual(a(1), 20, "a(1)")
+ TestUtil.AssertEqual(a(2), 30, "a(2)")
+
+ Dim MyWeek
+ MyWeek = Array("Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun")
+ TestUtil.AssertEqual(MyWeek(1), "Tue", "MyWeek(1)")
+ TestUtil.AssertEqual(MyWeek(3), "Thu", "MyWeek(3)")
+
+ Dim mt As MyType
+ mt.ax(0) = 42
+ mt.ax(1) = 43
+ mt.bx = 3.14
+ TestUtil.AssertEqual(mt.ax(1), 43, "mt.ax(1)")
+ TestUtil.AssertEqual(mt.bx, 3.14, "mt.bx")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testARRAY", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/vba_tests/asc.vb b/basic/qa/vba_tests/asc.vb
new file mode 100644
index 000000000..8da24e349
--- /dev/null
+++ b/basic/qa/vba_tests/asc.vb
@@ -0,0 +1,29 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Rem Attribute VBA_ModuleType=VBAModule
+Option VBASupport 1
+Option Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testASC
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testASC()
+ On Error GoTo errorHandler
+
+ TestUtil.AssertEqual(Asc("A"), 65, "Asc(""A"")")
+ TestUtil.AssertEqual(Asc("a"), 97, "Asc(""a"")")
+ TestUtil.AssertEqual(Asc("Apple"), 65, "Asc(""Apple"")")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testASC", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/vba_tests/atn.vb b/basic/qa/vba_tests/atn.vb
new file mode 100644
index 000000000..826165e29
--- /dev/null
+++ b/basic/qa/vba_tests/atn.vb
@@ -0,0 +1,30 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+Option Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testATN
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testATN()
+ On Error GoTo errorHandler
+
+ TestUtil.AssertEqualApprox(Atn(2), 1.10714871779409, 1E-14, "Atn(2)")
+ TestUtil.AssertEqualApprox(Atn(2.51), 1.19166451926354, 1E-14, "Atn(2.51)")
+ TestUtil.AssertEqualApprox(Atn(-3.25), -1.27229739520872, 1E-14, "Atn(-3.25)")
+ TestUtil.AssertEqualApprox(Atn(210), 1.56603445802574, 1E-14, "Atn(210)")
+ TestUtil.AssertEqual (Atn(0), 0, "Atn(0)")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testATN", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/vba_tests/booltypename.vb b/basic/qa/vba_tests/booltypename.vb
new file mode 100644
index 000000000..202c2370e
--- /dev/null
+++ b/basic/qa/vba_tests/booltypename.vb
@@ -0,0 +1,47 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+Option Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testTypeNameBoolean
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testTypeNameBoolean()
+ On Error GoTo errorHandler
+
+ TestUtil.AssertEqual(TypeName(1>2), "Boolean", "TypeName(1>2)")
+ TestUtil.AssertEqual(TypeName(2.0>1.0), "Boolean", "TypeName(2.0>1.0)")
+ TestUtil.AssertEqual(TypeName("A">"B"), "Boolean", "TypeName(""A"">""B"")")
+
+ TestUtil.AssertEqual(Str(2>1), "True", "Str(2>1)")
+ TestUtil.AssertEqual(Str(1>2), "False", "Str(1>2)")
+
+ TestUtil.AssertEqual(Str(2.0>1.0), "True", "Str(2.0>1.0)")
+ TestUtil.AssertEqual(Str(1.0>2.0), "False", "Str(1.0>2.0)")
+
+ TestUtil.AssertEqual(Str("B">"A"), "True", "Str(""B"">""A"")")
+ TestUtil.AssertEqual(Str("A">"B"), "False", "Str(""A"">""B"")")
+
+ ' tdf#145960 - return type of boolean operators should be of type boolean
+ TestUtil.AssertEqual(TypeName(True Mod True), "Long", "TypeName(True Mod True)")
+ TestUtil.AssertEqual(TypeName(True \ True), "Long", "TypeName(True \ True)")
+ TestUtil.AssertEqual(TypeName(True And True), "Boolean", "TypeName(True And True)")
+ TestUtil.AssertEqual(TypeName(True Or True), "Boolean", "TypeName(True Or True)")
+ TestUtil.AssertEqual(TypeName(True Xor True), "Boolean", "TypeName(True Xor True)")
+ TestUtil.AssertEqual(TypeName(True Eqv True), "Boolean", "TypeName(True Eqv True)")
+ TestUtil.AssertEqual(TypeName(True Imp True), "Boolean", "TypeName(True Imp True)")
+ TestUtil.AssertEqual(TypeName(Not True), "Boolean", "TypeName(Not True)")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testTypeNameBoolean", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/vba_tests/bytearraystring.vb b/basic/qa/vba_tests/bytearraystring.vb
new file mode 100644
index 000000000..621871693
--- /dev/null
+++ b/basic/qa/vba_tests/bytearraystring.vb
@@ -0,0 +1,36 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+Option Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_ByteArrayString
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_ByteArrayString()
+ Dim MyString As String
+ Dim x() As Byte
+
+ On Error GoTo errorHandler
+
+ MyString = "abc"
+ x = MyString ' string -> byte array
+
+ ' test bytes in string
+ TestUtil.AssertEqual(UBound(x), 5, "UBound(x)")
+
+ MyString = x 'byte array -> string
+ TestUtil.AssertEqual(MyString, "abc", "MyString")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_ByteArrayString", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/vba_tests/cbool.vb b/basic/qa/vba_tests/cbool.vb
new file mode 100644
index 000000000..54334a23e
--- /dev/null
+++ b/basic/qa/vba_tests/cbool.vb
@@ -0,0 +1,40 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+Option Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testCBool
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testCBool()
+ On Error GoTo errorHandler
+
+ TestUtil.AssertEqual(CBool(1), True, "CBool(1)")
+ TestUtil.AssertEqual(CBool(1 = 2), False, "CBool(1 = 2)")
+ TestUtil.AssertEqual(CBool(0), False, "CBool(0)")
+ TestUtil.AssertEqual(CBool(21), True, "CBool(21)")
+ TestUtil.AssertEqual(CBool("true"), True, "CBool(""true"")")
+ TestUtil.AssertEqual(CBool("false"), False, "CBool(""false"")")
+ TestUtil.AssertEqual(CBool("1"), True, "CBool(""1"")")
+ TestUtil.AssertEqual(CBool("-1"), True, "CBool(""-1"")")
+ TestUtil.AssertEqual(CBool("0"), False, "CBool(""0"")")
+
+ Dim a1, a2 As Integer
+ a1 = 1: a2 = 10
+ TestUtil.AssertEqual(CBool(a1 = a2), False, "CBool(a1 = a2)")
+ a1 = 10: a2 = 10
+ TestUtil.AssertEqual(CBool(a1 = a2), True, "CBool(a1 = a2)")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testCBool", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/vba_tests/cdate.vb b/basic/qa/vba_tests/cdate.vb
new file mode 100644
index 000000000..227c29d0f
--- /dev/null
+++ b/basic/qa/vba_tests/cdate.vb
@@ -0,0 +1,28 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+Option Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testCDate
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testCDate()
+ On Error GoTo errorHandler
+
+ TestUtil.AssertEqual(CDate("12/02/1969"), 25246, "CDate(""12/02/1969"")")
+ TestUtil.AssertEqual(CDate("07/07/1977"), 28313, "CDate(""07/07/1977"")")
+ TestUtil.AssertEqual(CDate(#7/7/1977#), 28313, "CDate(#7/7/1977#)")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testCDate", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/vba_tests/cdbl.vb b/basic/qa/vba_tests/cdbl.vb
new file mode 100644
index 000000000..8a7d09cd5
--- /dev/null
+++ b/basic/qa/vba_tests/cdbl.vb
@@ -0,0 +1,34 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+Option Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testCdbl
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testCdbl()
+ On Error GoTo errorHandler
+
+ TestUtil.AssertEqual(CDbl(0), 0, "CDbl(0)")
+ TestUtil.AssertEqual(CDbl(10.1234567890123), 10.1234567890123, "CDbl(10.1234567890123)")
+ TestUtil.AssertEqual(CDbl(0.005 * 0.01), 0.00005, "CDbl(0.005 * 0.01)")
+ TestUtil.AssertEqual(CDbl("20"), 20, "CDbl(""20"")")
+
+
+ ' tdf#146672 - skip spaces and tabs at the end of the scanned string
+ TestUtil.AssertEqual(CDbl("28.8 "), 28.8, "CDbl(""28.8 "")")
+ TestUtil.AssertEqual(CDbl("28.8 "), 28.8, "CDbl(""28.8 "")")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testCdbl", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/vba_tests/cdec.vb b/basic/qa/vba_tests/cdec.vb
new file mode 100644
index 000000000..043625683
--- /dev/null
+++ b/basic/qa/vba_tests/cdec.vb
@@ -0,0 +1,41 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+Option Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testCDec
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testCDec()
+ On Error GoTo errorHandler
+
+ TestUtil.AssertEqual(CDec(""), 0, "CDec("""")")
+ TestUtil.AssertEqual(CDec("1234"), 1234, "CDec(""1234"")")
+ TestUtil.AssertEqual(CDec(" 1234 "), 1234, "CDec("" 1234 "")")
+ TestUtil.AssertEqual(CDec("-1234"), -1234, "CDec(""-1234"")")
+ TestUtil.AssertEqual(CDec(" - 1234 "), -1234, "CDec("" - 1234 "")")
+
+ '''''''''''''''
+ ' Those are erroneous, see i#64348
+ TestUtil.AssertEqual(CDec("1234-"), -1234, "CDec(""1234-"")")
+ TestUtil.AssertEqual(CDec(" 1234 -"), -1234, "CDec("" 1234 -"")")
+
+ 'TestUtil.AssertEqual(CDec("79228162514264300000000000001"), 79228162514264300000000000001, "CDec(""79228162514264300000000000001"")")
+ 'TestUtil.AssertEqual(CDec("79228162514264300000000000001") + 1, 79228162514264300000000000002, "CDec(""79228162514264300000000000001"") + 1")
+
+ TestUtil.AssertEqual(CDec("79228162514264400000000000000"), 62406456049664, "CDec(""79228162514264400000000000000"")")
+ TestUtil.AssertEqual(CDec("79228162514264340000000000000"), 0, "CDec(""79228162514264340000000000000"")")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testCDec", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/vba_tests/choose.vb b/basic/qa/vba_tests/choose.vb
new file mode 100644
index 000000000..b258af984
--- /dev/null
+++ b/basic/qa/vba_tests/choose.vb
@@ -0,0 +1,31 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+Option Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testChoose
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testChoose()
+ On Error GoTo errorHandler
+
+ TestUtil.AssertEqual(Choose(1, "Libre", "Office", "Suite"), "Libre", "Choose(1, ""Libre"", ""Office"", ""Suite"")")
+ TestUtil.AssertEqual(Choose(2, "Libre", "Office", "Suite"), "Office", "Choose(2, ""Libre"", ""Office"", ""Suite"")")
+ TestUtil.AssertEqual(Choose(3, "Libre", "Office", "Suite"), "Suite", "Choose(3, ""Libre"", ""Office"", ""Suite"")")
+ TestUtil.Assert(IsNull(Choose(4, "Libre", "Office", "Suite")), "IsNull(Choose(4, ""Libre"", ""Office"", ""Suite""))")
+ TestUtil.Assert(IsNull(Choose(0, "Libre", "Office", "Suite")), "IsNull(Choose(0, ""Libre"", ""Office"", ""Suite""))")
+ TestUtil.Assert(IsNull(Choose(-1, "Libre", "Office", "Suite")), "IsNull(Choose(-1, ""Libre"", ""Office"", ""Suite""))")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testChoose", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/vba_tests/chr.vb b/basic/qa/vba_tests/chr.vb
new file mode 100644
index 000000000..5dc85a0c9
--- /dev/null
+++ b/basic/qa/vba_tests/chr.vb
@@ -0,0 +1,31 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+Option Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testCHR
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testCHR()
+ On Error GoTo errorHandler
+
+ TestUtil.AssertEqual(Chr(87), "W", "Chr(87)")
+ TestUtil.AssertEqual(Chr(105), "i", "Chr(105)")
+ TestUtil.AssertEqual(Chr(35), "#", "Chr(35)")
+
+ ' tdf#145693 - argument name should be 'charcode' instead of 'string'
+ TestUtil.AssertEqual(Chr(charcode:=35), "#", "Chr(charcode:=35)")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testCHR", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/vba_tests/chrw.vb b/basic/qa/vba_tests/chrw.vb
new file mode 100644
index 000000000..47bd28d7e
--- /dev/null
+++ b/basic/qa/vba_tests/chrw.vb
@@ -0,0 +1,31 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+Option Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testCHRW
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testCHRW()
+ On Error GoTo errorHandler
+
+ TestUtil.AssertEqual(ChrW(87), "W", "ChrW(87)")
+ TestUtil.AssertEqual(ChrW(105), "i", "ChrW(105)")
+ TestUtil.AssertEqual(ChrW(35), "#", "ChrW(35)")
+
+ ' tdf#145693 - argument name should be 'charcode' instead of 'string'
+ TestUtil.AssertEqual(ChrW(charcode:=35), "#", "ChrW(charcode:=35)")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testCHRW", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/vba_tests/cint.vb b/basic/qa/vba_tests/cint.vb
new file mode 100644
index 000000000..42e41e535
--- /dev/null
+++ b/basic/qa/vba_tests/cint.vb
@@ -0,0 +1,42 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+Option Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testCInt
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testCInt()
+ On Error GoTo errorHandler
+
+ TestUtil.AssertEqual(CInt(-1.1), -1, "CInt(-1.1)")
+ TestUtil.AssertEqual(CInt(-1.1), -1, "CInt(-1.1)")
+ TestUtil.AssertEqual(CInt(-1.9), -2, "CInt(-1.9)")
+ TestUtil.AssertEqual(CInt(0.2), 0, "CInt(0.2)")
+
+REM In excel:
+REM If the fraction is less than or equal to .5, the result will round down.
+REM If the fraction is greater than .5, the result will round up.
+
+REM TestUtil.AssertEqual(CInt(0.5), 0, "CInt(0.5)")
+REM TestUtil.AssertEqual(CInt(1.5), 2, "CInt(1.5)")
+REM TestUtil.AssertEqual(CInt(2.5), 2, "CInt(2.5)")
+
+ TestUtil.AssertEqual(CInt(10.51), 11, "CInt(10.51)")
+ TestUtil.AssertEqual(CInt("&H75FF"), 30207, "CInt(""&H75FF"")")
+ TestUtil.AssertEqual(CInt("&H754"), 1876, "CInt(""&H754"")")
+ TestUtil.AssertEqual(CInt("+21"), 21, "CInt(""+21"")")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testCInt", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/vba_tests/clng.vb b/basic/qa/vba_tests/clng.vb
new file mode 100644
index 000000000..ae9421686
--- /dev/null
+++ b/basic/qa/vba_tests/clng.vb
@@ -0,0 +1,37 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+Option Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testCLng
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testCLng()
+ On Error GoTo errorHandler
+
+ TestUtil.AssertEqual(CLng(-1.1), -1, "CLng(-1.1)")
+ TestUtil.AssertEqual(CLng(-1.9), -2, "CLng(-1.9)")
+ TestUtil.AssertEqual(CLng(0.2), 0, "CLng(0.2)")
+
+REM TestUtil.AssertEqual(CLng(0.5), 0, "CLng(0.5)")
+
+REM If the fraction is less than or equal to .5, the result will round down.
+REM If the fraction is greater than .5, the result will round up.
+
+ TestUtil.AssertEqual(CLng(10.51), 11, "CLng(10.51)")
+ TestUtil.AssertEqual(CLng("&H75FF"), 30207, "CLng(""&H75FF"")")
+ TestUtil.AssertEqual(CLng("&H754"), 1876, "CLng(""&H754"")")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testCLng", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/vba_tests/collection.vb b/basic/qa/vba_tests/collection.vb
new file mode 100644
index 000000000..774f3c4c7
--- /dev/null
+++ b/basic/qa/vba_tests/collection.vb
@@ -0,0 +1,75 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+Option Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testCollection
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testCollection()
+
+ Dim a As Collection
+ Dim b As Collection
+
+ On Error Resume Next
+ Set a = New Collection
+ a.Add 1, "D"
+ a.Add 2, "d"
+ a.Add 3, "Д" ' uppercase Cyrillic script De
+ a.Add 4, "д" ' lowercase Cyrillic script De
+ On Error GoTo 0
+
+ On Error Resume Next
+ Set b = New Collection
+ b.Add 1, "SS"
+ b.Add 2, "ss"
+ b.Add 3, "ẞ" ' uppercase German Eszett
+ b.Add 4, "ß" ' lowercase German Eszett
+ On Error GoTo 0
+
+ On Error GoTo errorHandler
+
+ ' tdf#144245 - case-insensitive operation for non-ASCII characters
+ ' Without the fix in place, this test would have failed with
+ ' - Expected: 2
+ ' - Actual : 3
+ TestUtil.AssertEqual(a.Count, 2, "a.Count")
+
+ ' tdf#144245 - case-insensitive operation for non-ASCII item access
+ ' Without the fix in place, this test would have failed with
+ ' - Expected: 1 for d, 3 for lowercase Cyrillic script De (д)
+ ' - Actual : 2 for d, 4 for lowercase Cyrillic script De (д)
+ TestUtil.AssertEqual(a.Item("D"), 1, "a.Item(""D"")")
+ TestUtil.AssertEqual(a.Item("d"), 1, "a.Item(""d"")")
+ TestUtil.AssertEqual(a.Item("Д"), 3, "a.Item(""Д"")")
+ TestUtil.AssertEqual(a.Item("д"), 3, "a.Item(""д"")")
+
+ ' tdf#144245 - German Eszett is uppercased to a two-character 'SS'.
+ ' This test should fail after tdf#110003 has been fixed since the lowercase and the uppercase
+ ' German Eszett should be matched to the same index.
+ ' Before the fix of tdf#110003
+ 'TestUtil.AssertEqual(b.Count, 3, "b.Count")
+ ' After the fix of tdf#110003
+ TestUtil.AssertEqual(b.Count, 2, "b.Count")
+
+ TestUtil.AssertEqual(b.Item("SS"), 1, "b.Item(""SS"")")
+ TestUtil.AssertEqual(b.Item("ss"), 1, "b.Item(""ss"")")
+ TestUtil.AssertEqual(b.Item("ẞ"), 3, "b.Item(""ẞ"")")
+ ' Before the fix of tdf#110003
+ 'TestUtil.AssertEqual(b.Item("ß"), 4, "b.Item(""ß"")")
+ ' After the fix of tdf#110003
+ TestUtil.AssertEqual(b.Item("ß"), 3, "b.Item(""ß"")")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testCollection", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/vba_tests/constants.vb b/basic/qa/vba_tests/constants.vb
new file mode 100644
index 000000000..be7add515
--- /dev/null
+++ b/basic/qa/vba_tests/constants.vb
@@ -0,0 +1,42 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+Option Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testConstants
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testConstants()
+ On Error GoTo errorHandler
+
+ ' vbNewLine is the same as vbCrLf on Windows, and the same as vbLf on other OSes
+ If GetGuiType() = 1 Then
+ TestUtil.AssertEqual(vbNewline, vbCrLf, "vbNewline")
+ Else
+ TestUtil.AssertEqual(vbNewLine, vbLf, "vbNewline")
+ End If
+
+ ' tdf#131563 - check for vba color constants
+ ' See https://docs.microsoft.com/en-us/office/vba/language/reference/user-interface-help/color-constants
+ TestUtil.AssertEqual(vbBlack, RGB(0, 0, 0), "vbBlack")
+ TestUtil.AssertEqual(vbRed, RGB(255, 0, 0), "vbRed")
+ TestUtil.AssertEqual(vbGreen, RGB(0, 255, 0), "vbGreen")
+ TestUtil.AssertEqual(vbYellow, RGB(255, 255, 0), "vbYellow")
+ TestUtil.AssertEqual(vbBlue, RGB(0, 0, 255), "vbBlue")
+ TestUtil.AssertEqual(vbMagenta, RGB(255, 0, 255), "vbMagenta")
+ TestUtil.AssertEqual(vbCyan, RGB(0, 255, 255), "vbCyan")
+ TestUtil.AssertEqual(vbWhite, RGB(255, 255, 255), "vbWhite")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testConstants", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/vba_tests/cos.vb b/basic/qa/vba_tests/cos.vb
new file mode 100644
index 000000000..2dc88df31
--- /dev/null
+++ b/basic/qa/vba_tests/cos.vb
@@ -0,0 +1,28 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+Option Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testCOS
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testCOS()
+ On Error GoTo errorHandler
+
+ TestUtil.AssertEqualApprox(Cos(23), -0.532833020333398, 1E-14, "Cos(23)")
+ TestUtil.AssertEqualApprox(Cos(0.2), 0.980066577841242, 1E-14, "Cos(0.2)")
+ TestUtil.AssertEqualApprox(Cos(200), 0.487187675007006, 1E-14, "Cos(200)")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testCOS", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/vba_tests/csng.vb b/basic/qa/vba_tests/csng.vb
new file mode 100644
index 000000000..3e18d0282
--- /dev/null
+++ b/basic/qa/vba_tests/csng.vb
@@ -0,0 +1,36 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+Option Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testCSng
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testCSng()
+ Dim nr1 As Single 'variables for test
+ Dim nr2 As Double
+ On Error GoTo errorHandler
+
+ nr1 = 8.534535408
+ TestUtil.AssertEqual(CSng(8.534535408), nr1, "CSng(8.534535408)")
+
+ nr2 = 100.1234
+ nr1 = 100.1234
+ TestUtil.AssertEqual(CSng(nr2), nr1, "CSng(nr2)")
+
+ nr1 = 0
+ TestUtil.AssertEqual(CSng(0), nr1, "CSng(0)")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testCSng", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/vba_tests/cstr.vb b/basic/qa/vba_tests/cstr.vb
new file mode 100644
index 000000000..5eb43738f
--- /dev/null
+++ b/basic/qa/vba_tests/cstr.vb
@@ -0,0 +1,40 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+Option Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testCStr
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testCStr()
+ On Error GoTo errorHandler
+
+ Dim n
+ n = 437.324
+ TestUtil.AssertEqual(CStr(n), "437.324", "CStr(n)")
+ TestUtil.AssertEqual(CStr(500), "500", "CStr(500)")
+
+ ' tdf#143575 - round string to their nearest double representation
+ ' N.B.: check also how current conversion rounds a close number
+ ' Without the fix in place, this test would have failed with:
+ ' - Expected: 691.2
+ ' - Actual : 691.2000000000001
+ TestUtil.AssertEqual(CStr(691.2), "691.2", "CStr(691.2)")
+ ' Without the fix in place, this test would have failed with:
+ ' - Expected: 691.2
+ ' - Actual : 691.1999999999999
+ TestUtil.AssertEqual(CStr(123.4 + 567.8), "691.2", "CStr(123.4 + 567.8)")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testCStr", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/vba_tests/cvdate.vb b/basic/qa/vba_tests/cvdate.vb
new file mode 100644
index 000000000..0b71d7fe9
--- /dev/null
+++ b/basic/qa/vba_tests/cvdate.vb
@@ -0,0 +1,30 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+Option Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testCVDate
+ ' SKIPPED test due to CVDate not being available
+ 'doUnitTest = TestUtil.GetResult()
+ doUnitTest = "OK"
+End Function
+
+Sub verify_testCVDate()
+ On Error GoTo errorHandler
+
+ TestUtil.AssertEqual(CVDate("12.2.1969"), 25246, "CVDate(""12.2.1969"")")
+ TestUtil.AssertEqual(CVDate("07/07/1977"), 28313, "CVDate(""07/07/1977"")")
+ TestUtil.AssertEqual(CVDate(#7/7/1977#), 28313, "CVDate(#7/7/1977#)")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testCVDate", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/vba_tests/cverr.vb b/basic/qa/vba_tests/cverr.vb
new file mode 100644
index 000000000..3a314de76
--- /dev/null
+++ b/basic/qa/vba_tests/cverr.vb
@@ -0,0 +1,44 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+Option Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testCVErr
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testCVErr()
+ On Error GoTo errorHandler
+
+ TestUtil.AssertEqual(CStr(CVErr(3001)), "Error 3001", "CStr(CVErr(3001))")
+ TestUtil.AssertEqual(CStr(CVErr(xlErrDiv0)), "Error 2007", "CStr(CVErr(xlErrDiv0))")
+ TestUtil.AssertEqual(CStr(CVErr(xlErrNA)), "Error 2042", "CStr(CVErr(xlErrNA))")
+ TestUtil.AssertEqual(CStr(CVErr(xlErrName)), "Error 2029", "CStr(CVErr(xlErrName))")
+ TestUtil.AssertEqual(CStr(CVErr(xlErrNull)), "Error 2000", "CStr(CVErr(xlErrNull))")
+ TestUtil.AssertEqual(CStr(CVErr(xlErrNum)), "Error 2036", "CStr(CVErr(xlErrNum))")
+ TestUtil.AssertEqual(CStr(CVErr(xlErrRef)), "Error 2023", "CStr(CVErr(xlErrRef))")
+ TestUtil.AssertEqual(CStr(CVErr(xlErrValue)), "Error 2015", "CStr(CVErr(xlErrValue))")
+
+ ' tdf#79426 - passing an error object to a function
+ TestUtil.AssertEqual(TestCVErr(CVErr(2)), 2, "TestCVErr(CVErr(2))")
+ ' tdf#79426 - test with Error-Code 448 ( ERRCODE_BASIC_NAMED_NOT_FOUND )
+ TestUtil.AssertEqual(TestCVErr(CVErr(448)), 448, "TestCVErr(CVErr(448))")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testCVErr", Err, Error$, Erl)
+End Sub
+
+Function TestCVErr(vErr As Variant)
+ Dim nValue As Integer
+ nValue = vErr
+ TestCVErr = nValue
+End Function
diff --git a/basic/qa/vba_tests/data/ADODBdata.xls b/basic/qa/vba_tests/data/ADODBdata.xls
new file mode 100644
index 000000000..655b38a90
--- /dev/null
+++ b/basic/qa/vba_tests/data/ADODBdata.xls
Binary files differ
diff --git a/basic/qa/vba_tests/dateadd.vb b/basic/qa/vba_tests/dateadd.vb
new file mode 100644
index 000000000..8b0e6312e
--- /dev/null
+++ b/basic/qa/vba_tests/dateadd.vb
@@ -0,0 +1,40 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+Option Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testDateAdd
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testDateAdd()
+ On Error GoTo errorHandler
+
+ TestUtil.AssertEqual(DateAdd("m", 1, "1995-01-31"), CDate("1995-02-28"), "DateAdd(""m"", 1, ""1995-01-31"")")
+ TestUtil.AssertEqual(DateAdd("m", 1, "1995-01-31"), CDate("1995-02-28"), "DateAdd(""m"", 1, ""1995-01-31"")")
+ TestUtil.AssertEqual(DateAdd("m", 1, "1995-01-31"), CDate("1995-02-28"), "DateAdd(""m"", 1, ""1995-01-31"")")
+ TestUtil.AssertEqual(DateAdd("yyyy", 1, "1995-01-31"), CDate("1996-01-31"), "DateAdd(""yyyy"", 1, ""1995-01-31"")")
+ TestUtil.AssertEqual(DateAdd("q", 1, "1995-01-31"), CDate("1995-04-30"), "DateAdd(""q"", 1, ""1995-01-31"")")
+ TestUtil.AssertEqual(DateAdd("y", 1, "1995-01-31"), CDate("1995-02-01"), "DateAdd(""y"", 1, ""1995-01-31"")")
+ TestUtil.AssertEqual(DateAdd("d", 1, "1995-01-31"), CDate("1995-02-01"), "DateAdd(""d"", 1, ""1995-01-31"")")
+ TestUtil.AssertEqual(DateAdd("w", 1, "1995-01-31"), CDate("1995-02-01"), "DateAdd(""w"", 1, ""1995-01-31"")")
+ TestUtil.AssertEqual(DateAdd("ww", 1, "1995-01-31"), CDate("1995-02-07"), "DateAdd(""ww"", 1, ""1995-01-31"")")
+
+Rem This fails when directly comparing using AssertEqual, probably due to rounding.
+ TestUtil.AssertEqualApprox(DateAdd("h", 1, "1995-01-01 21:48:29"), CDate("1995-01-01 22:48:29"), 1E-10, "DateAdd(""h"", 1, ""1995-01-01 21:48:29"")")
+
+ TestUtil.AssertEqual(DateAdd("n", 1, "1995-01-31 21:48:29"), CDate("1995-01-31 21:49:29"), "DateAdd(""n"", 1, ""1995-01-31 21:48:29"")")
+ TestUtil.AssertEqual(DateAdd("s", 1, "1995-01-31 21:48:29"), CDate("1995-01-31 21:48:30"), "DateAdd(""s"", 1, ""1995-01-31 21:48:29"")")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testDateAdd", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/vba_tests/datediff.vb b/basic/qa/vba_tests/datediff.vb
new file mode 100644
index 000000000..01b798a33
--- /dev/null
+++ b/basic/qa/vba_tests/datediff.vb
@@ -0,0 +1,45 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+Option Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testDateDiff
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testDateDiff()
+ On Error GoTo errorHandler
+
+ TestUtil.AssertEqual(DateDiff("yyyy", "22/11/2003", "22/11/2013"), 10, "DateDiff(""yyyy"", ""22/11/2003"", ""22/11/2013"")")
+ TestUtil.AssertEqual(DateDiff("q", "22/11/2003", "22/11/2013"), 40, "DateDiff(""q"", ""22/11/2003"", ""22/11/2013"")")
+ TestUtil.AssertEqual(DateDiff("m", "22/11/2003", "22/11/2013"), 120, "DateDiff(""m"", ""22/11/2003"", ""22/11/2013"")")
+ TestUtil.AssertEqual(DateDiff("y", "22/11/2003", "22/11/2013"), 3653, "DateDiff(""y"", ""22/11/2003"", ""22/11/2013"")")
+ TestUtil.AssertEqual(DateDiff("d", "22/11/2003", "22/11/2013"), 3653, "DateDiff(""d"", ""22/11/2003"", ""22/11/2013"")")
+ TestUtil.AssertEqual(DateDiff("w", "22/11/2003", "22/11/2013"), 521, "DateDiff(""w"", ""22/11/2003"", ""22/11/2013"")")
+ TestUtil.AssertEqual(DateDiff("ww", "22/11/2003", "22/11/2013"), 522, "DateDiff(""ww"", ""22/11/2003"", ""22/11/2013"")")
+ TestUtil.AssertEqual(DateDiff("h", "22/11/2003", "22/11/2013"), 87672, "DateDiff(""h"", ""22/11/2003"", ""22/11/2013"")")
+ TestUtil.AssertEqual(DateDiff("n", "22/11/2012", "22/11/2013"), 525600, "DateDiff(""n"", ""22/11/2012"", ""22/11/2013"")")
+ TestUtil.AssertEqual(DateDiff("s", "22/10/2013", "22/11/2013"), 2678400, "DateDiff(""s"", ""22/10/2013"", ""22/11/2013"")")
+ TestUtil.AssertEqual(DateDiff("d", "22/11/2003", "22/11/2013", vbFriday), 3653, "DateDiff(""d"", ""22/11/2003"", ""22/11/2013"", vbFriday)")
+ TestUtil.AssertEqual(DateDiff("d", "22/11/2003", "22/11/2013", vbMonday), 3653, "DateDiff(""d"", ""22/11/2003"", ""22/11/2013"", vbMonday)")
+ TestUtil.AssertEqual(DateDiff("d", "22/12/2003", "22/11/2013", vbSaturday), 3623, "DateDiff(""d"", ""22/12/2003"", ""22/11/2013"", vbSaturday)")
+ TestUtil.AssertEqual(DateDiff("d", "22/10/2003", "22/11/2013", vbSunday), 3684, "DateDiff(""d"", ""22/10/2003"", ""22/11/2013"", vbSunday)")
+ TestUtil.AssertEqual(DateDiff("d", "22/11/2003", "22/11/2013", vbThursday), 3653, "DateDiff(""d"", ""22/11/2003"", ""22/11/2013"", vbThursday)")
+ TestUtil.AssertEqual(DateDiff("d", "22/11/2003", "22/11/2013", vbTuesday), 3653, "DateDiff(""d"", ""22/11/2003"", ""22/11/2013"", vbTuesday)")
+ TestUtil.AssertEqual(DateDiff("d", "22/11/2003", "22/11/2013", vbFriday, vbFirstJan1), 3653, "DateDiff(""d"", ""22/11/2003"", ""22/11/2013"", vbFriday, vbFirstJan1)")
+ TestUtil.AssertEqual(DateDiff("d", "22/11/2003", "22/11/2013", vbThursday, vbFirstFourDays), 3653, "DateDiff(""d"", ""22/11/2003"", ""22/11/2013"", vbThursday, vbFirstFourDays)")
+ TestUtil.AssertEqual(DateDiff("d", "22/11/2003", "22/11/2013", vbSunday, vbFirstFullWeek), 3653, "DateDiff(""d"", ""22/11/2003"", ""22/11/2013"", vbSunday, vbFirstFullWeek)")
+ TestUtil.AssertEqual(DateDiff("d", "22/11/2003", "22/11/2013", vbSaturday, vbFirstFullWeek), 3653, "DateDiff(""d"", ""22/11/2003"", ""22/11/2013"", vbSaturday, vbFirstFullWeek)")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testDateDiff", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/vba_tests/datepart.vb b/basic/qa/vba_tests/datepart.vb
new file mode 100644
index 000000000..28989c27a
--- /dev/null
+++ b/basic/qa/vba_tests/datepart.vb
@@ -0,0 +1,34 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+Option Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testDatePart
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testDatePart()
+ On Error GoTo errorHandler
+
+ TestUtil.AssertEqual(DatePart("yyyy", "1969-02-12"), 1969, "DatePart(""yyyy"", ""1969-02-12"")")
+ TestUtil.AssertEqual(DatePart("q", "1969-02-12"), 1, "DatePart(""q"", ""1969-02-12"")")
+ TestUtil.AssertEqual(DatePart("y", "1969-02-12"), 43, "DatePart(""y"", ""1969-02-12"")")
+ TestUtil.AssertEqual(DatePart("d", "1969-02-12"), 12, "DatePart(""d"", ""1969-02-12"")")
+ TestUtil.AssertEqual(DatePart("w", "1969-02-12"), 4, "DatePart(""w"", ""1969-02-12"")")
+ TestUtil.AssertEqual(DatePart("ww", "1969-02-12"), 7, "DatePart(""ww"", ""1969-02-12"")")
+ TestUtil.AssertEqual(DatePart("h", "1969-02-12 16:32:00"), 16, "DatePart(""h"", ""1969-02-12 16:32:00"")")
+ TestUtil.AssertEqual(DatePart("n", "1969-02-12 16:32:00"), 32, "DatePart(""n"", ""1969-02-12 16:32:00"")")
+ TestUtil.AssertEqual(DatePart("s", "1969-02-12 16:32:00"), 0, "DatePart(""s"", ""1969-02-12 16:32:00"")")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testDatePart", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/vba_tests/dateserial.vb b/basic/qa/vba_tests/dateserial.vb
new file mode 100644
index 000000000..8e961aefb
--- /dev/null
+++ b/basic/qa/vba_tests/dateserial.vb
@@ -0,0 +1,28 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+Option Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testDateSerial
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testDateSerial()
+ On Error GoTo errorHandler
+
+ TestUtil.AssertEqual(DateSerial(1999, 6, 15), 36326, "DateSerial(1999, 6, 15)")
+ TestUtil.AssertEqual(DateSerial(2000, 1 - 7, 15), 36326, "DateSerial(2000, 1 - 7, 15)")
+ TestUtil.AssertEqual(DateSerial(1999, 1, 166), 36326, "DateSerial(1999, 1, 166)")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testDateSerial", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/vba_tests/datevalue.vb b/basic/qa/vba_tests/datevalue.vb
new file mode 100644
index 000000000..e433eba46
--- /dev/null
+++ b/basic/qa/vba_tests/datevalue.vb
@@ -0,0 +1,27 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+Option Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testDateValue
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Function verify_testDateValue() as String
+ On Error GoTo errorHandler
+
+ TestUtil.AssertEqual(DateValue("February 12, 1969"), 25246, "DateValue(""February 12, 1969"")")
+ TestUtil.AssertEqual(DateValue("21/01/2008"), 39468, "DateValue(""21/01/2008"")")
+
+ Exit Function
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testFix", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/vba_tests/day.vb b/basic/qa/vba_tests/day.vb
new file mode 100644
index 000000000..525ad455c
--- /dev/null
+++ b/basic/qa/vba_tests/day.vb
@@ -0,0 +1,26 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+Option Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testday
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testday()
+ On Error GoTo errorHandler
+
+ TestUtil.AssertEqual(Day("1969-02-12"), 12, "Day(""1969-02-12"")")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testday", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/vba_tests/enum.vb b/basic/qa/vba_tests/enum.vb
new file mode 100644
index 000000000..72f0c4fb8
--- /dev/null
+++ b/basic/qa/vba_tests/enum.vb
@@ -0,0 +1,52 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+Option Explicit
+
+Enum CountDown ' Values get ROUNDED to Int32
+ FIVE = 4.11
+ FOUR = -4.25
+ THREE = 5
+ TWO = -.315E1
+ ONE = 286.0E-2 ' equals 3
+ LIFT_OFF = 7
+End Enum ' CountDown
+
+Function doUnitTest()
+ ''' test_vba.cxx main entry point '''
+ TestUtil.TestInit
+ Call ENUM_TestCases
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub ENUM_TestCases()
+try:
+ On Error Goto catch
+
+ With CountDown
+
+a: TestUtil.AssertEqual(.ONE, 3, ".ONE")
+
+b: TestUtil.AssertEqual(.TWO, -3, ".TWO")
+
+c: TestUtil.AssertEqual(TypeName(.FOUR), "Long", "TypeName(.FOUR)")
+
+d: Dim sum As Double
+ sum = .FIVE + .FOUR + .THREE + .TWO + .ONE + .LIFT_OFF
+ TestUtil.AssertEqual(sum, 12, "sum")
+
+ End With
+
+finally:
+ Exit Sub
+
+catch:
+ TestUtil.ReportErrorHandler("ENUM_TestCases", Err, Error$, Erl)
+ Resume Next
+End Sub
diff --git a/basic/qa/vba_tests/error.vb b/basic/qa/vba_tests/error.vb
new file mode 100644
index 000000000..9b10ff8ff
--- /dev/null
+++ b/basic/qa/vba_tests/error.vb
@@ -0,0 +1,27 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+Option Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testError
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testError()
+ On Error GoTo errorHandler
+
+ ' https://help.libreoffice.org/Basic/Error_Sub_Runtime
+ TestUtil.AssertEqual(Error(11), "Division by zero.", "Error(11)")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testError", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/vba_tests/error_message.vb b/basic/qa/vba_tests/error_message.vb
new file mode 100644
index 000000000..7f9605735
--- /dev/null
+++ b/basic/qa/vba_tests/error_message.vb
@@ -0,0 +1,34 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+Option Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testErrorMessage
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testErrorMessage()
+
+try: On Error Goto catch
+
+ a = 5
+
+catch:
+
+ ' tdf#123144 - check for a meaningful error message
+ ' Without the fix in place, this test would have failed with
+ ' - Expected: Variable not defined.\n Additional information: a
+ ' - Actual : a
+ TestUtil.AssertEqual(Err.Description, _
+ + "Variable not defined." & Chr$(10) & "Additional information: a", _
+ + "Err.Description failure (Err.Description = " & Err.Description & ")")
+
+End Sub
diff --git a/basic/qa/vba_tests/exp.vb b/basic/qa/vba_tests/exp.vb
new file mode 100644
index 000000000..7c2a7a861
--- /dev/null
+++ b/basic/qa/vba_tests/exp.vb
@@ -0,0 +1,26 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+Option Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testExp
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testExp()
+ On Error GoTo errorHandler
+
+ TestUtil.AssertEqualApprox(Exp(1), 2.71828182845904, 1E-14, "Exp(1)")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testExp", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/vba_tests/fix.vb b/basic/qa/vba_tests/fix.vb
new file mode 100644
index 000000000..9f2af4008
--- /dev/null
+++ b/basic/qa/vba_tests/fix.vb
@@ -0,0 +1,28 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+Option Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testFix
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testFix()
+ On Error GoTo errorHandler
+
+ TestUtil.AssertEqual(Fix(12.34), 12, "Fix(12.34)")
+ TestUtil.AssertEqual(Fix(12.99), 12, "Fix(12.99)")
+ TestUtil.AssertEqual(Fix(-8.4), -8, "Fix(-8.4)")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testFix", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/vba_tests/format.vb b/basic/qa/vba_tests/format.vb
new file mode 100644
index 000000000..0e997ca82
--- /dev/null
+++ b/basic/qa/vba_tests/format.vb
@@ -0,0 +1,186 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+Option Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+
+ 'Predefined_Datetime_Format_Sample
+ Predefined_Number_Format_Sample
+ 'Custom_Datetime_Format_Sample
+ Custom_Number_Format_Sample
+ Custom_Text_Format_Sample
+ testFormat
+
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub Predefined_Datetime_Format_Sample()
+ Dim TestStr As String
+ const myDate = "01/06/98"
+ const MyTime = "17:08:06"
+
+ On Error GoTo errorHandler
+
+ ' These tests only apply to en_US locale
+
+ ' The date/time format have a little different between ms office and OOo due to different locale and system...
+ TestStr = Format(myDate, "General Date") ' 1/6/98
+ TestUtil.Assert(IsDate(TestStr), "IsDate(TestStr)", "General Date")
+ 'TestUtil.AssertEqual(TestStr, "1/6/98", "General Date")
+
+ TestStr = Format(myDate, "Long Date") ' Tuesday, January 06, 1998
+ TestUtil.AssertEqual(TestStr, "Tuesday, January 06, 1998", "Long Date")
+ 'TestUtil.Assert(IsDate(TestStr), "IsDate(TestStr)", "Long Date")
+
+ TestStr = Format(myDate, "Medium Date") ' 06-Jan-98
+ 'TestUtil.AssertEqual(TestStr, "06-Jan-98", "Medium Date")
+ TestUtil.Assert(IsDate(TestStr), "IsDate(TestStr)", "Medium Date")
+
+ TestStr = Format(myDate, "Short Date") ' 1/6/98
+ 'TestUtil.AssertEqual(TestStr, "1/6/98", "Short Date")
+ TestUtil.Assert(IsDate(TestStr), "IsDate(TestStr)", "Short Date")
+
+ TestStr = Format(MyTime, "Long Time") ' 5:08:06 PM
+ 'TestUtil.AssertEqual(TestStr, "5:08:06 PM", "Long Time")
+ TestUtil.Assert(IsDate(TestStr), "IsDate(TestStr)", "Long Time")
+
+ TestStr = Format(MyTime, "Medium Time") ' 05:08 PM
+ 'TestUtil.AssertEqual(TestStr, "05:08 PM", "Medium Time")
+ TestUtil.Assert(IsDate(TestStr), "IsDate(TestStr)", "Medium Time")
+
+ TestStr = Format(MyTime, "Short Time") ' 17:08
+ 'TestUtil.AssertEqual(TestStr, "17:08", "Short Time")
+ TestUtil.Assert(IsDate(TestStr), "IsDate(TestStr)", "Short Time")
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("Predefined_Datetime_Format_Sample", Err, Error$, Erl)
+End Sub
+
+Sub Predefined_Number_Format_Sample()
+ On Error GoTo errorHandler
+
+ TestUtil.AssertEqual(Format(562486.2356, "General Number"), "562486.2356", "Format(562486.2356, ""General Number"")")
+ TestUtil.AssertEqual(Format(0.2, "Fixed"), "0.20", "Format(0.2, ""Fixed"")")
+ TestUtil.AssertEqual(Format(562486.2356, "Standard"), "562,486.24", "Format(562486.2356, ""Standard"")")
+ TestUtil.AssertEqual(Format(0.7521, "Percent"), "75.21%", "Format(0.7521, ""Percent"")")
+ TestUtil.AssertEqual(Format(562486.2356, "Scientific"), "5.62E+05", "Format(562486.2356, ""Scientific"")")
+ TestUtil.AssertEqual(Format(-3456.789, "Scientific"), "-3.46E+03", "Format(-3456.789, ""Scientific"")")
+ TestUtil.AssertEqual(Format(0, "Yes/No"), "No", "Format(0, ""Yes/No"")")
+ TestUtil.AssertEqual(Format(23, "Yes/No"), "Yes", "Format(23, ""Yes/No"")")
+ TestUtil.AssertEqual(Format(0, "True/False"), "False", "Format(0, ""True/False"")")
+ TestUtil.AssertEqual(Format(23, "True/False"), "True", "Format(23, ""True/False"")")
+ TestUtil.AssertEqual(Format(0, "On/Off"), "Off", "Format(0, ""On/Off"")")
+ TestUtil.AssertEqual(Format(23, "On/Off"), "On", "Format(23, ""On/Off"")")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("Predefined_Number_Format_Sample", Err, Error$, Erl)
+End Sub
+
+Sub Custom_Datetime_Format_Sample()
+ const myDate = "01/06/98"
+ const MyTime = "05:08:06"
+ const MyTimePM = "17:08:06"
+
+ On Error GoTo errorHandler
+
+ ' These tests only apply to en_US locale
+ TestUtil.AssertEqual(Format("01/06/98 17:08:06", "c"), "1/6/98 5:08:06 PM", "Format(""01/06/98 17:08:06"", ""c"")")
+ TestUtil.AssertEqual(Format(myDate, "dddddd"), "Tuesday, January 06, 1998", "Format(myDate, ""dddddd"")")
+ TestUtil.AssertEqual(Format(myDate, "mm-dd-yyyy"), "01-06-1998", "Format(myDate, ""mm-dd-yyyy"")")
+ TestUtil.AssertEqual(Format(myDate, "d"), "6", "Format(myDate, ""d"")")
+ TestUtil.AssertEqual(Format(myDate, "dd"), "06", "Format(myDate, ""dd"")")
+ TestUtil.AssertEqual(Format(myDate, "ddd"), "Tue", "Format(myDate, ""ddd"")")
+ TestUtil.AssertEqual(Format(myDate, "dddd"), "Tuesday", "Format(myDate, ""dddd"")")
+ TestUtil.AssertEqual(Format(MyTime, "h"), "5", "Format(MyTime, ""h"")")
+ TestUtil.AssertEqual(Format(MyTime, "hh"), "05", "Format(MyTime, ""hh"")")
+ TestUtil.AssertEqual(Format(MyTime, "n"), "8", "Format(MyTime, ""n"")")
+ TestUtil.AssertEqual(Format(MyTime, "nn"), "08", "Format(MyTime, ""nn"")")
+ TestUtil.AssertEqual(Format(myDate, "m"), "1", "Format(myDate, ""m"")")
+ TestUtil.AssertEqual(Format(myDate, "mm"), "01", "Format(myDate, ""mm"")")
+ TestUtil.AssertEqual(Format(myDate, "mmm"), "Jan", "Format(myDate, ""mmm"")")
+ TestUtil.AssertEqual(Format(myDate, "mmmm"), "January", "Format(myDate, ""mmmm"")")
+ TestUtil.AssertEqual(Format(MyTime, "s"), "6", "Format(MyTime, ""s"")")
+ TestUtil.AssertEqual(Format(MyTime, "ss"), "06", "Format(MyTime, ""ss"")")
+ TestUtil.AssertEqual(Format(MyTimePM, "hh:mm:ss AM/PM"), "05:08:06 PM", "Format(MyTimePM, ""hh:mm:ss AM/PM"")")
+ TestUtil.AssertEqual(Format(MyTimePM, "hh:mm:ss"), "17:08:06", "Format(MyTimePM, ""hh:mm:ss"")")
+ TestUtil.AssertEqual(Format(myDate, "ww"), "2", "Format(myDate, ""ww"")")
+ TestUtil.AssertEqual(Format(myDate, "w"), "3", "Format(myDate, ""w"")")
+ TestUtil.AssertEqual(Format(myDate, "y"), "6", "Format(myDate, ""y"")")
+ TestUtil.AssertEqual(Format(myDate, "yy"), "98", "Format(myDate, ""yy"")")
+ TestUtil.AssertEqual(Format(myDate, "yyyy"), "1998", "Format(myDate, ""yyyy"")")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("Custom_Datetime_Format_Sample", Err, Error$, Erl)
+End Sub
+
+Sub Custom_Number_Format_Sample()
+ On Error GoTo errorHandler
+
+ TestUtil.AssertEqual(Format(23.675, "00.0000"), "23.6750", "Format(23.675, ""00.0000"")")
+ TestUtil.AssertEqual(Format(23.675, "00.00"), "23.68", "Format(23.675, ""00.00"")")
+ TestUtil.AssertEqual(Format(2658, "00000"), "02658", "Format(2658, ""00000"")")
+ TestUtil.AssertEqual(Format(2658, "00.00"), "2658.00", "Format(2658, ""00.00"")")
+ TestUtil.AssertEqual(Format(23.675, "##.####"), "23.675", "Format(23.675, ""##.####"")")
+ TestUtil.AssertEqual(Format(23.675, "##.##"), "23.68", "Format(23.675, ""##.##"")")
+ TestUtil.AssertEqual(Format(12345.25, "#,###.##"), "12,345.25", "Format(12345.25, ""#,###.##"")")
+ TestUtil.AssertEqual(Format(0.25, "##.00%"), "25.00%", "Format(0.25, ""##.00%"")")
+ TestUtil.AssertEqual(Format(1000000, "#,###"), "1,000,000", "Format(1000000, ""#,###"")")
+ TestUtil.AssertEqual(Format(1.09837555, "#.#####E+###"), "1.09838E+000", "Format(1.09837555, ""#.#####E+###"")")
+ TestUtil.AssertEqual(Format(1.09837555, "###.####E#"), "1.0984E0", "Format(1.09837555, ""###.####E#"")")
+ TestUtil.AssertEqual(Format(1098.37555, "###.####E#"), "1.0984E3", "Format(1098.37555, ""###.####E#"")")
+ TestUtil.AssertEqual(Format(1098375.55, "###.####E#"), "1.0984E6", "Format(1098375.55, ""###.####E#"")")
+ TestUtil.AssertEqual(Format(1.09837555, "######E#"), "1E0", "Format(1.09837555, ""######E#"")")
+ TestUtil.AssertEqual(Format(123456.789, "###E0"), "123E3", "Format(123456.789, ""###E0"")")
+ TestUtil.AssertEqual(Format(123567.89, "###E0"), "124E3", "Format(123567.89, ""###E0"")")
+ TestUtil.AssertEqual(Format(12, "###E0"), "12E0", "Format(12, ""###E0"")")
+ TestUtil.AssertEqual(Format(12, "000E0"), "012E0", "Format(12, ""000E0"")")
+ TestUtil.AssertEqual(Format(0.12345, "###E0"), "123E-3", "Format(0.12345, ""###E0"")")
+ TestUtil.AssertEqual(Format(123456, "####E0"), "12E4", "Format(123456, ""####E0"")")
+ TestUtil.AssertEqual(Format(2345.25, "$#,###.##"), "$2,345.25", "Format(2345.25, ""$#,###.##"")")
+ TestUtil.AssertEqual(Format(0.25, "##.###\%"), ".25%", "Format(0.25, ""##.###\%"")")
+ TestUtil.AssertEqual(Format(12.25, "0.???"), "12.25 ", "Format(12.25, ""0.???"")")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("Custom_Number_Format_Sample", Err, Error$, Erl)
+End Sub
+
+Sub Custom_Text_Format_Sample()
+ On Error GoTo errorHandler
+
+ TestUtil.AssertEqual(Format("VBA", "<"), "vba", "Format(""VBA"", ""<"")")
+ TestUtil.AssertEqual(Format("vba", ">"), "VBA", "Format(""vba"", "">"")")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("Custom_Text_Format_Sample", Err, Error$, Erl)
+End Sub
+
+Sub testFormat()
+ On Error GoTo errorHandler
+
+ const TestDateTime = #2001-1-27T17:04:23#
+ TestUtil.AssertEqual(Format(TestDateTime, "h:m:s"), "17:4:23", "Format(TestDateTime, ""h:m:s"")")
+ TestUtil.AssertEqual(Format(TestDateTime, "ttttt"), "5:04:23 PM", "Format(TestDateTime, ""ttttt"")")
+ TestUtil.AssertEqual(Format(TestDateTime, "dddd, MMM d yyyy"), "Saturday, Jan 27 2001", "Format(TestDateTime, ""dddd, MMM d yyyy"")")
+ TestUtil.AssertEqual(Format(TestDateTime, "HH:mm:ss"), "17:04:23", "Format(TestDateTime, ""HH:mm:ss"")")
+
+ TestUtil.AssertEqual(Format(23), "23", "Format(23)")
+ TestUtil.AssertEqual(Format(5459.4, "##,##0.00"), "5,459.40", "Format(5459.4, ""##,##0.00"")")
+ TestUtil.AssertEqual(Format(334.9, "###0.00"), "334.90", "Format(334.9, ""###0.00"")")
+ TestUtil.AssertEqual(Format(5, "0.00%"), "500.00%", "Format(5, ""0.00%"")")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("testFormat", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/vba_tests/formatnumber.vb b/basic/qa/vba_tests/formatnumber.vb
new file mode 100644
index 000000000..6ddcf9594
--- /dev/null
+++ b/basic/qa/vba_tests/formatnumber.vb
@@ -0,0 +1,31 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+Option Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testFormatNumber
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testFormatNumber()
+ On Error GoTo errorHandler
+
+ TestUtil.AssertEqual(FormatNumber("12.2", 2, vbFalse, vbFalse, vbFalse), "12.20", "FormatNumber(""12.2"", 2, vbFalse, vbFalse, vbFalse)")
+ TestUtil.AssertEqual(FormatNumber("-.2", 20, vbTrue, vbFalse, vbFalse), "-0.20000000000000000000", "FormatNumber(""-.2"", 20, vbTrue, vbFalse, vbFalse)")
+ TestUtil.AssertEqual(FormatNumber("-0.2", 20, vbFalse, vbFalse, vbFalse), "-.20000000000000000000", "FormatNumber(""-0.2"", 20, vbFalse, vbFalse, vbFalse)")
+ TestUtil.AssertEqual(FormatNumber("-0.2", -1, vbFalse, vbTrue, vbFalse), "(.20)", "FormatNumber(""-0.2"", -1, vbFalse, vbTrue, vbFalse)")
+ TestUtil.AssertEqual(FormatNumber("-0.2", -1, vbUseDefault, vbTrue, vbFalse), "(0.20)", "FormatNumber(""-0.2"", -1, vbUseDefault, vbTrue, vbFalse)")
+ TestUtil.AssertEqual(FormatNumber("-12345678", -1, vbUseDefault, vbUseDefault, vbTrue), "-12,345,678.00", "FormatNumber(""-12345678"", -1, vbUseDefault, vbUseDefault, vbTrue)")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testFormatNumber", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/vba_tests/formatpercent.vb b/basic/qa/vba_tests/formatpercent.vb
new file mode 100644
index 000000000..0a8c551c2
--- /dev/null
+++ b/basic/qa/vba_tests/formatpercent.vb
@@ -0,0 +1,31 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+Option Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testFormatPercent
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testFormatPercent()
+ On Error GoTo errorHandler
+
+ TestUtil.AssertEqual(FormatPercent("12.2", 2, vbFalse, vbFalse, vbFalse), "1220.00%", "FormatPercent(""12.2"", 2, vbFalse, vbFalse, vbFalse)")
+ TestUtil.AssertEqual(FormatPercent("-.2", 2, vbTrue, vbFalse, vbFalse), "-20.00%", "FormatPercent(""-.2"", 20, vbTrue, vbFalse, vbFalse)")
+ TestUtil.AssertEqual(FormatPercent("-0.2", 2, vbFalse, vbFalse, vbFalse), "-20.00%", "FormatPercent(""-0.2"", 20, vbFalse, vbFalse, vbFalse)")
+ TestUtil.AssertEqual(FormatPercent("-0.2", -1, vbFalse, vbTrue, vbFalse), "(20.00)%", "FormatPercent(""-0.2"", -1, vbFalse, vbTrue, vbFalse)")
+ TestUtil.AssertEqual(FormatPercent("-0.2", -1, vbUseDefault, vbTrue, vbFalse), "(20.00)%", "FormatPercent(""-0.2"", -1, vbUseDefault, vbTrue, vbFalse)")
+ TestUtil.AssertEqual(FormatPercent("-12345678", -1, vbUseDefault, vbUseDefault, vbTrue), "-1,234,567,800.00%", "FormatPercent(""-12345678"", -1, vbUseDefault, vbUseDefault, vbTrue)")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testFormatPercent", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/vba_tests/hex.vb b/basic/qa/vba_tests/hex.vb
new file mode 100644
index 000000000..6c0cd145b
--- /dev/null
+++ b/basic/qa/vba_tests/hex.vb
@@ -0,0 +1,31 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+Option Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testHex
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testHex()
+ On Error GoTo errorHandler
+
+ TestUtil.AssertEqual(Hex(9), "9", "Hex(9)")
+ TestUtil.AssertEqual(Hex(10), "A", "Hex(10)")
+ TestUtil.AssertEqual(Hex(16), "10", "Hex(16)")
+ TestUtil.AssertEqual(Hex(255), "FF", "Hex(255)")
+ TestUtil.AssertEqual(Hex(256), "100", "Hex(256)")
+ TestUtil.AssertEqual(Hex(459), "1CB", "Hex(459)")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testHex", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/vba_tests/hour.vb b/basic/qa/vba_tests/hour.vb
new file mode 100644
index 000000000..860096cca
--- /dev/null
+++ b/basic/qa/vba_tests/hour.vb
@@ -0,0 +1,28 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+Option Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testHour
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testHour()
+ On Error GoTo errorHandler
+
+ TestUtil.AssertEqual(Hour("6:25:39 AM"), 6, "Hour(""6:25:39 AM"")")
+ TestUtil.AssertEqual(Hour("6:25:39 PM"), 18, "Hour(""6:25:39 PM"")")
+ TestUtil.AssertEqual(Hour("06:25:39 AM"), 6, "Hour(""06:25:39 AM"")")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testHour", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/vba_tests/iif.vb b/basic/qa/vba_tests/iif.vb
new file mode 100644
index 000000000..8db7e48de
--- /dev/null
+++ b/basic/qa/vba_tests/iif.vb
@@ -0,0 +1,31 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+Option Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testIIf
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testIIf()
+ On Error GoTo errorHandler
+
+ TestUtil.AssertEqual(IIf(True, "it is true", "it is false"), "it is true", "IIf(True, ""it is true"", ""it is false"")")
+ TestUtil.AssertEqual(IIf(False, "It is true", "it is false"), "it is false", "IIf(False, ""It is true"", ""it is false"")")
+
+ Dim testnr
+ testnr = 1001
+ TestUtil.AssertEqual(IIf(testnr > 1000, "Large", "Small"), "Large", "IIf(testnr > 1000, ""Large"", ""Small"")")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testIIf", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/vba_tests/instr.vb b/basic/qa/vba_tests/instr.vb
new file mode 100644
index 000000000..cda19712b
--- /dev/null
+++ b/basic/qa/vba_tests/instr.vb
@@ -0,0 +1,45 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+Option Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testInStr
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testInStr()
+ On Error GoTo errorHandler
+
+ TestUtil.AssertEqual(InStr(1, "somemoretext", "more"), 5, "InStr(1, ""somemoretext"", ""more"")")
+ TestUtil.AssertEqual(InStr("somemoretext", "more"), 5, "InStr(""somemoretext"", ""more"")")
+ TestUtil.AssertEqual(InStr("somemoretext", "somemoretext"), 1, "InStr(""somemoretext"", ""somemoretext"")")
+ TestUtil.AssertEqual(InStr("somemoretext", "nothing"), 0, "InStr(""somemoretext"", ""nothing"")")
+
+ Dim SearchString, SearchChar
+ SearchString = "XXpXXpXXPXXP" ' String to search in.
+ SearchChar = "P" ' Search for "P".
+ TestUtil.AssertEqual(InStr(4, SearchString, SearchChar, 1), 6, "InStr(4, SearchString, SearchChar, 1)")
+ TestUtil.AssertEqual(InStr(1, SearchString, SearchChar, 0), 9, "InStr(1, SearchString, SearchChar, 0)")
+ TestUtil.AssertEqual(InStr(1, SearchString, "W"), 0, "InStr(1, SearchString, ""W"")")
+
+ ' tdf#139840 - case-insensitive operation for non-ASCII characters
+ TestUtil.AssertEqual(InStr(1, "α", "Α", 1), 1, "InStr(1, ""α"", ""Α"", 1)")
+ ' tdf#139840 - German Eszett is uppercased to a two-character 'SS'.
+ ' This test should fail after tdf#110003 has been fixed.
+ TestUtil.AssertEqual(InStr(2, "Straße", "s", 1), 5, "InStr(2, ""Straße"", ""s"", 1)")
+
+ ' Start position is greater than the length of the string being searched.
+ TestUtil.AssertEqual(InStr(2, "α", "Α", 1), 0, "InStr(2, ""α"", ""Α"", 1)")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testInStr", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/vba_tests/instrrev.vb b/basic/qa/vba_tests/instrrev.vb
new file mode 100644
index 000000000..7d047fc74
--- /dev/null
+++ b/basic/qa/vba_tests/instrrev.vb
@@ -0,0 +1,43 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+Option Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testInStrRev
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testInStrRev()
+ On Error GoTo errorHandler
+
+ TestUtil.AssertEqual(InStrRev("somemoretext", "more", -1), 5, "InStrRev(""somemoretext"", ""more"", -1)")
+ TestUtil.AssertEqual(InStrRev("somemoretext", "more"), 5, "InStrRev(""somemoretext"", ""more"")")
+ TestUtil.AssertEqual(InStrRev("somemoretext", "somemoretext"), 1, "InStrRev(""somemoretext"", ""somemoretext"")")
+ TestUtil.AssertEqual(InStrRev("somemoretext", "nothing"), 0, "InStrRev(""somemoretext"", ""nothing"")")
+
+ Dim SearchString, SearchChar
+ SearchString = "XXpXXpXXPXXP" ' String to search in.
+ SearchChar = "P" ' Search for "P".
+ TestUtil.AssertEqual(InStrRev(SearchString, SearchChar, 4, 1), 3, "InStrRev(SearchString, SearchChar, 4, 1)")
+ TestUtil.AssertEqual(InStrRev(SearchString, SearchChar, -1, 0), 12, "InStrRev(SearchString, SearchChar, -1, 0)")
+ TestUtil.AssertEqual(InStrRev(SearchString, "W", 1), 0, "InStrRev(SearchString, ""W"", 1)")
+
+ ' tdf#143332 - case-insensitive operation for non-ASCII characters
+ TestUtil.AssertEqual(InStrRev("α", "Α", -1, 1), 1, "InStrRev(""α"", ""Α"", -1, 1)")
+ TestUtil.AssertEqual(InStrRev("abc", "d", -1, 1), 0, "InStrRev(""abc"", ""d"", -1, 1)")
+ ' tdf#143332 - German Eszett is uppercased to a two-character 'SS'.
+ ' This test should fail after tdf#110003 has been fixed.
+ TestUtil.AssertEqual(InStrRev("Straße", "s", -1, 1), 5, "InStrRev(""Straße"", ""s"", -1, 1)")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testInStrRev", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/vba_tests/int.vb b/basic/qa/vba_tests/int.vb
new file mode 100644
index 000000000..632999d34
--- /dev/null
+++ b/basic/qa/vba_tests/int.vb
@@ -0,0 +1,30 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+Option Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testInt
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testInt()
+ On Error GoTo errorHandler
+
+ TestUtil.AssertEqual(Int(99.8), 99, "Int(99.8)")
+ TestUtil.AssertEqual(Int(-99.8), -100, "Int(-99.8)")
+ TestUtil.AssertEqual(Int(-99.2), -100, "Int(-99.2)")
+ TestUtil.AssertEqual(Int(0.2), 0, "Int(0.2)")
+ TestUtil.AssertEqual(Int(0), 0, "Int(0)")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testInt", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/vba_tests/isarray.vb b/basic/qa/vba_tests/isarray.vb
new file mode 100644
index 000000000..b028d8524
--- /dev/null
+++ b/basic/qa/vba_tests/isarray.vb
@@ -0,0 +1,32 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+Option Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testIsArray
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testIsArray()
+ On Error GoTo errorHandler
+ Dim MyArray(1 To 5) As Integer, YourArray ' Declare array variables.
+ Dim AVar
+ YourArray = Array(1, 2, 3) ' Use Array function.
+ AVar = False
+
+ TestUtil.Assert(IsArray(MyArray), "IsArray(MyArray)")
+ TestUtil.Assert(IsArray(YourArray), "IsArray(YourArray)")
+ TestUtil.Assert(Not IsArray(AVar), "Not IsArray(AVar)")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testIsArray", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/vba_tests/isdate.vb b/basic/qa/vba_tests/isdate.vb
new file mode 100644
index 000000000..5d66bf7d8
--- /dev/null
+++ b/basic/qa/vba_tests/isdate.vb
@@ -0,0 +1,28 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+Option Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testIsDate
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testIsDate()
+ On Error GoTo errorHandler
+
+ TestUtil.Assert(IsDate(cdate("12/2/1969")), "IsDate(cdate(""12/2/1969""))")
+ TestUtil.Assert(IsDate("12:22:12"), "IsDate(""12:22:12"")")
+ TestUtil.Assert(Not IsDate("a12.2.1969"), "Not IsDate(""a12.2.1969"")")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testIsDate", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/vba_tests/isempty.vb b/basic/qa/vba_tests/isempty.vb
new file mode 100644
index 000000000..22a71804a
--- /dev/null
+++ b/basic/qa/vba_tests/isempty.vb
@@ -0,0 +1,33 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+Option Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testIsEmpty
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testIsEmpty()
+ On Error GoTo errorHandler
+
+ Dim MyVar
+ TestUtil.Assert(IsEmpty(MyVar), "IsEmpty(MyVar)")
+
+ MyVar = Null ' Assign Null.
+ TestUtil.Assert(Not IsEmpty(MyVar), "Not IsEmpty(MyVar)")
+
+ MyVar = Empty ' Assign Empty.
+ TestUtil.Assert(IsEmpty(MyVar), "IsEmpty(MyVar)")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testIsEmpty", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/vba_tests/iserror.vb b/basic/qa/vba_tests/iserror.vb
new file mode 100644
index 000000000..0250933ca
--- /dev/null
+++ b/basic/qa/vba_tests/iserror.vb
@@ -0,0 +1,27 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+Option Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testIsError
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testIsError()
+ On Error GoTo errorHandler
+
+ TestUtil.Assert(Not IsError("12.2.1969"), "Not IsError(""12.2.1969"")")
+ TestUtil.Assert(IsError(CVErr(64)), "IsError(CVErr(64))")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testIsError", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/vba_tests/ismissing.vb b/basic/qa/vba_tests/ismissing.vb
new file mode 100644
index 000000000..febe0339f
--- /dev/null
+++ b/basic/qa/vba_tests/ismissing.vb
@@ -0,0 +1,181 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+
+Const IsMissingNone = -1
+Const IsMissingA = 0
+Const IsMissingB = 1
+Const IsMissingAB = 2
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testIsMissingVba
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+' tdf#36737 - Test isMissing function with different datatypes. In LO Basic
+' with option VBASupport, optional parameters are allowed including additional
+' default values. Missing optional parameters having types other than variant,
+' which don't have explicit default values, will be initialized to their
+' respective default value of its datatype.
+Sub verify_testIsMissingVba()
+
+ testName = "Test missing (VBA)"
+ On Error GoTo errorHandler
+
+ ' optionals with variant datatypes
+ TestUtil.AssertEqual(TestOptVariant(), IsMissingA, "TestOptVariant()")
+ TestUtil.AssertEqual(TestOptVariant(123), IsMissingNone, "TestOptVariant(123)")
+ TestUtil.AssertEqual(TestOptVariant(, 456), IsMissingA, "TestOptVariant(, 456)")
+ TestUtil.AssertEqual(TestOptVariant(123, 456), IsMissingNone, "TestOptVariant(123, 456)")
+
+ ' optionals with variant datatypes (ByRef and ByVal)
+ TestUtil.AssertEqual(TestOptVariantByRefByVal(), IsMissingA, "TestOptVariantByRefByVal()")
+ TestUtil.AssertEqual(TestOptVariantByRefByVal(123),IsMissingNone, "TestOptVariantByRefByVal(123)")
+ TestUtil.AssertEqual(TestOptVariantByRefByVal(, 456), IsMissingA, "TestOptVariantByRefByVal(, 456)")
+ TestUtil.AssertEqual(TestOptVariantByRefByVal(123, 456), IsMissingNone, "TestOptVariantByRefByVal(123, 456)")
+
+ ' optionals with double datatypes
+ TestUtil.AssertEqual(TestOptDouble(), IsMissingNone, "TestOptDouble()")
+ TestUtil.AssertEqual(TestOptDouble(123.4), IsMissingNone, "TestOptDouble(123.4)")
+ TestUtil.AssertEqual(TestOptDouble(, 567.8), IsMissingNone, "TestOptDouble(, 567.8)")
+ TestUtil.AssertEqual(TestOptDouble(123.4, 567.8), IsMissingNone, "TestOptDouble(123.4, 567.8)")
+
+ ' optionals with double datatypes (ByRef and ByVal)
+ TestUtil.AssertEqual(TestOptDoubleByRefByVal(), IsMissingNone, "TestOptDouble()")
+ TestUtil.AssertEqual(TestOptDoubleByRefByVal(123.4), IsMissingNone, "TestOptDouble(123.4)")
+ TestUtil.AssertEqual(TestOptDoubleByRefByVal(, 567.8), IsMissingNone, "TestOptDoubleByRefByVal(, 567.8)")
+ TestUtil.AssertEqual(TestOptDoubleByRefByVal(123.4, 567.8), IsMissingNone, "TestOptDoubleByRefByVal(123.4, 567.8)")
+
+ ' optionals with integer datatypes
+ TestUtil.AssertEqual(TestOptInteger(), IsMissingNone, "TestOptInteger()")
+ TestUtil.AssertEqual(TestOptInteger(123), IsMissingNone, "TestOptInteger(123)")
+ TestUtil.AssertEqual(TestOptInteger(, 456), IsMissingNone, "TestOptInteger(, 456)")
+ TestUtil.AssertEqual(TestOptInteger(123, 456), IsMissingNone, "TestOptInteger(123, 456)")
+
+ ' optionals with integer datatypes (ByRef and ByVal)
+ TestUtil.AssertEqual(TestOptIntegerByRefByVal(), IsMissingNone, "TestOptIntegerByRefByVal()")
+ TestUtil.AssertEqual(TestOptIntegerByRefByVal(123), IsMissingNone, "TestOptIntegerByRefByVal(123)")
+ TestUtil.AssertEqual(TestOptIntegerByRefByVal(, 456), IsMissingNone, "TestOptIntegerByRefByVal(, 456)")
+ TestUtil.AssertEqual(TestOptIntegerByRefByVal(123, 456), IsMissingNone, "TestOptIntegerByRefByVal(123, 456)")
+
+ ' optionals with string datatypes
+ TestUtil.AssertEqual(TestOptString(), IsMissingNone, "TestOptString()")
+ TestUtil.AssertEqual(TestOptString("123"), IsMissingNone, "TestOptString(""123"")")
+ TestUtil.AssertEqual(TestOptString(, "456"), IsMissingNone, "TestOptString(, ""456"")")
+ TestUtil.AssertEqual(TestOptString("123", "456"), IsMissingNone, "TestOptString(""123"", ""456"")")
+
+ ' optionals with string datatypes (ByRef and ByVal)
+ TestUtil.AssertEqual(TestOptStringByRefByVal(), IsMissingNone, "TestOptStringByRefByVal()")
+ TestUtil.AssertEqual(TestOptStringByRefByVal("123"), IsMissingNone, "TestOptStringByRefByVal(""123"")")
+ TestUtil.AssertEqual(TestOptStringByRefByVal(, "456"), IsMissingNone, "TestOptStringByRefByVal(, ""456"")")
+ TestUtil.AssertEqual(TestOptStringByRefByVal("123", "456"), IsMissingNone, "TestOptStringByRefByVal(""123"", ""456"")")
+
+ ' optionals with object datatypes
+ Dim cA As New Collection
+ cA.Add (123)
+ cA.Add (456)
+ Dim cB As New Collection
+ cB.Add (123.4)
+ cB.Add (567.8)
+ TestUtil.AssertEqual(TestOptObject(), IsMissingAB, "TestOptObject()")
+ TestUtil.AssertEqual(TestOptObject(cA), IsMissingB, "TestOptObject(A)")
+ TestUtil.AssertEqual(TestOptObject(, cB), IsMissingA, "TestOptObject(, B)")
+ TestUtil.AssertEqual(TestOptObject(cA, cB), IsMissingNone, "TestOptObject(A, B)")
+
+ ' optionals with object datatypes (ByRef and ByVal)
+ TestUtil.AssertEqual(TestOptObjectByRefByVal(), IsMissingAB, "TestOptObjectByRefByVal()")
+ TestUtil.AssertEqual(TestOptObjectByRefByVal(cA), IsMissingB, "TestOptObjectByRefByVal(A)")
+ TestUtil.AssertEqual(TestOptObjectByRefByVal(, cB), IsMissingA, "TestOptObjectByRefByVal(, B)")
+ TestUtil.AssertEqual(TestOptObjectByRefByVal(cA, cB), IsMissingNone, "TestOptObjectByRefByVal(A, B)")
+
+ ' optionals with array datatypes
+ Dim aA(0 To 1) As Integer
+ aA(0) = 123
+ aA(1) = 456
+ Dim aB(0 To 1) As Variant
+ aB(0) = 123.4
+ aB(1) = 567.8
+ ' TODO - New bug report? Scanner initializes variable not as an array
+ ' TestUtil.AssertEqual(TestOptArray(), IsMissingAB, "TestOptArray()")
+ ' TestUtil.AssertEqual(TestOptArray(aA), IsMissingB, "TestOptArray(A)")
+ ' TestUtil.AssertEqual(TestOptArray(, aB), IsMissingA, "TestOptArray(, B)")
+ TestUtil.AssertEqual(TestOptArray(aA, aB), IsMissingNone, "TestOptArray(A, B)")
+
+ ' optionals with array datatypes (ByRef and ByVal)
+ ' TODO - New bug report? Scanner initializes variable not as an array
+ ' TestUtil.AssertEqual(TestOptArrayByRefByVal(), IsMissingAB, "TestOptArrayByRefByVal()")
+ ' TestUtil.AssertEqual(TestOptArrayByRefByVal(aA), IsMissingB, "TestOptArrayByRefByVal(A)")
+ ' TestUtil.AssertEqual(TestOptArrayByRefByVal(, aB), IsMissingA, "TestOptArrayByRefByVal(, B)")
+ TestUtil.AssertEqual(TestOptArrayByRefByVal(aA, aB), IsMissingNone, "TestOptArrayByRefByVal(A, B)")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testIsMissingVba", Err, Error$, Erl)
+End Sub
+
+Function TestOptVariant(Optional A, Optional B As Variant = 123)
+ TestOptVariant = WhatIsMissing(IsMissing(A), IsMissing(B))
+End Function
+
+Function TestOptVariantByRefByVal(Optional ByRef A, Optional ByVal B As Variant = 123)
+ TestOptVariantByRefByVal = WhatIsMissing(IsMissing(A), IsMissing(B))
+End Function
+
+Function TestOptDouble(Optional A As Double, Optional B As Double = 123.4)
+ TestOptDouble = WhatIsMissing(IsMissing(A), IsMissing(B))
+End Function
+
+Function TestOptDoubleByRefByVal(Optional ByRef A As Double, Optional ByVal B As Double = 123.4)
+ TestOptDoubleByRefByVal = WhatIsMissing(IsMissing(A), IsMissing(B))
+End Function
+
+Function TestOptInteger(Optional A As Integer, Optional B As Integer = 123)
+ TestOptInteger = WhatIsMissing(IsMissing(A), IsMissing(B))
+End Function
+
+Function TestOptIntegerByRefByVal(Optional ByRef A As Integer, Optional ByVal B As Integer = 123)
+ TestOptIntegerByRefByVal = WhatIsMissing(IsMissing(A), IsMissing(B))
+End Function
+
+Function TestOptString(Optional A As String, Optional B As String = "123")
+ TestOptString = WhatIsMissing(IsMissing(A), IsMissing(B))
+End Function
+
+Function TestOptStringByRefByVal(Optional ByRef A As String, Optional ByVal B As String = "123")
+ TestOptStringByRefByVal = WhatIsMissing(IsMissing(A), IsMissing(B))
+End Function
+
+Function TestOptObject(Optional A As Collection, Optional B As Collection)
+ TestOptObject = WhatIsMissing(IsNull(A), IsNull(B))
+End Function
+
+Function TestOptObjectByRefByVal(Optional ByRef A As Collection, Optional ByVal B As Collection)
+ TestOptObjectByRefByVal = WhatIsMissing(IsNull(A), IsNull(B))
+End Function
+
+Function TestOptArray(Optional A() As Integer, Optional B() As Variant)
+ TestOptArray = WhatIsMissing(IsEmpty(A), IsEmpty(B))
+End Function
+
+Function TestOptArrayByRefByVal(Optional ByRef A() As Integer, Optional ByVal B() As Variant)
+ TestOptArrayByRefByVal = WhatIsMissing(IsEmpty(A), IsEmpty(B))
+End Function
+
+Function WhatIsMissing(is_missingA, is_missingB)
+ If is_missingA And is_missingB Then
+ WhatIsMissing = IsMissingAB
+ ElseIf is_missingA Then
+ WhatIsMissing = IsMissingA
+ ElseIf is_missingB Then
+ WhatIsMissing = IsMissingB
+ Else
+ WhatIsMissing = IsMissingNone
+ End If
+End Function
diff --git a/basic/qa/vba_tests/isnull.vb b/basic/qa/vba_tests/isnull.vb
new file mode 100644
index 000000000..755023889
--- /dev/null
+++ b/basic/qa/vba_tests/isnull.vb
@@ -0,0 +1,27 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+Option Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testIsNull
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testIsNull()
+ On Error GoTo errorHandler
+
+ TestUtil.Assert(IsNull(Null), "IsNull(Null)")
+ TestUtil.Assert(Not IsNull(""), "Not IsNull("""")")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testIsNull", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/vba_tests/isnumeric.vb b/basic/qa/vba_tests/isnumeric.vb
new file mode 100644
index 000000000..ead7e83e1
--- /dev/null
+++ b/basic/qa/vba_tests/isnumeric.vb
@@ -0,0 +1,32 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+Option Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testIsNumeric
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testIsNumeric()
+ On Error GoTo errorHandler
+
+ TestUtil.Assert(IsNumeric(123), "IsNumeric(123)")
+ TestUtil.Assert(IsNumeric(-123), "IsNumeric(-123)")
+ TestUtil.Assert(IsNumeric(123.8), "IsNumeric(123.8)")
+ TestUtil.Assert(Not IsNumeric("a"), "Not IsNumeric(""a"")")
+rem TestUtil.Assert(IsNumeric(True), "IsNumeric(True)")
+ TestUtil.Assert(IsNumeric("123"), "IsNumeric(""123"")")
+ TestUtil.Assert(IsNumeric("+123"), "IsNumeric(""+123"")")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testIsNumeric", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/vba_tests/isobject.vb b/basic/qa/vba_tests/isobject.vb
new file mode 100644
index 000000000..beec43f79
--- /dev/null
+++ b/basic/qa/vba_tests/isobject.vb
@@ -0,0 +1,31 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+Option Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testIsObject
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testIsObject()
+ On Error GoTo errorHandler
+ Dim TestStr As String
+ Dim MyObject As Object
+ Dim YourObject
+
+ Set YourObject = MyObject ' Assign an object reference.
+ TestUtil.Assert(IsObject(YourObject), "IsObject(YourObject)")
+ TestUtil.Assert(Not IsObject(TestStr), "Not IsObject(TestStr)")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testIsObject", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/vba_tests/join.vb b/basic/qa/vba_tests/join.vb
new file mode 100644
index 000000000..c4f568f81
--- /dev/null
+++ b/basic/qa/vba_tests/join.vb
@@ -0,0 +1,33 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+Option Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testJoin
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testJoin()
+ On Error GoTo errorHandler
+ Dim vaArray(2) As String
+ vaArray(0) = "string1"
+ vaArray(1) = "string2"
+ vaArray(2) = "string3"
+
+ TestUtil.AssertEqual(Join(vaArray), "string1 string2 string3", "Join(vaArray)")
+ TestUtil.AssertEqual(Join(vaArray, " "), "string1 string2 string3", "Join(vaArray, "" "")")
+ TestUtil.AssertEqual(Join(vaArray, "<>"), "string1<>string2<>string3", "Join(vaArray, ""<>"")")
+ TestUtil.AssertEqual(Join(vaArray, ""), "string1string2string3", "Join(vaArray, """")")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testJoin", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/vba_tests/lbound.vb b/basic/qa/vba_tests/lbound.vb
new file mode 100644
index 000000000..5e40d709e
--- /dev/null
+++ b/basic/qa/vba_tests/lbound.vb
@@ -0,0 +1,28 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+Option Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testLBound
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testLBound()
+ On Error GoTo errorHandler
+ Dim MyArray(1 To 10, 5 To 15, 10 To 20) ' Declare array variables.
+
+ TestUtil.AssertEqual(LBound(MyArray, 1), 1, "LBound(MyArray, 1)")
+ TestUtil.AssertEqual(LBound(MyArray, 3), 10, "LBound(MyArray, 3)")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testLBound", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/vba_tests/lcase.vb b/basic/qa/vba_tests/lcase.vb
new file mode 100644
index 000000000..0553f338b
--- /dev/null
+++ b/basic/qa/vba_tests/lcase.vb
@@ -0,0 +1,29 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+Option Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testLCase
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testLCase()
+ On Error GoTo errorHandler
+
+ TestUtil.AssertEqual(LCase("LOWERCASE"), "lowercase", "LCase(""LOWERCASE"")")
+ TestUtil.AssertEqual(LCase("LowerCase"), "lowercase", "LCase(""LowerCase"")")
+ TestUtil.AssertEqual(LCase("lowercase"), "lowercase", "LCase(""lowercase"")")
+ TestUtil.AssertEqual(LCase("LOWER CASE"), "lower case", "LCase(""LOWER CASE"")")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testLCase", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/vba_tests/left.vb b/basic/qa/vba_tests/left.vb
new file mode 100644
index 000000000..047497ef0
--- /dev/null
+++ b/basic/qa/vba_tests/left.vb
@@ -0,0 +1,28 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+Option Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testLeft
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testLeft()
+ On Error GoTo errorHandler
+
+ TestUtil.AssertEqual(Left("sometext", 4), "some", "Left(""sometext"", 4)")
+ TestUtil.AssertEqual(Left("sometext", 48), "sometext", "Left(""sometext"", 48)")
+ TestUtil.AssertEqual(Left("", 4), "", "Left("""", 4)")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testLeft", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/vba_tests/len.vb b/basic/qa/vba_tests/len.vb
new file mode 100644
index 000000000..f91ebd04c
--- /dev/null
+++ b/basic/qa/vba_tests/len.vb
@@ -0,0 +1,28 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+Option Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testLen
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testLen()
+ On Error GoTo errorHandler
+
+ TestUtil.AssertEqual(Len("sometext"), 8, "Len(""sometext"")")
+ TestUtil.AssertEqual(Len("some text"), 9, "Len(""some text"")")
+ TestUtil.AssertEqual(Len(""), 0, "Len("""")")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testLen", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/vba_tests/log.vb b/basic/qa/vba_tests/log.vb
new file mode 100644
index 000000000..431bea642
--- /dev/null
+++ b/basic/qa/vba_tests/log.vb
@@ -0,0 +1,28 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+Option Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testLog
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testLog()
+ On Error GoTo errorHandler
+
+ TestUtil.AssertEqualApprox(Log(86), 4.45434729625351, 1E-14, "Log(86)")
+ TestUtil.AssertEqualApprox(Log(2.71828182845904), 1, 1E-14, "Log(2.71828182845904)")
+ TestUtil.AssertEqual(Exp(Log(4)), 4, "Exp(Log(4))")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testLog", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/vba_tests/ltrim.vb b/basic/qa/vba_tests/ltrim.vb
new file mode 100644
index 000000000..c265e6846
--- /dev/null
+++ b/basic/qa/vba_tests/ltrim.vb
@@ -0,0 +1,26 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+Option Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testLTrim
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testLTrim()
+ On Error GoTo errorHandler
+
+ TestUtil.AssertEqual(LTrim(" some text "), "some text ", "LTrim("" some text "")")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testLTrim", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/vba_tests/mid.vb b/basic/qa/vba_tests/mid.vb
new file mode 100644
index 000000000..863e24784
--- /dev/null
+++ b/basic/qa/vba_tests/mid.vb
@@ -0,0 +1,28 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+Option Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testMid
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testMid()
+ On Error GoTo errorHandler
+
+ TestUtil.AssertEqual(Mid("Mid Function Demo", 1, 3), "Mid", "Mid(""Mid Function Demo"", 1, 3)")
+ TestUtil.AssertEqual(Mid("Mid Function Demo", 14, 4), "Demo", "Mid(""Mid Function Demo"", 14, 4)")
+ TestUtil.AssertEqual(Mid("Mid Function Demo", 5), "Function Demo", "Mid(""Mid Function Demo"", 5)")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testMid", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/vba_tests/minute.vb b/basic/qa/vba_tests/minute.vb
new file mode 100644
index 000000000..70deb1252
--- /dev/null
+++ b/basic/qa/vba_tests/minute.vb
@@ -0,0 +1,26 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+Option Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testMinute
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testMinute()
+ On Error GoTo errorHandler
+
+ TestUtil.AssertEqual(Minute("09:34:20"), 34, "Minute(""09:34:20"")")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testMinute", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/vba_tests/month.vb b/basic/qa/vba_tests/month.vb
new file mode 100644
index 000000000..05222071f
--- /dev/null
+++ b/basic/qa/vba_tests/month.vb
@@ -0,0 +1,32 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+Option Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testMonth
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testMonth()
+ On Error GoTo errorHandler
+
+ Dim ldate As Date
+ ldate = 32616
+ TestUtil.AssertEqual(Month(ldate), 4, "Month(ldate)")
+ TestUtil.AssertEqual(Month("01/02/2007"), 2, "Month(""01/02/2007"")")
+ TestUtil.AssertEqual(Month(1), 12, "Month(1)")
+ TestUtil.AssertEqual(Month(60), 2, "Month(60)")
+ TestUtil.AssertEqual(Month(2000), 6, "Month(2000)")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testMonth", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/vba_tests/monthname.vb b/basic/qa/vba_tests/monthname.vb
new file mode 100644
index 000000000..6c01de511
--- /dev/null
+++ b/basic/qa/vba_tests/monthname.vb
@@ -0,0 +1,28 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+Option Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testMonthName
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testMonthName()
+ On Error GoTo errorHandler
+
+ TestUtil.AssertEqual(MonthName(2), "February", "MonthName(2)")
+ TestUtil.AssertEqual(MonthName(2, True), "Feb", "MonthName(2, True)")
+ TestUtil.AssertEqual(MonthName(2, False), "February", "MonthName(2, False)")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testMonthName", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/vba_tests/oct.vb b/basic/qa/vba_tests/oct.vb
new file mode 100644
index 000000000..d733bb763
--- /dev/null
+++ b/basic/qa/vba_tests/oct.vb
@@ -0,0 +1,28 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+Option Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testOct
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testOct()
+ On Error GoTo errorHandler
+
+ TestUtil.AssertEqual(Oct(4), "4", "Oct(4)")
+ TestUtil.AssertEqual(Oct(8), "10", "Oct(8)")
+ TestUtil.AssertEqual(Oct(459), "713", "Oct(459)")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testOct", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/vba_tests/ole_ObjAssignNoDflt.vb b/basic/qa/vba_tests/ole_ObjAssignNoDflt.vb
new file mode 100644
index 000000000..b1a591b0c
--- /dev/null
+++ b/basic/qa/vba_tests/ole_ObjAssignNoDflt.vb
@@ -0,0 +1,30 @@
+Option VBASupport 1
+Function doUnitTest(TestData as String, Driver as String) as String
+Rem Ensure object assignment is by reference
+Rem when object member is used ( as lhs )
+Dim origTimeout As Long
+Dim modifiedTimeout As Long
+Set cn = New ADODB.Connection
+origTimeout = cn.CommandTimeout
+modifiedTimeout = origTimeout * 2
+cn.CommandTimeout = modifiedTimeout
+Dim conStr As String
+conStr = "Provider=MSDASQL;Driver={" & Driver & "};DBQ="
+conStr = conStr & TestData & "; ReadOnly=False;"
+cn.Open conStr
+Set objCmd = New ADODB.Command
+objCmd.ActiveConnection = cn
+If objCmd.ActiveConnection.CommandTimeout <> modifiedTimeout Then
+ Rem if we copied the object by reference then we should have the
+ Rem modified timeout ( because we should be just pointing as cn )
+ doUnitTest = "FAIL expected modified timeout " & modifiedTimeout & " but got " & objCmd.ActiveConnection.CommandTimeout
+ Exit Function
+End If
+cn.CommandTimeout = origTimeout ' restore timeout
+Rem Double check objCmd.ActiveConnection is pointing to objCmd.ActiveConnection
+If objCmd.ActiveConnection.CommandTimeout <> origTimeout Then
+ doUnitTest = "FAIL expected original timeout " & origTimeout & " but got " & objCmd.ActiveConnection.CommandTimeout
+ Exit Function
+End If
+doUnitTest = "OK" ' no error
+End Function
diff --git a/basic/qa/vba_tests/ole_ObjAssignToNothing.vb b/basic/qa/vba_tests/ole_ObjAssignToNothing.vb
new file mode 100644
index 000000000..d68664b41
--- /dev/null
+++ b/basic/qa/vba_tests/ole_ObjAssignToNothing.vb
@@ -0,0 +1,19 @@
+Option VBASupport 1
+Function doUnitTest(TestData as String, Driver as String) as String
+Rem Ensure object assignment is by reference
+Rem when object member is used ( as lhs )
+Rem This time we are testing assigning with special Nothing
+Rem keyword
+Set cn = New ADODB.Connection
+Dim conStr As String
+conStr = "Provider=MSDASQL;Driver={" & Driver & "};DBQ="
+conStr = conStr & TestData & "; ReadOnly=False;"
+cn.Open conStr
+Set objCmd = New ADODB.Command
+objCmd.ActiveConnection = Nothing
+if objCmd.ActiveConnection Is Nothing Then
+ doUnitTest = "OK" ' no error
+Else
+ doUnitTest = "Fail - expected objCmd.ActiveConnection be Nothing"
+End If
+End Function
diff --git a/basic/qa/vba_tests/optional_paramters.vb b/basic/qa/vba_tests/optional_paramters.vb
new file mode 100644
index 000000000..d47854d2f
--- /dev/null
+++ b/basic/qa/vba_tests/optional_paramters.vb
@@ -0,0 +1,208 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testOptionalsVba
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+' tdf#36737 - Test optionals with different datatypes. In LO Basic
+' with option VBASupport, optional parameters are allowed including additional
+' default values. Missing optional parameters having types other than variant,
+' which don't have explicit default values, will be initialized to their
+' respective default value of its datatype
+Sub verify_testOptionalsVba()
+ On Error GoTo errorHandler
+
+ ' tdf#143707 - check correct initialization of default value for optionals
+ ' Without the fix in place, this test would have failed with
+ ' - Expected: 123
+ ' - Actual : 123%
+ TestUtil.AssertEqual(TestOptVariantInit(), 123, "TestOptVariantInit()")
+
+ ' optionals with variant datatypes
+ TestUtil.AssertEqual(TestOptVariant(), 123, "TestOptVariant()")
+ TestUtil.AssertEqual(TestOptVariant(123), 246, "TestOptVariant(123)")
+ TestUtil.AssertEqual(TestOptVariant(, 456), 456, "TestOptVariant(, 456)")
+ TestUtil.AssertEqual(TestOptVariant(123, 456), 579, "TestOptVariant(123, 456)")
+
+ ' optionals with variant datatypes (ByRef and ByVal)
+ TestUtil.AssertEqual(TestOptVariantByRefByVal(), 123, "TestOptVariantByRefByVal()")
+ TestUtil.AssertEqual(TestOptVariantByRefByVal(123), 246, "TestOptVariantByRefByVal(123)")
+ TestUtil.AssertEqual(TestOptVariantByRefByVal(, 456), 456, "TestOptVariantByRefByVal(, 456)")
+ TestUtil.AssertEqual(TestOptVariantByRefByVal(123, 456), 579, "TestOptVariantByRefByVal(123, 456)")
+
+ ' optionals with double datatypes
+ TestUtil.AssertEqualApprox(TestOptDouble(), 123.4, 1E-5, "TestOptDouble()")
+ TestUtil.AssertEqualApprox(TestOptDouble(123.4), 246.8, 1E-5, "TestOptDouble(123.4)")
+ TestUtil.AssertEqualApprox(TestOptDouble(, 567.8), 567.8, 1E-5, "TestOptDouble(, 567.8)")
+ TestUtil.AssertEqualApprox(TestOptDouble(123.4, 567.8), 691.2, 1E-5, "TestOptDouble(123.4, 567.8)")
+
+ ' optionals with double datatypes (ByRef and ByVal)
+ TestUtil.AssertEqualApprox(TestOptDoubleByRefByVal(), 123.4, 1E-5, "TestOptDoubleByRefByVal()")
+ TestUtil.AssertEqualApprox(TestOptDoubleByRefByVal(123.4), 246.8, 1E-5, "TestOptDoubleByRefByVal(123.4)")
+ TestUtil.AssertEqualApprox(TestOptDoubleByRefByVal(, 567.8), 567.8, 1E-5, "TestOptDoubleByRefByVal(, 567.8)")
+ TestUtil.AssertEqualApprox(TestOptDoubleByRefByVal(123.4, 567.8), 691.2, 1E-5, "TestOptDoubleByRefByVal(123.4, 567.8)")
+
+ ' optionals with integer datatypes
+ TestUtil.AssertEqual(TestOptInteger(), 123, "TestOptInteger()")
+ TestUtil.AssertEqual(TestOptInteger(123), 246, "TestOptInteger(123)")
+ TestUtil.AssertEqual(TestOptInteger(, 456), 456, "TestOptInteger(, 456)")
+ TestUtil.AssertEqual(TestOptInteger(123, 456), 579, "TestOptInteger(123, 456)")
+
+ ' optionals with integer datatypes (ByRef and ByVal)
+ TestUtil.AssertEqual(TestOptIntegerByRefByVal(), 123, "TestOptIntegerByRefByVal()")
+ TestUtil.AssertEqual(TestOptIntegerByRefByVal(123), 246, "TestOptIntegerByRefByVal(123)")
+ TestUtil.AssertEqual(TestOptIntegerByRefByVal(, 456), 456, "TestOptIntegerByRefByVal(, 456)")
+ TestUtil.AssertEqual(TestOptIntegerByRefByVal(123, 456), 579, "TestOptIntegerByRefByVal(123, 456)")
+
+ ' optionals with string datatypes
+ TestUtil.AssertEqual(TestOptString(), "123", "TestOptString()")
+ TestUtil.AssertEqual(TestOptString("123"), "123123", "TestOptString(""123"")")
+ TestUtil.AssertEqual(TestOptString(, "456"), "456", "TestOptString(, ""456"")")
+ TestUtil.AssertEqual(TestOptString("123", "456"), "123456", "TestOptString(""123"", ""456"")")
+
+ ' optionals with string datatypes (ByRef and ByVal)
+ TestUtil.AssertEqual(TestOptStringByRefByVal(), "123", "TestOptStringByRefByVal()")
+ TestUtil.AssertEqual(TestOptStringByRefByVal("123"), "123123", "TestOptStringByRefByVal(""123"")")
+ TestUtil.AssertEqual(TestOptStringByRefByVal(, "456"), "456", "TestOptStringByRefByVal(, ""456"")")
+ TestUtil.AssertEqual(TestOptStringByRefByVal("123", "456"), "123456", "TestOptStringByRefByVal(""123"", ""456"")")
+
+ ' optionals with object datatypes
+ Dim cA As New Collection
+ cA.Add (123)
+ cA.Add (456)
+ Dim cB As New Collection
+ cB.Add (123.4)
+ cB.Add (567.8)
+ TestUtil.AssertEqual(TestOptObject(), 0, "TestOptObject()")
+ TestUtil.AssertEqual(TestOptObject(cA), 579, "TestOptObject(A)")
+ TestUtil.AssertEqualApprox(TestOptObject(, cB), 691.2, 1E-5, "TestOptObject(, B)")
+ TestUtil.AssertEqualApprox(TestOptObject(cA, cB), 1270.2, 1E-5, "TestOptObject(A, B)")
+
+ ' optionals with object datatypes (ByRef and ByVal)
+ TestUtil.AssertEqual(TestOptObjectByRefByVal(), 0, "TestOptObjectByRefByVal()")
+ TestUtil.AssertEqual(TestOptObjectByRefByVal(cA), 579, "TestOptObjectByRefByVal(A)")
+ TestUtil.AssertEqualApprox(TestOptObjectByRefByVal(, cB), 691.2, 1E-5, "TestOptObjectByRefByVal(, B)")
+ TestUtil.AssertEqualApprox(TestOptObjectByRefByVal(cA, cB), 1270.2, 1E-5, "TestOptObjectByRefByVal(A, B)")
+
+ ' optionals with array datatypes
+ Dim aA(0 To 1) As Integer
+ aA(0) = 123
+ aA(1) = 456
+ Dim aB(0 To 1) As Variant
+ aB(0) = 123.4
+ aB(1) = 567.8
+ ' TODO - New bug report? Scanner initializes variable not as an array
+ ' TestUtil.AssertEqual(TestOptArray(), 0, "TestOptArray()")
+ ' TestUtil.AssertEqual(TestOptArray(aA), 579, "TestOptArray(A)")
+ ' TestUtil.AssertEqualApprox(TestOptArray(, aB), 691.2, 1E-5, "TestOptArray(, B)")
+ TestUtil.AssertEqualApprox(TestOptArray(aA, aB), 1270.2, 1E-5, "TestOptArray(A, B)")
+
+ ' optionals with array datatypes (ByRef and ByVal)
+ ' TODO - New bug report? Scanner initializes variable not as an array
+ ' TestUtil.AssertEqual(TestOptArrayByRefByVal(), 0, "TestOptArrayByRefByVal()")
+ ' TestUtil.AssertEqual(TestOptArrayByRefByVal(aA), 579, "TestOptArrayByRefByVal(A)")
+ ' TestUtil.AssertEqualApprox(TestOptArrayByRefByVal(, aB), 691.2, 1E-5, "TestOptArrayByRefByVal(, B)")
+ TestUtil.AssertEqualApprox(TestOptArrayByRefByVal(aA, aB), 1270.2, 1E-5, "TestOptArrayByRefByVal(A, B)")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testOptionalsVba", Err, Error$, Erl)
+End Sub
+
+Function TestOptVariantInit(Optional A As Variant = 123)
+ TestOptVariantInit = A
+End Function
+
+Function TestOptVariant(Optional A, Optional B As Variant = 123)
+ TestOptVariant = OptNumberSum(IsMissing(A), A, IsMissing(B), B)
+End Function
+
+Function TestOptVariantByRefByVal(Optional ByRef A, Optional ByVal B As Variant = 123)
+ TestOptVariantByRefByVal = OptNumberSum(IsMissing(A), A, IsMissing(B), B)
+End Function
+
+Function TestOptDouble(Optional A As Double, Optional B As Double = 123.4)
+ TestOptDouble = OptNumberSum(IsMissing(A), A, IsMissing(B), B)
+End Function
+
+Function TestOptDoubleByRefByVal(Optional ByRef A As Double, Optional ByVal B As Double = 123.4)
+ TestOptDoubleByRefByVal = OptNumberSum(IsMissing(A), A, IsMissing(B), B)
+End Function
+
+Function TestOptInteger(Optional A As Integer, Optional B As Integer = 123)
+ TestOptInteger = OptNumberSum(IsMissing(A), A, IsMissing(B), B)
+End Function
+
+Function TestOptIntegerByRefByVal(Optional ByRef A As Integer, Optional ByVal B As Integer = 123)
+ TestOptIntegerByRefByVal = OptNumberSum(IsMissing(A), A, IsMissing(B), B)
+End Function
+
+Function TestOptString(Optional A As String, Optional B As String = "123")
+ TestOptString = OptStringConcat(IsMissing(A), A, IsMissing(B), B)
+End Function
+
+Function TestOptStringByRefByVal(Optional ByRef A As String, Optional ByVal B As String = "123")
+ TestOptStringByRefByVal = OptStringConcat(IsMissing(A), A, IsMissing(B), B)
+End Function
+
+Function TestOptObject(Optional A As Collection, Optional B As Collection)
+ ' TODO - isMissing returns false even though the collection is null and is missing?
+ TestOptObject = 0
+ If Not IsNull(A) Then TestOptObject = CollectionSum(A)
+ If Not IsNull(B) Then TestOptObject = TestOptObject + CollectionSum(B)
+End Function
+
+Function TestOptObjectByRefByVal(Optional ByRef A As Collection, Optional ByVal B As Collection)
+ ' TODO - isMissing returns false even though the collection is null and is missing?
+ TestOptObjectByRefByVal = 0
+ If Not IsNull(A) Then TestOptObjectByRefByVal = CollectionSum(A)
+ If Not IsNull(B) Then TestOptObjectByRefByVal = TestOptObjectByRefByVal + CollectionSum(B)
+End Function
+
+Function TestOptArray(Optional A() As Integer, Optional B() As Variant)
+ TestOptArray = ArraySum(IsMissing(A), A) + ArraySum(IsMissing(B), B)
+End Function
+
+Function TestOptArrayByRefByVal(Optional ByRef A() As Integer, Optional ByVal B() As Variant)
+ TestOptArrayByRefByVal = ArraySum(IsMissing(A), A) + ArraySum(IsMissing(B), B)
+End Function
+
+Function OptNumberSum(is_missingA As Boolean, A, is_missingB As Boolean, B)
+ OptNumberSum = 0
+ If Not is_missingA Then OptNumberSum = A
+ If Not is_missingB Then OptNumberSum = OptNumberSum + B
+End Function
+
+Function OptStringConcat(is_missingA As Boolean, A, is_missingB As Boolean, B)
+ OptStringConcat = ""
+ If Not is_missingA Then OptStringConcat = A
+ If Not is_missingB Then OptStringConcat = OptStringConcat & B
+End Function
+
+Function CollectionSum(C)
+ Dim idx As Integer
+ CollectionSum = 0
+ For idx = 1 To C.Count
+ CollectionSum = CollectionSum + C.Item(idx)
+ Next idx
+End Function
+
+Function ArraySum(is_missingC As Boolean, C)
+ Dim idx As Integer
+ ArraySum = 0
+ If Not is_missingC Then
+ For idx = LBound(C) To UBound(C)
+ ArraySum = ArraySum + C(idx)
+ Next idx
+ End If
+End Function
diff --git a/basic/qa/vba_tests/partition.vb b/basic/qa/vba_tests/partition.vb
new file mode 100644
index 000000000..a31b7a6c8
--- /dev/null
+++ b/basic/qa/vba_tests/partition.vb
@@ -0,0 +1,30 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+Option Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testPartition
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testPartition()
+ On Error GoTo errorHandler
+
+ TestUtil.AssertEqual(Partition(20, 0, 98, 5), "20:24", "Partition(20, 0, 98, 5)")
+ TestUtil.AssertEqual(Partition(20, 0, 99, 1), " 20: 20", "Partition(20, 0, 99, 1)")
+ TestUtil.AssertEqual(Partition(120, 0, 99, 5), "100: ", "Partition(120, 0, 99, 5)")
+ TestUtil.AssertEqual(Partition(-5, 0, 99, 5), " : -1", "Partition(-5, 0, 99, 5)")
+ TestUtil.AssertEqual(Partition(2, 0, 5, 2), " 2: 3", "Partition(2, 0, 5, 2)")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testPartition", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/vba_tests/qbcolor.vb b/basic/qa/vba_tests/qbcolor.vb
new file mode 100644
index 000000000..64e213ad1
--- /dev/null
+++ b/basic/qa/vba_tests/qbcolor.vb
@@ -0,0 +1,34 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+Option Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testQBcolor
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testQBcolor()
+ On Error GoTo errorHandler
+
+ TestUtil.AssertEqual(QBColor(0), 0, "QBColor(0)")
+ TestUtil.AssertEqual(QBColor(1), 8388608, "QBColor(1)")
+ TestUtil.AssertEqual(QBColor(2), 32768, "QBColor(2)")
+ TestUtil.AssertEqual(QBColor(3), 8421376, "QBColor(3)")
+ TestUtil.AssertEqual(QBColor(4), 128, "QBColor(4)")
+ TestUtil.AssertEqual(QBColor(5), 8388736, "QBColor(5)")
+ TestUtil.AssertEqual(QBColor(6), 32896, "QBColor(6)")
+ TestUtil.AssertEqual(QBColor(7), 12632256, "QBColor(7)")
+ TestUtil.AssertEqual(QBColor(8), 8421504, "QBColor(8)")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testQBcolor", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/vba_tests/rate.vb b/basic/qa/vba_tests/rate.vb
new file mode 100644
index 000000000..76f38cdb8
--- /dev/null
+++ b/basic/qa/vba_tests/rate.vb
@@ -0,0 +1,31 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+Option Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testRATE
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testRATE()
+ On Error GoTo errorHandler
+
+ TestUtil.AssertEqualApprox(Rate(3, -5, 0, 16), 0.07, 1E-5, "Rate(3, -5, 0, 16)")
+ TestUtil.AssertEqualApprox(Rate(3, -5, 0, 15), 0, 1E-5, "Rate(3, -5, 0, 15)")
+ TestUtil.AssertEqualApprox(Rate(3, -5, 0, 30), 0.79, 1E-5, "Rate(3, -5, 0, 30)")
+ TestUtil.AssertEqualApprox(Rate(3, -5, 0, 35), 1, 1E-5, "Rate(3, -5, 0, 35)")
+ TestUtil.AssertEqualApprox(Rate(4, -300, 1000, 0, 0), 0.077, 1E-5, "Rate(4, -300, 1000, 0, 0)")
+ TestUtil.AssertEqualApprox(Rate(4, -300, 1000, 0, 1), 0.14, 1E-5, "Rate(4, -300, 1000, 0, 1)")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testRATE", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/vba_tests/redim_objects.vb b/basic/qa/vba_tests/redim_objects.vb
new file mode 100644
index 000000000..9355b28da
--- /dev/null
+++ b/basic/qa/vba_tests/redim_objects.vb
@@ -0,0 +1,42 @@
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+Option Explicit
+
+Type testType
+ iNr As Integer
+ sType As String
+ aValue As Variant
+ oColor As Object
+End Type
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testReDimObjects
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testReDimObjects()
+ On Error GoTo errorHandler
+
+ ' tdf#136755 - ReDim did not work on an array of objects
+ Dim aPropertyValues(1) As New com.sun.star.beans.PropertyValue
+ TestUtil.AssertEqual(UBound(aPropertyValues), 1, "UBound(aPropertyValues)")
+ ReDim aPropertyValues(5) As com.sun.star.beans.PropertyValue
+ TestUtil.AssertEqual(UBound(aPropertyValues), 5, "UBound(aPropertyValues)")
+
+ ' tdf#124008 - ReDim did not work on an array of individual declared types
+ Dim aType(1) As testType
+ TestUtil.AssertEqual(UBound(aType), 1, "UBound(aType)")
+ ReDim aType(5) As testType
+ TestUtil.AssertEqual(UBound(aType), 5, "UBound(aType)")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testReDimObjects", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/vba_tests/replace.vb b/basic/qa/vba_tests/replace.vb
new file mode 100644
index 000000000..ca1fde9c1
--- /dev/null
+++ b/basic/qa/vba_tests/replace.vb
@@ -0,0 +1,37 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+Option Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testReplace
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testReplace()
+ On Error GoTo errorHandler
+
+ TestUtil.AssertEqual(Replace("abcbcdBc", "bc", "ef"), "aefefdBc", "Replace(""abcbcdBc"", ""bc"", ""ef"")")
+ TestUtil.AssertEqual(Replace("abcbcdbc", "bc", "ef"), "aefefdef", "Replace(""abcbcdbc"", ""bc"", ""ef"")")
+ TestUtil.AssertEqual(Replace("abcbcdBc", "bc", "ef", 1, -1, vbBinaryCompare), "aefefdBc", "Replace(""abcbcdBc"", ""bc"", ""ef"", 1, -1, vbBinaryCompare)")
+ TestUtil.AssertEqual(Replace("abcbcdBc", "bc", "ef", 1, -1, vbTextCompare), "aefefdef", "Replace(""abcbcdBc"", ""bc"", ""ef"", 1, -1, vbTextCompare)")
+ TestUtil.AssertEqual(Replace("abcbcdBc", "bc", "ef", compare:=vbTextCompare), "aefefdef", "Replace(""abcbcdBc"", ""bc"", ""ef"", compare:=vbTextCompare)")
+ TestUtil.AssertEqual(Replace("abcbcdBc", "bc", "ef", 3, -1, vbBinaryCompare), "cefdBc", "Replace(""abcbcdBc"", ""bc"", ""ef"", 3, -1, vbBinaryCompare)")
+ TestUtil.AssertEqual(Replace("abcbcdBc", "bc", "ef", 1, 2, vbBinaryCompare), "aefefdBc", "Replace(""abcbcdBc"", ""bc"", ""ef"", 1, 2, vbBinaryCompare)")
+ TestUtil.AssertEqual(Replace("abcbcdBc", "bc", "ef", 1, 0, vbBinaryCompare), "abcbcdBc", "Replace(""abcbcdBc"", ""bc"", ""ef"", 1, 0, vbBinaryCompare)") ' not support in Unix
+
+ ' tdf#132389 - case-insensitive operation for non-ASCII characters
+ TestUtil.AssertEqual(Replace("ABCabc", "b", "*", 1, 2, vbTextCompare), "A*Ca*c", "Replace(""ABCabc"", ""b"", ""*"", 1, 2, vbTextCompare)")
+ TestUtil.AssertEqual(Replace("АБВабв", "б", "*", 1, 2, vbTextCompare), "А*Ва*в", "Replace(""АБВабв"", ""б"", ""*"", 1, 2, vbTextCompare)")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testReplace", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/vba_tests/rgb.vb b/basic/qa/vba_tests/rgb.vb
new file mode 100644
index 000000000..448d19d06
--- /dev/null
+++ b/basic/qa/vba_tests/rgb.vb
@@ -0,0 +1,28 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+Option Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testRGB
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testRGB()
+ On Error GoTo errorHandler
+
+ TestUtil.AssertEqual(RGB(255, 0, 0), 255, "RGB(255, 0, 0)")
+ TestUtil.AssertEqual(RGB(75, 139, 203), 13339467, "RGB(75, 139, 203)")
+ TestUtil.AssertEqual(RGB(255, 255, 255), 16777215, "RGB(255, 255, 255)")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testRGB", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/vba_tests/right.vb b/basic/qa/vba_tests/right.vb
new file mode 100644
index 000000000..c7cb58372
--- /dev/null
+++ b/basic/qa/vba_tests/right.vb
@@ -0,0 +1,28 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+Option Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testRight
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testRight()
+ On Error GoTo errorHandler
+
+ TestUtil.AssertEqual(Right("sometext", 4), "text", "Right(""sometext"", 4)")
+ TestUtil.AssertEqual(Right("sometext", 48), "sometext", "Right(""sometext"", 48)")
+ TestUtil.AssertEqual(Right("", 4), "", "Right("""", 4)")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testRight", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/vba_tests/roundcompatibility.vb b/basic/qa/vba_tests/roundcompatibility.vb
new file mode 100644
index 000000000..aaa078925
--- /dev/null
+++ b/basic/qa/vba_tests/roundcompatibility.vb
@@ -0,0 +1,29 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+Option Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_roundCompatibility
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_roundCompatibility()
+ On Error GoTo errorHandler
+
+ TestUtil.AssertEqual(Round(0.12335,4), 0.1234, "Round(0.12335,4)")
+ TestUtil.AssertEqual(Round(0.12345,4), 0.1234, "Round(0.12345,4)")
+ TestUtil.AssertEqual(Round(0.12355,4), 0.1236, "Round(0.12355,4)")
+ TestUtil.AssertEqual(Round(0.12365,4), 0.1236, "Round(0.12365,4)")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_roundCompatibility", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/vba_tests/rtrim.vb b/basic/qa/vba_tests/rtrim.vb
new file mode 100644
index 000000000..1daf40e56
--- /dev/null
+++ b/basic/qa/vba_tests/rtrim.vb
@@ -0,0 +1,26 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+Option Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testRTrim
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testRTrim()
+ On Error GoTo errorHandler
+
+ TestUtil.AssertEqual(RTrim(" some text "), " some text", "RTrim("" some text "")")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testRTrim", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/vba_tests/second.vb b/basic/qa/vba_tests/second.vb
new file mode 100644
index 000000000..b192ef5d4
--- /dev/null
+++ b/basic/qa/vba_tests/second.vb
@@ -0,0 +1,27 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+Option Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testSecond
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testSecond()
+ On Error GoTo errorHandler
+
+ TestUtil.AssertEqual(Second(37566.3), 0, "Second(37566.3)")
+ TestUtil.AssertEqual(Second("4:35:17"), 17, "Second(""4:35:17"")")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testSecond", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/vba_tests/sgn.vb b/basic/qa/vba_tests/sgn.vb
new file mode 100644
index 000000000..e0475cb7f
--- /dev/null
+++ b/basic/qa/vba_tests/sgn.vb
@@ -0,0 +1,30 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+Option Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_SGN
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_SGN()
+ On Error GoTo errorHandler
+
+ TestUtil.AssertEqual(sgn(0), 0, "sgn(0)")
+ TestUtil.AssertEqual(sgn(-1), -1, "sgn(-1)")
+ TestUtil.AssertEqual(sgn(1), 1, "sgn(1)")
+ TestUtil.AssertEqual(sgn(50), 1, "sgn(50)")
+ TestUtil.AssertEqual(sgn(-50), -1, "sgn(-50)")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_SGN", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/vba_tests/sin.vb b/basic/qa/vba_tests/sin.vb
new file mode 100644
index 000000000..0f416a05c
--- /dev/null
+++ b/basic/qa/vba_tests/sin.vb
@@ -0,0 +1,26 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+Option Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testSIN
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testSIN()
+ On Error GoTo errorHandler
+
+ TestUtil.AssertEqualApprox(Sin(0.45), 0.43496553411123, 1E-14, "Sin(0.45)")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testSIN", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/vba_tests/space.vb b/basic/qa/vba_tests/space.vb
new file mode 100644
index 000000000..70d09c3ea
--- /dev/null
+++ b/basic/qa/vba_tests/space.vb
@@ -0,0 +1,26 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+Option Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testSpace
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testSpace()
+ On Error GoTo errorHandler
+
+ TestUtil.AssertEqual(Space(2), " ", "Space(2)")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testSpace", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/vba_tests/split.vb b/basic/qa/vba_tests/split.vb
new file mode 100644
index 000000000..56d452218
--- /dev/null
+++ b/basic/qa/vba_tests/split.vb
@@ -0,0 +1,57 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+Option Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testSplit
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testSplit
+ On Error GoTo errorHandler
+
+ ' SPLIT
+ TestUtil.AssertEqual(Split( "Hello world" )(1), "world", "Split( ""Hello world"" )(1)")
+
+ ' tdf#123025 - split function sets the datatype of the array to empty,
+ ' preventing any subsequent assignments of values to the array and to the elements itself.
+ Dim arr(1) As String
+ arr = Split("a/b", "/")
+ TestUtil.AssertEqual(arr(0), "a", "Split(""a/b"", ""/"")(0)")
+ TestUtil.AssertEqual(arr(1), "b", "Split(""a/b"", ""/"")(1)")
+ ReDim Preserve arr(1)
+ TestUtil.AssertEqual(arr(0), "a", "ReDim Preserve arr(1)(0)")
+ TestUtil.AssertEqual(arr(1), "b", "ReDim Preserve arr(1)(1)")
+ ReDim arr(1)
+ TestUtil.AssertEqual(arr(0), "", "ReDim arr(1)(0)")
+ TestUtil.AssertEqual(arr(1), "", "ReDim arr(1)(1)")
+
+ arr(0) = "a"
+ arr(1) = "b"
+ TestUtil.AssertEqual(arr(0), "a", "arr(0)")
+ TestUtil.AssertEqual(arr(1), "b", "arr(1)")
+ ReDim Preserve arr(1)
+ TestUtil.AssertEqual(arr(0), "a", "ReDim Preserve arr(1)(0) after assignment")
+ TestUtil.AssertEqual(arr(1), "b", "ReDim Preserve arr(1)(1) after assignment")
+
+ ' tdf#144924 - using VBASupport 1, the split function returns an array of substrings, hence no
+ ' assignment of different data types to the individual elements is possible
+ Dim splitArr
+ splitArr = Split("a/b&&c/d", "&&")
+ ' Without the fix in place, this test would have failed with:
+ ' - Expected: 8 (8 for String)
+ ' - Actual : 8200 (8192 for Array and 8 for String)
+ TestUtil.AssertEqual(VarType(splitArr(0)), 8, "VarType(splitArr(0))")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testSplit", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/vba_tests/sqr.vb b/basic/qa/vba_tests/sqr.vb
new file mode 100644
index 000000000..f7df49148
--- /dev/null
+++ b/basic/qa/vba_tests/sqr.vb
@@ -0,0 +1,26 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+Option Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testSQR
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testSQR()
+ On Error GoTo errorHandler
+
+ TestUtil.AssertEqual(Sqr(9), 3, "Sqr(9)")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testSQR", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/vba_tests/str.vb b/basic/qa/vba_tests/str.vb
new file mode 100644
index 000000000..1a336e9e3
--- /dev/null
+++ b/basic/qa/vba_tests/str.vb
@@ -0,0 +1,29 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+Option Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testSTR
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testSTR()
+ On Error GoTo errorHandler
+
+ TestUtil.AssertEqual(Str(459), " 459", "Str(459)")
+ TestUtil.AssertEqual(Str(-459.65), "-459.65", "Str(-459.65)")
+ TestUtil.AssertEqual(Str(459.001), " 459.001", "Str(459.001)")
+ TestUtil.AssertEqual(Str(0.24), " .24", "Str(0.24)")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testSTR", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/vba_tests/strcomp.vb b/basic/qa/vba_tests/strcomp.vb
new file mode 100644
index 000000000..0c77577c1
--- /dev/null
+++ b/basic/qa/vba_tests/strcomp.vb
@@ -0,0 +1,34 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+Option Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testSTRcomp
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testSTRcomp()
+ On Error GoTo errorHandler
+
+ TestUtil.AssertEqual(StrComp("ABCD", "abcd", vbTextCompare), 0, "StrComp(""ABCD"", ""abcd"", vbTextCompare)")
+ TestUtil.AssertEqual(StrComp("ABCD", "abcd", vbBinaryCompare), -1, "StrComp(""ABCD"", ""abcd"", vbBinaryCompare)")
+ TestUtil.AssertEqual(StrComp("ABCD", "abcd"), -1, "StrComp(""ABCD"", ""abcd"")")
+ TestUtil.AssertEqual(StrComp("text", "text", vbBinaryCompare), 0, "StrComp(""text"", ""text"", vbBinaryCompare)")
+ TestUtil.AssertEqual(StrComp("text ", "text", vbBinaryCompare), 1, "StrComp(""text "", ""text"", vbBinaryCompare)")
+ TestUtil.AssertEqual(StrComp("Text", "text", vbBinaryCompare), -1, "StrComp(""Text"", ""text"", vbBinaryCompare)")
+ TestUtil.AssertEqual(StrComp("text", "text", vbTextCompare), 0, "StrComp(""text"", ""text"", vbTextCompare)")
+ TestUtil.AssertEqual(StrComp("text ", "text", vbTextCompare), 1, "StrComp(""text "", ""text"", vbTextCompare)")
+ TestUtil.AssertEqual(StrComp("Text", "text", vbTextCompare), 0, "StrComp(""Text"", ""text"", vbTextCompare)")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testSTRcomp", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/vba_tests/strconv.vb b/basic/qa/vba_tests/strconv.vb
new file mode 100644
index 000000000..b0295df42
--- /dev/null
+++ b/basic/qa/vba_tests/strconv.vb
@@ -0,0 +1,55 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+Option Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testStrConv
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testStrConv()
+ On Error GoTo errorHandler
+
+ TestUtil.AssertEqual(StrConv("abc EFG hij", vbUpperCase), "ABC EFG HIJ", "StrConv(""abc EFG hij"", vbUpperCase)")
+ TestUtil.AssertEqual(StrConv("abc EFG hij", vbLowerCase), "abc efg hij", "StrConv(""abc EFG hij"", vbLowerCase)")
+ TestUtil.AssertEqual(StrConv("abc EFG hij", vbProperCase), "Abc Efg Hij", "StrConv(""abc EFG hij"", vbProperCase)")
+
+ ' Converts narrow (single-byte) characters in string to wide
+ TestUtil.AssertEqual(StrConv("ABCDEVB¥ì¥¹¥­¥å©", vbWide), "ABCDEVB¥ì¥¹¥­¥å©", "StrConv(""ABCDEVB¥ì¥¹¥­¥å©"", vbWide)")
+
+ ' Converts wide (double-byte) characters in string to narrow (single-byte) characters
+ TestUtil.AssertEqual(StrConv("ABCD@$%23'?EG", vbNarrow), "ABCD@$%23'?EG", "StrConv(""ABCD@$%23'?EG"", vbNarrow)")
+
+ ' Converts Hiragana characters in string to Katakana characters
+ TestUtil.AssertEqual(StrConv("かたかな", vbKatakana), "カタカナ", "StrConv(""かたかな"", vbKatakana)")
+
+ ' Converts Katakana characters in string to Hiragana characters
+ TestUtil.AssertEqual(StrConv("カタカナ", vbHiragana), "かたかな", "StrConv(""カタカナ"", vbHiragana)")
+
+ ' Assumes CP-1252 encoding associated with en-US locale used in unit tests.
+ Dim x() As Byte
+ x = StrConv("ÉϺ£ÊÐABC", vbFromUnicode)
+ TestUtil.AssertEqual(UBound(x), 8, "UBound(x)")
+ TestUtil.AssertEqual(x(0), 201, "x(0)")
+ TestUtil.AssertEqual(x(1), 207, "x(1)")
+ TestUtil.AssertEqual(x(2), 186, "x(2)")
+ TestUtil.AssertEqual(x(3), 163, "x(3)")
+ TestUtil.AssertEqual(x(4), 202, "x(4)")
+ TestUtil.AssertEqual(x(5), 208, "x(5)")
+ TestUtil.AssertEqual(x(6), 65, "x(6)")
+ TestUtil.AssertEqual(x(7), 66, "x(7)")
+ TestUtil.AssertEqual(x(8), 67, "x(8)")
+ TestUtil.AssertEqual(StrConv(x, vbUnicode), "ÉϺ£ÊÐABC", "StrConv(x, vbUnicode)")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testStrConv", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/vba_tests/string.vb b/basic/qa/vba_tests/string.vb
new file mode 100644
index 000000000..eca3fce3b
--- /dev/null
+++ b/basic/qa/vba_tests/string.vb
@@ -0,0 +1,28 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+Option Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testString
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testString()
+ On Error GoTo errorHandler
+
+ TestUtil.AssertEqual(String(5, "P"), "PPPPP", "String(5, ""P"")")
+ TestUtil.AssertEqual(String(5, "a"), "aaaaa", "String(5, ""a"")")
+ TestUtil.AssertEqual(String(0, "P"), "", "String(0, ""P"")")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testString", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/vba_tests/stringplusdouble.vb b/basic/qa/vba_tests/stringplusdouble.vb
new file mode 100644
index 000000000..7c5045ead
--- /dev/null
+++ b/basic/qa/vba_tests/stringplusdouble.vb
@@ -0,0 +1,243 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+Option Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ DSD ' double = string + double
+ SSD ' string = string + double
+ DSS ' double = string + string
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub DSD()
+ Dim s As String
+ Dim d As Double
+ Dim r As Double
+
+ On Error GoTo ErrorHandler
+
+ r = s + d
+ TestUtil.AssertEqual(r, -1, "s = null, d = null, r = s + d")
+
+ r = s & d
+ TestUtil.AssertEqual(r, 0, "s = null, d = null, r = s & d")
+
+ d = 20
+ r = s + d
+ TestUtil.AssertEqual(r, -1, "s = null, d = 20, r = s + d")
+
+ d = 20
+ r = s & d
+ TestUtil.AssertEqual(r, 20, "s = null, d = 20, r = s & d")
+
+ ''''''''''''''
+ s = "10"
+ Dim d2 As Double
+ r = s + d2
+ TestUtil.AssertEqual(r, 10, "s = '10', d = null, r = s + d")
+
+ r = s & d2
+ TestUtil.AssertEqual(r, 100, "s = '10', d = null, r = s & d")
+
+ d2 = 20
+ r = s + d2
+ TestUtil.AssertEqual(r, 30, "s = '10', d = 20, r = s + d")
+
+ d2 = 20
+ r = s & d2
+ TestUtil.AssertEqual(r, 1020, "s = '10', d = 20, r = s & d")
+
+ ''''''''''''''
+ s = "abc"
+ Dim d3 As Double
+ r = s + d3
+ TestUtil.AssertEqual(r, -1, "s = 'abc', d = null, r = s + d")
+
+ r = s & d3
+ TestUtil.AssertEqual(r, -1, "s = 'abc', d = null, r = s & d")
+
+ d3 = 20
+ r = s + d3
+ TestUtil.AssertEqual(r, -1, "s = 'abc', d = 20, r = s + d")
+
+ d3 = 20
+ r = s & d3
+ TestUtil.AssertEqual(r, -1, "s = 'abc', d = 20, r = s & d")
+
+ Exit Sub
+
+ErrorHandler:
+ r = -1
+ Resume Next
+End Sub
+
+Sub SSD()
+ Dim s As String
+ Dim d As Double
+ Dim r As String
+
+ On Error GoTo ErrorHandler
+
+ r = s + d
+ TestUtil.AssertEqual(r, "-1", "s = null, d = null, r = s + d")
+
+ r = s & d
+ TestUtil.AssertEqual(r, "0", "s = null, d = null, r = s & d")
+
+ d = 20
+ r = s + d
+ TestUtil.AssertEqual(r, "-1", "s = null, d = 20, r = s + d")
+
+ d = 20
+ r = s & d
+ TestUtil.AssertEqual(r, "20", "s = null, d = 20, r = s & d")
+
+ ''''''''''''''
+ s = "10"
+ Dim d2 As Double
+ r = s + d2
+ TestUtil.AssertEqual(r, "10", "s = '10', d = null, r = s + d")
+
+ r = s & d2
+ TestUtil.AssertEqual(r, "100", "s = '10', d = null, r = s & d")
+
+ d2 = 20
+ r = s + d2
+ TestUtil.AssertEqual(r, "30", "s = '10', d = 20, r = s + d")
+
+ d2 = 20
+ r = s & d2
+ TestUtil.AssertEqual(r, "1020", "s = '10', d = 20, r = s & d")
+
+ ''''''''''''''
+ s = "abc"
+ Dim d3 As Double
+ r = s + d3
+ TestUtil.AssertEqual(r, "-1", "s = 'abc', d = null, r = s + d")
+
+ r = s & d3
+ TestUtil.AssertEqual(r, "abc0", "s = 'abc', d = null, r = s & d")
+
+ d3 = 20
+ r = s + d3
+ TestUtil.AssertEqual(r, "-1", "s = 'abc', d = 20, r = s + d")
+
+ d3 = 20
+ r = s & d3
+ TestUtil.AssertEqual(r, "abc20", "s = 'abc', d = 20, r = s & d")
+ Exit Sub
+
+ErrorHandler:
+ r = "-1"
+ Resume Next
+End Sub
+
+Sub DSS()
+ Dim s As String
+ Dim d As String
+ Dim r As Double
+
+ On Error GoTo ErrorHandler
+
+ r = s + d
+ TestUtil.AssertEqual(r, -1, "s = null, d = null, r = s + d")
+
+ r = s & d
+ TestUtil.AssertEqual(r, -1, "s = null, d = null, r = s & d")
+
+ d = "20"
+ r = s + d
+ TestUtil.AssertEqual(r, 20, "s = null, d = 20, r = s + d")
+
+ d = "20"
+ r = s & d
+ TestUtil.AssertEqual(r, 20, "s = null, d = 20, r = s & d")
+
+ ''''''''''''''
+ s = "10"
+ Dim d2 As String
+ r = s + d2
+ TestUtil.AssertEqual(r, 10, "s = '10', d = null, r = s + d")
+
+ r = s & d2
+ TestUtil.AssertEqual(r, 10, "s = '10', d = null, r = s & d")
+
+ d2 = "20"
+ r = s + d2
+ TestUtil.AssertEqual(r, 1020, "s = '10', d = 20, r = s + d")
+
+ d2 = "20"
+ r = s & d2
+ TestUtil.AssertEqual(r, 1020, "s = '10', d = 20, r = s & d")
+
+ ''''''''''''''
+ s = "abc"
+ Dim d3 As String
+ r = s + d3
+ TestUtil.AssertEqual(r, -1, "s = 'abc', d = null, r = s + d")
+
+ r = s & d3
+ TestUtil.AssertEqual(r, -1, "s = 'abc', d = null, r = s & d")
+
+ d3 = "20"
+ r = s + d3
+ TestUtil.AssertEqual(r, -1, "s = 'abc', d = 20, r = s + d")
+
+ d3 = "20"
+ r = s & d3
+ TestUtil.AssertEqual(r, -1, "s = 'abc', d = 20, r = s & d")
+ Exit Sub
+
+ErrorHandler:
+ r = -1
+ Resume Next
+End Sub
+
+Sub test2()
+ Dim s As String
+ Dim d As Double
+ s = ""
+ d = s ' fail in MSO
+ MsgBox d
+End Sub
+
+Sub testBoolean()
+ Dim a As String
+ Dim b As Boolean
+ Dim c As Boolean
+ Dim d As String
+
+ b = True
+
+ a = "1"
+ c = a + b ' c = false
+ MsgBox c
+
+ d = a + b 'd = 0
+ MsgBox d
+End Sub
+
+Sub testCurrency()
+ Dim a As String
+ Dim b As Currency
+ Dim c As Currency
+ Dim d As String
+
+ a = "10"
+ b = 30.3
+
+ c = a + b ' c = 40.3
+ MsgBox c
+
+ d = a + b ' c =40.3
+ MsgBox d
+
+End Sub
diff --git a/basic/qa/vba_tests/strreverse.vb b/basic/qa/vba_tests/strreverse.vb
new file mode 100644
index 000000000..ad78bdf8d
--- /dev/null
+++ b/basic/qa/vba_tests/strreverse.vb
@@ -0,0 +1,29 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+Option Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testStrReverse
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testStrReverse()
+ On Error GoTo errorHandler
+
+ TestUtil.AssertEqual(StrReverse("abcd"), "dcba", "StrReverse(""abcd"")")
+ TestUtil.AssertEqual(StrReverse("ABABAB"), "BABABA", "StrReverse(""ABABAB"")")
+ TestUtil.AssertEqual(StrReverse("123456"), "654321", "StrReverse(""123456"")")
+ TestUtil.AssertEqual(StrReverse(6), "6", "StrReverse(6)")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testStrReverse", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/vba_tests/switch.vb b/basic/qa/vba_tests/switch.vb
new file mode 100644
index 000000000..45b1bc05a
--- /dev/null
+++ b/basic/qa/vba_tests/switch.vb
@@ -0,0 +1,32 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+Option Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testSwitch
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testSwitch()
+ On Error GoTo errorHandler
+
+ TestUtil.AssertEqual(MatchUp("Paris"), "French", "MatchUp(""Paris"")")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testSwitch", Err, Error$, Erl)
+End Sub
+
+Function MatchUp(CityName As String)
+ MatchUp = Switch(CityName = "London", "English", _
+ CityName = "Rome", "Italian", _
+ CityName = "Paris", "French")
+End Function
diff --git a/basic/qa/vba_tests/tdf147089_idiv.vb b/basic/qa/vba_tests/tdf147089_idiv.vb
new file mode 100644
index 000000000..515f1e00c
--- /dev/null
+++ b/basic/qa/vba_tests/tdf147089_idiv.vb
@@ -0,0 +1,31 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+Option Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testIDiv
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testIDiv
+ On Error GoTo errorHandler
+
+ ' tdf#147089 - IDIV operands are rounded to Integer values before the operation is performed
+ TestUtil.AssertEqual(8.4 \ 2, 4, "8.4 \ 2")
+ TestUtil.AssertEqual(9.9 \ 2, 5, "9.9 \ 2")
+ TestUtil.AssertEqual(20 \ 4.9, 4, "20 \ 4.9")
+ TestUtil.AssertEqual(20 \ 4.4, 5, "20 \ 4.4")
+ TestUtil.AssertEqual(16.4 \ 5.9, 2, "16.4 \ 5.9")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testIDiv", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/vba_tests/tdf147529_optional_parameters_msgbox.vb b/basic/qa/vba_tests/tdf147529_optional_parameters_msgbox.vb
new file mode 100755
index 000000000..e599f46ee
--- /dev/null
+++ b/basic/qa/vba_tests/tdf147529_optional_parameters_msgbox.vb
@@ -0,0 +1,37 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+Option Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testOptionalParametersMsgBox
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testOptionalParametersMsgBox
+ On Error GoTo errorHandler
+
+ ' tdf#147529 - check for missing optional parameters
+ TestUtil.AssertEqual(TestOptionalParametersMsgBox(), True, "TestOptionalParametersMsgBox()")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testOptionalParametersMsgBox", Err, Error$, Erl)
+End Sub
+
+Function TestOptionalParametersMsgBox(Optional text, Optional dialogType, Optional dialogTitle) As Boolean
+On Error GoTo errorHandler
+ MsgBox text, dialogType, dialogTitle
+ TestOptionalParametersMsgBox = False
+ Exit Function
+errorHandler:
+ TestUtil.AssertEqual(Err, 449, "Argument not optional (Error 449)")
+ TestOptionalParametersMsgBox = True
+End Function
diff --git a/basic/qa/vba_tests/tdf148358_non_ascii_names.vb b/basic/qa/vba_tests/tdf148358_non_ascii_names.vb
new file mode 100644
index 000000000..95e710540
--- /dev/null
+++ b/basic/qa/vba_tests/tdf148358_non_ascii_names.vb
@@ -0,0 +1,33 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+Option Explicit
+
+Function doUnitTest as String
+ TestUtil.TestInit
+ verify_testNonAsciiNames
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Function TestNonAscii as Integer
+ Dim Абв as Integer
+ Абв = 10
+ TestNonAscii = абв
+End Function
+
+Sub verify_testNonAsciiNames
+ On Error GoTo errorHandler
+
+ ' tdf#148358 - compare Non-ASCII variable names case-insensitive
+ TestUtil.AssertEqual(TestNonAscii(), 10, "TestNonAscii()")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testNonAsciiNames", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/vba_tests/timeserial.vb b/basic/qa/vba_tests/timeserial.vb
new file mode 100644
index 000000000..be2c9d2bc
--- /dev/null
+++ b/basic/qa/vba_tests/timeserial.vb
@@ -0,0 +1,35 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+Option Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testTimeSerial
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testTimeSerial()
+ Dim timeVal As Date
+ On Error GoTo errorHandler
+
+rem bug 114229
+rem timeVal = "5:45:00"
+rem TestUtil.AssertEqual(TimeSerial(12 - 6, -15, 0), timeVal, "TimeSerial(12 - 6, -15, 0)")
+
+ timeVal = "12:30:00"
+ TestUtil.AssertEqual(TimeSerial(12, 30, 0), timeVal, "TimeSerial(12, 30, 0)")
+
+rem timeVal = "11:30:00"
+rem TestUtil.AssertEqual(TimeSerial(10, 90, 0), timeVal, "TimeSerial(10, 90, 0)")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testTimeSerial", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/vba_tests/timevalue.vb b/basic/qa/vba_tests/timevalue.vb
new file mode 100644
index 000000000..e53d55b27
--- /dev/null
+++ b/basic/qa/vba_tests/timevalue.vb
@@ -0,0 +1,28 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+Option Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testTimeValue
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testTimeValue()
+ Dim timeVal As Date
+ On Error GoTo errorHandler
+
+ timeVal = "16:35:17"
+ TestUtil.AssertEqual(TimeValue("4:35:17 PM"), timeVal, "TimeValue(""4:35:17 PM"")")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testTimeValue", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/vba_tests/trim.vb b/basic/qa/vba_tests/trim.vb
new file mode 100644
index 000000000..d5f3a32ac
--- /dev/null
+++ b/basic/qa/vba_tests/trim.vb
@@ -0,0 +1,26 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+Option Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testTrim
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testTrim()
+ On Error GoTo errorHandler
+
+ TestUtil.AssertEqual(Trim(" some text "), "some text", "Trim("" some text "")")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testTrim", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/vba_tests/typename.vb b/basic/qa/vba_tests/typename.vb
new file mode 100644
index 000000000..98bfd58fe
--- /dev/null
+++ b/basic/qa/vba_tests/typename.vb
@@ -0,0 +1,69 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+Option Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testTypeName
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testTypeName()
+ On Error GoTo errorHandler
+ Dim b1 As Boolean
+ Dim c1 As Byte
+ Dim d1 As Date
+ Dim d2 As Double
+ Dim i1 As Integer
+ Dim l1 As Long
+ Dim s1 As String
+
+ Dim TestIntSign%
+ Dim TestLongSign&
+ Dim TestSingleSign!
+ Dim TestDoubleSign#
+ Dim TestCurrSign@
+ Dim TestStrSign$
+
+ TestUtil.AssertEqual(TypeName(s1), "String", "TypeName(s1)")
+ TestUtil.AssertEqual(TypeName(b1), "Boolean", "TypeName(b1)")
+ TestUtil.AssertEqual(TypeName(c1), "Byte", "TypeName(c1)")
+ TestUtil.AssertEqual(TypeName(d1), "Date", "TypeName(d1)")
+ TestUtil.AssertEqual(TypeName(d2), "Double", "TypeName(d2)")
+ TestUtil.AssertEqual(TypeName(i1), "Integer", "TypeName(i1)")
+ TestUtil.AssertEqual(TypeName(l1), "Long", "TypeName(l1)")
+
+ ' tdf#129596 - Types of constant values
+ TestUtil.AssertEqual(TypeName(32767), "Integer", "TypeName(32767)")
+ TestUtil.AssertEqual(TypeName(-32767), "Integer", "TypeName(-32767)")
+ TestUtil.AssertEqual(TypeName(1048575), "Long", "TypeName(1048575)")
+ TestUtil.AssertEqual(TypeName(-1048575), "Long", "TypeName(-1048575)")
+
+ TestUtil.AssertEqual(TypeName(TestIntSign), "Integer", "TypeName(TestIntSign)")
+ TestUtil.AssertEqual(TypeName(TestLongSign), "Long", "TypeName(TestLongSign)")
+ TestUtil.AssertEqual(TypeName(TestSingleSign), "Single", "TypeName(TestSingleSign)")
+ TestUtil.AssertEqual(TypeName(TestDoubleSign), "Double", "TypeName(TestDoubleSign)")
+ TestUtil.AssertEqual(TypeName(TestCurrSign), "Currency", "TypeName(TestCurrSign)")
+ TestUtil.AssertEqual(TypeName(TestStrSign), "String", "TypeName(TestStrSign)")
+
+ ' tdf#143707 - check correct initialization of default value for optionals
+ ' Without the fix in place, this test would have failed with
+ ' - Expected: Integer
+ ' - Actual : String
+ TestUtil.AssertEqual(TestOptVariantInit(), "Integer", "TestOptVariantInit()")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testTypeName", Err, Error$, Erl)
+End Sub
+
+Function TestOptVariantInit(Optional A As Variant = 123)
+ TestOptVariantInit = TypeName(A)
+End Function
diff --git a/basic/qa/vba_tests/ubound.vb b/basic/qa/vba_tests/ubound.vb
new file mode 100644
index 000000000..587940699
--- /dev/null
+++ b/basic/qa/vba_tests/ubound.vb
@@ -0,0 +1,29 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+Option Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testUBound
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testUBound()
+ On Error GoTo errorHandler
+ Dim A(1 To 100, 0 To 3, -3 To 4)
+
+ TestUtil.AssertEqual(UBound(A, 1), 100, "UBound(A, 1)")
+ TestUtil.AssertEqual(UBound(A, 2), 3, "UBound(A, 2)")
+ TestUtil.AssertEqual(UBound(A, 3), 4, "UBound(A, 3)")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testUBound", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/vba_tests/ucase.vb b/basic/qa/vba_tests/ucase.vb
new file mode 100644
index 000000000..7f898ea7e
--- /dev/null
+++ b/basic/qa/vba_tests/ucase.vb
@@ -0,0 +1,26 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+Option Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testUCase
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testUCase()
+ On Error GoTo errorHandler
+
+ TestUtil.AssertEqual(UCase("hello 12"), "HELLO 12", "UCase(""hello 12"")")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testUCase", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/vba_tests/val.vb b/basic/qa/vba_tests/val.vb
new file mode 100644
index 000000000..473f16123
--- /dev/null
+++ b/basic/qa/vba_tests/val.vb
@@ -0,0 +1,35 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+Option Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testVal
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testVal()
+ On Error GoTo errorHandler
+
+ TestUtil.AssertEqual(Val("02/04/2010"), 2, "Val(""02/04/2010"")")
+ TestUtil.AssertEqual(Val("1050"), 1050, "Val(""1050"")")
+ TestUtil.AssertEqual(Val("130.75"), 130.75, "Val(""130.75"")")
+ TestUtil.AssertEqual(Val("50 Park Lane"), 50, "Val(""50 Park Lane"")")
+ TestUtil.AssertEqual(Val("1320 then some text"), 1320, "Val(""1320 then some text"")")
+ TestUtil.AssertEqual(Val("L13.5"), 0, "Val(""L13.5"")")
+ TestUtil.AssertEqual(Val("sometext"), 0, "Val(""sometext"")")
+REM tdf#111999
+REM TestUtil.AssertEqual(Val("1, 2"), 1, "Val(""1, 2"")")
+ TestUtil.AssertEqual(Val("&HFFFF"), -1, "Val(""&HFFFF"")")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testVal", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/vba_tests/vartype.vb b/basic/qa/vba_tests/vartype.vb
new file mode 100644
index 000000000..2d8345ed1
--- /dev/null
+++ b/basic/qa/vba_tests/vartype.vb
@@ -0,0 +1,63 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+Option Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testVarType
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testVarType()
+ Dim TestDateTime As Date
+ Dim TestStr As String
+ Dim TestInt As Integer
+ Dim TestLong As Long
+ Dim TestDouble As Double
+ Dim TestBoo As Boolean
+ Dim TestSingle As Single
+ Dim TestCurr As Currency
+
+ Dim TestIntSign%
+ Dim TestLongSign&
+ Dim TestSingleSign!
+ Dim TestDoubleSign#
+ Dim TestCurrSign@
+ Dim TestStrSign$
+ On Error GoTo errorHandler
+
+ TestUtil.AssertEqual(vbInteger, 2, "vbInteger")
+ TestUtil.AssertEqual(vbLong, 3, "vbLong")
+ TestUtil.AssertEqual(vbSingle, 4, "vbSingle")
+ TestUtil.AssertEqual(vbDouble, 5, "vbDouble")
+ TestUtil.AssertEqual(vbCurrency, 6, "vbCurrency")
+ TestUtil.AssertEqual(vbDate, 7, "vbDate")
+ TestUtil.AssertEqual(vbString, 8, "vbString")
+ TestUtil.AssertEqual(vbBoolean, 11, "vbBoolean")
+
+ TestUtil.AssertEqual(VarType(TestStr), vbString, "VarType(TestStr)")
+ TestUtil.AssertEqual(VarType(TestBoo), vbBoolean, "VarType(TestBoo)")
+ TestUtil.AssertEqual(VarType(TestDouble), vbDouble, "VarType(TestDouble)")
+ TestUtil.AssertEqual(VarType(TestLong), vbLong, "VarType(TestLong)")
+ TestUtil.AssertEqual(VarType(TestInt), vbInteger, "VarType(TestInt)")
+ TestUtil.AssertEqual(VarType(TestDateTime), vbDate, "VarType(TestDateTime)")
+ TestUtil.AssertEqual(VarType(TestSingle), vbSingle, "VarType(TestSingle)")
+ TestUtil.AssertEqual(VarType(TestCurr), vbCurrency, "VarType(TestCurr)")
+
+ TestUtil.AssertEqual(VarType(TestIntSign), vbInteger, "VarType(TestIntSign)")
+ TestUtil.AssertEqual(VarType(TestLongSign), vbLong, "VarType(TestLongSign)")
+ TestUtil.AssertEqual(VarType(TestSingleSign), vbSingle, "VarType(TestSingleSign)")
+ TestUtil.AssertEqual(VarType(TestDoubleSign), vbDouble, "VarType(TestDoubleSign)")
+ TestUtil.AssertEqual(VarType(TestCurrSign), vbCurrency, "VarType(TestCurrSign)")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testVarType", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/vba_tests/weekday.vb b/basic/qa/vba_tests/weekday.vb
new file mode 100644
index 000000000..2ff4fbe47
--- /dev/null
+++ b/basic/qa/vba_tests/weekday.vb
@@ -0,0 +1,31 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+Option Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testWeekDay
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testWeekDay()
+ On Error GoTo errorHandler
+
+ TestUtil.AssertEqual(Weekday(#6/7/2009#, vbMonday), 7, "Weekday(#6/7/2009#, vbMonday)")
+ TestUtil.AssertEqual(Weekday(#7/7/2009#, vbMonday), 2, "Weekday(#7/7/2009#, vbMonday)")
+ TestUtil.AssertEqual(Weekday(#8/7/2009#, vbMonday), 5, "Weekday(#8/7/2009#, vbMonday)")
+ TestUtil.AssertEqual(Weekday(#12/7/2009#, vbMonday), 1, "Weekday(#12/7/2009#, vbMonday)")
+ TestUtil.AssertEqual(Weekday(#6/7/2009#, vbSunday), 1, "Weekday(#6/7/2009#, vbSunday)")
+ TestUtil.AssertEqual(Weekday(#6/7/2009#, 4), 5, "Weekday(#6/7/2009#, 4)")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testWeekDay", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/vba_tests/weekdayname.vb b/basic/qa/vba_tests/weekdayname.vb
new file mode 100644
index 000000000..bddbdb773
--- /dev/null
+++ b/basic/qa/vba_tests/weekdayname.vb
@@ -0,0 +1,33 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+Option Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testWeekDayName
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testWeekDayName()
+ On Error GoTo errorHandler
+
+ ' basic/qa/cppunit/test_vba.cxx sets LANGUAGE_ENGLISH_UK
+ TestUtil.AssertEqual(WeekdayName(1), "Monday", "WeekdayName(1)")
+ TestUtil.AssertEqual(WeekdayName(1, , vbSunday), "Sunday", "WeekdayName(1, , vbSunday)")
+ TestUtil.AssertEqual(WeekdayName(1, , vbMonday), "Monday", "WeekdayName(1, , vbMonday)")
+ TestUtil.AssertEqual(WeekdayName(2), "Tuesday","WeekdayName(2)")
+ TestUtil.AssertEqual(WeekdayName(2, True, vbMonday), "Tue", "WeekdayName(2, True, vbMonday)")
+ TestUtil.AssertEqual(WeekdayName(2, True, vbTuesday), "Wed", "WeekdayName(2, True, vbTuesday)")
+ TestUtil.AssertEqual(WeekdayName(2, True, vbWednesday), "Thu", "WeekdayName(2, True, vbWednesday)")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testWeekDayName", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/vba_tests/win32compat.vb b/basic/qa/vba_tests/win32compat.vb
new file mode 100644
index 000000000..020c1245b
--- /dev/null
+++ b/basic/qa/vba_tests/win32compat.vb
@@ -0,0 +1,47 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+' Test built-in compatibility versions of methods whose absence
+' is really felt in VBA, and large numbers of macros import from
+' the system.
+'
+
+Option VBASupport 1
+Option Explicit
+
+Private Declare Function QueryPerformanceCounter Lib "kernel32" (ByRef lpPerformanceCount As Currency) As Long
+Private Declare Function QueryPerformanceFrequency Lib "kernel32" (ByRef lpFrequency As Currency) As Long
+
+Function doUnitTest() As String
+ TestUtil.TestInit()
+ verify_win32compat
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_win32compat()
+ Dim freq As Currency
+ Dim count_a As Currency
+ Dim count_b As Currency
+ Dim success As Long
+
+ On Error GoTo errorHandler
+
+ success = QueryPerformanceFrequency(freq)
+ TestUtil.Assert(success <> 0, "QueryPerformanceFrequency")
+ TestUtil.Assert(freq > 0, "QueryPerformanceFrequency", "perf. frequency is incorrect " & freq)
+
+ success = QueryPerformanceCounter(count_a)
+ TestUtil.Assert(success <> 0, "QueryPerformanceCounter(count_a)")
+
+ success = QueryPerformanceCounter(count_b)
+ TestUtil.Assert(success <> 0, "QueryPerformanceCounter(count_b)")
+ TestUtil.Assert(count_a < count_b, "count mismatch " & count_a & " is > " & count_b)
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_win32compat", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/vba_tests/win32compatb.vb b/basic/qa/vba_tests/win32compatb.vb
new file mode 100644
index 000000000..f729725ea
--- /dev/null
+++ b/basic/qa/vba_tests/win32compatb.vb
@@ -0,0 +1,66 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+' Test built-in compatibility versions of methods whose absence
+' is really felt in VBA, and large numbers of macros import from
+' the system.
+'
+' This module tests different signatures for the same methods.
+'
+
+Option VBASupport 1
+Option Explicit
+
+Private Type LARGE_INTEGER
+ lowpart As Long
+ highpart As Long
+End Type
+
+Private Declare Function QueryPerformanceCounter Lib "kernel32" (lpPerformanceCount As LARGE_INTEGER) As Long
+Private Declare Function QueryPerformanceFrequency Lib "kernel32" (lpFrequency As LARGE_INTEGER) As Long
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_win32compatb
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Function convertLarge(scratch As LARGE_INTEGER) As Double
+ Dim ret As Double
+ ret = scratch.highpart
+ ret = ret * 65536 * 65536
+ ret = ret + scratch.lowpart
+ convertLarge = ret
+End Function
+
+Sub verify_win32compatb()
+ Dim scratch as LARGE_INTEGER
+ Dim freq As Double
+ Dim count_a As Double
+ Dim count_b As Double
+ Dim success As Long
+
+ On Error GoTo errorHandler
+
+ success = QueryPerformanceFrequency(scratch)
+ TestUtil.Assert(success <> 0, "QueryPerformanceFrequency")
+ freq = convertLarge(scratch)
+ TestUtil.Assert(freq > 0, "QueryPerformanceFrequency", "perf. frequency is incorrect " & freq)
+
+ success = QueryPerformanceCounter(scratch)
+ TestUtil.Assert(success <> 0, "QueryPerformanceCounter")
+ count_a = convertLarge(scratch)
+
+' success = QueryPerformanceCounter(scratch)
+' TestUtil.Assert(success <> 0, "fetching performance count")
+' count_b = convertLarge(scratch)
+' TestUtil.Assert(count_a < count_b, "count mismatch " & count_a & " is > " & count_b)
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_win32compatb", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/vba_tests/year.vb b/basic/qa/vba_tests/year.vb
new file mode 100644
index 000000000..3ba0df62d
--- /dev/null
+++ b/basic/qa/vba_tests/year.vb
@@ -0,0 +1,27 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+Option Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testYear
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testYear()
+ On Error GoTo errorHandler
+
+ TestUtil.AssertEqual(Year("12/2/1969"), 1969, "Year(""12/2/1969"")")
+ TestUtil.AssertEqual(Year(256), 1900, "Year(256)")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testYear", Err, Error$, Erl)
+End Sub