summaryrefslogtreecommitdiffstats
path: root/basic/qa
diff options
context:
space:
mode:
authorDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 05:54:39 +0000
committerDaniel Baumann <daniel.baumann@progress-linux.org>2024-04-15 05:54:39 +0000
commit267c6f2ac71f92999e969232431ba04678e7437e (patch)
tree358c9467650e1d0a1d7227a21dac2e3d08b622b2 /basic/qa
parentInitial commit. (diff)
downloadlibreoffice-267c6f2ac71f92999e969232431ba04678e7437e.tar.xz
libreoffice-267c6f2ac71f92999e969232431ba04678e7437e.zip
Adding upstream version 4:24.2.0.upstream/4%24.2.0
Signed-off-by: Daniel Baumann <daniel.baumann@progress-linux.org>
Diffstat (limited to 'basic/qa')
-rw-r--r--basic/qa/basic_coverage/da-DK/cdbl-2.bas24
-rw-r--r--basic/qa/basic_coverage/da-DK/cdbl.bas24
-rw-r--r--basic/qa/basic_coverage/dateadd.bas31
-rw-r--r--basic/qa/basic_coverage/test_CallByName.bas43
-rw-r--r--basic/qa/basic_coverage/test_Collection_class.bas71
-rw-r--r--basic/qa/basic_coverage/test_Date.bas21
-rw-r--r--basic/qa/basic_coverage/test_Property.GetLet.bas28
-rw-r--r--basic/qa/basic_coverage/test_Property.GetSet.bas38
-rw-r--r--basic/qa/basic_coverage/test_abs_method.bas19
-rw-r--r--basic/qa/basic_coverage/test_array_method.bas22
-rw-r--r--basic/qa/basic_coverage/test_asc_method.bas17
-rw-r--r--basic/qa/basic_coverage/test_atn_method.bas17
-rw-r--r--basic/qa/basic_coverage/test_beep_method.bas14
-rw-r--r--basic/qa/basic_coverage/test_booltypename.bas46
-rw-r--r--basic/qa/basic_coverage/test_cbool_method.bas18
-rw-r--r--basic/qa/basic_coverage/test_cbyte_method.bas18
-rw-r--r--basic/qa/basic_coverage/test_ccur_method.bas24
-rw-r--r--basic/qa/basic_coverage/test_cdate_method.bas18
-rw-r--r--basic/qa/basic_coverage/test_cdatetofromiso_methods.bas43
-rw-r--r--basic/qa/basic_coverage/test_cdatetounodatecdatefromunodate_methods.bas20
-rw-r--r--basic/qa/basic_coverage/test_cdatetounodatetimecdatefromunodatetime_methods.bas20
-rw-r--r--basic/qa/basic_coverage/test_cdatetounotimecdatefromunotime_methods.bas20
-rw-r--r--basic/qa/basic_coverage/test_cdbl_method.bas30
-rw-r--r--basic/qa/basic_coverage/test_chdircurdir_methods.bas14
-rw-r--r--basic/qa/basic_coverage/test_choose_method.bas18
-rw-r--r--basic/qa/basic_coverage/test_chr_method.bas30
-rw-r--r--basic/qa/basic_coverage/test_chr_overflow_method.bas66
-rw-r--r--basic/qa/basic_coverage/test_cint_method.bas18
-rw-r--r--basic/qa/basic_coverage/test_compatibilitymode_method.bas17
-rw-r--r--basic/qa/basic_coverage/test_converttofromurl_methods.bas34
-rw-r--r--basic/qa/basic_coverage/test_cossin_methods.bas17
-rw-r--r--basic/qa/basic_coverage/test_createobject_method.bas22
-rw-r--r--basic/qa/basic_coverage/test_createunolistener_method.bas15
-rw-r--r--basic/qa/basic_coverage/test_createunoservice_method.bas15
-rw-r--r--basic/qa/basic_coverage/test_createunostruct_method.bas15
-rw-r--r--basic/qa/basic_coverage/test_createunovalue_method.bas17
-rw-r--r--basic/qa/basic_coverage/test_csng_method.bas18
-rw-r--r--basic/qa/basic_coverage/test_cstr_method.bas37
-rw-r--r--basic/qa/basic_coverage/test_cvar_method.bas18
-rw-r--r--basic/qa/basic_coverage/test_cverr_method.bas30
-rw-r--r--basic/qa/basic_coverage/test_date_literal.bas17
-rw-r--r--basic/qa/basic_coverage/test_datedateadddatediff_methods.bas20
-rw-r--r--basic/qa/basic_coverage/test_datedatepartday_methods.bas20
-rw-r--r--basic/qa/basic_coverage/test_declare_from_dll.bas36
-rw-r--r--basic/qa/basic_coverage/test_dimarray_method.bas20
-rw-r--r--basic/qa/basic_coverage/test_empty_parameter.bas22
-rw-r--r--basic/qa/basic_coverage/test_environ_method.bas14
-rw-r--r--basic/qa/basic_coverage/test_equalunoobjects_method.bas25
-rw-r--r--basic/qa/basic_coverage/test_erl_method.bas22
-rw-r--r--basic/qa/basic_coverage/test_err_method.bas24
-rw-r--r--basic/qa/basic_coverage/test_falsetrue_method.bas18
-rw-r--r--basic/qa/basic_coverage/test_filedatetime_nonexistent.bas23
-rw-r--r--basic/qa/basic_coverage/test_filedatetime_nonexistent2.bas23
-rw-r--r--basic/qa/basic_coverage/test_fix_method.bas17
-rw-r--r--basic/qa/basic_coverage/test_for_each.bas43
-rw-r--r--basic/qa/basic_coverage/test_frac_method.bas17
-rw-r--r--basic/qa/basic_coverage/test_freefile_method.bas17
-rw-r--r--basic/qa/basic_coverage/test_freelibrary_method.bas14
-rw-r--r--basic/qa/basic_coverage/test_getdefaultcontext_method.bas14
-rw-r--r--basic/qa/basic_coverage/test_getdialogzoomfactorx_method.bas17
-rw-r--r--basic/qa/basic_coverage/test_getdialogzoomfactory_method.bas17
-rw-r--r--basic/qa/basic_coverage/test_getguitype_method.bas17
-rw-r--r--basic/qa/basic_coverage/test_getguiversion_method.bas17
-rw-r--r--basic/qa/basic_coverage/test_getpathseparator_method.bas17
-rw-r--r--basic/qa/basic_coverage/test_getprocessservicemanager_method.bas14
-rw-r--r--basic/qa/basic_coverage/test_getsolarversion_method.bas17
-rw-r--r--basic/qa/basic_coverage/test_getsystemtype_method.bas17
-rw-r--r--basic/qa/basic_coverage/test_hasunointerfaces_method.bas18
-rw-r--r--basic/qa/basic_coverage/test_hex_method.bas17
-rw-r--r--basic/qa/basic_coverage/test_hour_method.bas18
-rw-r--r--basic/qa/basic_coverage/test_iif_method.bas18
-rw-r--r--basic/qa/basic_coverage/test_instr_method.bas30
-rw-r--r--basic/qa/basic_coverage/test_int_method.bas17
-rw-r--r--basic/qa/basic_coverage/test_isarray_method.bas20
-rw-r--r--basic/qa/basic_coverage/test_isdate_method.bas20
-rw-r--r--basic/qa/basic_coverage/test_isempty_method.bas20
-rw-r--r--basic/qa/basic_coverage/test_iserror_method.bas24
-rw-r--r--basic/qa/basic_coverage/test_ismissing_basic.bas175
-rw-r--r--basic/qa/basic_coverage/test_ismissing_cascade.bas36
-rw-r--r--basic/qa/basic_coverage/test_ismissing_compatible.bas175
-rw-r--r--basic/qa/basic_coverage/test_isnull_method.bas20
-rw-r--r--basic/qa/basic_coverage/test_isnumeric_method.bas20
-rw-r--r--basic/qa/basic_coverage/test_isobject_method.bas19
-rw-r--r--basic/qa/basic_coverage/test_isunostruct_method.bas19
-rw-r--r--basic/qa/basic_coverage/test_join_method.bas34
-rw-r--r--basic/qa/basic_coverage/test_lbound_method.bas21
-rw-r--r--basic/qa/basic_coverage/test_lcase_method.bas19
-rw-r--r--basic/qa/basic_coverage/test_left_method.bas28
-rw-r--r--basic/qa/basic_coverage/test_len_method.bas19
-rw-r--r--basic/qa/basic_coverage/test_lenb_method.bas19
-rw-r--r--basic/qa/basic_coverage/test_like.bas41
-rw-r--r--basic/qa/basic_coverage/test_logexp_methods.bas17
-rw-r--r--basic/qa/basic_coverage/test_ltrim_method.bas19
-rw-r--r--basic/qa/basic_coverage/test_method_name_variable.bas37
-rw-r--r--basic/qa/basic_coverage/test_mid_CountNegative_3args.bas17
-rw-r--r--basic/qa/basic_coverage/test_mid_EndOutOfBounds_3args.bas17
-rw-r--r--basic/qa/basic_coverage/test_mid_StartOutOfBounds_2args.bas17
-rw-r--r--basic/qa/basic_coverage/test_mid_StartOutOfBounds_3args.bas17
-rw-r--r--basic/qa/basic_coverage/test_mid_firstletter_3args.bas17
-rw-r--r--basic/qa/basic_coverage/test_mid_keyword_names.bas26
-rw-r--r--basic/qa/basic_coverage/test_mid_replace_less.bas19
-rw-r--r--basic/qa/basic_coverage/test_mid_replace_more.bas19
-rw-r--r--basic/qa/basic_coverage/test_mid_replace_more_end.bas19
-rw-r--r--basic/qa/basic_coverage/test_mid_sub2letters_2args.bas17
-rw-r--r--basic/qa/basic_coverage/test_minute_method.bas18
-rw-r--r--basic/qa/basic_coverage/test_mod_operator.bas27
-rw-r--r--basic/qa/basic_coverage/test_month_method.bas20
-rw-r--r--basic/qa/basic_coverage/test_non_ascii_names.bas37
-rw-r--r--basic/qa/basic_coverage/test_non_ascii_names_compatible.bas45
-rw-r--r--basic/qa/basic_coverage/test_nowtimevalue_methods.bas22
-rw-r--r--basic/qa/basic_coverage/test_numeric_constant_parameter.bas37
-rw-r--r--basic/qa/basic_coverage/test_oct_method.bas17
-rw-r--r--basic/qa/basic_coverage/test_option_base.bas50
-rw-r--r--basic/qa/basic_coverage/test_option_base_compatible.bas52
-rw-r--r--basic/qa/basic_coverage/test_optional_paramter_type.bas40
-rw-r--r--basic/qa/basic_coverage/test_optional_paramters_basic.bas270
-rw-r--r--basic/qa/basic_coverage/test_optional_paramters_compatible.bas272
-rw-r--r--basic/qa/basic_coverage/test_qbcolor_method.bas17
-rw-r--r--basic/qa/basic_coverage/test_random_methods.bas18
-rw-r--r--basic/qa/basic_coverage/test_redim_objects.bas35
-rw-r--r--basic/qa/basic_coverage/test_resolvepath_method.bas17
-rw-r--r--basic/qa/basic_coverage/test_rgb_method.bas17
-rw-r--r--basic/qa/basic_coverage/test_right_method.bas28
-rw-r--r--basic/qa/basic_coverage/test_rtrim_method.bas19
-rw-r--r--basic/qa/basic_coverage/test_second_method.bas18
-rw-r--r--basic/qa/basic_coverage/test_sgn_method.bas17
-rw-r--r--basic/qa/basic_coverage/test_space_method.bas17
-rw-r--r--basic/qa/basic_coverage/test_spc_method.bas17
-rw-r--r--basic/qa/basic_coverage/test_split_method.bas65
-rw-r--r--basic/qa/basic_coverage/test_sqr_method.bas17
-rw-r--r--basic/qa/basic_coverage/test_strcomp_method.bas19
-rw-r--r--basic/qa/basic_coverage/test_string_literal_comparison.bas21
-rw-r--r--basic/qa/basic_coverage/test_string_method.bas31
-rw-r--r--basic/qa/basic_coverage/test_string_overflow_safe.bas29
-rw-r--r--basic/qa/basic_coverage/test_string_replace.bas46
-rw-r--r--basic/qa/basic_coverage/test_strtrim_methods.bas17
-rw-r--r--basic/qa/basic_coverage/test_switch_method.bas22
-rw-r--r--basic/qa/basic_coverage/test_tab_method.bas17
-rw-r--r--basic/qa/basic_coverage/test_tan_method.bas17
-rw-r--r--basic/qa/basic_coverage/test_tdf111313.bas19
-rw-r--r--basic/qa/basic_coverage/test_tdf125637.bas34
-rw-r--r--basic/qa/basic_coverage/test_tdf132388_ReplacePerformance.bas28
-rw-r--r--basic/qa/basic_coverage/test_tdf134692.bas38
-rw-r--r--basic/qa/basic_coverage/test_tdf147089_idiv.bas30
-rw-r--r--basic/qa/basic_coverage/test_tdf147529_optional_parameters_msgbox.bas36
-rw-r--r--basic/qa/basic_coverage/test_tdf149622.bas48
-rw-r--r--basic/qa/basic_coverage/test_tdf150137_parse_fail.bas37
-rw-r--r--basic/qa/basic_coverage/test_tdf98778.bas29
-rw-r--r--basic/qa/basic_coverage/test_timer_method.bas18
-rw-r--r--basic/qa/basic_coverage/test_timeserialtimevalue_methods.bas18
-rw-r--r--basic/qa/basic_coverage/test_transliteration.bas52
-rw-r--r--basic/qa/basic_coverage/test_twipsperpixelx_method.bas18
-rw-r--r--basic/qa/basic_coverage/test_twipsperpixely_method.bas18
-rw-r--r--basic/qa/basic_coverage/test_typelen_method.bas58
-rw-r--r--basic/qa/basic_coverage/test_typename_method.bas80
-rw-r--r--basic/qa/basic_coverage/test_types_conversion.bas86
-rw-r--r--basic/qa/basic_coverage/test_ucase_method.bas19
-rw-r--r--basic/qa/basic_coverage/test_unsigned_integers.bas46
-rw-r--r--basic/qa/basic_coverage/test_val_method.bas18
-rw-r--r--basic/qa/basic_coverage/test_vartype_method.bas95
-rw-r--r--basic/qa/basic_coverage/test_wait_method.bas14
-rw-r--r--basic/qa/basic_coverage/test_weekday_method.bas20
-rw-r--r--basic/qa/basic_coverage/test_year_method.bas20
-rw-r--r--basic/qa/basic_coverage/uno_struct_assign.bas16
-rw-r--r--basic/qa/cppunit/_test_asserts.bas72
-rw-r--r--basic/qa/cppunit/_test_asserts.vb73
-rw-r--r--basic/qa/cppunit/basic_coverage.cxx126
-rw-r--r--basic/qa/cppunit/basictest.cxx125
-rw-r--r--basic/qa/cppunit/basictest.hxx52
-rw-r--r--basic/qa/cppunit/test_append.cxx78
-rw-r--r--basic/qa/cppunit/test_compiler_checks.cxx117
-rw-r--r--basic/qa/cppunit/test_global_array.cxx86
-rw-r--r--basic/qa/cppunit/test_global_as_new.cxx83
-rw-r--r--basic/qa/cppunit/test_language_conditionals.cxx166
-rw-r--r--basic/qa/cppunit/test_nested_struct.cxx323
-rw-r--r--basic/qa/cppunit/test_scanner.cxx1165
-rw-r--r--basic/qa/cppunit/test_vba.cxx267
-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.vb51
-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.vb50
-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.vb38
-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.vb31
-rw-r--r--basic/qa/vba_tests/len.vb28
-rw-r--r--basic/qa/vba_tests/like.vb42
-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.vb32
-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.vb38
-rw-r--r--basic/qa/vba_tests/ole_ObjAssignToNothing.vb27
-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.vb31
-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.vb63
-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.vb64
-rw-r--r--basic/qa/vba_tests/string.vb32
-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
-rw-r--r--basic/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.vb71
-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.vb65
-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
283 files changed, 12078 insertions, 0 deletions
diff --git a/basic/qa/basic_coverage/da-DK/cdbl-2.bas b/basic/qa/basic_coverage/da-DK/cdbl-2.bas
new file mode 100644
index 0000000000..a3fb352ea1
--- /dev/null
+++ b/basic/qa/basic_coverage/da-DK/cdbl-2.bas
@@ -0,0 +1,24 @@
+'
+' 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 Explicit
+
+Function doUnitTest() as String
+ Dim A As String
+ Dim B As Double
+ Dim Expected As Double
+ A = "222,222"
+ ' in da-DK locale ',' is the decimal separator
+ Expected = 222.222
+ B = Cdbl(A)
+ If B <> Expected Then
+ doUnitTest = "FAIL"
+ Else
+ doUnitTest = "OK"
+ End If
+End Function
diff --git a/basic/qa/basic_coverage/da-DK/cdbl.bas b/basic/qa/basic_coverage/da-DK/cdbl.bas
new file mode 100644
index 0000000000..452f168fe2
--- /dev/null
+++ b/basic/qa/basic_coverage/da-DK/cdbl.bas
@@ -0,0 +1,24 @@
+'
+' 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 Explicit
+
+Function doUnitTest() as String
+ Dim A As String
+ Dim B As Double
+ Dim Expected As String
+ A = "222.222"
+ ' in da-DK locale ',' is the decimal separator
+ Expected = "222222"
+ B = Cdbl(A)
+ If B <> Expected Then
+ doUnitTest = "FAIL"
+ Else
+ doUnitTest = "OK"
+ End If
+End Function
diff --git a/basic/qa/basic_coverage/dateadd.bas b/basic/qa/basic_coverage/dateadd.bas
new file mode 100644
index 0000000000..409a55a9b7
--- /dev/null
+++ b/basic/qa/basic_coverage/dateadd.bas
@@ -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 Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testDateAdd
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testDateAdd()
+ On Error GoTo errorHandler
+
+ ' tdf#117612
+ TestUtil.AssertEqual(DateAdd("m", 1, "2014-01-29"), CDate("2014-02-28"), "DateAdd(""m"", 1, ""2014-01-29"")")
+
+ ' tdf#114011 Without the fix in place, this test would have failed with
+ ' returned 01/31/32767, expected 12/31/32767
+ TestUtil.AssertEqual(DateAdd("m", 1, 31012004), CDate("32767-12-31"), "DateAdd(""m"", 1, 31012004)")
+ TestUtil.AssertEqual(DateAdd("M", 1, 31012005), CDate("32767-12-31"), "DateAdd(""M"", 1, 31012005)")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testDateAdd", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/basic_coverage/test_CallByName.bas b/basic/qa/basic_coverage/test_CallByName.bas
new file mode 100644
index 0000000000..3eca805fb1
--- /dev/null
+++ b/basic/qa/basic_coverage/test_CallByName.bas
@@ -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 Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_CallByName
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_CallByName()
+ Const _Get = 2, _Let = 4, _Method = 1, _Set = 8
+
+ On Error GoTo errorHandler
+
+ ' Basic modules are Objects
+ TestUtil.AssertEqual(CallByName(TestUtil, "failCount", _Get), 0, "CallByName(TestUtil, ""failCount"", _Get")
+ TestUtil.AssertEqual(CallByName(TestUtil, "passCount", _Get), 1, "CallByName(TestUtil, ""passCount"", _Get")
+ TestUtil.AssertEqual(CallByName(TestUtil, "GetResult", _Method), "OK", "CallByName(TestUtil, ""GetResult"", _Method")
+
+ ' Collection instances
+ Dim c As New Collection
+ c.Add(100, "1st") : c.Add(101)
+ TestUtil.AssertEqual(CallByName(c,"Count", _Get), 2, "CallByName(c,""Count"", _Get)")
+ c.Remove(2)
+ TestUtil.AssertEqual(CallByName(callType:=_Get, object:=c, procName:="Count"), 1, _
+ "CallByName(callType:=_Get, object:=c, procName:=""Count"")")
+
+ ' ClassModule instances or UNO services are 'CallByNamable' objects too!
+ ' see https://help.libreoffice.org/7.4/en-US/text/sbasic/shared/CallByName.html?DbPAR=BASIC#bm_id3150669
+ ' for more _Let and _Set examples
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_CallByName", Err, Error$, Erl)
+ Resume Next
+
+End Sub \ No newline at end of file
diff --git a/basic/qa/basic_coverage/test_Collection_class.bas b/basic/qa/basic_coverage/test_Collection_class.bas
new file mode 100644
index 0000000000..06ed6b6658
--- /dev/null
+++ b/basic/qa/basic_coverage/test_Collection_class.bas
@@ -0,0 +1,71 @@
+'
+' 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 Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ Call verify_Collection
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_Collection()
+try: On Error GoTo catch
+
+ Dim c As New Collection, planet as String, ndx As Integer
+
+ TestUtil.assertEqual(c.Count, 0,"c.Count")
+
+ ' Let's collect Solar system planets from closest to SUN,
+ ' ranking them alphabetically using before/after keywords,
+ ' in order to validate various Add() method syntax variations.
+ c.Add("Mercury")
+ c.Add("Venus", "♀")
+ c.Add("Earth", "♁", before:=1)
+ TestUtil.assertEqual(c.Count, 3,"c.Count")
+ TestUtil.assertEqual(c.Item(1), "Earth","c.Item(1)")
+ TestUtil.assertEqual(c.Item("♁"), "Earth","c.Item(""♁"")")
+ TestUtil.assertEqual(c.Item(3), "Venus","c.Item(3)")
+ TestUtil.assertEqual(c.Item("♀"), "Venus","c.Item(""♀"")")
+
+ c.Add("Mars", "♂", after:="♁")
+ c.Add("Jupiter", after:="♁")
+ c.Add("Saturn", before:=5)
+ TestUtil.assertEqual(c.Count, 6,"c.Count")
+ TestUtil.assertEqual(c.Item(2), "Jupiter","c.Item(2)")
+ TestUtil.assertEqual(c.Item(3), "Mars","c.Item(3)")
+ TestUtil.assertEqual(c.Item("♂"), "Mars","c.Item(""♂"")")
+ TestUtil.assertEqual(c.Item(5), "Saturn","c.Item(5)")
+ TestUtil.assertEqual(c.Item(6), "Venus","c.Item(6)")
+
+ c.Add("Uranus", before:="♀")
+ c.Add("Neptune", "♆", after:=4)
+ TestUtil.assertEqual(c.Count, 8,"c.Count")
+ TestUtil.assertEqual(c.Item(7), "Uranus","c.Item(7)")
+ TestUtil.assertEqual(c.Item(5), "Neptune","c.Item(5)")
+ TestUtil.assertEqual(c.Item("♆"), "Neptune","c.Item(""♆"")")
+ TestUtil.assertEqual(c.Item(6), "Saturn","c.Item(6)")
+
+ c.remove(4)
+ c.remove("♁")
+
+ TestUtil.assertEqual(c.Count, 6,"c.Count")
+
+ For ndx = c.Count to 1 Step -1
+ c.Remove(ndx)
+ Next ndx
+
+ TestUtil.assertEqual(c.Count, 0,"c.Count")
+
+finally:
+ Exit Sub
+
+catch:
+ TestUtil.ReportErrorHandler("verify_Collection", Err, Error$, Erl)
+ Resume Next
+End Sub
diff --git a/basic/qa/basic_coverage/test_Date.bas b/basic/qa/basic_coverage/test_Date.bas
new file mode 100644
index 0000000000..8154da1859
--- /dev/null
+++ b/basic/qa/basic_coverage/test_Date.bas
@@ -0,0 +1,21 @@
+'
+' 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 Explicit
+
+Function doUnitTest as String
+ ''' Return 'text' OR 'date' variable '''
+
+ If ( TypeName(Date$)<>"String" Or Vartype(Date())<>V_DATE) Then
+ doUnitTest = "FAIL" ' not successful
+ Else
+ doUnitTest = "OK" ' Ok
+ End If
+End Function
+
+Sub DEV_TST : MsgBox doUnitTesT : End Sub \ No newline at end of file
diff --git a/basic/qa/basic_coverage/test_Property.GetLet.bas b/basic/qa/basic_coverage/test_Property.GetLet.bas
new file mode 100644
index 0000000000..f8fa6dd14b
--- /dev/null
+++ b/basic/qa/basic_coverage/test_Property.GetLet.bas
@@ -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 Explicit
+Option Compatible
+
+Function doUnitTest as String
+ ' PROPERTY GET/LET
+ aString = "Office"
+ If ( aString <> "LibreOffice") Then
+ doUnitTest = "FAIL" ' Ko
+ Else
+ doUnitTest = "OK" ' Ok
+ End If
+End Function
+
+Dim _pn As String
+Property Get aString As String
+ aString = _pn
+End Property
+Property Let aString(value As String)
+ _pn = "Libre"& value
+End Property
diff --git a/basic/qa/basic_coverage/test_Property.GetSet.bas b/basic/qa/basic_coverage/test_Property.GetSet.bas
new file mode 100644
index 0000000000..701bcc7f49
--- /dev/null
+++ b/basic/qa/basic_coverage/test_Property.GetSet.bas
@@ -0,0 +1,38 @@
+'
+' 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 Explicit
+Option Compatible
+
+Function doUnitTest as String
+ ' PROPERTY GET/SET for classes or UNO services
+
+ Set objSetter = New Collection ' OR objLetter = New Collection
+ If ( objGetter.Count <> 3 ) Then
+ doUnitTest = "FAIL" ' not Ok
+ Else
+ doUnitTest = "OK" ' Ok
+ End If
+End Function
+
+Sub DEV_TST : MsgBox doUnitTesT : End Sub
+
+Property Get objGetter As Object
+ _obj.add "roots"
+ Set objGetter = _obj
+End Property
+
+Private _obj As Object
+
+Property Set objSetter(value As Object)
+ Set _obj = value
+ With _obj
+ .add "branches"
+ .add "leaves"
+ End With
+End Property
diff --git a/basic/qa/basic_coverage/test_abs_method.bas b/basic/qa/basic_coverage/test_abs_method.bas
new file mode 100644
index 0000000000..e9d4b95258
--- /dev/null
+++ b/basic/qa/basic_coverage/test_abs_method.bas
@@ -0,0 +1,19 @@
+' 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 Explicit
+
+Function doUnitTest as String
+ ' ABS
+ If (Abs(-3.5) <> 3.5) Then
+ doUnitTest = "FAIL"
+ ElseIf (Abs(3.5) <> 3.5) Then
+ doUnitTest = "FAIL"
+ Else
+ doUnitTest = "OK"
+ End If
+End Function
diff --git a/basic/qa/basic_coverage/test_array_method.bas b/basic/qa/basic_coverage/test_array_method.bas
new file mode 100644
index 0000000000..1456826198
--- /dev/null
+++ b/basic/qa/basic_coverage/test_array_method.bas
@@ -0,0 +1,22 @@
+'
+' 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 Explicit
+
+Function doUnitTest as String
+ dim aVector as Variant
+ ' ARRAY
+ aVector = Array( "Hello", -3.14)
+ If (aVector(0) <> "Hello") Then
+ doUnitTest = "FAIL"
+ ElseIf ( aVector(1) <> -3.14 ) Then
+ doUnitTest = "FAIL"
+ Else
+ doUnitTest = "OK"
+ End If
+End Function
diff --git a/basic/qa/basic_coverage/test_asc_method.bas b/basic/qa/basic_coverage/test_asc_method.bas
new file mode 100644
index 0000000000..131c7cbe1d
--- /dev/null
+++ b/basic/qa/basic_coverage/test_asc_method.bas
@@ -0,0 +1,17 @@
+' 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 Explicit
+
+Function doUnitTest as String
+ ' ASC
+ If (Asc("€a") <> 8364) Then
+ doUnitTest = "FAIL"
+ Else
+ doUnitTest = "OK"
+ End If
+End Function
diff --git a/basic/qa/basic_coverage/test_atn_method.bas b/basic/qa/basic_coverage/test_atn_method.bas
new file mode 100644
index 0000000000..9e2f382c13
--- /dev/null
+++ b/basic/qa/basic_coverage/test_atn_method.bas
@@ -0,0 +1,17 @@
+' 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 Explicit
+
+Function doUnitTest as String
+ ' ATN (arc tan)
+ If (Atn(1) <> PI/4) Then
+ doUnitTest = "FAIL"
+ Else
+ doUnitTest = "OK"
+ End If
+End Function
diff --git a/basic/qa/basic_coverage/test_beep_method.bas b/basic/qa/basic_coverage/test_beep_method.bas
new file mode 100644
index 0000000000..8270341b4b
--- /dev/null
+++ b/basic/qa/basic_coverage/test_beep_method.bas
@@ -0,0 +1,14 @@
+' 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 Explicit
+
+Function doUnitTest as String
+ ' BEEP
+ Beep
+ doUnitTest = "OK"
+End Function
diff --git a/basic/qa/basic_coverage/test_booltypename.bas b/basic/qa/basic_coverage/test_booltypename.bas
new file mode 100644
index 0000000000..f8ed1f13e2
--- /dev/null
+++ b/basic/qa/basic_coverage/test_booltypename.bas
@@ -0,0 +1,46 @@
+'
+' 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 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/basic_coverage/test_cbool_method.bas b/basic/qa/basic_coverage/test_cbool_method.bas
new file mode 100644
index 0000000000..70d3459abc
--- /dev/null
+++ b/basic/qa/basic_coverage/test_cbool_method.bas
@@ -0,0 +1,18 @@
+'
+' 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 Explicit
+
+Function doUnitTest as String
+ ' CBOOL
+ If (CBool(3) <> True) Then
+ doUnitTest = "FAIL"
+ Else
+ doUnitTest = "OK"
+ End If
+End Function
diff --git a/basic/qa/basic_coverage/test_cbyte_method.bas b/basic/qa/basic_coverage/test_cbyte_method.bas
new file mode 100644
index 0000000000..d8dbe65693
--- /dev/null
+++ b/basic/qa/basic_coverage/test_cbyte_method.bas
@@ -0,0 +1,18 @@
+'
+' 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 Explicit
+
+Function doUnitTest as String
+ ' CBYTE
+ If (CByte("3") <> 3) Then
+ doUnitTest = "FAIL"
+ Else
+ doUnitTest = "OK"
+ End If
+End Function
diff --git a/basic/qa/basic_coverage/test_ccur_method.bas b/basic/qa/basic_coverage/test_ccur_method.bas
new file mode 100644
index 0000000000..cd700cad3c
--- /dev/null
+++ b/basic/qa/basic_coverage/test_ccur_method.bas
@@ -0,0 +1,24 @@
+'
+' 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 Explicit
+
+Function doUnitTest as String
+
+ doUnitTest = "FAIL"
+
+ ' CCUR
+ if (CCur("100") <> 100) Then Exit Function
+ ' tdf#141050 - passing a number with + sign
+ if (CCur("+100") <> 100) Then Exit Function
+ ' tdf#141050 - passing a number with - sign
+ if (CCur("-100") <> -100) Then Exit Function
+
+ doUnitTest = "OK"
+
+End Function
diff --git a/basic/qa/basic_coverage/test_cdate_method.bas b/basic/qa/basic_coverage/test_cdate_method.bas
new file mode 100644
index 0000000000..2e4bbd1e99
--- /dev/null
+++ b/basic/qa/basic_coverage/test_cdate_method.bas
@@ -0,0 +1,18 @@
+'
+' 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 Explicit
+
+Function doUnitTest as String
+ ' CDATE
+ If (CDate(100) <> 100) Then
+ doUnitTest = "FAIL"
+ Else
+ doUnitTest = "OK"
+ End If
+End Function
diff --git a/basic/qa/basic_coverage/test_cdatetofromiso_methods.bas b/basic/qa/basic_coverage/test_cdatetofromiso_methods.bas
new file mode 100644
index 0000000000..8cb65b74d3
--- /dev/null
+++ b/basic/qa/basic_coverage/test_cdatetofromiso_methods.bas
@@ -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 Explicit
+
+Function doUnitTest as String
+ ' CDateFromIso CDateToIso
+ If ( CDateToIso( CDateFromIso("20161016") ) <> "20161016" ) Then
+ doUnitTest = "FAIL"
+ ElseIf ( CDateToIso( CDateFromIso("2016-10-16") ) <> "20161016" ) Then
+ doUnitTest = "FAIL"
+ ElseIf ( CDateToIso( CDateFromIso("-2016-10-16") ) <> "-20161016" ) Then
+ doUnitTest = "FAIL"
+ ElseIf ( CDateToIso( CDateFromIso("-20161016") ) <> "-20161016" ) Then
+ doUnitTest = "FAIL"
+ ElseIf ( CDateToIso( CDateFromIso("12016-10-16") ) <> "120161016" ) Then
+ doUnitTest = "FAIL"
+ ElseIf ( CDateToIso( CDateFromIso("120161016") ) <> "120161016" ) Then
+ doUnitTest = "FAIL"
+ ElseIf ( CDateToIso( CDateFromIso("-12016-10-16") ) <> "-120161016" ) Then
+ doUnitTest = "FAIL"
+ ElseIf ( CDateToIso( CDateFromIso("-120161016") ) <> "-120161016" ) Then
+ doUnitTest = "FAIL"
+ ElseIf ( CDateToIso( CDateFromIso("0001-01-01") ) <> "00010101" ) Then
+ doUnitTest = "FAIL"
+ ElseIf ( CDateToIso( CDateFromIso("00010101") ) <> "00010101" ) Then
+ doUnitTest = "FAIL"
+ ElseIf ( CDateToIso( CDateFromIso("-0001-12-31") ) <> "-00011231" ) Then
+ doUnitTest = "FAIL"
+ ElseIf ( CDateToIso( CDateFromIso("-00011231") ) <> "-00011231" ) Then
+ doUnitTest = "FAIL"
+ ElseIf ( CDateToIso( CDateFromIso("991231") ) <> "19991231" ) Then
+ doUnitTest = "FAIL"
+ Else
+ doUnitTest = "OK"
+ End If
+ ' TODO: add some failure tests for misformed input, On Error whatever?
+End Function
diff --git a/basic/qa/basic_coverage/test_cdatetounodatecdatefromunodate_methods.bas b/basic/qa/basic_coverage/test_cdatetounodatecdatefromunodate_methods.bas
new file mode 100644
index 0000000000..cf71398157
--- /dev/null
+++ b/basic/qa/basic_coverage/test_cdatetounodatecdatefromunodate_methods.bas
@@ -0,0 +1,20 @@
+'
+' 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 Explicit
+
+Function doUnitTest as String
+ dim aDate as Date
+ aDate = Date()
+ ' CDateToUnoDate CDateFromUnoDate
+ If ( CDateFromUnoDate( CDateToUnoDate( aDate ) ) <> aDate ) Then
+ doUnitTest = "FAIL"
+ Else
+ doUnitTest = "OK"
+ End If
+End Function
diff --git a/basic/qa/basic_coverage/test_cdatetounodatetimecdatefromunodatetime_methods.bas b/basic/qa/basic_coverage/test_cdatetounodatetimecdatefromunodatetime_methods.bas
new file mode 100644
index 0000000000..ef8d296831
--- /dev/null
+++ b/basic/qa/basic_coverage/test_cdatetounodatetimecdatefromunodatetime_methods.bas
@@ -0,0 +1,20 @@
+'
+' 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 Explicit
+
+Function doUnitTest as String
+ dim aDate as Date
+ aDate = Now()
+ ' CDateToUnoDateTime CDateFromUnoDateTime
+ If ( CDateFromUnoDateTime( CDateToUnoDateTime( aDate ) ) <> aDate ) Then
+ doUnitTest = "FAIL"
+ Else
+ doUnitTest = "OK"
+ End If
+End Function
diff --git a/basic/qa/basic_coverage/test_cdatetounotimecdatefromunotime_methods.bas b/basic/qa/basic_coverage/test_cdatetounotimecdatefromunotime_methods.bas
new file mode 100644
index 0000000000..ac26647557
--- /dev/null
+++ b/basic/qa/basic_coverage/test_cdatetounotimecdatefromunotime_methods.bas
@@ -0,0 +1,20 @@
+'
+' 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 Explicit
+
+Function doUnitTest as String
+ dim aDate as Date
+ aDate = Time()
+ ' CDateToUnoTime CDateFromUnoTime
+ If ( CDateFromUnoTime( CDateToUnoTime( aDate ) ) <> aDate ) Then
+ doUnitTest = "FAIL"
+ Else
+ doUnitTest = "OK"
+ End If
+End Function
diff --git a/basic/qa/basic_coverage/test_cdbl_method.bas b/basic/qa/basic_coverage/test_cdbl_method.bas
new file mode 100644
index 0000000000..e44c23456f
--- /dev/null
+++ b/basic/qa/basic_coverage/test_cdbl_method.bas
@@ -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 Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testCdbl
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testCdbl
+ On Error GoTo errorHandler
+
+ ' CDBL
+ TestUtil.AssertEqual(CDbl("100"), 100, "CDbl(""100"")")
+
+ ' 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/basic_coverage/test_chdircurdir_methods.bas b/basic/qa/basic_coverage/test_chdircurdir_methods.bas
new file mode 100644
index 0000000000..58e0bab02e
--- /dev/null
+++ b/basic/qa/basic_coverage/test_chdircurdir_methods.bas
@@ -0,0 +1,14 @@
+' 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 Explicit
+
+Function doUnitTest as String
+ ' CHDIR CURDIR
+ ChDir( CurDir )
+ doUnitTest = "OK"
+End Function
diff --git a/basic/qa/basic_coverage/test_choose_method.bas b/basic/qa/basic_coverage/test_choose_method.bas
new file mode 100644
index 0000000000..163a387ba4
--- /dev/null
+++ b/basic/qa/basic_coverage/test_choose_method.bas
@@ -0,0 +1,18 @@
+'
+' 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 Explicit
+
+Function doUnitTest as String
+ ' CHOOSE
+ If (Choose(2, 1, 100, 3) <> 100) Then
+ doUnitTest = "FAIL"
+ Else
+ doUnitTest = "OK"
+ End If
+End Function
diff --git a/basic/qa/basic_coverage/test_chr_method.bas b/basic/qa/basic_coverage/test_chr_method.bas
new file mode 100644
index 0000000000..96d6fe3d99
--- /dev/null
+++ b/basic/qa/basic_coverage/test_chr_method.bas
@@ -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 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/basic_coverage/test_chr_overflow_method.bas b/basic/qa/basic_coverage/test_chr_overflow_method.bas
new file mode 100644
index 0000000000..9c1df6659c
--- /dev/null
+++ b/basic/qa/basic_coverage/test_chr_overflow_method.bas
@@ -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/.
+
+Option Explicit
+
+Function overflow1 as Integer
+ On Error GoTo handler
+ Chr(-32769)
+ overflow1 = 0
+ Exit Function
+handler:
+ if (Err <> 6) Then
+ overflow1 = 0
+ Exit Function
+ Endif
+ overflow1 = 1
+End Function
+
+Function overflow2 as Integer
+ On Error GoTo handler
+ Chr(65536)
+ overflow2 = 0
+ Exit Function
+handler:
+ if (Err <> 6) Then
+ overflow2 = 0
+ Exit Function
+ Endif
+ overflow2 = 1
+End Function
+
+Function overflow3 as Integer
+ On Error GoTo handler
+ Chr(&H10000)
+ overflow3 = 0
+ Exit Function
+handler:
+ if (Err <> 6) Then
+ overflow3 = 0
+ Exit Function
+ Endif
+ overflow3 = 1
+End Function
+
+Function doUnitTest as String
+ Chr(-32768)
+ Chr(65535)
+ Chr(&H8000)
+ Chr(&HFFFF)
+ if (overflow1 = 0) Then
+ doUnitTest = "FAIL"
+ Exit Function
+ Endif
+ if (overflow2 = 0) Then
+ doUnitTest = "FAIL"
+ Exit Function
+ Endif
+ if (overflow3 = 0) Then
+ doUnitTest = "FAIL"
+ Exit Function
+ Endif
+ doUnitTest = "OK"
+End Function
diff --git a/basic/qa/basic_coverage/test_cint_method.bas b/basic/qa/basic_coverage/test_cint_method.bas
new file mode 100644
index 0000000000..e3bd740947
--- /dev/null
+++ b/basic/qa/basic_coverage/test_cint_method.bas
@@ -0,0 +1,18 @@
+'
+' 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 Explicit
+
+Function doUnitTest as String
+ ' CINT
+ If (CInt("100") <> 100) Then
+ doUnitTest = "FAIL"
+ Else
+ doUnitTest = "OK"
+ End If
+End Function
diff --git a/basic/qa/basic_coverage/test_compatibilitymode_method.bas b/basic/qa/basic_coverage/test_compatibilitymode_method.bas
new file mode 100644
index 0000000000..4d8256c1d2
--- /dev/null
+++ b/basic/qa/basic_coverage/test_compatibilitymode_method.bas
@@ -0,0 +1,17 @@
+' 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 Explicit
+
+Function doUnitTest as String
+ ' CompatibilityMode
+ If (CompatibilityMode(True) <> True) Then
+ doUnitTest = "FAIL"
+ Else
+ doUnitTest = "OK"
+ End If
+End Function
diff --git a/basic/qa/basic_coverage/test_converttofromurl_methods.bas b/basic/qa/basic_coverage/test_converttofromurl_methods.bas
new file mode 100644
index 0000000000..c17d17e631
--- /dev/null
+++ b/basic/qa/basic_coverage/test_converttofromurl_methods.bas
@@ -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 Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testConvertToFromUrl
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testConvertToFromUrl
+ On Error GoTo errorHandler
+
+ TestUtil.AssertEqual( ConvertToUrl( ConvertFromUrl("") ), "", "ConvertToUrl( ConvertFromUrl("") )")
+
+ ' tdf#152917: Without the fix in place, this test would have failed with
+ ' Failed: ConvertFromUrl("file:///foo/bar/test.txt") returned , expected /foo/bar/test.txt
+ If (GetGUIType() <> 1) Then
+ 'Linux
+ TestUtil.AssertEqual( ConvertFromUrl("file:///foo/bar/test.txt"), "/foo/bar/test.txt", "ConvertFromUrl(""file:///foo/bar/test.txt"")")
+ Else
+ 'Windows
+ TestUtil.AssertEqual( ConvertFromUrl("file://foo/bar/test.txt"), "\\foo\bar\test.txt", "ConvertFromUrl(""file://foo/bar/test.txt"")")
+ End If
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testConvertToFromUrl", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/basic_coverage/test_cossin_methods.bas b/basic/qa/basic_coverage/test_cossin_methods.bas
new file mode 100644
index 0000000000..733a6afa34
--- /dev/null
+++ b/basic/qa/basic_coverage/test_cossin_methods.bas
@@ -0,0 +1,17 @@
+' 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 Explicit
+
+Function doUnitTest as String
+ ' COS SIN
+ If ( Abs(Cos(PI/3) - Sin(PI/6)) > 1E-6 ) Then
+ doUnitTest = "FAIL"
+ Else
+ doUnitTest = "OK"
+ End If
+End Function
diff --git a/basic/qa/basic_coverage/test_createobject_method.bas b/basic/qa/basic_coverage/test_createobject_method.bas
new file mode 100644
index 0000000000..e8281c7d2f
--- /dev/null
+++ b/basic/qa/basic_coverage/test_createobject_method.bas
@@ -0,0 +1,22 @@
+'
+' 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 Explicit
+Type address
+ Name1 As String
+ City As String
+End Type
+
+Function doUnitTest as String
+ ' CREATEOBJECT
+ If ( IsObject( CreateObject("address") ) = False ) Then
+ doUnitTest = "FAIL"
+ Else
+ doUnitTest = "OK"
+ End If
+End Function
diff --git a/basic/qa/basic_coverage/test_createunolistener_method.bas b/basic/qa/basic_coverage/test_createunolistener_method.bas
new file mode 100644
index 0000000000..cd89716cde
--- /dev/null
+++ b/basic/qa/basic_coverage/test_createunolistener_method.bas
@@ -0,0 +1,15 @@
+' 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 Explicit
+
+Function doUnitTest as String
+ ' CreateUnoListener
+ Dim oListener
+ oListener = CreateUnoListener( "ContListener_","com.sun.star.container.XContainerListener" )
+ doUnitTest = "OK"
+End Function
diff --git a/basic/qa/basic_coverage/test_createunoservice_method.bas b/basic/qa/basic_coverage/test_createunoservice_method.bas
new file mode 100644
index 0000000000..33bb875f17
--- /dev/null
+++ b/basic/qa/basic_coverage/test_createunoservice_method.bas
@@ -0,0 +1,15 @@
+' 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 Explicit
+
+Function doUnitTest as String
+ ' CreateUnoService
+ Dim filepicker
+ filepicker = CreateUnoService("com.sun.star.ui.dialogs.FilePicker")
+ doUnitTest = "OK"
+End Function
diff --git a/basic/qa/basic_coverage/test_createunostruct_method.bas b/basic/qa/basic_coverage/test_createunostruct_method.bas
new file mode 100644
index 0000000000..26b676aaeb
--- /dev/null
+++ b/basic/qa/basic_coverage/test_createunostruct_method.bas
@@ -0,0 +1,15 @@
+' 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 Explicit
+
+Function doUnitTest as String
+ ' CreateUnoStruct
+ Dim oStruct
+ oStruct = CreateUnoStruct( "com.sun.star.beans.Property" )
+ doUnitTest = "OK"
+End Function
diff --git a/basic/qa/basic_coverage/test_createunovalue_method.bas b/basic/qa/basic_coverage/test_createunovalue_method.bas
new file mode 100644
index 0000000000..3ea82acdd7
--- /dev/null
+++ b/basic/qa/basic_coverage/test_createunovalue_method.bas
@@ -0,0 +1,17 @@
+' 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 Explicit
+
+Function doUnitTest as String
+ ' CreateUnoValue
+ Dim oUnoValue as Variant
+ Dim aValue as Variant
+ aValue = Array ( 1, 1 )
+ oUnoValue = CreateUnoValue( "[]byte", aValue )
+ doUnitTest = "OK"
+End Function
diff --git a/basic/qa/basic_coverage/test_csng_method.bas b/basic/qa/basic_coverage/test_csng_method.bas
new file mode 100644
index 0000000000..83b4d24e4c
--- /dev/null
+++ b/basic/qa/basic_coverage/test_csng_method.bas
@@ -0,0 +1,18 @@
+'
+' 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 Explicit
+
+Function doUnitTest as String
+ ' CSNG
+ If (CSng("100") <> 100) Then
+ doUnitTest = "FAIL"
+ Else
+ doUnitTest = "OK"
+ End If
+End Function
diff --git a/basic/qa/basic_coverage/test_cstr_method.bas b/basic/qa/basic_coverage/test_cstr_method.bas
new file mode 100644
index 0000000000..c2ac003e8c
--- /dev/null
+++ b/basic/qa/basic_coverage/test_cstr_method.bas
@@ -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 Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testCStr
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testCStr
+ On Error GoTo errorHandler
+
+ ' CSTR
+ TestUtil.AssertEqual(CStr(100), "100", "CStr(100)")
+
+ ' 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/basic_coverage/test_cvar_method.bas b/basic/qa/basic_coverage/test_cvar_method.bas
new file mode 100644
index 0000000000..94ebc714fe
--- /dev/null
+++ b/basic/qa/basic_coverage/test_cvar_method.bas
@@ -0,0 +1,18 @@
+'
+' 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 Explicit
+
+Function doUnitTest as String
+ ' CVAR
+ If (CVar(100) <> 100) Then
+ doUnitTest = "FAIL"
+ Else
+ doUnitTest = "OK"
+ End If
+End Function
diff --git a/basic/qa/basic_coverage/test_cverr_method.bas b/basic/qa/basic_coverage/test_cverr_method.bas
new file mode 100644
index 0000000000..2142fd335f
--- /dev/null
+++ b/basic/qa/basic_coverage/test_cverr_method.bas
@@ -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 Explicit
+
+Function doUnitTest as String
+
+ doUnitTest = "FAIL"
+
+ ' CVERR
+ If (CVerr(100) <> 100) Then Exit Function
+ ' tdf#79426 - passing an error object to a function
+ If (TestCVErr(CVErr(2)) <> 2) Then Exit Function
+ ' tdf#79426 - test with Error-Code 448 ( ERRCODE_BASIC_NAMED_NOT_FOUND )
+ If (TestCVErr(CVErr(448)) <> 448) Then Exit Function
+
+ doUnitTest = "OK"
+
+End Function
+
+Function TestCVErr(vErr As Variant)
+ Dim nValue As Integer
+ nValue = vErr
+ TestCVErr = nValue
+End Function \ No newline at end of file
diff --git a/basic/qa/basic_coverage/test_date_literal.bas b/basic/qa/basic_coverage/test_date_literal.bas
new file mode 100644
index 0000000000..3eb4510a3b
--- /dev/null
+++ b/basic/qa/basic_coverage/test_date_literal.bas
@@ -0,0 +1,17 @@
+'
+' 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 Explicit
+
+Function doUnitTest as String
+ If #07/28/1977# = 28334 And #1977-07-28# = 28334 Then
+ doUnitTest = "OK"
+ Else
+ doUnitTest = "FAIL"
+ End If
+End Function
diff --git a/basic/qa/basic_coverage/test_datedateadddatediff_methods.bas b/basic/qa/basic_coverage/test_datedateadddatediff_methods.bas
new file mode 100644
index 0000000000..6de53c0117
--- /dev/null
+++ b/basic/qa/basic_coverage/test_datedateadddatediff_methods.bas
@@ -0,0 +1,20 @@
+'
+' 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 Explicit
+
+Function doUnitTest as String
+ dim aDate as Date
+ aDate = Date()
+ ' DATE DATEDIFF DATEADD
+ If ( DateDiff( "d", aDate, DateAdd("d", 1, aDate) ) <> 1 ) Then
+ doUnitTest = "FAIL"
+ Else
+ doUnitTest = "OK"
+ End If
+End Function
diff --git a/basic/qa/basic_coverage/test_datedatepartday_methods.bas b/basic/qa/basic_coverage/test_datedatepartday_methods.bas
new file mode 100644
index 0000000000..b81e964220
--- /dev/null
+++ b/basic/qa/basic_coverage/test_datedatepartday_methods.bas
@@ -0,0 +1,20 @@
+'
+' 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 Explicit
+
+Function doUnitTest as String
+ dim aDate as Date
+ aDate = Date()
+ ' DATEPART DAY
+ If ( DatePart( "d", aDate ) <> Day( aDate ) ) Then
+ doUnitTest = "FAIL"
+ Else
+ doUnitTest = "OK"
+ End If
+End Function
diff --git a/basic/qa/basic_coverage/test_declare_from_dll.bas b/basic/qa/basic_coverage/test_declare_from_dll.bas
new file mode 100644
index 0000000000..7bdd1b1704
--- /dev/null
+++ b/basic/qa/basic_coverage/test_declare_from_dll.bas
@@ -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 Explicit
+
+' We link to shlwapi in many places, so safe to rely on it here
+Declare Function PathFindExtensionA Lib "Shlwapi" (ByVal pszPath As String) As String
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testPathFindExtensionA
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testPathFindExtensionA()
+ On Error GoTo errorHandler
+
+ ' Only test on Windows
+ If (GetGUIType() <> 1) Then
+ TestUtil.Assert(True) ' The test passed
+ Exit Sub
+ End If
+
+ ' Without the fix for tdf#147364 in place, the next call would crash in 64-bit version with
+ ' *** Exception 0xc0000005 occurred ***
+ TestUtil.AssertEqual(PathFindExtensionA("filename.ext"), ".ext", "PathFindExtensionA(""filename.ext"")")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testPathFindExtensionA", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/basic_coverage/test_dimarray_method.bas b/basic/qa/basic_coverage/test_dimarray_method.bas
new file mode 100644
index 0000000000..c5f268b12c
--- /dev/null
+++ b/basic/qa/basic_coverage/test_dimarray_method.bas
@@ -0,0 +1,20 @@
+' 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 Explicit
+
+Function doUnitTest as String
+ Dim aValue as variant
+ aValue = DimArray( 1, 2, 4 )
+ aValue( 1, 2, 4 ) = 3
+ ' DIMARRAY
+ If ( aValue( 1, 2, 4 ) <> 3 ) Then
+ doUnitTest = "FAIL"
+ Else
+ doUnitTest = "OK"
+ End If
+End Function
diff --git a/basic/qa/basic_coverage/test_empty_parameter.bas b/basic/qa/basic_coverage/test_empty_parameter.bas
new file mode 100644
index 0000000000..913f8e0cc4
--- /dev/null
+++ b/basic/qa/basic_coverage/test_empty_parameter.bas
@@ -0,0 +1,22 @@
+'
+' 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/.
+'
+
+Sub assignVar(v As Variant)
+ v = 1
+End Sub
+
+Function doUnitTest() As String
+ ' tdf#132563 - check if empty parameters are converted to their respective types
+ anEmptyVar = Empty
+ assignVar(anEmptyVar)
+ If (anEmptyVar = 1 And TypeName(anEmptyVar) = "Integer") Then
+ doUnitTest = "OK"
+ Else
+ doUnitTest = "FAIL"
+ End If
+End Function
diff --git a/basic/qa/basic_coverage/test_environ_method.bas b/basic/qa/basic_coverage/test_environ_method.bas
new file mode 100644
index 0000000000..4504a3feb9
--- /dev/null
+++ b/basic/qa/basic_coverage/test_environ_method.bas
@@ -0,0 +1,14 @@
+' 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 Explicit
+
+Function doUnitTest as String
+ ' ENVIRON
+ Environ ("TMP")
+ doUnitTest = "OK"
+End Function
diff --git a/basic/qa/basic_coverage/test_equalunoobjects_method.bas b/basic/qa/basic_coverage/test_equalunoobjects_method.bas
new file mode 100644
index 0000000000..9e7666ae5b
--- /dev/null
+++ b/basic/qa/basic_coverage/test_equalunoobjects_method.bas
@@ -0,0 +1,25 @@
+' 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/.
+'
+
+Function doUnitTest as String
+ ' EqualUnoObjects
+ ' Copy of objects -> same instance
+ oIntrospection = CreateUnoService( "com.sun.star.beans.Introspection" )
+ oIntro2 = oIntrospection
+ If ( EqualUnoObjects( oIntrospection, oIntro2 ) = False ) Then
+ doUnitTest = "FAIL"
+ Else
+ ' Copy of structs as value -> new instance
+ Dim Struct1 as new com.sun.star.beans.Property
+ Struct2 = Struct1
+ If ( EqualUnoObjects( Struct1, Struct2 ) ) Then
+ doUnitTest = "FAIL"
+ Else
+ doUnitTest = "OK"
+ End If
+ End If
+End Function
diff --git a/basic/qa/basic_coverage/test_erl_method.bas b/basic/qa/basic_coverage/test_erl_method.bas
new file mode 100644
index 0000000000..ab834650c9
--- /dev/null
+++ b/basic/qa/basic_coverage/test_erl_method.bas
@@ -0,0 +1,22 @@
+' 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/.
+'
+
+Function doUnitTest as String
+ ' ERL
+ On Error GoTo ErrorHandler ' Set up error handler
+ Dim nVar As Integer
+ nVar = 0
+ nVar = 1/nVar
+ doUnitTest = "FAIL"
+ Exit Function
+ErrorHandler:
+ If ( Erl <> 13 ) Then
+ doUnitTest = "FAIL"
+ Else
+ doUnitTest = "OK"
+ Endif
+End Function
diff --git a/basic/qa/basic_coverage/test_err_method.bas b/basic/qa/basic_coverage/test_err_method.bas
new file mode 100644
index 0000000000..9732a25e6f
--- /dev/null
+++ b/basic/qa/basic_coverage/test_err_method.bas
@@ -0,0 +1,24 @@
+' 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 Explicit
+
+Function doUnitTest as String
+ ' ERR
+ On Error GoTo ErrorHandler ' Set up error handler
+ Dim nVar As Integer
+ nVar = 0
+ nVar = 1/nVar
+ doUnitTest = "FAIL"
+ Exit Function
+ErrorHandler:
+ If ( Err <> 11 ) Then
+ doUnitTest = "FAIL"
+ Else
+ doUnitTest = "OK"
+ Endif
+End Function
diff --git a/basic/qa/basic_coverage/test_falsetrue_method.bas b/basic/qa/basic_coverage/test_falsetrue_method.bas
new file mode 100644
index 0000000000..10ef7d5fbe
--- /dev/null
+++ b/basic/qa/basic_coverage/test_falsetrue_method.bas
@@ -0,0 +1,18 @@
+'
+' 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 Explicit
+
+Function doUnitTest as String
+ ' FALSE TRUE
+ If (False = True) Then
+ doUnitTest = "FAIL"
+ Else
+ doUnitTest = "OK"
+ End If
+End Function
diff --git a/basic/qa/basic_coverage/test_filedatetime_nonexistent.bas b/basic/qa/basic_coverage/test_filedatetime_nonexistent.bas
new file mode 100644
index 0000000000..4478ba416b
--- /dev/null
+++ b/basic/qa/basic_coverage/test_filedatetime_nonexistent.bas
@@ -0,0 +1,23 @@
+' 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/.
+'
+'Bug 121337 - FileDateTime("\\nonexistent\smb\path") returns bogus result rather than throwing error
+
+Option Explicit
+
+Function doUnitTest as String
+ On Error GoTo ErrorHandler ' Set up error handler
+ Dim result
+ result = FileDateTime("/bogus/unix/path")
+ doUnitTest = "FAIL"
+ Exit Function
+ErrorHandler:
+ If ( Err <> 0 ) Then
+ doUnitTest = "FAIL"
+ Else
+ doUnitTest = "OK"
+ Endif
+End Function
diff --git a/basic/qa/basic_coverage/test_filedatetime_nonexistent2.bas b/basic/qa/basic_coverage/test_filedatetime_nonexistent2.bas
new file mode 100644
index 0000000000..e95fde34e7
--- /dev/null
+++ b/basic/qa/basic_coverage/test_filedatetime_nonexistent2.bas
@@ -0,0 +1,23 @@
+' 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/.
+'
+'Bug 121337 - FileDateTime("\\nonexistent\smb\path") returns bogus result rather than throwing error
+
+Option Explicit
+
+Function doUnitTest as String
+ On Error GoTo ErrorHandler ' Set up error handler
+ Dim result
+ result = FileDateTime("\\bogus\smb\path")
+ doUnitTest = "FAIL"
+ Exit Function
+ErrorHandler:
+ If ( Err <> 0 ) Then
+ doUnitTest = "FAIL"
+ Else
+ doUnitTest = "OK"
+ Endif
+End Function
diff --git a/basic/qa/basic_coverage/test_fix_method.bas b/basic/qa/basic_coverage/test_fix_method.bas
new file mode 100644
index 0000000000..7ec5c4ac62
--- /dev/null
+++ b/basic/qa/basic_coverage/test_fix_method.bas
@@ -0,0 +1,17 @@
+' 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 Explicit
+
+Function doUnitTest as String
+ ' FIX
+ If (Fix(PI) <> 3) Then
+ doUnitTest = "FAIL"
+ Else
+ doUnitTest = "OK"
+ End If
+End Function
diff --git a/basic/qa/basic_coverage/test_for_each.bas b/basic/qa/basic_coverage/test_for_each.bas
new file mode 100644
index 0000000000..3d9b74c273
--- /dev/null
+++ b/basic/qa/basic_coverage/test_for_each.bas
@@ -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/.
+'
+
+Function doUnitTest as String
+ Dim n As Integer, i
+ Dim a(3)
+ n = 0
+ For Each i In a
+ n = n + 1
+ Next i
+ If n <> 4 Then
+ doUnitTest = "For Each over array failed"
+ Exit Function
+ End If
+
+ If TestInvalidForEachWithErrorHandler <> "13 91 14 " Then
+ doUnitTest = "For Each doesn't generate proper errors on bad arguments"
+ Exit Function
+ End If
+
+ doUnitTest = "OK"
+End Function
+
+Function TestInvalidForEachWithErrorHandler
+ Dim s As String
+ On Error Goto ErrHandler
+' This For Each is given a bad iterable; it must generate first error ("Data type mismatch") for b;
+ For Each a In b
+' Then proceed here (Resume Next from ErrHandler), and generate "Object variable not set" for c;
+ c.d
+' Then proceed here (Resume Next from ErrHandler), and generate "Invalid parameter" at Next.
+ Next
+ TestInvalidForEachWithErrorHandler = s
+ Exit Function
+ErrHandler:
+ s = s & Err & " "
+ Resume Next
+End Function
diff --git a/basic/qa/basic_coverage/test_frac_method.bas b/basic/qa/basic_coverage/test_frac_method.bas
new file mode 100644
index 0000000000..73763f4eea
--- /dev/null
+++ b/basic/qa/basic_coverage/test_frac_method.bas
@@ -0,0 +1,17 @@
+' 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 Explicit
+
+Function doUnitTest as String
+ ' FRAC
+ If ( 3+Frac(PI) <> PI) Then
+ doUnitTest = "FAIL"
+ Else
+ doUnitTest = "OK"
+ End If
+End Function
diff --git a/basic/qa/basic_coverage/test_freefile_method.bas b/basic/qa/basic_coverage/test_freefile_method.bas
new file mode 100644
index 0000000000..03180b7df1
--- /dev/null
+++ b/basic/qa/basic_coverage/test_freefile_method.bas
@@ -0,0 +1,17 @@
+' 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 Explicit
+
+Function doUnitTest as String
+ ' FREEFILE
+ If ( FreeFile < 0 ) Then
+ doUnitTest = "FAIL"
+ Else
+ doUnitTest = "OK"
+ End If
+End Function
diff --git a/basic/qa/basic_coverage/test_freelibrary_method.bas b/basic/qa/basic_coverage/test_freelibrary_method.bas
new file mode 100644
index 0000000000..6dc399de35
--- /dev/null
+++ b/basic/qa/basic_coverage/test_freelibrary_method.bas
@@ -0,0 +1,14 @@
+' 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 Explicit
+
+Function doUnitTest as String
+ ' FREELIBRARY
+ FreeLibrary("")
+ doUnitTest = "OK"
+End Function
diff --git a/basic/qa/basic_coverage/test_getdefaultcontext_method.bas b/basic/qa/basic_coverage/test_getdefaultcontext_method.bas
new file mode 100644
index 0000000000..7eb12dde4b
--- /dev/null
+++ b/basic/qa/basic_coverage/test_getdefaultcontext_method.bas
@@ -0,0 +1,14 @@
+' 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 Explicit
+
+Function doUnitTest as String
+ ' GetDefaultContext
+ GetDefaultContext()
+ doUnitTest = "OK"
+End Function
diff --git a/basic/qa/basic_coverage/test_getdialogzoomfactorx_method.bas b/basic/qa/basic_coverage/test_getdialogzoomfactorx_method.bas
new file mode 100644
index 0000000000..989f7ba7af
--- /dev/null
+++ b/basic/qa/basic_coverage/test_getdialogzoomfactorx_method.bas
@@ -0,0 +1,17 @@
+' 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 Explicit
+
+Function doUnitTest as String
+ ' GETDIALOGFACTORX
+ If ( GetDialogZoomFactorX(100) < 0 ) Then
+ doUnitTest = "FAIL"
+ Else
+ doUnitTest = "OK"
+ End If
+End Function
diff --git a/basic/qa/basic_coverage/test_getdialogzoomfactory_method.bas b/basic/qa/basic_coverage/test_getdialogzoomfactory_method.bas
new file mode 100644
index 0000000000..207447aef6
--- /dev/null
+++ b/basic/qa/basic_coverage/test_getdialogzoomfactory_method.bas
@@ -0,0 +1,17 @@
+' 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 Explicit
+
+Function doUnitTest as String
+ ' GETDIALOGFACTORY
+ If ( GetDialogZoomFactorY(100) < 0 ) Then
+ doUnitTest = "FAIL"
+ Else
+ doUnitTest = "OK"
+ End If
+End Function
diff --git a/basic/qa/basic_coverage/test_getguitype_method.bas b/basic/qa/basic_coverage/test_getguitype_method.bas
new file mode 100644
index 0000000000..76c136c584
--- /dev/null
+++ b/basic/qa/basic_coverage/test_getguitype_method.bas
@@ -0,0 +1,17 @@
+' 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 Explicit
+
+Function doUnitTest as String
+ ' GETGUITYPE
+ If ( GetGuiType = 0 ) Then
+ doUnitTest = "FAIL"
+ Else
+ doUnitTest = "OK"
+ End If
+End Function
diff --git a/basic/qa/basic_coverage/test_getguiversion_method.bas b/basic/qa/basic_coverage/test_getguiversion_method.bas
new file mode 100644
index 0000000000..deccf9527b
--- /dev/null
+++ b/basic/qa/basic_coverage/test_getguiversion_method.bas
@@ -0,0 +1,17 @@
+' 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 Explicit
+
+Function doUnitTest as String
+ ' GETGUIVERSION
+ If ( GetGuiVersion = 0 ) Then
+ doUnitTest = "FAIL"
+ Else
+ doUnitTest = "OK"
+ End If
+End Function
diff --git a/basic/qa/basic_coverage/test_getpathseparator_method.bas b/basic/qa/basic_coverage/test_getpathseparator_method.bas
new file mode 100644
index 0000000000..3d9b744418
--- /dev/null
+++ b/basic/qa/basic_coverage/test_getpathseparator_method.bas
@@ -0,0 +1,17 @@
+' 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 Explicit
+
+Function doUnitTest as String
+ ' GETPATHSEPARATOR
+ If ( GetPathSeparator = "" ) Then
+ doUnitTest = "FAIL"
+ Else
+ doUnitTest = "OK"
+ End If
+End Function
diff --git a/basic/qa/basic_coverage/test_getprocessservicemanager_method.bas b/basic/qa/basic_coverage/test_getprocessservicemanager_method.bas
new file mode 100644
index 0000000000..5e202bd723
--- /dev/null
+++ b/basic/qa/basic_coverage/test_getprocessservicemanager_method.bas
@@ -0,0 +1,14 @@
+' 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 Explicit
+
+Function doUnitTest as String
+ ' GetProcessServiceManager
+ GetProcessServiceManager()
+ doUnitTest = "OK"
+End Function
diff --git a/basic/qa/basic_coverage/test_getsolarversion_method.bas b/basic/qa/basic_coverage/test_getsolarversion_method.bas
new file mode 100644
index 0000000000..f48a5703e6
--- /dev/null
+++ b/basic/qa/basic_coverage/test_getsolarversion_method.bas
@@ -0,0 +1,17 @@
+' 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 Explicit
+
+Function doUnitTest as String
+ ' GetSolarVersion
+ If ( GetSolarVersion() < 50000) Then
+ doUnitTest = "FAIL"
+ Else
+ doUnitTest = "OK"
+ End If
+End Function
diff --git a/basic/qa/basic_coverage/test_getsystemtype_method.bas b/basic/qa/basic_coverage/test_getsystemtype_method.bas
new file mode 100644
index 0000000000..93a9a9ceb1
--- /dev/null
+++ b/basic/qa/basic_coverage/test_getsystemtype_method.bas
@@ -0,0 +1,17 @@
+' 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 Explicit
+
+Function doUnitTest as String
+ ' GETSYSTEMTYPE
+ If ( GetSystemType <> -1 ) Then
+ doUnitTest = "FAIL"
+ Else
+ doUnitTest = "OK"
+ End If
+End Function
diff --git a/basic/qa/basic_coverage/test_hasunointerfaces_method.bas b/basic/qa/basic_coverage/test_hasunointerfaces_method.bas
new file mode 100644
index 0000000000..5f0f63832b
--- /dev/null
+++ b/basic/qa/basic_coverage/test_hasunointerfaces_method.bas
@@ -0,0 +1,18 @@
+' 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 Explicit
+
+Function doUnitTest as String
+ ' HASUNOINTERFACES
+ dim aObject as Object
+ If ( HasUnoInterfaces( aObject, "com.sun.star.beans.XIntrospection" ) ) Then
+ doUnitTest = "FAIL"
+ Else
+ doUnitTest = "OK"
+ End If
+End Function
diff --git a/basic/qa/basic_coverage/test_hex_method.bas b/basic/qa/basic_coverage/test_hex_method.bas
new file mode 100644
index 0000000000..8bfcb1c362
--- /dev/null
+++ b/basic/qa/basic_coverage/test_hex_method.bas
@@ -0,0 +1,17 @@
+' 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 Explicit
+
+Function doUnitTest as String
+ ' HEX
+ If ( Hex(100) <> "64") Then
+ doUnitTest = "FAIL"
+ Else
+ doUnitTest = "OK"
+ End If
+End Function
diff --git a/basic/qa/basic_coverage/test_hour_method.bas b/basic/qa/basic_coverage/test_hour_method.bas
new file mode 100644
index 0000000000..16f1bdc9d3
--- /dev/null
+++ b/basic/qa/basic_coverage/test_hour_method.bas
@@ -0,0 +1,18 @@
+'
+' 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 Explicit
+
+Function doUnitTest as String
+ ' HOUR
+ If ( Hour(TimeSerial(12,30,41)) <> 12 ) Then
+ doUnitTest = "FAIL"
+ Else
+ doUnitTest = "OK"
+ End If
+End Function
diff --git a/basic/qa/basic_coverage/test_iif_method.bas b/basic/qa/basic_coverage/test_iif_method.bas
new file mode 100644
index 0000000000..b6003d0520
--- /dev/null
+++ b/basic/qa/basic_coverage/test_iif_method.bas
@@ -0,0 +1,18 @@
+'
+' 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 Explicit
+
+Function doUnitTest as String
+ ' IIF
+ If ( IIF(True, 10, 12) <> 10 ) Then
+ doUnitTest = "FAIL"
+ Else
+ doUnitTest = "OK"
+ End If
+End Function
diff --git a/basic/qa/basic_coverage/test_instr_method.bas b/basic/qa/basic_coverage/test_instr_method.bas
new file mode 100644
index 0000000000..9e4545bb3b
--- /dev/null
+++ b/basic/qa/basic_coverage/test_instr_method.bas
@@ -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 Explicit
+
+Function doUnitTest as String
+
+ doUnitTest = "FAIL"
+
+ Dim aString As Variant
+ aString = "Hello"
+ ' InStr
+ If (InStr(1, aString, "l", 1) <> 3) Then Exit Function
+
+ ' tdf#139840 - case-insensitive operation for non-ASCII characters
+ If (InStr(1, "α", "Α", 1) <> 1) Then Exit Function
+ ' tdf#139840 - German Eszett is uppercased to a two-character 'SS'.
+ ' This test should fail after tdf#110003 has been fixed.
+ If (InStr(2, "Straße", "s", 1) <> 5) Then Exit Function
+
+ ' Start position is greater than the length of the string being searched.
+ If (InStr(2, "α", "Α", 1) <> 0) Then Exit Function
+
+ doUnitTest = "OK"
+
+End Function
diff --git a/basic/qa/basic_coverage/test_int_method.bas b/basic/qa/basic_coverage/test_int_method.bas
new file mode 100644
index 0000000000..563fd5898b
--- /dev/null
+++ b/basic/qa/basic_coverage/test_int_method.bas
@@ -0,0 +1,17 @@
+' 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 Explicit
+
+Function doUnitTest as String
+ ' INT
+ If ( Int(PI) <> 3 ) Then
+ doUnitTest = "FAIL"
+ Else
+ doUnitTest = "OK"
+ End If
+End Function
diff --git a/basic/qa/basic_coverage/test_isarray_method.bas b/basic/qa/basic_coverage/test_isarray_method.bas
new file mode 100644
index 0000000000..f3080d5fc0
--- /dev/null
+++ b/basic/qa/basic_coverage/test_isarray_method.bas
@@ -0,0 +1,20 @@
+'
+' 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 Explicit
+
+Function doUnitTest as String
+ dim aVector as Variant
+ aVector = Array( 123, "Hello", -3.14)
+ ' ISARRAY
+ If ( IsArray( aVector ) = False ) Then
+ doUnitTest = "FAIL"
+ Else
+ doUnitTest = "OK"
+ End If
+End Function
diff --git a/basic/qa/basic_coverage/test_isdate_method.bas b/basic/qa/basic_coverage/test_isdate_method.bas
new file mode 100644
index 0000000000..f4f0dfa6f6
--- /dev/null
+++ b/basic/qa/basic_coverage/test_isdate_method.bas
@@ -0,0 +1,20 @@
+'
+' 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 Explicit
+
+Function doUnitTest as String
+ dim aDate as Date
+ aDate = Date( )
+ ' ISDATE
+ If ( IsDate( aDate ) = False ) Then
+ doUnitTest = "FAIL"
+ Else
+ doUnitTest = "OK"
+ End If
+End Function
diff --git a/basic/qa/basic_coverage/test_isempty_method.bas b/basic/qa/basic_coverage/test_isempty_method.bas
new file mode 100644
index 0000000000..3ea6a4a140
--- /dev/null
+++ b/basic/qa/basic_coverage/test_isempty_method.bas
@@ -0,0 +1,20 @@
+'
+' 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 Explicit
+
+Function doUnitTest as String
+ dim aVariant as Variant
+ aVariant = Date( )
+ ' ISEMPTY
+ If ( IsEmpty( aVariant ) ) Then
+ doUnitTest = "FAIL"
+ Else
+ doUnitTest = "OK"
+ End If
+End Function
diff --git a/basic/qa/basic_coverage/test_iserror_method.bas b/basic/qa/basic_coverage/test_iserror_method.bas
new file mode 100644
index 0000000000..83d3f60432
--- /dev/null
+++ b/basic/qa/basic_coverage/test_iserror_method.bas
@@ -0,0 +1,24 @@
+'
+' 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 Explicit
+
+Type MyType
+ tName as String
+End Type
+
+Function doUnitTest as String
+ dim aVariant as MyType
+ aVariant.tName = "A string"
+ ' ISERROR
+ If ( IsError( aVariant ) ) Then
+ doUnitTest = "FAIL"
+ Else
+ doUnitTest = "OK"
+ End If
+End Function
diff --git a/basic/qa/basic_coverage/test_ismissing_basic.bas b/basic/qa/basic_coverage/test_ismissing_basic.bas
new file mode 100644
index 0000000000..0996da0f82
--- /dev/null
+++ b/basic/qa/basic_coverage/test_ismissing_basic.bas
@@ -0,0 +1,175 @@
+' 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/.
+'
+
+Const IsMissingNone = -1
+Const IsMissingA = 0
+Const IsMissingB = 1
+Const IsMissingAB = 2
+
+Option Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testIsMissingBasic
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+' tdf#36737 - Test optionals with different datatypes. In LO Basic, optional
+' parameters are allowed, but without any default values. Missing optional parameters
+' will not be initialized to their respective default values of its datatype, either.
+Sub verify_testIsMissingBasic()
+
+ On Error GoTo errorHandler
+
+ ' optionals with variant datatypes
+ TestUtil.AssertEqual(TestOptVariant(), IsMissingAB, "TestOptVariant()")
+ TestUtil.AssertEqual(TestOptVariant(123), IsMissingB, "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(), IsMissingAB, "TestOptVariantByRefByVal()")
+ TestUtil.AssertEqual(TestOptVariantByRefByVal(123), IsMissingB, "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(), IsMissingAB, "TestOptDouble()")
+ TestUtil.AssertEqual(TestOptDouble(123.4), IsMissingB, "TestOptDouble(123.4)")
+ TestUtil.AssertEqual(TestOptDouble(, 567.8), IsMissingA, "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(), IsMissingAB, "TestOptDouble()")
+ TestUtil.AssertEqual(TestOptDoubleByRefByVal(123.4), IsMissingB, "TestOptDouble(123.4)")
+ TestUtil.AssertEqual(TestOptDoubleByRefByVal(, 567.8), IsMissingA, "TestOptDoubleByRefByVal(, 567.8)")
+ TestUtil.AssertEqual(TestOptDoubleByRefByVal(123.4, 567.8), IsMissingNone, "TestOptDoubleByRefByVal(123.4, 567.8)")
+
+ ' optionals with integer datatypes
+ TestUtil.AssertEqual(TestOptInteger(), IsMissingAB, "TestOptInteger()")
+ TestUtil.AssertEqual(TestOptInteger(123), IsMissingB, "TestOptInteger(123)")
+ TestUtil.AssertEqual(TestOptInteger(, 456), IsMissingA, "TestOptInteger(, 456)")
+ TestUtil.AssertEqual(TestOptInteger(123, 456), IsMissingNone, "TestOptInteger(123, 456)")
+
+ ' optionals with integer datatypes (ByRef and ByVal)
+ TestUtil.AssertEqual(TestOptIntegerByRefByVal(), IsMissingAB, "TestOptIntegerByRefByVal()")
+ TestUtil.AssertEqual(TestOptIntegerByRefByVal(123), IsMissingB, "TestOptIntegerByRefByVal(123)")
+ TestUtil.AssertEqual(TestOptIntegerByRefByVal(, 456), IsMissingA, "TestOptIntegerByRefByVal(, 456)")
+ TestUtil.AssertEqual(TestOptIntegerByRefByVal(123, 456), IsMissingNone, "TestOptIntegerByRefByVal(123, 456)")
+
+ ' optionals with string datatypes
+ TestUtil.AssertEqual(TestOptString(), IsMissingAB, "TestOptString()")
+ TestUtil.AssertEqual(TestOptString("123"), IsMissingB, "TestOptString(""123"")")
+ TestUtil.AssertEqual(TestOptString(, "456"), IsMissingA, "TestOptString(, ""456"")")
+ TestUtil.AssertEqual(TestOptString("123", "456"), IsMissingNone, "TestOptString(""123"", ""456"")")
+
+ ' optionals with string datatypes (ByRef and ByVal)
+ TestUtil.AssertEqual(TestOptStringByRefByVal(), IsMissingAB, "TestOptStringByRefByVal()")
+ TestUtil.AssertEqual(TestOptStringByRefByVal("123"), IsMissingB, "TestOptStringByRefByVal(""123"")")
+ TestUtil.AssertEqual(TestOptStringByRefByVal(, "456"), IsMissingA, "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
+ 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)
+ 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_testIsMissingBasic", Err, Error$, Erl)
+End Sub
+
+Function TestOptVariant(Optional A, Optional B As Variant)
+ TestOptVariant = WhatIsMissing(IsMissing(A), IsMissing(B))
+End Function
+
+Function TestOptVariantByRefByVal(Optional ByRef A, Optional ByVal B As Variant)
+ TestOptVariantByRefByVal = WhatIsMissing(IsMissing(A), IsMissing(B))
+End Function
+
+Function TestOptDouble(Optional A As Double, Optional B As Double)
+ TestOptDouble = WhatIsMissing(IsMissing(A), IsMissing(B))
+End Function
+
+Function TestOptDoubleByRefByVal(Optional ByRef A As Double, Optional ByVal B As Double)
+ TestOptDoubleByRefByVal = WhatIsMissing(IsMissing(A), IsMissing(B))
+End Function
+
+Function TestOptInteger(Optional A As Integer, Optional B As Integer)
+ TestOptInteger = WhatIsMissing(IsMissing(A), IsMissing(B))
+End Function
+
+Function TestOptIntegerByRefByVal(Optional ByRef A As Integer, Optional ByVal B As Integer)
+ TestOptIntegerByRefByVal = WhatIsMissing(IsMissing(A), IsMissing(B))
+End Function
+
+Function TestOptString(Optional A As String, Optional B As String)
+ TestOptString = WhatIsMissing(IsMissing(A), IsMissing(B))
+End Function
+
+Function TestOptStringByRefByVal(Optional ByRef A As String, Optional ByVal B As String)
+ TestOptStringByRefByVal = WhatIsMissing(IsMissing(A), IsMissing(B))
+End Function
+
+Function TestOptObject(Optional A As Collection, Optional B As Collection)
+ TestOptObject = WhatIsMissing(IsMissing(A), IsMissing(B))
+End Function
+
+Function TestOptObjectByRefByVal(Optional ByRef A As Collection, Optional ByVal B As Collection)
+ TestOptObjectByRefByVal = WhatIsMissing(IsMissing(A), IsMissing(B))
+End Function
+
+Function TestOptArray(Optional A() As Integer, Optional B() As Variant)
+ TestOptArray = WhatIsMissing(IsMissing(A), IsMissing(B))
+End Function
+
+Function TestOptArrayByRefByVal(Optional ByRef A() As Integer, Optional ByVal B() As Variant)
+ TestOptArrayByRefByVal = WhatIsMissing(IsMissing(A), IsMissing(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/basic_coverage/test_ismissing_cascade.bas b/basic/qa/basic_coverage/test_ismissing_cascade.bas
new file mode 100644
index 0000000000..3c6d9a71c0
--- /dev/null
+++ b/basic/qa/basic_coverage/test_ismissing_cascade.bas
@@ -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 Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testIsMissingCascade
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testIsMissingCascade()
+
+ On Error GoTo errorHandler
+
+ ' tdf#136143 - test cascading optionals in order to prevent type conversion errors, because
+ ' optional arguments are of type SbxERROR and set to not fixed.
+ TestUtil.AssertEqual(TestOpt(), 2, "Cascading optionals")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testIsMissingCascade", Err, Error$, Erl)
+End Sub
+
+Function TestOpt(Optional A)
+ TestOpt = TestOptCascade(A)
+End Function
+
+Function TestOptCascade(Optional A)
+ If IsMissing(A) Then A = 2
+ TestOptCascade = A
+End Function
diff --git a/basic/qa/basic_coverage/test_ismissing_compatible.bas b/basic/qa/basic_coverage/test_ismissing_compatible.bas
new file mode 100644
index 0000000000..6d11ab0902
--- /dev/null
+++ b/basic/qa/basic_coverage/test_ismissing_compatible.bas
@@ -0,0 +1,175 @@
+' 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 Compatible
+Option Explicit
+Const IsMissingNone = -1
+Const IsMissingA = 0
+Const IsMissingB = 1
+Const IsMissingAB = 2
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testIsMissingCompatible
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+' tdf#36737 - Test isMissing function with different datatypes. In LO Basic
+' with option Compatible, optional parameters are allowed with default values.
+' Missing optional parameters that don't have explicit default values will
+' not be initialized to their default values of its datatype.
+Sub verify_testIsMissingCompatible()
+ 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(), IsMissingA, "TestOptDouble()")
+ TestUtil.AssertEqual(TestOptDouble(123.4), IsMissingNone, "TestOptDouble(123.4)")
+ TestUtil.AssertEqual(TestOptDouble(, 567.8), IsMissingA, "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(), IsMissingA, "TestOptDouble()")
+ TestUtil.AssertEqual(TestOptDoubleByRefByVal(123.4), IsMissingNone, "TestOptDouble(123.4)")
+ TestUtil.AssertEqual(TestOptDoubleByRefByVal(, 567.8), IsMissingA, "TestOptDoubleByRefByVal(, 567.8)")
+ TestUtil.AssertEqual(TestOptDoubleByRefByVal(123.4, 567.8), IsMissingNone, "TestOptDoubleByRefByVal(123.4, 567.8)")
+
+ ' optionals with integer datatypes
+ TestUtil.AssertEqual(TestOptInteger(), IsMissingA, "TestOptInteger()")
+ TestUtil.AssertEqual(TestOptInteger(123), IsMissingNone, "TestOptInteger(123)")
+ TestUtil.AssertEqual(TestOptInteger(, 456), IsMissingA, "TestOptInteger(, 456)")
+ TestUtil.AssertEqual(TestOptInteger(123, 456), IsMissingNone, "TestOptInteger(123, 456)")
+
+ ' optionals with integer datatypes (ByRef and ByVal)
+ TestUtil.AssertEqual(TestOptIntegerByRefByVal(), IsMissingA, "TestOptIntegerByRefByVal()")
+ TestUtil.AssertEqual(TestOptIntegerByRefByVal(123), IsMissingNone, "TestOptIntegerByRefByVal(123)")
+ TestUtil.AssertEqual(TestOptIntegerByRefByVal(, 456), IsMissingA, "TestOptIntegerByRefByVal(, 456)")
+ TestUtil.AssertEqual(TestOptIntegerByRefByVal(123, 456), IsMissingNone, "TestOptIntegerByRefByVal(123, 456)")
+
+ ' optionals with string datatypes
+ TestUtil.AssertEqual(TestOptString(), IsMissingA, "TestOptString()")
+ TestUtil.AssertEqual(TestOptString("123"), IsMissingNone, "TestOptString(""123"")")
+ TestUtil.AssertEqual(TestOptString(, "456"), IsMissingA, "TestOptString(, ""456"")")
+ TestUtil.AssertEqual(TestOptString("123", "456"), IsMissingNone, "TestOptString(""123"", ""456"")")
+
+ ' optionals with string datatypes (ByRef and ByVal)
+ TestUtil.AssertEqual(TestOptStringByRefByVal(), IsMissingA, "TestOptStringByRefByVal()")
+ TestUtil.AssertEqual(TestOptStringByRefByVal("123"), IsMissingNone, "TestOptStringByRefByVal(""123"")")
+ TestUtil.AssertEqual(TestOptStringByRefByVal(, "456"), IsMissingA, "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
+ 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)
+ 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_testIsMissingCompatible", 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(IsMissing(A), IsMissing(B))
+End Function
+
+Function TestOptObjectByRefByVal(Optional ByRef A As Collection, Optional ByVal B As Collection)
+ TestOptObjectByRefByVal = WhatIsMissing(IsMissing(A), IsMissing(B))
+End Function
+
+Function TestOptArray(Optional A() As Integer, Optional B() As Variant)
+ TestOptArray = WhatIsMissing(IsMissing(A), IsMissing(B))
+End Function
+
+Function TestOptArrayByRefByVal(Optional ByRef A() As Integer, Optional ByVal B() As Variant)
+ TestOptArrayByRefByVal = WhatIsMissing(IsMissing(A), IsMissing(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/basic_coverage/test_isnull_method.bas b/basic/qa/basic_coverage/test_isnull_method.bas
new file mode 100644
index 0000000000..28000e9fb5
--- /dev/null
+++ b/basic/qa/basic_coverage/test_isnull_method.bas
@@ -0,0 +1,20 @@
+'
+' 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 Explicit
+
+Function doUnitTest as String
+ dim aVariant as Variant
+ aVariant = Null
+ ' ISNULL
+ If ( IsNull( aVariant ) = False ) Then
+ doUnitTest = "FAIL"
+ Else
+ doUnitTest = "OK"
+ End If
+End Function
diff --git a/basic/qa/basic_coverage/test_isnumeric_method.bas b/basic/qa/basic_coverage/test_isnumeric_method.bas
new file mode 100644
index 0000000000..1b454aa8d5
--- /dev/null
+++ b/basic/qa/basic_coverage/test_isnumeric_method.bas
@@ -0,0 +1,20 @@
+'
+' 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 Explicit
+
+Function doUnitTest as String
+ dim aVariant as Variant
+ aVariant = 3
+ ' ISNUMERIC
+ If ( IsNumeric( aVariant ) = False ) Then
+ doUnitTest = "FAIL"
+ Else
+ doUnitTest = "OK"
+ End If
+End Function
diff --git a/basic/qa/basic_coverage/test_isobject_method.bas b/basic/qa/basic_coverage/test_isobject_method.bas
new file mode 100644
index 0000000000..1299b3a880
--- /dev/null
+++ b/basic/qa/basic_coverage/test_isobject_method.bas
@@ -0,0 +1,19 @@
+'
+' 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 Explicit
+
+Function doUnitTest as String
+ dim aVariant as Object
+ ' ISOBJECT
+ If ( IsObject( aVariant ) = False ) Then
+ doUnitTest = "FAIL"
+ Else
+ doUnitTest = "OK"
+ End If
+End Function
diff --git a/basic/qa/basic_coverage/test_isunostruct_method.bas b/basic/qa/basic_coverage/test_isunostruct_method.bas
new file mode 100644
index 0000000000..85b6ab27dd
--- /dev/null
+++ b/basic/qa/basic_coverage/test_isunostruct_method.bas
@@ -0,0 +1,19 @@
+'
+' 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 Explicit
+
+Function doUnitTest as String
+ dim aVariant as Object
+ ' ISUNOSTRUCT
+ If ( IsUnoStruct( aVariant ) ) Then
+ doUnitTest = "FAIL"
+ Else
+ doUnitTest = "OK"
+ End If
+End Function
diff --git a/basic/qa/basic_coverage/test_join_method.bas b/basic/qa/basic_coverage/test_join_method.bas
new file mode 100644
index 0000000000..a3769ae188
--- /dev/null
+++ b/basic/qa/basic_coverage/test_join_method.bas
@@ -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 Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_Join_method
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_Join_method
+ On Error GoTo errorHandler
+
+ ' JOIN
+ Dim aStrings(2) as String
+ aStrings(0) = "Hello"
+ aStrings(1) = "world"
+ TestUtil.AssertEqual(Join( aStrings, " " ), "Hello world ", "Join(aStrings, "" "" is not ""Hello world """)
+
+ ' tdf#141474 keyword names need to match that of VBA
+ Dim aList(0 to 7) As String : aList = Array("(", "Star", "|", "Open", "|", "Libre", ")", "Office")
+ TestUtil.AssertEqual(Join(sourceArray:=aList), "( Star | Open | Libre ) Office", "Join() with 1 keyword name")
+ TestUtil.AssertEqual(Join(delimiter:="", sourceArray:=aList), "(Star|Open|Libre)Office", "Join() with 2 keyword names")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_Join_method", Err, Error$, Erl)
+End Sub
+
diff --git a/basic/qa/basic_coverage/test_lbound_method.bas b/basic/qa/basic_coverage/test_lbound_method.bas
new file mode 100644
index 0000000000..b79b604103
--- /dev/null
+++ b/basic/qa/basic_coverage/test_lbound_method.bas
@@ -0,0 +1,21 @@
+'
+' 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 Explicit
+
+Function doUnitTest as String
+ dim aVector as Variant
+ ' ARRAY
+ aVector = Array( "Hello", -3.14)
+ ' LBOUND
+ If ( LBound( aVector() ) <> 0 ) Then
+ doUnitTest = "FAIL"
+ Else
+ doUnitTest = "OK"
+ End If
+End Function
diff --git a/basic/qa/basic_coverage/test_lcase_method.bas b/basic/qa/basic_coverage/test_lcase_method.bas
new file mode 100644
index 0000000000..9e2a2af661
--- /dev/null
+++ b/basic/qa/basic_coverage/test_lcase_method.bas
@@ -0,0 +1,19 @@
+' 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 Explicit
+
+Function doUnitTest as String
+ dim aString as Variant
+ aString = "Hello"
+ ' LCASE
+ If ( LCase( aString ) <> "hello" ) Then
+ doUnitTest = "FAIL"
+ Else
+ doUnitTest = "OK"
+ End If
+End Function
diff --git a/basic/qa/basic_coverage/test_left_method.bas b/basic/qa/basic_coverage/test_left_method.bas
new file mode 100644
index 0000000000..1c33bc9a71
--- /dev/null
+++ b/basic/qa/basic_coverage/test_left_method.bas
@@ -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 Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_Left_method
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_Left_method
+ On Error GoTo errorHandler
+
+ ' LEFT
+ TestUtil.AssertEqual(Left("abc", 2), "ab", "Left(""abc"",2)")
+
+ ' tdf#141474 keyword names need to match that of VBA
+ TestUtil.AssertEqual(Left(Length:=4, String:="sometext"), "some", "Left(Length:=4, String:=""sometext"")")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_Left_method", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/basic_coverage/test_len_method.bas b/basic/qa/basic_coverage/test_len_method.bas
new file mode 100644
index 0000000000..58211fc933
--- /dev/null
+++ b/basic/qa/basic_coverage/test_len_method.bas
@@ -0,0 +1,19 @@
+' 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 Explicit
+
+Function doUnitTest as String
+ dim aString as Variant
+ aString = "Hello"
+ ' LEN
+ If ( Len( aString ) <> 5 ) Then
+ doUnitTest = "FAIL"
+ Else
+ doUnitTest = "OK"
+ End If
+End Function
diff --git a/basic/qa/basic_coverage/test_lenb_method.bas b/basic/qa/basic_coverage/test_lenb_method.bas
new file mode 100644
index 0000000000..2a907e209b
--- /dev/null
+++ b/basic/qa/basic_coverage/test_lenb_method.bas
@@ -0,0 +1,19 @@
+' 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 Explicit
+
+Function doUnitTest as String
+ dim aString as Variant
+ aString = "Hello"
+ ' LENB
+ If ( LenB( aString ) <> 5 ) Then
+ doUnitTest = "FAIL"
+ Else
+ doUnitTest = "OK"
+ End If
+End Function
diff --git a/basic/qa/basic_coverage/test_like.bas b/basic/qa/basic_coverage/test_like.bas
new file mode 100644
index 0000000000..2d018bf64f
--- /dev/null
+++ b/basic/qa/basic_coverage/test_like.bas
@@ -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 Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testLike
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testLike()
+ On Error GoTo errorHandler
+ ' Negation test
+ TestUtil.AssertEqual("!" Like "[.!?]", True, "Negation1")
+ TestUtil.AssertEqual("a" Like "[!abc]", False, "Negation2")
+ TestUtil.AssertEqual("!" Like "[!!?]", False, "Negation3")
+ TestUtil.AssertEqual("^" Like "[.!?]", False, "Negation4")
+ TestUtil.AssertEqual("^" Like "[.^?]", True, "Negation5")
+ ' Like test from microsoft vba
+ TestUtil.AssertEqual("aBBBa" Like "a*a", True, "Like1")
+ TestUtil.AssertEqual("F" Like "[A-Z]", True, "Like2")
+ TestUtil.AssertEqual("F" Like "[!A-Z]", False, "Like3")
+ TestUtil.AssertEqual("a2a" Like "a#a", True, "Like4")
+ TestUtil.AssertEqual("aM5b" Like "a[L-P]#[!c-e]", True, "Like5")
+ TestUtil.AssertEqual("BAT123khg" Like "B?T*", True, "Like6")
+ TestUtil.AssertEqual("CAT123khg" Like "B?T*", False, "Like7")
+ TestUtil.AssertEqual("ab" Like "a*b", True, "Like8")
+ TestUtil.AssertEqual("a*b" Like "a [*]b", False, "Like9")
+ TestUtil.AssertEqual("axxxxxb" Like "a [*]b", False, "Like10")
+ TestUtil.AssertEqual("a [xyz" Like "a [[]*", True, "Like11")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testLike", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/basic_coverage/test_logexp_methods.bas b/basic/qa/basic_coverage/test_logexp_methods.bas
new file mode 100644
index 0000000000..c120f72186
--- /dev/null
+++ b/basic/qa/basic_coverage/test_logexp_methods.bas
@@ -0,0 +1,17 @@
+' 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 Explicit
+
+Function doUnitTest as String
+ ' EXP LOG
+ If ( Log( Exp(1) ) <> 1 ) Then
+ doUnitTest = "FAIL"
+ Else
+ doUnitTest = "OK"
+ End If
+End Function
diff --git a/basic/qa/basic_coverage/test_ltrim_method.bas b/basic/qa/basic_coverage/test_ltrim_method.bas
new file mode 100644
index 0000000000..3395f5f243
--- /dev/null
+++ b/basic/qa/basic_coverage/test_ltrim_method.bas
@@ -0,0 +1,19 @@
+' 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 Explicit
+
+Function doUnitTest as String
+ dim aString as Variant
+ aString = "Hello"
+ ' LTRIM
+ If ( LTrim( " Hello" ) <> aString ) Then
+ doUnitTest = "FAIL"
+ Else
+ doUnitTest = "OK"
+ End If
+End Function
diff --git a/basic/qa/basic_coverage/test_method_name_variable.bas b/basic/qa/basic_coverage/test_method_name_variable.bas
new file mode 100644
index 0000000000..da9e83bca2
--- /dev/null
+++ b/basic/qa/basic_coverage/test_method_name_variable.bas
@@ -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 Explicit
+
+Function assignVarToMethod() As Integer
+
+ ' method name used as dimension specifier
+ Dim fieldOfLongs() As Long
+ ReDim fieldOfLongs(assignVarToMethod) As Long
+
+ ' method name used as loop index
+ Dim sum As Integer
+ For assignVarToMethod = 1 To 3
+ sum = sum + assignVarToMethod
+ Next assignVarToMethod
+ assignVarToMethod = sum
+
+End Function
+
+Function doUnitTest() As String
+
+ doUnitTest = "FAIL"
+
+ ' tdf#85371 - check if the name of the method can be used as a variable in certain statements
+ If (assignVarToMethod() <> 6) Then Exit Function
+ ' tdf#85371 - check if an assignment to the function fails outside of the function itself
+ assignVarToMethod = 0
+ If (assignVarToMethod() <> 6) Then Exit Function
+
+ doUnitTest = "OK"
+
+End Function
diff --git a/basic/qa/basic_coverage/test_mid_CountNegative_3args.bas b/basic/qa/basic_coverage/test_mid_CountNegative_3args.bas
new file mode 100644
index 0000000000..3df3ae7412
--- /dev/null
+++ b/basic/qa/basic_coverage/test_mid_CountNegative_3args.bas
@@ -0,0 +1,17 @@
+'
+' 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 Explicit
+
+Function doUnitTest as String
+ If (Mid("abc", 5, -3) = "") Then
+ doUnitTest = "OK"
+ Else
+ doUnitTest = "FAIL"
+ End If
+End Function
diff --git a/basic/qa/basic_coverage/test_mid_EndOutOfBounds_3args.bas b/basic/qa/basic_coverage/test_mid_EndOutOfBounds_3args.bas
new file mode 100644
index 0000000000..525a9cd2a6
--- /dev/null
+++ b/basic/qa/basic_coverage/test_mid_EndOutOfBounds_3args.bas
@@ -0,0 +1,17 @@
+'
+' 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 Explicit
+
+Function doUnitTest as String
+ If (Mid("abc", 1, 4) = "abc") Then
+ doUnitTest = "OK"
+ Else
+ doUnitTest = "FAIL"
+ End If
+End Function
diff --git a/basic/qa/basic_coverage/test_mid_StartOutOfBounds_2args.bas b/basic/qa/basic_coverage/test_mid_StartOutOfBounds_2args.bas
new file mode 100644
index 0000000000..89c6cd309a
--- /dev/null
+++ b/basic/qa/basic_coverage/test_mid_StartOutOfBounds_2args.bas
@@ -0,0 +1,17 @@
+'
+' 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 Explicit
+
+Function doUnitTest as String
+ If (Mid("abc", 5) = "") Then
+ doUnitTest = "OK"
+ Else
+ doUnitTest = "FAIL"
+ End If
+End Function
diff --git a/basic/qa/basic_coverage/test_mid_StartOutOfBounds_3args.bas b/basic/qa/basic_coverage/test_mid_StartOutOfBounds_3args.bas
new file mode 100644
index 0000000000..1f538788b5
--- /dev/null
+++ b/basic/qa/basic_coverage/test_mid_StartOutOfBounds_3args.bas
@@ -0,0 +1,17 @@
+'
+' 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 Explicit
+
+Function doUnitTest as String
+ If (Mid("abc", 5, 1) = "") Then
+ doUnitTest = "OK"
+ Else
+ doUnitTest = "FAIL"
+ End If
+End Function
diff --git a/basic/qa/basic_coverage/test_mid_firstletter_3args.bas b/basic/qa/basic_coverage/test_mid_firstletter_3args.bas
new file mode 100644
index 0000000000..e9bcb1378f
--- /dev/null
+++ b/basic/qa/basic_coverage/test_mid_firstletter_3args.bas
@@ -0,0 +1,17 @@
+'
+' 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 Explicit
+
+Function doUnitTest as String
+ If (Mid("abc", 1, 1) = "a") Then
+ doUnitTest = "OK"
+ Else
+ doUnitTest = "FAIL"
+ End If
+End Function
diff --git a/basic/qa/basic_coverage/test_mid_keyword_names.bas b/basic/qa/basic_coverage/test_mid_keyword_names.bas
new file mode 100644
index 0000000000..abe56043ad
--- /dev/null
+++ b/basic/qa/basic_coverage/test_mid_keyword_names.bas
@@ -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 Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_Mid_method
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_Mid_method
+ On Error GoTo errorHandler
+
+ ' tdf#141474 keyword names need to match that of VBA
+ TestUtil.AssertEqual(Mid(start:=6, string:="LibreOffice" ), "Office", "Mid() with 2 keyword names" )
+ TestUtil.AssertEqual(Mid(length:=5, start:=1, string:="LibreOffice" ), "Libre", "Mid() with 3 keyword names" )
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_Mid_method", Err, Error$, Erl)
+End Sub \ No newline at end of file
diff --git a/basic/qa/basic_coverage/test_mid_replace_less.bas b/basic/qa/basic_coverage/test_mid_replace_less.bas
new file mode 100644
index 0000000000..0088563887
--- /dev/null
+++ b/basic/qa/basic_coverage/test_mid_replace_less.bas
@@ -0,0 +1,19 @@
+'
+' 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/.
+'
+
+' cf. <https://bugs.documentfoundation.org/show_bug.cgi?id=62090> "Mid statement doesn't work as
+' expected":
+Function doUnitTest as String
+ s = "The lightbrown fox"
+ Mid(s, 5, 10, "lazy")
+ If (s = "The lazy fox") Then
+ doUnitTest = "OK"
+ Else
+ doUnitTest = "FAIL"
+ End If
+End Function
diff --git a/basic/qa/basic_coverage/test_mid_replace_more.bas b/basic/qa/basic_coverage/test_mid_replace_more.bas
new file mode 100644
index 0000000000..40b9ac3379
--- /dev/null
+++ b/basic/qa/basic_coverage/test_mid_replace_more.bas
@@ -0,0 +1,19 @@
+'
+' 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/.
+'
+
+' cf. examples at <https://docs.microsoft.com/en-us/dotnet/visual-basic/language-reference/
+' statements/mid-statement>:
+Function doUnitTest as String
+ s = "The fox jumps"
+ Mid(s, 5, 3, "duck")
+ If (s = "The duc jumps") Then
+ doUnitTest = "OK"
+ Else
+ doUnitTest = "FAIL"
+ End If
+End Function
diff --git a/basic/qa/basic_coverage/test_mid_replace_more_end.bas b/basic/qa/basic_coverage/test_mid_replace_more_end.bas
new file mode 100644
index 0000000000..593cf1abb0
--- /dev/null
+++ b/basic/qa/basic_coverage/test_mid_replace_more_end.bas
@@ -0,0 +1,19 @@
+'
+' 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/.
+'
+
+' cf. examples at <https://docs.microsoft.com/en-us/dotnet/visual-basic/language-reference/
+' statements/mid-statement>:
+Function doUnitTest as String
+ s = "The fox jumps"
+ Mid(s, 5, 100, "cow jumped over")
+ If (s = "The cow jumpe") Then
+ doUnitTest = "OK"
+ Else
+ doUnitTest = "FAIL"
+ End If
+End Function
diff --git a/basic/qa/basic_coverage/test_mid_sub2letters_2args.bas b/basic/qa/basic_coverage/test_mid_sub2letters_2args.bas
new file mode 100644
index 0000000000..2cbb21ecf9
--- /dev/null
+++ b/basic/qa/basic_coverage/test_mid_sub2letters_2args.bas
@@ -0,0 +1,17 @@
+'
+' 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 Explicit
+
+Function doUnitTest as String
+ If (Mid("abc", 2) = "bc") Then
+ doUnitTest = "OK"
+ Else
+ doUnitTest = "FAIL"
+ End If
+End Function
diff --git a/basic/qa/basic_coverage/test_minute_method.bas b/basic/qa/basic_coverage/test_minute_method.bas
new file mode 100644
index 0000000000..4f120cc3f4
--- /dev/null
+++ b/basic/qa/basic_coverage/test_minute_method.bas
@@ -0,0 +1,18 @@
+'
+' 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 Explicit
+
+Function doUnitTest as String
+ ' MINUTE
+ If ( Minute(TimeSerial(12,30,41)) <> 30 ) Then
+ doUnitTest = "FAIL"
+ Else
+ doUnitTest = "OK"
+ End If
+End Function
diff --git a/basic/qa/basic_coverage/test_mod_operator.bas b/basic/qa/basic_coverage/test_mod_operator.bas
new file mode 100644
index 0000000000..79ad49fda1
--- /dev/null
+++ b/basic/qa/basic_coverage/test_mod_operator.bas
@@ -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 Explicit
+
+Function doUnitTest as String
+
+ doUnitTest = "FAIL"
+
+ Dim a As Double, b as Double
+ a = 16.4
+ b = 5.9
+
+ ' tdf#141201 - MOD operands are rounded to Integer values before the operation is performed
+ if (a MOD b <> 4) Then Exit Function
+ if (16.4 MOD 5.9 <> 4) Then Exit Function
+ if (15.9 MOD 6.4 <> 4) Then Exit Function
+ if (2147483647.4 MOD 4 <> 3) Then Exit Function
+
+ doUnitTest = "OK"
+
+End Function
diff --git a/basic/qa/basic_coverage/test_month_method.bas b/basic/qa/basic_coverage/test_month_method.bas
new file mode 100644
index 0000000000..cbef221c94
--- /dev/null
+++ b/basic/qa/basic_coverage/test_month_method.bas
@@ -0,0 +1,20 @@
+'
+' 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 Explicit
+
+Function doUnitTest as String
+ dim aDate as Date
+ aDate = Date()
+ ' MONTH
+ If ( DatePart( "m", aDate ) <> Month( aDate ) ) Then
+ doUnitTest = "FAIL"
+ Else
+ doUnitTest = "OK"
+ End If
+End Function
diff --git a/basic/qa/basic_coverage/test_non_ascii_names.bas b/basic/qa/basic_coverage/test_non_ascii_names.bas
new file mode 100644
index 0000000000..c85c9cae12
--- /dev/null
+++ b/basic/qa/basic_coverage/test_non_ascii_names.bas
@@ -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 Explicit
+
+Function doUnitTest as String
+ [Prüfung]
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Function [Функция]([😁])
+ [Функция] = [😁] & " and some text"
+End Function
+
+Function TestNonAsciiNative as Integer
+ Dim [Абв] as Integer
+ [Абв] = 5
+ TestNonAsciiNative = [абв]
+End Function
+
+Sub [Prüfung]
+ On Error GoTo errorHandler
+
+ TestUtil.AssertEqual([Функция]("Smiley"), "Smiley and some text", "[Функция](""Smiley"")")
+
+ ' tdf#148358 - compare Non-ASCII variable names case-insensitive
+ TestUtil.AssertEqual(TestNonAsciiNative(), 5, "TestNonAsciiNative()")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("Prüfung", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/basic_coverage/test_non_ascii_names_compatible.bas b/basic/qa/basic_coverage/test_non_ascii_names_compatible.bas
new file mode 100644
index 0000000000..1abc272443
--- /dev/null
+++ b/basic/qa/basic_coverage/test_non_ascii_names_compatible.bas
@@ -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 Compatible
+Option Explicit
+
+Function doUnitTest as String
+ [Prüfung]
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Function [Функция]([😁])
+ [Функция] = [😁] & " and some text"
+End Function
+
+Function TestNonAscii as Integer
+ Dim Абв as Integer
+ Абв = 10
+ TestNonAscii = абв
+End Function
+
+Function TestNonAsciiNative as Integer
+ Dim [Абв] as Integer
+ [Абв] = 5
+ TestNonAsciiNative = [абв]
+End Function
+
+Sub [Prüfung]
+ On Error GoTo errorHandler
+
+ TestUtil.AssertEqual([Функция]("Smiley"), "Smiley and some text", "[Функция](""Smiley"")")
+
+ ' tdf#148358 - compare Non-ASCII variable names case-insensitive
+ TestUtil.AssertEqual(TestNonAscii(), 10, "TestNonAscii()")
+ TestUtil.AssertEqual(TestNonAsciiNative(), 5, "TestNonAsciiNative()")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("Prüfung Compatible", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/basic_coverage/test_nowtimevalue_methods.bas b/basic/qa/basic_coverage/test_nowtimevalue_methods.bas
new file mode 100644
index 0000000000..b99b9a3830
--- /dev/null
+++ b/basic/qa/basic_coverage/test_nowtimevalue_methods.bas
@@ -0,0 +1,22 @@
+'
+' 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 Explicit
+
+Function doUnitTest as String
+ dim aDate as Date
+ dim aTime as Date
+ aDate = Date()
+ aTime = Time()
+ ' NOW TIMEVALUE
+ If ( Now() < aDate + TimeValue(aTime) ) Then
+ doUnitTest = "FAIL"
+ Else
+ doUnitTest = "OK"
+ End If
+End Function
diff --git a/basic/qa/basic_coverage/test_numeric_constant_parameter.bas b/basic/qa/basic_coverage/test_numeric_constant_parameter.bas
new file mode 100644
index 0000000000..4f93f3f45c
--- /dev/null
+++ b/basic/qa/basic_coverage/test_numeric_constant_parameter.bas
@@ -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 Explicit
+
+' assigns a numeric constant (integer) to a parameter of type variant
+Function assignInteger( numericConstant ) As String
+ numericConstant = 1
+ assignInteger = TypeName( numericConstant )
+End Function
+
+' assigns a numeric constant (long) to a parameter of type variant
+Function assignLong( numericConstant ) As String
+ numericConstant = 32768
+ assignLong = TypeName( numericConstant )
+End Function
+
+Function doUnitTest() As String
+ ' tdf#133913 - check if numeric constants are converted correctly to
+ ' their respective types, if they are passed as arguments to a function
+ ' with variant parameter types.
+ On Error GoTo errorHandler
+ If (assignInteger( 1 ) = "Integer" And assignLong( 1 ) = "Long") Then
+ doUnitTest = "OK"
+ Else
+ doUnitTest = "FAIL"
+ End If
+ Exit Function
+errorHandler:
+ doUnitTest = "FAIL"
+End Function
diff --git a/basic/qa/basic_coverage/test_oct_method.bas b/basic/qa/basic_coverage/test_oct_method.bas
new file mode 100644
index 0000000000..31028195be
--- /dev/null
+++ b/basic/qa/basic_coverage/test_oct_method.bas
@@ -0,0 +1,17 @@
+' 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 Explicit
+
+Function doUnitTest as String
+ ' OCT
+ If ( Oct(100) <> "144" ) Then
+ doUnitTest = "FAIL"
+ Else
+ doUnitTest = "OK"
+ End If
+End Function
diff --git a/basic/qa/basic_coverage/test_option_base.bas b/basic/qa/basic_coverage/test_option_base.bas
new file mode 100644
index 0000000000..69282f80be
--- /dev/null
+++ b/basic/qa/basic_coverage/test_option_base.bas
@@ -0,0 +1,50 @@
+' 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 Base 1
+Option Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_optionBase
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_optionBase() As String
+ On Error GoTo errorHandler
+
+ ' tdf#54912 - with option base arrays should start at index 1.
+ ' Without option compatible the upper bound is changed as well (#109275).
+ Dim strArray(2) As String
+ TestUtil.AssertEqual(LBound(strArray), 1, "Lower bound of a string array (before assignment): " & LBound(strArray))
+ TestUtil.AssertEqual(UBound(strArray), 3, "Upper bound of a string array (before assignment): " & UBound(strArray))
+ strArray = Array("a", "b")
+ TestUtil.AssertEqual(LBound(strArray), 1, "Lower bound of a string array (after assignment): " & LBound(strArray))
+ TestUtil.AssertEqual(UBound(strArray), 2, "Upper bound of a string array (after assignment): " & UBound(strArray))
+
+ Dim intArray(2) As Integer
+ TestUtil.AssertEqual(LBound(intArray), 1, "Lower bound of an integer array (before assignment): " & LBound(intArray))
+ TestUtil.AssertEqual(UBound(intArray), 3, "Upper bound of an integer array (before assignment): " & UBound(intArray))
+ intArray = Array(1, 2)
+ TestUtil.AssertEqual(LBound(intArray), 1, "Lower bound of an integer array (after assignment): " & LBound(intArray))
+ TestUtil.AssertEqual(UBound(intArray), 2, "Upper bound of an integer array (after assignment): " & UBound(intArray))
+
+ Dim byteArray(2) As Byte
+ TestUtil.AssertEqual(LBound(byteArray), 1, "Lower bound of a byte array (before assignment): " & LBound(byteArray))
+ TestUtil.AssertEqual(UBound(byteArray), 3, "Upper bound of a byte array (before assignment): " & UBound(byteArray))
+ byteArray = StrConv("ab", 128)
+ TestUtil.AssertEqual(LBound(byteArray), 1, "Lower bound of a byte array (StrConv): " & LBound(byteArray))
+ TestUtil.AssertEqual(UBound(byteArray), 2, "Upper bound of a byte array (StrConv): " & UBound(byteArray))
+
+ ReDim byteArray(3)
+ TestUtil.AssertEqual(LBound(byteArray), 1, "Lower bound of a byte array (ReDim): " & LBound(byteArray))
+ TestUtil.AssertEqual(UBound(byteArray), 4, "Upper bound of a byte array (ReDim): " & UBound(byteArray))
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_optionBase", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/basic_coverage/test_option_base_compatible.bas b/basic/qa/basic_coverage/test_option_base_compatible.bas
new file mode 100644
index 0000000000..296b208f58
--- /dev/null
+++ b/basic/qa/basic_coverage/test_option_base_compatible.bas
@@ -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 Base 1
+Option Compatible
+Option Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_optionBase
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_optionBase()
+
+ On Error GoTo errorHandler
+
+ ' tdf#54912 - with option base arrays should start at index 1.
+ ' With option compatible the upper bound is not changed (#109275).
+ Dim strArray(2) As String
+ TestUtil.AssertEqual(LBound(strArray), 1, "Lower bound of a string array (before assignment): " & LBound(strArray))
+ TestUtil.AssertEqual(UBound(strArray), 2, "Upper bound of a string array (before assignment): " & UBound(strArray))
+ strArray = Array("a", "b")
+ TestUtil.AssertEqual(LBound(strArray), 1, "Lower bound of a string array (after assignment): " & LBound(strArray))
+ TestUtil.AssertEqual(UBound(strArray), 2, "Upper bound of a string array (after assignment): " & UBound(strArray))
+
+ Dim intArray(2) As Integer
+ TestUtil.AssertEqual(LBound(intArray), 1, "Lower bound of an integer array (before assignment): " & LBound(intArray))
+ TestUtil.AssertEqual(UBound(intArray), 2, "Upper bound of an integer array (before assignment): " & UBound(intArray))
+ intArray = Array(1, 2)
+ TestUtil.AssertEqual(LBound(intArray), 1, "Lower bound of an integer array (after assignment): " & LBound(intArray))
+ TestUtil.AssertEqual(UBound(intArray), 2, "Upper bound of an integer array (after assignment): " & UBound(intArray))
+
+ Dim byteArray(2) As Byte
+ TestUtil.AssertEqual(LBound(byteArray), 1, "Lower bound of a byte array (before assignment): " & LBound(byteArray))
+ TestUtil.AssertEqual(UBound(byteArray), 2, "Upper bound of a byte array (before assignment): " & UBound(byteArray))
+ byteArray = StrConv("ab", 128)
+ TestUtil.AssertEqual(LBound(byteArray), 1, "Lower bound of a byte array (StrConv): " & LBound(byteArray))
+ TestUtil.AssertEqual(UBound(byteArray), 2, "Upper bound of a byte array (StrConv): " & UBound(byteArray))
+
+ ReDim byteArray(3)
+ TestUtil.AssertEqual(LBound(byteArray), 1, "Lower bound of a byte array (ReDim): " & LBound(byteArray))
+ TestUtil.AssertEqual(UBound(byteArray), 3, "Upper bound of a byte array (ReDim): " & UBound(byteArray))
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_optionBase", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/basic_coverage/test_optional_paramter_type.bas b/basic/qa/basic_coverage/test_optional_paramter_type.bas
new file mode 100644
index 0000000000..a98e422cd0
--- /dev/null
+++ b/basic/qa/basic_coverage/test_optional_paramter_type.bas
@@ -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 Compatible
+Option Explicit
+
+Function doUnitTest() As String
+ doUnitTest = "FAIL"
+ If CheckType1(32) = 0 Then
+ Exit Function
+ End If
+ If CheckType2(32) = 0 Then
+ Exit Function
+ End If
+ If CheckType2() = 0 Then
+ Exit Function
+ End If
+ doUnitTest = "OK"
+End Function
+
+Function CheckType1(x As Integer) As Integer
+ If TypeName(x) = "Integer" Then
+ CheckType1 = 1
+ Else
+ CheckType1 = 0
+ End If
+End Function
+
+
+Function CheckType2(Optional y As Integer = 32 ) As Integer
+ If TypeName(y) = "Integer" Then
+ CheckType2 = 1
+ Else
+ CheckType2 = 0
+ End If
+End Function
diff --git a/basic/qa/basic_coverage/test_optional_paramters_basic.bas b/basic/qa/basic_coverage/test_optional_paramters_basic.bas
new file mode 100644
index 0000000000..82880e11bd
--- /dev/null
+++ b/basic/qa/basic_coverage/test_optional_paramters_basic.bas
@@ -0,0 +1,270 @@
+' 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 Explicit
+
+Type testObject
+ testInt As Integer
+End Type
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testOptionalsBasic
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+' tdf#36737 - Test optionals with different datatypes. In LO Basic, optional
+' parameters are allowed, but without any default values. Missing optional
+' parameters will not be initialized to their respective default values of
+' its datatype, either.
+Sub verify_testOptionalsBasic()
+ On Error GoTo errorHandler
+
+ ' optionals with variant datatypes
+ TestUtil.AssertEqual(TestOptVariant(), 0, "TestOptVariant()")
+ TestUtil.AssertEqual(TestOptVariant(123), 123, "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(), 0, "TestOptVariantByRefByVal()")
+ TestUtil.AssertEqualApprox(TestOptVariantByRefByVal(123), 123, "TestOptVariantByRefByVal(123)")
+ TestUtil.AssertEqualApprox(TestOptVariantByRefByVal(, 456), 456, "TestOptVariantByRefByVal(, 456)")
+ TestUtil.AssertEqualApprox(TestOptVariantByRefByVal(123, 456), 579, "TestOptVariantByRefByVal(123, 456)")
+
+ ' optionals with double datatypes
+ TestUtil.AssertEqual(TestOptDouble(), 0, "TestOptDouble()")
+ TestUtil.AssertEqualApprox(TestOptDouble(123.4), 123.4, 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.AssertEqual(TestOptDoubleByRefByVal(), 0, "TestOptDoubleByRefByVal()")
+ TestUtil.AssertEqualApprox(TestOptDoubleByRefByVal(123.4), 123.4, 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(), 0, "TestOptInteger()")
+ TestUtil.AssertEqual(TestOptInteger(123), 123, "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(), 0, "TestOptIntegerByRefByVal()")
+ TestUtil.AssertEqual(TestOptIntegerByRefByVal(123), 123, "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(), "", "TestOptString()")
+ TestUtil.AssertEqual(TestOptString("123"), "123", "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(), "", "TestOptStringByRefByVal()")
+ TestUtil.AssertEqual(TestOptStringByRefByVal("123"), "123", "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
+ 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)
+ 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)")
+
+ ' tdf#144353 - error handling of missing optional parameters (arithmetic operator)
+ ' Without the fix in place, this test would have failed with:
+ ' - Expected: 449 (ERRCODE_BASIC_NOT_OPTIONAL - Argument not optional)
+ ' - Actual : 549 (Actual value of the variable)
+ TestUtil.AssertEqual(TestArithmeticOperator, 449, "TestArithmeticOperator")
+
+ ' tdf#144353 - error handling of missing optional parameters (unary operator)
+ ' Without the fix in place, this test would have failed with:
+ ' - Expected: 449 (ERRCODE_BASIC_NOT_OPTIONAL - Argument not optional)
+ ' - Actual : 100 (Actual value of the variable)
+ TestUtil.AssertEqual(TestUnaryOperator, 449, "TestUnaryOperator")
+
+ ' tdf#144353 - error handling of missing optional parameters (assigning to a collection)
+ ' Without the fix in place, this test would have failed with:
+ ' - Expected: 449 (ERRCODE_BASIC_NOT_OPTIONAL - Argument not optional)
+ ' - Actual : 549 (Actual value of the variable)
+ TestUtil.AssertEqual(TestCollection, 449, "TestCollection")
+
+ ' tdf#144353 - error handling of missing optional parameters
+ ' Without the fix in place, this test would have failed with:
+ ' - Expected: 449 (ERRCODE_BASIC_NOT_OPTIONAL - Argument not optional)
+ ' - Actual : 448 (Actual value of the variable)
+ TestUtil.AssertEqual(TestObjectError, 449, "TestObjectError")
+
+ ' tdf#151503 - error handling of missing optional parameters (boolean operations)
+ ' Without the fix in place, this test would have failed with:
+ ' - Expected: 449 (ERRCODE_BASIC_NOT_OPTIONAL - Argument not optional)
+ ' - Actual : 0 (No error code since a missing parameter evaluates to true)
+ TestUtil.AssertEqual(TestBooleanOperations, 449, "TestBooleanOperations")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testOptionalsBasic", Err, Error$, Erl)
+End Sub
+
+Function TestOptVariant(Optional A, Optional B As Variant)
+ TestOptVariant = OptNumberSum(IsMissing(A), A, IsMissing(B), B)
+End Function
+
+Function TestOptVariantByRefByVal(Optional ByRef A, Optional ByVal B As Variant)
+ TestOptVariantByRefByVal = OptNumberSum(IsMissing(A), A, IsMissing(B), B)
+End Function
+
+Function TestOptDouble(Optional A As Double, Optional B As Double)
+ TestOptDouble = OptNumberSum(IsMissing(A), A, IsMissing(B), B)
+End Function
+
+Function TestOptDoubleByRefByVal(Optional ByRef A As Double, Optional ByVal B As Double)
+ TestOptDoubleByRefByVal = OptNumberSum(IsMissing(A), A, IsMissing(B), B)
+End Function
+
+Function TestOptInteger(Optional A As Integer, Optional B As Integer)
+ TestOptInteger = OptNumberSum(IsMissing(A), A, IsMissing(B), B)
+End Function
+
+Function TestOptIntegerByRefByVal(Optional ByRef A As Integer, Optional ByVal B As Integer)
+ TestOptIntegerByRefByVal = OptNumberSum(IsMissing(A), A, IsMissing(B), B)
+End Function
+
+Function TestOptString(Optional A As String, Optional B As String)
+ TestOptString = OptStringConcat(IsMissing(A), A, IsMissing(B), B)
+End Function
+
+Function TestOptStringByRefByVal(Optional ByRef A As String, Optional ByVal B As String)
+ TestOptStringByRefByVal = OptStringConcat(IsMissing(A), A, IsMissing(B), B)
+End Function
+
+Function TestOptObject(Optional A As Collection, Optional B As Collection)
+ TestOptObject = 0
+ If Not IsMissing(A) Then TestOptObject = CollectionSum(A)
+ If Not IsMissing(B) Then TestOptObject = TestOptObject + CollectionSum(B)
+End Function
+
+Function TestOptObjectByRefByVal(Optional ByRef A As Collection, Optional ByVal B As Collection)
+ TestOptObjectByRefByVal = 0
+ If Not IsMissing(A) Then TestOptObjectByRefByVal = CollectionSum(A)
+ If Not IsMissing(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 TestArithmeticOperator(Optional optInt)
+On Error GoTo errorHandler
+ optInt = optInt + 100
+ TestArithmeticOperator = optInt
+errorHandler:
+ TestArithmeticOperator = Err()
+End Function
+
+Function TestUnaryOperator(Optional optInt)
+On Error GoTo errorHandler
+ If (Not optInt) Then optInt = 100
+ TestUnaryOperator = optInt
+errorHandler:
+ TestUnaryOperator = Err()
+End Function
+
+Function TestCollection(Optional optInt)
+On Error GoTo errorHandler
+ Dim cA As New Collection
+ cA.Add(optInt)
+ TestCollection = cA.Item(1) + 100
+errorHandler:
+ TestCollection = Err()
+End Function
+
+Function TestObjectError(Optional optInt)
+On Error GoTo errorHandler
+ Dim aTestObject As Variant
+ aTestObject = CreateObject("testObject")
+ aTestObject.testInt = optInt
+ TestObjectError = optInt
+errorHandler:
+ TestObjectError = Err()
+End Function
+
+Function TestBooleanOperations(Optional optBool As Boolean)
+On Error GoTo errorHandler
+ if optBool then
+ TestBooleanOperations = 0
+ end if
+errorHandler:
+ TestBooleanOperations = Err()
+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/basic_coverage/test_optional_paramters_compatible.bas b/basic/qa/basic_coverage/test_optional_paramters_compatible.bas
new file mode 100644
index 0000000000..78d14eb152
--- /dev/null
+++ b/basic/qa/basic_coverage/test_optional_paramters_compatible.bas
@@ -0,0 +1,272 @@
+' 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 Compatible
+Option Explicit
+
+Type testObject
+ testInt As Integer
+End Type
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testOptionalsCompatible
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+' tdf#36737 - Test optionals with different datatypes. In LO Basic
+' with option Compatible, optional parameters are allowed with default values.
+' Missing optional parameters that don't have explicit default values will
+' not be initialized to their default values of its datatype.
+Sub verify_testOptionalsCompatible()
+
+ On Error GoTo errorHandler
+
+ ' 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
+ 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)
+ 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)")
+
+ ' tdf#144353 - error handling of missing optional parameters (arithmetic operator)
+ ' Without the fix in place, this test would have failed with:
+ ' - Expected: 449 (ERRCODE_BASIC_NOT_OPTIONAL - Argument not optional)
+ ' - Actual : 549 (Actual value of the variable)
+ TestUtil.AssertEqual(TestArithmeticOperator, 449, "TestArithmeticOperator")
+
+ ' tdf#144353 - error handling of missing optional parameters (unary operator)
+ ' Without the fix in place, this test would have failed with:
+ ' - Expected: 449 (ERRCODE_BASIC_NOT_OPTIONAL - Argument not optional)
+ ' - Actual : 100 (Actual value of the variable)
+ TestUtil.AssertEqual(TestUnaryOperator, 449, "TestUnaryOperator")
+
+ ' tdf#144353 - error handling of missing optional parameters (assigning to a collection)
+ ' Without the fix in place, this test would have failed with:
+ ' - Expected: 449 (ERRCODE_BASIC_NOT_OPTIONAL - Argument not optional)
+ ' - Actual : 549 (Actual value of the variable)
+ TestUtil.AssertEqual(TestCollection, 449, "TestCollection")
+
+ ' tdf#144353 - error handling of missing optional parameters (assigning to an object)
+ ' Without the fix in place, this test would have failed with:
+ ' - Expected: 449 (ERRCODE_BASIC_NOT_OPTIONAL - Argument not optional)
+ ' - Actual : 448 (Actual value of the variable)
+ TestUtil.AssertEqual(TestObjectError, 449, "TestObjectError")
+
+ ' tdf#151503 - error handling of missing optional parameters (boolean operations)
+ ' Without the fix in place, this test would have failed with:
+ ' - Expected: 449 (ERRCODE_BASIC_NOT_OPTIONAL - Argument not optional)
+ ' - Actual : 0 (No error code since a missing parameter evaluates to true)
+ TestUtil.AssertEqual(TestBooleanOperations, 449, "TestBooleanOperations")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testOptionalsCompatible", Err, Error$, Erl)
+End Sub
+
+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)
+ TestOptObject = 0
+ If Not IsMissing(A) Then TestOptObject = CollectionSum(A)
+ If Not IsMissing(B) Then TestOptObject = TestOptObject + CollectionSum(B)
+End Function
+
+Function TestOptObjectByRefByVal(Optional ByRef A As Collection, Optional ByVal B As Collection)
+ TestOptObjectByRefByVal = 0
+ If Not IsMissing(A) Then TestOptObjectByRefByVal = CollectionSum(A)
+ If Not IsMissing(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 TestArithmeticOperator(Optional optInt)
+On Error GoTo errorHandler
+ optInt = optInt + 100
+ TestArithmeticOperator = optInt
+errorHandler:
+ TestArithmeticOperator = Err()
+End Function
+
+Function TestUnaryOperator(Optional optInt)
+On Error GoTo errorHandler
+ If (Not optInt) Then optInt = 100
+ TestUnaryOperator = optInt
+errorHandler:
+ TestUnaryOperator = Err()
+End Function
+
+Function TestCollection(Optional optInt)
+On Error GoTo errorHandler
+ Dim cA As New Collection
+ cA.Add(optInt)
+ TestCollection = cA.Item(1) + 100
+errorHandler:
+ TestCollection = Err()
+End Function
+
+Function TestObjectError(Optional optInt)
+On Error GoTo errorHandler
+ Dim aTestObject As Variant
+ aTestObject = CreateObject("testObject")
+ aTestObject.testInt = optInt
+ TestObjectError = optInt
+errorHandler:
+ TestObjectError = Err()
+End Function
+
+Function TestBooleanOperations(Optional optBool As Boolean)
+On Error GoTo errorHandler
+ if optBool then
+ TestBooleanOperations = 0
+ end if
+errorHandler:
+ TestBooleanOperations = Err()
+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/basic_coverage/test_qbcolor_method.bas b/basic/qa/basic_coverage/test_qbcolor_method.bas
new file mode 100644
index 0000000000..8c2b6ed7af
--- /dev/null
+++ b/basic/qa/basic_coverage/test_qbcolor_method.bas
@@ -0,0 +1,17 @@
+' 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 Explicit
+
+Function doUnitTest as String
+ ' QBCOLOR
+ If ( QBColor(7) <> 12632256 ) Then
+ doUnitTest = "FAIL"
+ Else
+ doUnitTest = "OK"
+ End If
+End Function
diff --git a/basic/qa/basic_coverage/test_random_methods.bas b/basic/qa/basic_coverage/test_random_methods.bas
new file mode 100644
index 0000000000..5df5e93134
--- /dev/null
+++ b/basic/qa/basic_coverage/test_random_methods.bas
@@ -0,0 +1,18 @@
+' 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 Explicit
+
+Function doUnitTest as String
+ Randomize 42
+ ' RND
+ If ( Rnd >= 1 ) Then
+ doUnitTest = "FAIL"
+ Else
+ doUnitTest = "OK"
+ End If
+End Function
diff --git a/basic/qa/basic_coverage/test_redim_objects.bas b/basic/qa/basic_coverage/test_redim_objects.bas
new file mode 100644
index 0000000000..b2699956d7
--- /dev/null
+++ b/basic/qa/basic_coverage/test_redim_objects.bas
@@ -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 Explicit
+
+Type testType
+ iNr As Integer
+ sType As String
+ aValue As Variant
+ oColor As Object
+End Type
+
+Function doUnitTest as String
+
+ doUnitTest = "FAIL"
+
+ ' tdf#136755 - ReDim did not work on an array of objects
+ Dim aPropertyValues(1) As New com.sun.star.beans.PropertyValue
+ If (UBound(aPropertyValues) <> 1) Then Exit Function
+ ReDim aPropertyValues(5) As com.sun.star.beans.PropertyValue
+ If (UBound(aPropertyValues) <> 5) Then Exit Function
+
+ ' tdf#124008 - ReDim did not work on an array of individual declared types
+ Dim aType(1) As testType
+ If (UBound(aType) <> 1) Then Exit Function
+ ReDim aType(5) As testType
+ If (UBound(aType) <> 5) Then Exit Function
+
+ doUnitTest = "OK"
+
+End Function
diff --git a/basic/qa/basic_coverage/test_resolvepath_method.bas b/basic/qa/basic_coverage/test_resolvepath_method.bas
new file mode 100644
index 0000000000..249900c3b7
--- /dev/null
+++ b/basic/qa/basic_coverage/test_resolvepath_method.bas
@@ -0,0 +1,17 @@
+' 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 Explicit
+
+Function doUnitTest as String
+ ' RESOLVEPATH
+ If ( ResolvePath( "" ) <> "" ) Then
+ doUnitTest = "FAIL"
+ Else
+ doUnitTest = "OK"
+ End If
+End Function
diff --git a/basic/qa/basic_coverage/test_rgb_method.bas b/basic/qa/basic_coverage/test_rgb_method.bas
new file mode 100644
index 0000000000..3665af50cf
--- /dev/null
+++ b/basic/qa/basic_coverage/test_rgb_method.bas
@@ -0,0 +1,17 @@
+' 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 Explicit
+
+Function doUnitTest as String
+ ' RGB
+ If ( RGB( 128, 50, 200 ) <> 8401608 ) Then
+ doUnitTest = "FAIL"
+ Else
+ doUnitTest = "OK"
+ End If
+End Function
diff --git a/basic/qa/basic_coverage/test_right_method.bas b/basic/qa/basic_coverage/test_right_method.bas
new file mode 100644
index 0000000000..45801d5d86
--- /dev/null
+++ b/basic/qa/basic_coverage/test_right_method.bas
@@ -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 Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_Right_method
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_Right_method
+ On Error GoTo errorHandler
+
+ ' RIGHT
+ TestUtil.AssertEqual(Right("abc", 2), "bc", "Right(""abc"",2)")
+
+ ' tdf#141474 keyword names need to match that of VBA
+ TestUtil.AssertEqual(Right(Length:=4, String:="sometext"), "text", "Right(Length:=4, String:=""sometext"")")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_Right_method", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/basic_coverage/test_rtrim_method.bas b/basic/qa/basic_coverage/test_rtrim_method.bas
new file mode 100644
index 0000000000..f74c04a661
--- /dev/null
+++ b/basic/qa/basic_coverage/test_rtrim_method.bas
@@ -0,0 +1,19 @@
+' 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 Explicit
+
+Function doUnitTest as String
+ dim aString as Variant
+ aString = "Hello"
+ ' RTRIM
+ If ( RTrim( "Hello " ) <> aString ) Then
+ doUnitTest = "FAIL"
+ Else
+ doUnitTest = "OK"
+ End If
+End Function
diff --git a/basic/qa/basic_coverage/test_second_method.bas b/basic/qa/basic_coverage/test_second_method.bas
new file mode 100644
index 0000000000..d06ee20769
--- /dev/null
+++ b/basic/qa/basic_coverage/test_second_method.bas
@@ -0,0 +1,18 @@
+'
+' 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 Explicit
+
+Function doUnitTest as String
+ ' SECOND
+ If ( Second(TimeSerial(12,30,41)) <> 41 ) Then
+ doUnitTest = "FAIL"
+ Else
+ doUnitTest = "OK"
+ End If
+End Function
diff --git a/basic/qa/basic_coverage/test_sgn_method.bas b/basic/qa/basic_coverage/test_sgn_method.bas
new file mode 100644
index 0000000000..7e4dd5d4bd
--- /dev/null
+++ b/basic/qa/basic_coverage/test_sgn_method.bas
@@ -0,0 +1,17 @@
+' 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 Explicit
+
+Function doUnitTest as String
+ ' SGN
+ If ( Sgn(-3.14) <> -1 ) Then
+ doUnitTest = "FAIL"
+ Else
+ doUnitTest = "OK"
+ End If
+End Function
diff --git a/basic/qa/basic_coverage/test_space_method.bas b/basic/qa/basic_coverage/test_space_method.bas
new file mode 100644
index 0000000000..6c44482de1
--- /dev/null
+++ b/basic/qa/basic_coverage/test_space_method.bas
@@ -0,0 +1,17 @@
+' 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 Explicit
+
+Function doUnitTest as String
+ ' SPACE
+ If ( Space(3) <> " " ) Then
+ doUnitTest = "FAIL"
+ Else
+ doUnitTest = "OK"
+ End If
+End Function
diff --git a/basic/qa/basic_coverage/test_spc_method.bas b/basic/qa/basic_coverage/test_spc_method.bas
new file mode 100644
index 0000000000..81f43d40bb
--- /dev/null
+++ b/basic/qa/basic_coverage/test_spc_method.bas
@@ -0,0 +1,17 @@
+' 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 Explicit
+
+Function doUnitTest as String
+ ' SPC
+ If ( Spc(3) <> " " ) Then
+ doUnitTest = "FAIL"
+ Else
+ doUnitTest = "OK"
+ End If
+End Function
diff --git a/basic/qa/basic_coverage/test_split_method.bas b/basic/qa/basic_coverage/test_split_method.bas
new file mode 100644
index 0000000000..e53dfd9705
--- /dev/null
+++ b/basic/qa/basic_coverage/test_split_method.bas
@@ -0,0 +1,65 @@
+' 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 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 - allow the assignment of different data types to the individual elements
+ Dim splitArr
+ splitArr = Split("a/b&&c/d", "&&")
+ Dim i As Integer
+ For i = 0 To UBound(splitArr)
+ ' Without the fix in place, this assignment would have failed
+ splitArr(i) = Split(splitArr(i), "/")
+ ' Without the fix in place, this test would have failed with:
+ ' - Expected: 8200 (8192 for Array and 8 for String)
+ ' - Actual : 8 (8 for String)
+ TestUtil.AssertEqual(VarType(splitArr(i)), 8200, "VarType(splitArr(i))")
+ Next
+
+ ' tdf#141474 keyword names need to match that of VBA
+ TestUtil.AssertEqual(Split(expression:="LibreOffice StarOffice")(1), "StarOffice", "Split with 1 keyword name" )
+ Dim txt As String : txt = "Libre_Office_Star_Office"
+ TestUtil.AssertEqual(Split(delimiter:="_", expression:=txt)(2), "Star", "Split with 2 keyword names" )
+ TestUtil.AssertEqual(Split(limit:=3, delimiter:="_", expression:=txt)(2), "Star_Office", "Split with 3 keyword names" )
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testSplit", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/basic_coverage/test_sqr_method.bas b/basic/qa/basic_coverage/test_sqr_method.bas
new file mode 100644
index 0000000000..064a870d19
--- /dev/null
+++ b/basic/qa/basic_coverage/test_sqr_method.bas
@@ -0,0 +1,17 @@
+' 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 Explicit
+
+Function doUnitTest as String
+ ' SQR
+ If ( Sqr( 4 ) <> 2 ) Then
+ doUnitTest = "FAIL"
+ Else
+ doUnitTest = "OK"
+ End If
+End Function
diff --git a/basic/qa/basic_coverage/test_strcomp_method.bas b/basic/qa/basic_coverage/test_strcomp_method.bas
new file mode 100644
index 0000000000..73ee3002fd
--- /dev/null
+++ b/basic/qa/basic_coverage/test_strcomp_method.bas
@@ -0,0 +1,19 @@
+' 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 Explicit
+
+Function doUnitTest as String
+ dim aString as Variant
+ aString = "Hello"
+ ' STRCOMP
+ If ( StrComp( aString, "Hello" ) <> 0 ) Then
+ doUnitTest = "FAIL"
+ Else
+ doUnitTest = "OK"
+ End If
+End Function
diff --git a/basic/qa/basic_coverage/test_string_literal_comparison.bas b/basic/qa/basic_coverage/test_string_literal_comparison.bas
new file mode 100644
index 0000000000..8144632844
--- /dev/null
+++ b/basic/qa/basic_coverage/test_string_literal_comparison.bas
@@ -0,0 +1,21 @@
+' 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 Explicit
+
+Function doUnitTest as String
+ ' tdf#142180 - Invalid text comparison result in Basic
+
+ doUnitTest = "FAIL"
+ If ( "Z" < "A" ) Then Exit Function
+ If ( "A" > "Z" ) Then Exit Function
+ If ( "A" < "A" ) Then Exit Function
+ If ( "A" > "A" ) Then Exit Function
+ If ( "Z" <= "A" ) Then Exit Function
+ If ( "A" >= "Z" ) Then Exit Function
+ doUnitTest = "OK"
+End Function
diff --git a/basic/qa/basic_coverage/test_string_method.bas b/basic/qa/basic_coverage/test_string_method.bas
new file mode 100644
index 0000000000..39b567a788
--- /dev/null
+++ b/basic/qa/basic_coverage/test_string_method.bas
@@ -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 Explicit
+
+Dim failedAssertion As Boolean, messages As String
+
+Function doUnitTest ' String(Number As Long, Character As String)
+
+ assert(String(3, "H")= "HHH", "String(3, ""H"") is not ""HHH""")
+ assert(String(5.8, "à")= "àààààà", "String(5.8, ""à"") is not ""àààààà""")
+ assert(String(Number:=3.45, Character:="test")="ttt", "String(Number:=3.45, Character:=""test"") is not ""ttt""")
+ assert(String(Character:="☺😎", Number:=7)= "☺☺☺☺☺☺☺", "String(Character:=""☺😎"", Number:=7) is not ""☺☺☺☺☺☺☺""")
+
+ If FailedAssertion Then
+ doUnitTest = "test_string_method.vb failed" + messages
+ Exit Function
+ EndIf
+ doUnitTest = "OK" ' All checks passed
+End Function
+
+Sub assert(expression As Boolean, errMessage As String)
+ if ( Not expression ) Then
+ messages = messages + Chr(10) + ErrMessage
+ failedAssertion = True
+ EndIf
+End Sub \ No newline at end of file
diff --git a/basic/qa/basic_coverage/test_string_overflow_safe.bas b/basic/qa/basic_coverage/test_string_overflow_safe.bas
new file mode 100644
index 0000000000..0b4fec15f0
--- /dev/null
+++ b/basic/qa/basic_coverage/test_string_overflow_safe.bas
@@ -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 Explicit
+
+Function doUnitTest As String
+ ' Trying to create too long string should generate proper BASIC overflow error.
+ ' Longest possible string is 2147483638 wchar_t (2G - 10).
+ ' This tries to create string with 2G wchar_t. If it does not overflow, test fails.
+ ' If overflow is not safe, it segfaults.
+ On Error GoTo errorHandler
+ Dim s As String, i As Integer
+ s = "0"
+ For i=1 To 31
+ s = s & s
+ Next i
+ doUnitTest = "FAIL"
+ Exit Function
+errorHandler:
+ If ( Err <> 6 ) Then
+ doUnitTest = "FAIL"
+ Else
+ doUnitTest = "OK"
+ Endif
+End Function
diff --git a/basic/qa/basic_coverage/test_string_replace.bas b/basic/qa/basic_coverage/test_string_replace.bas
new file mode 100644
index 0000000000..2b0f6354cd
--- /dev/null
+++ b/basic/qa/basic_coverage/test_string_replace.bas
@@ -0,0 +1,46 @@
+' 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 0
+Option Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_stringReplace
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_stringReplace()
+ On Error GoTo errorHandler
+ ' tdf#132389 - case-insensitive operation for non-ASCII characters
+ Dim retStr
+ retStr = Replace("ABCabc", "b", "*")
+ TestUtil.AssertEqual(retStr, "A*Ca*c", "case-insensitive ASCII: " & retStr)
+ retStr = Replace("АБВабв", "б", "*")
+ TestUtil.AssertEqual(retStr, "А*Ва*в", "case-insensitive non-ASCII: " & retStr)
+
+ ' tdf#141045 - different length of search and replace string. It is important
+ ' that the search string starts with the original string in order to test the error.
+ ' Without the fix in place, the string index calculations result in a crash.
+ retStr = Replace("a", "abc", "ab")
+ TestUtil.AssertEqual(retStr, "a", "different length of search and replace string: " & retStr)
+
+ ' tdf#143081 - Without the fix in place, this test would have crashed here
+ retStr = Replace("""Straße""", """", "&quot;")
+ TestUtil.AssertEqual(retStr, "&quot;Straße&quot;", "replace doesn't crash: " & retStr)
+
+ ' tdf#142487 - replace of special unicode characters.
+ ' Without the fix in place, this test would have failed with:
+ ' - Expected: Straßen
+ ' - Actual : Straßeen
+ retStr = Replace("Straße", "e", "en")
+ TestUtil.AssertEqual(retStr, "Straßen", "special unicode character: " & retStr)
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_stringReplace", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/basic_coverage/test_strtrim_methods.bas b/basic/qa/basic_coverage/test_strtrim_methods.bas
new file mode 100644
index 0000000000..97875933ad
--- /dev/null
+++ b/basic/qa/basic_coverage/test_strtrim_methods.bas
@@ -0,0 +1,17 @@
+' 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 Explicit
+
+Function doUnitTest as String
+ ' STR TRIM
+ If ( Trim( Str( 4 ) ) <> "4" ) Then
+ doUnitTest = "FAIL"
+ Else
+ doUnitTest = "OK"
+ End If
+End Function
diff --git a/basic/qa/basic_coverage/test_switch_method.bas b/basic/qa/basic_coverage/test_switch_method.bas
new file mode 100644
index 0000000000..ec4c8a14c9
--- /dev/null
+++ b/basic/qa/basic_coverage/test_switch_method.bas
@@ -0,0 +1,22 @@
+'
+' 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 Explicit
+
+Function doUnitTest as String
+ dim aVariant as Object
+ ' SWITCH
+ If ( Switch( False, 10,_
+ True, 11,_
+ False, 12,_
+ True, 13 ) <> 11 ) Then
+ doUnitTest = "FAIL"
+ Else
+ doUnitTest = "OK"
+ End If
+End Function
diff --git a/basic/qa/basic_coverage/test_tab_method.bas b/basic/qa/basic_coverage/test_tab_method.bas
new file mode 100644
index 0000000000..997d9fb105
--- /dev/null
+++ b/basic/qa/basic_coverage/test_tab_method.bas
@@ -0,0 +1,17 @@
+' 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 Explicit
+
+Function doUnitTest as String
+ ' TAB
+ If ( "Hello" & Tab(0) & "World" <> "HelloWorld" ) Then
+ doUnitTest = "FAIL"
+ Else
+ doUnitTest = "OK"
+ End If
+End Function
diff --git a/basic/qa/basic_coverage/test_tan_method.bas b/basic/qa/basic_coverage/test_tan_method.bas
new file mode 100644
index 0000000000..f780f978e1
--- /dev/null
+++ b/basic/qa/basic_coverage/test_tan_method.bas
@@ -0,0 +1,17 @@
+' 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 Explicit
+
+Function doUnitTest as String
+ ' TAN
+ If ( Abs( Tan(PI/4) - 1 ) > 1E-6 ) Then
+ doUnitTest = "FAIL"
+ Else
+ doUnitTest = "OK"
+ End If
+End Function
diff --git a/basic/qa/basic_coverage/test_tdf111313.bas b/basic/qa/basic_coverage/test_tdf111313.bas
new file mode 100644
index 0000000000..3a2604732e
--- /dev/null
+++ b/basic/qa/basic_coverage/test_tdf111313.bas
@@ -0,0 +1,19 @@
+'
+' 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/.
+'
+
+Function doUnitTest as String
+
+ ' Without the fix in place, this test would have crashed
+ s = "abc"
+ Mid(s,1) = "d"
+ If (s = "d") Then
+ doUnitTest = "OK"
+ Else
+ doUnitTest = "FAIL"
+ End If
+End Function
diff --git a/basic/qa/basic_coverage/test_tdf125637.bas b/basic/qa/basic_coverage/test_tdf125637.bas
new file mode 100644
index 0000000000..e4eff75c27
--- /dev/null
+++ b/basic/qa/basic_coverage/test_tdf125637.bas
@@ -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 Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_tdf125637
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_tdf125637
+ On Error GoTo errorHandler
+
+ ' tdf#125637 - correctly hand names ending with an underscore character at the end of the line
+ Dim test As Long
+ Dim test_ As Long
+ test_ = 1234
+ test = test_
+
+ ' Without the fix in place, this test would have failed with:
+ ' - Expected: 1234
+ ' - Actual : 0
+ TestUtil.AssertEqual(test, 1234, "Assignment of the variable failed (tdf#125637)")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_tdf125637", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/basic_coverage/test_tdf132388_ReplacePerformance.bas b/basic/qa/basic_coverage/test_tdf132388_ReplacePerformance.bas
new file mode 100644
index 0000000000..1bb3b3de21
--- /dev/null
+++ b/basic/qa/basic_coverage/test_tdf132388_ReplacePerformance.bas
@@ -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/.
+'
+
+Function doUnitTest as String
+ TestUtil.TestInit
+ TestReplacePerformance()
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub TestReplacePerformance()
+ On Error GoTo errorHandler
+ ' Assume the normal case to be much faster than 60 s even on slow boxes, and the test string
+ ' is long enough to cause serious performance regressions make it perform much longer
+ n = 10000000
+ s = Space(n)
+ t = Now
+ s = Replace(s, " ", "*", 1, -1, 1)
+ t = Now - t
+ TestUtil.Assert(t <= TimeSerial(0, 2, 0), "TestReplacePerformance", Format(t, """t = ""[s]"" s"""))
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("TestReplacePerformance", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/basic_coverage/test_tdf134692.bas b/basic/qa/basic_coverage/test_tdf134692.bas
new file mode 100644
index 0000000000..1f389f06cc
--- /dev/null
+++ b/basic/qa/basic_coverage/test_tdf134692.bas
@@ -0,0 +1,38 @@
+' 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 0
+Option Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_tdf134692
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_tdf134692()
+ On Error GoTo errorHandler
+
+ dim a(2 to 5)
+ dim b, i, s
+ b = a
+ redim preserve b(4 to 6)
+ for i = lbound(b) to ubound(b)
+ b(i) = i
+ next i
+ for i = lbound(a) to ubound(a)
+ s = s & " a(" & i & ")=" & a(i)
+ next i
+ for i = lbound(b) to ubound(b)
+ s = s & " b(" & i & ")=" & b(i)
+ next i
+ TestUtil.AssertEqual(s, " a(2)= a(3)= a(4)= a(5)= b(4)=4 b(5)=5 b(6)=6", "tdf#134692")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_tdf134692", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/basic_coverage/test_tdf147089_idiv.bas b/basic/qa/basic_coverage/test_tdf147089_idiv.bas
new file mode 100644
index 0000000000..3d5e227114
--- /dev/null
+++ b/basic/qa/basic_coverage/test_tdf147089_idiv.bas
@@ -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 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/basic_coverage/test_tdf147529_optional_parameters_msgbox.bas b/basic/qa/basic_coverage/test_tdf147529_optional_parameters_msgbox.bas
new file mode 100644
index 0000000000..67378213e2
--- /dev/null
+++ b/basic/qa/basic_coverage/test_tdf147529_optional_parameters_msgbox.bas
@@ -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 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/basic_coverage/test_tdf149622.bas b/basic/qa/basic_coverage/test_tdf149622.bas
new file mode 100644
index 0000000000..5c4738c068
--- /dev/null
+++ b/basic/qa/basic_coverage/test_tdf149622.bas
@@ -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/.
+'
+
+Option Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_tdf149622()
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_tdf149622()
+ On Error GoTo errorHandler
+
+ ' Testing fixed-type return value (Handler_handleEvent(...) As Boolean)
+ Dim oHandler
+ oHandler = CreateUnoListener("Handler_", "com.sun.star.awt.XEventHandler")
+ TestUtil.AssertEqualStrict(oHandler.handleEvent(0), True, "oHandler.handleEvent(0)")
+ ' Before the fix for tdf#149622, this returned the previous return value
+ TestUtil.AssertEqualStrict(oHandler.handleEvent(1), False, "oHandler.handleEvent(1)")
+
+ ' Testing Variant return value (Transfer_getData)
+ Dim oTransferable, aId0(0) As Byte, aId1(1) As Byte
+ oTransferable = CreateUnoListener("Transfer_", "com.sun.star.datatransfer.XSystemTransferable")
+ TestUtil.AssertEqualStrict(oTransferable.getData(aId0), True, "oTransferable.getData(aId0)")
+ ' Before the fix for tdf#149622, this returned the previous return value
+ TestUtil.AssertEqualStrict(oTransferable.getData(aId1), Empty, "oTransferable.getData(aId1)")
+
+ Exit Sub
+
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_tdf149622", Err, Error$, Erl)
+End Sub
+
+Function Handler_handleEvent(Event) As Boolean
+ If Event = 0 Then Handler_handleEvent = True
+ ' Do not define return value explicitly in Else case
+End Function
+
+Function Transfer_getData(aProcessId())
+ If UBound(aProcessId) - LBound(aProcessId) = 0 Then Transfer_getData = True ' only for 1-element array
+ ' Do not define return value explicitly in Else case
+End Function
diff --git a/basic/qa/basic_coverage/test_tdf150137_parse_fail.bas b/basic/qa/basic_coverage/test_tdf150137_parse_fail.bas
new file mode 100644
index 0000000000..fdf9f1e994
--- /dev/null
+++ b/basic/qa/basic_coverage/test_tdf150137_parse_fail.bas
@@ -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 Explicit
+
+Function doUnitTest() As String
+ On Error GoTo ErrorHandler ' Set up error handler
+
+ Dim Xml As String
+ Dim XmlLen As Long
+ ' Not namespace-well-formed XML, parse is expected to fail
+ Xml = "<a:xml/>"
+ XmlLen = Len(Xml)
+ Dim XmlByte(1 To XmlLen) As Byte
+ Dim Index As Integer
+ For Index = 1 To XmlLen
+ XmlByte(Index) = Asc(Mid(Xml, Index, 1))
+ Next
+ Dim source As Object
+ source = CreateUnoStruct("com.sun.star.xml.sax.InputSource")
+ source.aInputStream = com.sun.star.io.SequenceInputStream.createStreamFromSequence(XmlByte)
+ Dim parser As Object
+ parser = CreateUnoService("com.sun.star.xml.sax.FastParser")
+ ' Parse crashed before the fix
+ parser.ParseStream(source)
+
+ ' Shouldn't end up here
+ doUnitTest = "FAIL"
+ Exit Function
+ErrorHandler:
+ doUnitTest = "OK"
+End Function
diff --git a/basic/qa/basic_coverage/test_tdf98778.bas b/basic/qa/basic_coverage/test_tdf98778.bas
new file mode 100644
index 0000000000..451d4bde70
--- /dev/null
+++ b/basic/qa/basic_coverage/test_tdf98778.bas
@@ -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 0
+Option Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_tdf98778
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_tdf98778()
+ On Error GoTo errorHandler
+
+ dim d as double
+ dim s as string
+ s="1.0E-5"
+ d=s
+ TestUtil.AssertEqual(d, 1E-05, "tdf#98778")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_tdf98778", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/basic_coverage/test_timer_method.bas b/basic/qa/basic_coverage/test_timer_method.bas
new file mode 100644
index 0000000000..8e28425825
--- /dev/null
+++ b/basic/qa/basic_coverage/test_timer_method.bas
@@ -0,0 +1,18 @@
+'
+' 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 Explicit
+
+Function doUnitTest as String
+ ' TIMER max value = 24*3600
+ If ( Timer() > 86400 ) Then
+ doUnitTest = "FAIL"
+ Else
+ doUnitTest = "OK"
+ End If
+End Function
diff --git a/basic/qa/basic_coverage/test_timeserialtimevalue_methods.bas b/basic/qa/basic_coverage/test_timeserialtimevalue_methods.bas
new file mode 100644
index 0000000000..ce3ea1cf04
--- /dev/null
+++ b/basic/qa/basic_coverage/test_timeserialtimevalue_methods.bas
@@ -0,0 +1,18 @@
+'
+' 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 Explicit
+
+Function doUnitTest as String
+ ' TIMESERIAL TIMEVALUE
+ If ( TimeSerial(13,54,48) <> TimeValue("13:54:48") ) Then
+ doUnitTest = "FAIL"
+ Else
+ doUnitTest = "OK"
+ End If
+End Function
diff --git a/basic/qa/basic_coverage/test_transliteration.bas b/basic/qa/basic_coverage/test_transliteration.bas
new file mode 100644
index 0000000000..dd5f24fb4d
--- /dev/null
+++ b/basic/qa/basic_coverage/test_transliteration.bas
@@ -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 Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testTransliteration
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testTransliteration
+ On Error GoTo errorHandler
+
+ Dim oTr As Object, s$, oLoc as new com.sun.star.lang.Locale
+
+ With oLoc
+ .Country="US"
+ .Language="en"
+ .Variant=""
+ End With
+
+ s="AB cd. eF. "
+ oTr = CreateUnoService("com.sun.star.i18n.Transliteration")
+
+ oTr.LoadModuleByImplName("LOWERCASE_UPPERCASE", oLoc)
+ TestUtil.AssertEqual(oTr.transliterateString2String(s, 0, Len(s)), "AB CD. EF. ", "LOWERCASE_UPPERCASE")
+
+ oTr.LoadModuleByImplName("UPPERCASE_LOWERCASE", oLoc)
+ TestUtil.AssertEqual(oTr.transliterateString2String(s, 0, Len(s)), "ab cd. ef. ", "UPPERCASE_LOWERCASE")
+
+ oTr.LoadModuleByImplName("TOGGLE_CASE", oLoc)
+ TestUtil.AssertEqual(oTr.transliterateString2String(s, 0, Len(s)), "ab CD. Ef. ", "TOGGLE_CASE")
+
+ oTr.LoadModuleByImplName("IGNORE_CASE", oLoc)
+ TestUtil.AssertEqual(oTr.transliterateString2String(s, 0, Len(s)), "ab cd. ef. ", "IGNORE_CASE")
+
+ ' tdf#152520: Without the fix in place, this test would have crashed here
+ oTr.LoadModuleByImplName("TITLE_CASE", oLoc)
+ TestUtil.AssertEqual(oTr.transliterateString2String(s, 0, Len(s)), "Ab cd. ef. ", "TITLE_CASE")
+
+ oTr.LoadModuleByImplName("SENTENCE_CASE", oLoc)
+ TestUtil.AssertEqual(oTr.transliterateString2String(s, 0, Len(s)), "Ab cd. ef. ", "SENTENCE_CASE")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testTransliteration", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/basic_coverage/test_twipsperpixelx_method.bas b/basic/qa/basic_coverage/test_twipsperpixelx_method.bas
new file mode 100644
index 0000000000..ababb7aa79
--- /dev/null
+++ b/basic/qa/basic_coverage/test_twipsperpixelx_method.bas
@@ -0,0 +1,18 @@
+'
+' 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 Explicit
+
+Function doUnitTest as String
+ ' TWIPSPERPIXELX
+ If ( TwipsPerPixelX < 0 ) Then
+ doUnitTest = "FAIL"
+ Else
+ doUnitTest = "OK"
+ End If
+End Function
diff --git a/basic/qa/basic_coverage/test_twipsperpixely_method.bas b/basic/qa/basic_coverage/test_twipsperpixely_method.bas
new file mode 100644
index 0000000000..a29affb88e
--- /dev/null
+++ b/basic/qa/basic_coverage/test_twipsperpixely_method.bas
@@ -0,0 +1,18 @@
+'
+' 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 Explicit
+
+Function doUnitTest as String
+ ' TWIPSPERPIXELY
+ If ( TwipsPerPixelY < 0 ) Then
+ doUnitTest = "FAIL"
+ Else
+ doUnitTest = "OK"
+ End If
+End Function
diff --git a/basic/qa/basic_coverage/test_typelen_method.bas b/basic/qa/basic_coverage/test_typelen_method.bas
new file mode 100644
index 0000000000..cb86d15690
--- /dev/null
+++ b/basic/qa/basic_coverage/test_typelen_method.bas
@@ -0,0 +1,58 @@
+'
+' 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 Explicit
+
+Dim int16 As Integer, int32 As Long, flt32 As Single, flt64 As Double, _
+ curr As Currency, dat As Date, str As String, _
+ myErr As Variant, var As Variant, byt3 As Byte, bool As Boolean
+
+Dim int_%, long_&, single_!, double_#, currency_@, string_$, array_
+
+Function doUnitTest
+ ' TypeLen()
+
+ dat = #02/17/2012# : myErr = CVErr("errMsg")
+ assert( TypeLen(int16) = 2 , "TypeLen(int16) is not 2")
+ assert( TypeLen(int32) = 4 , "TypeLen(int32) is not 4")
+ assert( TypeLen(flt32) = 4 , "TypeLen(flt32) is not 4" )
+ assert( TypeLen(flt64) = 8 , "TypeLen(flt64) is not 8" )
+ assert( TypeLen(curr) = 8 , "TypeLen(curr) is not 8" )
+ assert( TypeLen(dat) = 8 , "TypeLen(dat) is not 8" )
+ assert( TypeLen(str) = 0 , "TypeLen(str) is not 0" ) ' when empty
+ assert( TypeLen(myErr) = 2 , "TypeLen(myErr) is not 2" )
+ assert( TypeLen(bool) = 1 , "TypeLen(bool) is not 1" )
+ assert( TypeLen(var) = 0 , "TypeLen(var) is not 0" ) ' when empty
+ assert( TypeLen(byt3) = 1 , "TypeLen(byt3) is not 1" )
+
+ assert( TypeLen(int_) = 2 , "TypeLen(int_) is not 2" )
+ assert( TypeLen(long_) = 4 , "TypeLen(long_) is not 4" )
+ assert( TypeLen(single_) = 4 , "TypeLen(single_) is not 4" )
+ assert( TypeLen(double_) = 8 , "TypeLen(double_) is not 8" )
+ assert( TypeLen(currency_) = 8 , "TypeLen(currency_) is not 8" )
+ assert( TypeLen(string_) = 0 , "TypeLen(string_) is not 0" )
+
+ If FailedAssertion Then
+ doUnitTest = "test_typelen_method.vb fails" + messages
+ Exit Function
+ EndIf
+ doUnitTest = "OK" ' All checks passed
+End Function
+
+Sub DEV_TEST
+ MsgBox doUnitTest
+End Sub
+
+Dim failedAssertion As Boolean, messages As String
+
+Sub assert(expression As Boolean, errMessage As String)
+ If ( Not expression ) Then
+ messages = messages + Chr(10) + ErrMessage
+ failedAssertion = True
+ EndIf
+End Sub
diff --git a/basic/qa/basic_coverage/test_typename_method.bas b/basic/qa/basic_coverage/test_typename_method.bas
new file mode 100644
index 0000000000..028f57f0e8
--- /dev/null
+++ b/basic/qa/basic_coverage/test_typename_method.bas
@@ -0,0 +1,80 @@
+'
+' 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 Explicit
+
+Type UDF ' User defined type
+ l As Object
+ s as String
+End Type
+Dim myUDF as UDF
+
+Dim int16 As Integer, int32 As Long, flt32 As Single, flt64 As Double, _
+ curr As Currency, dat As Date, str As String, obj As Object, _
+ myErr As Variant, var As Variant, byt3 As Byte, bool As Boolean
+
+Dim int_%, long_&, single_!, double_#, currency_@, string_$, array_
+
+Dim intArray() As Integer, lngArray(5) As Long, sngArray!() As Single, dblArray#(8) As Double, _
+ curArray@() As Currency, datArray() As Date, strArray$() As String, objArray(5,15) As Object, _
+ varArray() As Variant, byteArray() As Byte, boolArray() As Boolean
+
+Function doUnitTest ' TypeName()
+
+ myErr = CVErr(0.56E-41)
+ assert(TypeName(varName:=int16) = "Integer", "TypeName(varName:=int16) is not ""Integer""")
+
+ assert( TypeName(int16) = "Integer" , "TypeName(int16) is not ""Integer""")
+ assert( TypeName(int32) = "Long" , "TypeName(int32) is not ""Long""")
+ assert( TypeName(flt32) = "Single" , "TypeName(flt32) is not ""Single""" )
+ assert( TypeName(flt64) = "Double" , "TypeName(flt64) is not ""Double""" )
+ assert( TypeName(curr) = "Currency", "TypeName(curr) is not ""Currency""" )
+ assert( TypeName(dat) = "Date" , "TypeName(dat) is not ""Date""" )
+ assert( TypeName(byt3) = "Byte" , "TypeName(byt3) is not ""Byte""" )
+ assert( TypeName(MyErr) = "Error" , "TypeName(MyErr) is not ""Error""" )
+ assert( TypeName(bool) = "Boolean" , "TypeName(bool) is not ""Boolean""" )
+ assert( TypeName(str) = "String" , "TypeName(str) is not ""String""" )
+ assert( TypeName(obj) = "Object" , "TypeName(obj) is not ""Object""" )
+ assert( TypeName(myUDF) = "Object" , "TypeName(myUDF) is not ""Object""" )
+ assert( TypeName(var) = "Empty" , "TypeName(var) is not ""Empty""" )
+
+ assert( TypeName(int_) = "Integer" , "TypeName(int_) is not ""Integer""" )
+ assert( TypeName(long_) = "Long" , "TypeName(long_) is not ""Long""" )
+ assert( TypeName(single_) = "Single" , "TypeName(single_) is not ""Single""" )
+ assert( TypeName(double_) = "Double" , "TypeName(double_) is not ""Double""" )
+ assert( TypeName(currency_) = "Currency", "TypeName(currency_) is not ""Currency""" )
+ assert( TypeName(string_) = "String" , "TypeName(string_) is not ""String""" )
+
+ assert( TypeName(intArray) = "Integer()" , "TypeName(intArray) is not ""Integer()""" )
+ assert( TypeName(lngArray) = "Long()" , "TypeName(lngArray) is not ""Long()""" )
+ assert( TypeName(sngArray) = "Single()" , "TypeName(sngArray) is not ""Single()""" )
+ assert( TypeName(dblArray) = "Double()" , "TypeName(dblArray) is not ""Double()""" )
+ assert( TypeName(curArray) = "Currency()", "TypeName(curArray) is not ""Currency()""" )
+ assert( TypeName(datArray) = "Date()" , "TypeName(datArray) is not ""Date()""" )
+ assert( TypeName(strArray) = "String()" , "TypeName(strArray) is not ""String()""" )
+ assert( TypeName(objArray) = "Object()" , "TypeName(objArray) is not ""Object()""" )
+ assert( TypeName(boolArray) = "Boolean()" , "TypeName(boolArray) is not ""Boolean()""" )
+ assert( TypeName(varArray) = "Variant()" , "TypeName(varArray) is not ""Variant()""" )
+ assert( TypeName(byteArray) = "Byte()" , "TypeName(byteArray) is not ""Byte()""" )
+ If FailedAssertion Then
+ doUnitTest = "test_typename_method.vb failed" + messages
+ Exit Function
+ EndIf
+ doUnitTest = "OK" ' All checks passed
+End Function
+
+Sub DEV_TEST : Print doUnitTest : End Sub
+
+Dim failedAssertion As Boolean, messages As String
+
+Sub assert(expression As Boolean, errMessage As String)
+ if ( Not expression ) Then
+ messages = messages + Chr(10) + ErrMessage
+ failedAssertion = True
+ EndIf
+End Sub
diff --git a/basic/qa/basic_coverage/test_types_conversion.bas b/basic/qa/basic_coverage/test_types_conversion.bas
new file mode 100644
index 0000000000..2d93114533
--- /dev/null
+++ b/basic/qa/basic_coverage/test_types_conversion.bas
@@ -0,0 +1,86 @@
+'
+' 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 Explicit
+
+Dim nTotalCount As Integer
+Dim nPassCount As Integer
+Dim nFailCount As Integer
+
+' See LibreOffice6FloatingPointMode in basic/source/runtime/methods1.cxx
+Function LibreOffice6FloatingPointMode() As Boolean
+ Dim bMode As Boolean
+ bMode = Environ("LIBREOFFICE6FLOATINGPOINTMODE") <> ""
+ If (Not bMode) Then
+ Dim oConfigProvider As Object, aNodePath(0) As New com.sun.star.beans.PropertyValue, oRegistryKey As Object
+ oConfigProvider = createUnoService("com.sun.star.configuration.ConfigurationProvider")
+ aNodePath(0).Name = "nodepath"
+ aNodePath(0).Value = "org.openoffice.Office.Scripting/Basic/Compatibility"
+ oRegistryKey = oConfigProvider.createInstanceWithArguments("com.sun.star.configuration.ConfigurationAccess", aNodePath)
+ bMode = oRegistryKey.getPropertyValue("UseLibreOffice6FloatingPointConversion")
+ End If
+ LibreOffice6FloatingPointMode = bMode
+End Function
+
+' For the following tests the en-US (English - United States) locale is required
+Function doUnitTest() As String
+ nTotalCount = 0
+ nPassCount = 0
+ nFailCount = 0
+
+ ' Test implicit conversions from string to number
+ Dim nVal As Double
+ ' Simple integer
+ StartTest()
+ nVal = "123"
+ AssertTest(nVal = 123)
+
+ ' Negative integer
+ StartTest()
+ nVal = "-123"
+ AssertTest(nVal = -123)
+
+ ' Negative floating-point
+ StartTest()
+ nVal = "-123.45"
+ AssertTest(nVal = -123.45)
+
+ ' Negative floating-point with leading and trailing spaces
+ StartTest()
+ nVal = " -123.456 "
+ AssertTest(nVal = -123.456)
+
+ If LibreOffice6FloatingPointMode() Then
+ ' Wrong decimal separator (and not even interpreted as group separator)
+ StartTest()
+ nVal = " -123,45 "
+ AssertTest(nVal = -123)
+ Else
+ ' Wrong decimal separator (interpreted as group separator)
+ StartTest()
+ nVal = " -123,456 "
+ AssertTest(nVal = -123456)
+ End If
+
+ If ((nFailCount > 0) Or (nPassCount <> nTotalCount)) Then
+ doUnitTest = "FAIL"
+ Else
+ doUnitTest = "OK"
+ End If
+End Function
+
+Sub StartTest()
+ nTotalCount = nTotalCount + 1
+End Sub
+
+Sub AssertTest(testResult As Boolean)
+ If (testResult) Then
+ nPassCount = nPassCount + 1
+ Else
+ nFailCount = nFailCount + 1
+ End If
+End Sub
diff --git a/basic/qa/basic_coverage/test_ucase_method.bas b/basic/qa/basic_coverage/test_ucase_method.bas
new file mode 100644
index 0000000000..21779e148e
--- /dev/null
+++ b/basic/qa/basic_coverage/test_ucase_method.bas
@@ -0,0 +1,19 @@
+' 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 Explicit
+
+Function doUnitTest as String
+ dim aString as Variant
+ aString = "Hello"
+ ' UCASE
+ If ( UCase( aString ) <> "HELLO" ) Then
+ doUnitTest = "FAIL"
+ Else
+ doUnitTest = "OK"
+ End If
+End Function
diff --git a/basic/qa/basic_coverage/test_unsigned_integers.bas b/basic/qa/basic_coverage/test_unsigned_integers.bas
new file mode 100644
index 0000000000..d7f2385ecf
--- /dev/null
+++ b/basic/qa/basic_coverage/test_unsigned_integers.bas
@@ -0,0 +1,46 @@
+'
+' 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 Explicit
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testUnsignedIntegers
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Function convertToDouble(n)
+ Dim conv As Object
+ conv = CreateUnoService("com.sun.star.script.Converter")
+ convertToDouble = conv.convertToSimpleType(n, com.sun.star.uno.TypeClass.DOUBLE)
+End Function
+
+Sub verify_testUnsignedIntegers()
+ On Error GoTo errorHandler
+
+ Dim t As New com.sun.star.util.Time ' has both unsigned long and unsigned short
+ t.Seconds = 201
+ t.NanoSeconds = 202
+ Dim u8 As Byte, u16, u32
+ u8 = 200
+ u16 = t.Seconds ' UShort
+ u32 = t.NanoSeconds ' ULong
+
+ TestUtil.AssertEqual(TypeName(u8), "Byte", "TypeName(u8)")
+ TestUtil.AssertEqual(convertToDouble(u8), 200, "convertToDouble(u8)")
+
+ TestUtil.AssertEqual(TypeName(u16), "UShort", "TypeName(u16)")
+ TestUtil.AssertEqual(convertToDouble(u16), 201, "convertToDouble(u16)")
+
+ TestUtil.AssertEqual(TypeName(u32), "ULong", "TypeName(u32)")
+ TestUtil.AssertEqual(convertToDouble(u32), 202, "convertToDouble(u32)")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testUnsignedIntegers", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/basic_coverage/test_val_method.bas b/basic/qa/basic_coverage/test_val_method.bas
new file mode 100644
index 0000000000..306d15b4f3
--- /dev/null
+++ b/basic/qa/basic_coverage/test_val_method.bas
@@ -0,0 +1,18 @@
+'
+' 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 Explicit
+
+Function doUnitTest as String
+ ' VAL
+ If ( Val("4") <> 4 ) Then
+ doUnitTest = "FAIL"
+ Else
+ doUnitTest = "OK"
+ End If
+End Function
diff --git a/basic/qa/basic_coverage/test_vartype_method.bas b/basic/qa/basic_coverage/test_vartype_method.bas
new file mode 100644
index 0000000000..1b7372b279
--- /dev/null
+++ b/basic/qa/basic_coverage/test_vartype_method.bas
@@ -0,0 +1,95 @@
+'
+' 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 Explicit
+
+Type UDF ' User defined type
+ l As Object
+ s as String
+End Type
+Dim myUDF As UDF
+
+Dim int16 As Integer, int32 As Long, flt32 As Single, flt64 As Double, _
+ curr As Currency, dat As Date, str As String, obj As Object, _
+ myErr As Variant, var As Variant, byt3 As Byte, bool As Boolean
+
+Dim int_%, long_&, single_!, double_#, currency_@, string_$, array_
+
+Dim intArray() As Integer, lngArray(5) As Long, sngArray!() As Single, dblArray#(8) As Double, _
+ curArray@() As Currency, datArray() As Date, strArray$() As String, objArray() As Object, _
+ varArray() As Variant, byteArray() As Byte, boolArray() As Boolean
+
+' Constants that candidate for public exposure
+Private Const V_ARRAY=8192, V_OBJECT=9, V_ERROR=10, V_BOOLEAN=11, V_VARIANT=12, V_BYTE=17
+
+Function doUnitTest() As String
+ TestUtil.TestInit
+ verify_testvartype
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testvartype()
+ On Error GoTo errorHandler
+
+ ' VarType()
+
+ TestUtil.AssertEqual( V_EMPTY, 0 , "V_EMPTY is not 0")
+ TestUtil.AssertEqual( V_NULL, 1 , "V_NULL is not 1")
+ TestUtil.AssertEqual( V_INTEGER, 2 , "V_INTEGER is not 2")
+ TestUtil.AssertEqual( V_LONG, 3 , "V_LONG is not 3")
+ TestUtil.AssertEqual( V_SINGLE, 4 , "V_SINGLE is not 4")
+ TestUtil.AssertEqual( V_DOUBLE, 5 , "V_DOUBLE is not 5")
+ TestUtil.AssertEqual( V_CURRENCY, 6, "V_CURRENCY is not 6")
+ TestUtil.AssertEqual( V_DATE, 7 , "V_DATE is not 7")
+ TestUtil.AssertEqual( V_STRING, 8 , "V_STRING is not 8")
+
+ TestUtil.AssertEqual( VarType(Empty) , V_EMPTY , "Vartype(Empty) is not V_EMPTY")
+ TestUtil.AssertEqual( VarType(Null) , V_NULL , "Vartype(Empty) is not V_NULL")
+ TestUtil.AssertEqual( VarType(Nothing), V_OBJECT, "Vartype(Empty) is not V_OBJECT")
+
+ myErr = CVErr("errMsg")
+ TestUtil.AssertEqual(VarType(varName:=int16), V_INTEGER, "VarType(varName:=int16) is not V_INTEGER")
+
+ TestUtil.AssertEqual( VarType(int16), V_INTEGER , "VarType(int16) is not V_INTEGER")
+ TestUtil.AssertEqual( VarType(int32), V_LONG , "VarType(int32) is not V_LONG")
+ TestUtil.AssertEqual( VarType(flt32), V_SINGLE , "VarType(flt32) is not V_SINGLE" )
+ TestUtil.AssertEqual( VarType(flt64), V_DOUBLE , "VarType(flt64) is not V_DOUBLE" )
+ TestUtil.AssertEqual( VarType(curr) , V_CURRENCY, "VarType(curr) is not V_CURRENCY" )
+ TestUtil.AssertEqual( VarType(dat) , V_DATE , "VarType(dat) is not V_DATE" )
+ TestUtil.AssertEqual( VarType(str) , V_STRING , "VarType(str) is not V_STRING" )
+ TestUtil.AssertEqual( VarType(obj) , V_OBJECT , "VarType(obj) is not V_OBJECT" )
+ TestUtil.AssertEqual( VarType(myUDF), V_OBJECT , "VarType(myUDF) is not V_OBJECT" )
+ TestUtil.AssertEqual( VarType(myErr), V_ERROR , "VarType(myErr) is not V_ERROR" )
+ TestUtil.AssertEqual( VarType(bool) , V_BOOLEAN , "VarType(bool) is not V_BOOLEAN" )
+ TestUtil.AssertEqual( VarType(var) , V_EMPTY , "VarType(var) is not V_EMPTY" )
+ TestUtil.AssertEqual( VarType(byt3) , V_BYTE , "VarType(byt3) is not V_BYTE" )
+
+ TestUtil.AssertEqual( VarType(int_) , V_INTEGER , "VarType(int_) is not V_INTEGER" )
+ TestUtil.AssertEqual( VarType(long_) , V_LONG , "VarType(long_) is not V_LONG" )
+ TestUtil.AssertEqual( VarType(single_) , V_SINGLE , "VarType(single_) is not V_SINGLE" )
+ TestUtil.AssertEqual( VarType(double_) , V_DOUBLE , "VarType(double_) is not V_CURRENCY" )
+ TestUtil.AssertEqual( VarType(currency_), V_CURRENCY, "VarType(currency_) is not V_CURRENCY" )
+ TestUtil.AssertEqual( VarType(string_) , V_STRING , "VarType(string_) is not V_STRING" )
+
+ TestUtil.AssertEqual( VarType(intArray) , V_ARRAY+V_INTEGER , "VarType(intArray) is not V_ARRAY+V_INTEGER" )
+ TestUtil.AssertEqual( VarType(lngArray) , V_ARRAY+V_LONG , "VarType(lngArray) is not V_ARRAY+V_LONG" )
+ TestUtil.AssertEqual( VarType(sngArray) , V_ARRAY+V_SINGLE , "VarType(sngArray) is not V_ARRAY+V_SINGLE" )
+ TestUtil.AssertEqual( VarType(dblArray) , V_ARRAY+V_DOUBLE , "VarType(dblArray) is not V_ARRAY+V_DOUBLE" )
+ TestUtil.AssertEqual( VarType(curArray) , V_ARRAY+V_CURRENCY, "VarType(curArray) is not V_ARRAY+V_CURRENCY" )
+ TestUtil.AssertEqual( VarType(datArray) , V_ARRAY+V_DATE , "VarType(datArray) is not V_ARRAY+V_DATE" )
+ TestUtil.AssertEqual( VarType(strArray) , V_ARRAY+V_STRING , "VarType(strArray) is not V_ARRAY+V_STRING" )
+ TestUtil.AssertEqual( VarType(objArray) , V_ARRAY+V_OBJECT , "VarType(objArray) is not V_ARRAY+V_OBJECT" )
+ 'TestUtil.AssertEqual( VarType(***Array) , V_ARRAY+V_ERROR , "VarType(***Array) is not V_ARRAY+V_ERROR" )
+ TestUtil.AssertEqual( VarType(boolArray), V_ARRAY+V_BOOLEAN , "VarType(boolArray) is not V_ARRAY+V_BOOLEAN" )
+ TestUtil.AssertEqual( VarType(varArray) , V_ARRAY+V_VARIANT , "VarType(varArray) is not V_ARRAY+V_VARIANT" )
+ TestUtil.AssertEqual( VarType(byteArray), V_ARRAY+V_BYTE , "VarType(byteArray) is not V_ARRAY+V_BYTE" )
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testvartype", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/basic_coverage/test_wait_method.bas b/basic/qa/basic_coverage/test_wait_method.bas
new file mode 100644
index 0000000000..b9bd0e5f00
--- /dev/null
+++ b/basic/qa/basic_coverage/test_wait_method.bas
@@ -0,0 +1,14 @@
+' 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 Explicit
+
+Function doUnitTest as String
+ ' WAIT
+ Wait(0)
+ doUnitTest = "OK"
+End Function
diff --git a/basic/qa/basic_coverage/test_weekday_method.bas b/basic/qa/basic_coverage/test_weekday_method.bas
new file mode 100644
index 0000000000..3c66c0dfad
--- /dev/null
+++ b/basic/qa/basic_coverage/test_weekday_method.bas
@@ -0,0 +1,20 @@
+'
+' 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 Explicit
+
+Function doUnitTest as String
+ dim aDate as Date
+ aDate = Date()
+ ' WEEKDAY
+ If ( Weekday( aDate ) <> WeekDay( aDate ) ) Then
+ doUnitTest = "FAIL"
+ Else
+ doUnitTest = "OK"
+ End If
+End Function
diff --git a/basic/qa/basic_coverage/test_year_method.bas b/basic/qa/basic_coverage/test_year_method.bas
new file mode 100644
index 0000000000..6852f3986f
--- /dev/null
+++ b/basic/qa/basic_coverage/test_year_method.bas
@@ -0,0 +1,20 @@
+'
+' 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 Explicit
+
+Function doUnitTest as String
+ dim aDate as Date
+ aDate = Date()
+ ' YEAR
+ If ( DatePart( "yyyy", aDate ) <> Year( aDate ) ) Then
+ doUnitTest = "FAIL"
+ Else
+ doUnitTest = "OK"
+ End If
+End Function
diff --git a/basic/qa/basic_coverage/uno_struct_assign.bas b/basic/qa/basic_coverage/uno_struct_assign.bas
new file mode 100644
index 0000000000..f004762c55
--- /dev/null
+++ b/basic/qa/basic_coverage/uno_struct_assign.bas
@@ -0,0 +1,16 @@
+'
+' 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 Explicit
+
+Function doUnitTest as String
+ Dim oNamedValue as new com.sun.star.beans.NamedValue
+ Dim oCellAddress as new com.sun.star.table.CellAddress
+ oNamedValue.Value = oCellAddress ' fdo#60065 - this would throw an error
+ doUnitTest = "OK"
+End Function
diff --git a/basic/qa/cppunit/_test_asserts.bas b/basic/qa/cppunit/_test_asserts.bas
new file mode 100644
index 0000000000..0c3e0b371f
--- /dev/null
+++ b/basic/qa/cppunit/_test_asserts.bas
@@ -0,0 +1,72 @@
+'
+' 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 Explicit
+
+Dim passCount As Integer
+Dim failCount As Integer
+Dim result As String
+
+Function GetResult()
+ If passCount <> 0 and failCount = 0 Then
+ GetResult = "OK"
+ Else
+ GetResult = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
+ End If
+End Function
+
+Sub TestInit()
+ passCount = 0
+ failCount = 0
+ result = result & "Test Results" & Chr$(10) & "============" & Chr$(10)
+End Sub
+
+Sub Assert(Assertion As Boolean, Optional testId As String, Optional testComment As String)
+ If Assertion = True Then
+ passCount = passCount + 1
+ Else
+ Dim testMsg As String
+ If Not IsMissing(testId) Then
+ testMsg = " " + testId
+ End If
+ If Not IsMissing(testComment) Then
+ If Not (testComment = "") Then testMsg = testMsg + " (" + testComment + ")"
+ End If
+
+ result = result & Chr$(10) & " Failed:" & testMsg
+ failCount = failCount + 1
+ End If
+End Sub
+
+Sub AssertEqual(actual As Variant, expected As Variant, testName As String)
+ If expected = actual Then
+ passCount = passCount + 1
+ Else
+ result = result & Chr$(10) & " Failed: " & testName & " returned " & actual & ", expected " & expected
+ failCount = failCount + 1
+ End If
+End Sub
+
+' Same as AssertEqual, but also checks actual and expected types
+Sub AssertEqualStrict(actual As Variant, expected As Variant, testName As String)
+ AssertEqual actual, expected, testName
+ AssertEqual TypeName(actual), TypeName(expected), testName & " type mismatch:"
+End Sub
+
+Sub AssertEqualApprox(actual, expected, epsilon, testName As String)
+ If Abs(expected - actual) <= epsilon Then
+ passCount = passCount + 1
+ Else
+ result = result & Chr$(10) & " Failed: " & testName & " returned " & actual & ", expected " & expected & ", epsilon " & epsilon
+ failCount = failCount + 1
+ End If
+End Sub
+
+Sub ReportErrorHandler(testName As String, aErr, sError, nErl)
+ Assert False, testName, "hit error handler - " & aErr & ": " & sError & " line : " & nErl
+End Sub
diff --git a/basic/qa/cppunit/_test_asserts.vb b/basic/qa/cppunit/_test_asserts.vb
new file mode 100644
index 0000000000..2130ce02f4
--- /dev/null
+++ b/basic/qa/cppunit/_test_asserts.vb
@@ -0,0 +1,73 @@
+'
+' 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
+
+Dim passCount As Integer
+Dim failCount As Integer
+Dim result As String
+
+Function GetResult()
+ If passCount <> 0 and failCount = 0 Then
+ GetResult = "OK"
+ Else
+ GetResult = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
+ End If
+End Function
+
+Sub TestInit()
+ passCount = 0
+ failCount = 0
+ result = result & "Test Results" & Chr$(10) & "============" & Chr$(10)
+End Sub
+
+Sub Assert(Assertion As Boolean, Optional testId As String, Optional testComment As String)
+ If Assertion = True Then
+ passCount = passCount + 1
+ Else
+ Dim testMsg As String
+ If Not IsMissing(testId) Then
+ testMsg = " " + testId
+ End If
+ If Not IsMissing(testComment) Then
+ If Not (testComment = "") Then testMsg = testMsg + " (" + testComment + ")"
+ End If
+
+ result = result & Chr$(10) & " Failed:" & testMsg
+ failCount = failCount + 1
+ End If
+End Sub
+
+Sub AssertEqual(actual As Variant, expected As Variant, testName As String)
+ If expected = actual Then
+ passCount = passCount + 1
+ Else
+ result = result & Chr$(10) & " Failed: " & testName & " returned " & actual & ", expected " & expected
+ failCount = failCount + 1
+ End If
+End Sub
+
+' Same as AssertEqual, but also checks actual and expected types
+Sub AssertEqualStrict(actual As Variant, expected As Variant, testName As String)
+ AssertEqual actual, expected, testName
+ AssertEqual TypeName(actual), TypeName(expected), testName & " type mismatch:"
+End Sub
+
+Sub AssertEqualApprox(actual, expected, epsilon, testName As String)
+ If Abs(expected - actual) <= epsilon Then
+ passCount = passCount + 1
+ Else
+ result = result & Chr$(10) & " Failed: " & testName & " returned " & actual & ", expected " & expected & ", epsilon " & epsilon
+ failCount = failCount + 1
+ End If
+End Sub
+
+Sub ReportErrorHandler(testName As String, aErr, sError, nErl)
+ Assert False, testName, "hit error handler - " & aErr & ": " & sError & " line : " & nErl
+End Sub
diff --git a/basic/qa/cppunit/basic_coverage.cxx b/basic/qa/cppunit/basic_coverage.cxx
new file mode 100644
index 0000000000..0f07229172
--- /dev/null
+++ b/basic/qa/cppunit/basic_coverage.cxx
@@ -0,0 +1,126 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * 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/.
+ */
+
+#include "basictest.hxx"
+#include <osl/file.hxx>
+#include <i18nlangtag/languagetag.hxx>
+#include <unotools/syslocaleoptions.hxx>
+
+namespace
+{
+
+class Coverage : public test::BootstrapFixture
+{
+private:
+ void process_directory(const OUString& sDirName);
+ std::vector< OUString > get_subdirnames( const OUString& sDirName );
+
+public:
+ Coverage();
+
+ void Coverage_Iterator();
+
+ // Adds code needed to register the test suite
+ CPPUNIT_TEST_SUITE(Coverage);
+
+ // Declares the method as a test to call
+ CPPUNIT_TEST(Coverage_Iterator);
+
+ // End of test suite definition
+ CPPUNIT_TEST_SUITE_END();
+};
+
+Coverage::Coverage()
+ : BootstrapFixture(true, false)
+{
+}
+
+std::vector< OUString > Coverage::get_subdirnames( const OUString& sDirName )
+{
+ std::vector< OUString > sSubDirNames;
+ osl::Directory aDir(sDirName);
+ osl::DirectoryItem aItem;
+ osl::FileStatus aFileStatus(osl_FileStatus_Mask_FileURL|osl_FileStatus_Mask_Type);
+
+ if(aDir.open() == osl::FileBase::E_None)
+ {
+ while (aDir.getNextItem(aItem) == osl::FileBase::E_None)
+ {
+ aItem.getFileStatus(aFileStatus);
+ if(aFileStatus.isDirectory())
+ sSubDirNames.push_back( aFileStatus.getFileURL() );
+ }
+ }
+ return sSubDirNames;
+}
+void Coverage::process_directory(const OUString& sDirName)
+{
+ osl::Directory aDir(sDirName);
+ osl::DirectoryItem aItem;
+ osl::FileStatus aFileStatus(osl_FileStatus_Mask_FileURL|osl_FileStatus_Mask_Type);
+ OUString sMacroUtilsURL = m_directories.getURLFromSrc(u"basic/qa/cppunit/_test_asserts.bas");
+
+ if(aDir.open() == osl::FileBase::E_None)
+ {
+ while (aDir.getNextItem(aItem) == osl::FileBase::E_None)
+ {
+ aItem.getFileStatus(aFileStatus);
+ if(aFileStatus.isRegular())
+ {
+ OUString sFileURL = aFileStatus.getFileURL();
+ if (sFileURL.endsWith(".bas"))
+ {
+ MacroSnippet testMacro;
+ testMacro.LoadSourceFromFile("TestUtil", sMacroUtilsURL);
+ testMacro.LoadSourceFromFile("TestModule", sFileURL);
+ SbxVariableRef pReturn = testMacro.Run();
+ CPPUNIT_ASSERT_MESSAGE("No return variable huh?", pReturn.is());
+ fprintf(stderr, "macro result for %s\n", OUStringToOString(sFileURL,RTL_TEXTENCODING_UTF8).getStr());
+ fprintf(stderr, "macro returned:\n%s\n",
+ OUStringToOString(pReturn->GetOUString(), RTL_TEXTENCODING_UTF8).getStr());
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Result not as expected", OUString("OK"),
+ pReturn->GetOUString());
+ }
+ }
+ }
+ }
+ fprintf(stderr,"end process directory\n");
+}
+
+void Coverage::Coverage_Iterator()
+{
+ OUString sDirName = m_directories.getURLFromSrc(u"basic/qa/basic_coverage");
+
+ CPPUNIT_ASSERT(!sDirName.isEmpty());
+ process_directory(sDirName); // any files in the root test dir are run in test harness default locale ( en-US )
+ std::vector< OUString > sLangDirs = get_subdirnames( sDirName );
+
+ for (auto const& langDir : sLangDirs)
+ {
+ sal_Int32 nSlash = langDir.lastIndexOf('/');
+ if ( nSlash != -1 )
+ {
+ OUString sLangISO = langDir.copy( nSlash + 1 );
+ LanguageTag aLocale( sLangISO );
+ if ( aLocale.isValidBcp47() )
+ {
+ SvtSysLocaleOptions aLocalOptions;
+ // set locale for test dir
+ aLocalOptions.SetLocaleConfigString( sLangISO );
+ process_directory(langDir);
+ }
+ }
+ }
+}
+
+ CPPUNIT_TEST_SUITE_REGISTRATION(Coverage);
+
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basic/qa/cppunit/basictest.cxx b/basic/qa/cppunit/basictest.cxx
new file mode 100644
index 0000000000..13dc8c72e4
--- /dev/null
+++ b/basic/qa/cppunit/basictest.cxx
@@ -0,0 +1,125 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * 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/.
+ */
+
+#include "basictest.hxx"
+#include <cppunit/plugin/TestPlugIn.h>
+#include <basic/sbstar.hxx>
+#include <basic/sbmod.hxx>
+#include <basic/sbmeth.hxx>
+#include <basic/sbuno.hxx>
+#include <osl/file.hxx>
+
+void MacroSnippet::InitSnippet()
+{
+ mpBasic = new StarBASIC();
+ StarBASIC::SetGlobalErrorHdl( LINK( this, MacroSnippet, BasicErrorHdl ) );
+}
+
+void MacroSnippet::MakeModule(const OUString& sName, const OUString& sSource)
+{
+ mpMod = mpBasic->MakeModule(sName, sSource);
+}
+
+MacroSnippet::MacroSnippet( const OUString& sSource )
+ : mbError(false)
+{
+ InitSnippet();
+ MakeModule("TestModule", sSource);
+}
+
+MacroSnippet::MacroSnippet()
+ : mbError(false)
+{
+ InitSnippet();
+}
+
+void MacroSnippet::LoadSourceFromFile(const OUString& sModuleName, const OUString& sMacroFileURL)
+{
+ OUString sSource;
+ fprintf(stderr,"loadSource opening macro file %s\n", OUStringToOString( sMacroFileURL, RTL_TEXTENCODING_UTF8 ).getStr() );
+
+ osl::File aFile(sMacroFileURL);
+ if(aFile.open(osl_File_OpenFlag_Read) == osl::FileBase::E_None)
+ {
+ sal_uInt64 size;
+ if(aFile.getSize(size) == osl::FileBase::E_None)
+ {
+ void* buffer = calloc(1, size+1);
+ CPPUNIT_ASSERT(buffer);
+ sal_uInt64 size_read;
+ if(aFile.read( buffer, size, size_read) == osl::FileBase::E_None)
+ {
+ if(size == size_read)
+ {
+ OUString sCode(static_cast<char*>(buffer), size, RTL_TEXTENCODING_UTF8);
+ sSource = sCode;
+ }
+ }
+
+ free(buffer);
+ }
+ }
+ CPPUNIT_ASSERT_MESSAGE( "Source is empty", ( sSource.getLength() > 0 ) );
+ MakeModule(sModuleName, sSource);
+}
+
+SbxVariableRef MacroSnippet::Run( const css::uno::Sequence< css::uno::Any >& rArgs )
+{
+ SbxVariableRef pReturn;
+ if ( !Compile() )
+ return pReturn;
+ SbMethod* pMeth = mpMod.is() ? static_cast<SbMethod*>(mpMod->Find( "doUnitTest", SbxClassType::Method )) : nullptr;
+ if ( pMeth )
+ {
+ if ( rArgs.hasElements() )
+ {
+ SbxArrayRef aArgs = new SbxArray;
+ for ( int i=0; i < rArgs.getLength(); ++i )
+ {
+ SbxVariable* pVar = new SbxVariable();
+ unoToSbxValue( pVar, rArgs[ i ] );
+ aArgs->Put(pVar, i + 1);
+ }
+ pMeth->SetParameters( aArgs.get() );
+ }
+ pReturn = new SbxMethod( *static_cast<SbxMethod*>(pMeth));
+ }
+ return pReturn;
+}
+
+SbxVariableRef MacroSnippet::Run()
+{
+ css::uno::Sequence< css::uno::Any > aArgs;
+ return Run( aArgs );
+}
+
+bool MacroSnippet::Compile()
+{
+ CPPUNIT_ASSERT_MESSAGE("module is NULL", mpMod );
+ mpMod->Compile();
+ return !mbError;
+}
+
+bool MacroSnippet::HasError() const { return mbError; }
+
+const ErrCodeMsg& MacroSnippet::getError() const { return maErrCode; }
+
+IMPL_LINK( MacroSnippet, BasicErrorHdl, StarBASIC *, /*pBasic*/, bool)
+{
+ fprintf(stderr,"(%d:%d)\n",
+ StarBASIC::GetLine(), StarBASIC::GetCol1());
+ fprintf(stderr,"Basic error: %s\n", OUStringToOString( StarBASIC::GetErrorText(), RTL_TEXTENCODING_UTF8 ).getStr() );
+ mbError = true;
+ maErrCode = StarBASIC::GetErrorCode();
+ return false;
+}
+
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basic/qa/cppunit/basictest.hxx b/basic/qa/cppunit/basictest.hxx
new file mode 100644
index 0000000000..46af3542b8
--- /dev/null
+++ b/basic/qa/cppunit/basictest.hxx
@@ -0,0 +1,52 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * 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/.
+ */
+#pragma once
+
+#include <sal/types.h>
+#include <cppunit/TestFixture.h>
+#include <cppunit/extensions/HelperMacros.h>
+#include <cppunit/plugin/TestPlugIn.h>
+#include <test/bootstrapfixture.hxx>
+#include <basic/sbstar.hxx>
+#include <basic/basrdll.hxx>
+#include <basic/sbmod.hxx>
+#include <basic/sbmeth.hxx>
+#include <basic/sbuno.hxx>
+
+class MacroSnippet
+{
+private:
+ bool mbError;
+ ErrCodeMsg maErrCode;
+ BasicDLL maDll; // we need a dll instance for resource manager etc.
+ SbModuleRef mpMod;
+ StarBASICRef mpBasic;
+
+ void InitSnippet();
+ void MakeModule(const OUString& sName, const OUString& sSource);
+
+public:
+ explicit MacroSnippet(const OUString& sSource);
+ MacroSnippet();
+
+ void LoadSourceFromFile(const OUString& sName, const OUString& sMacroFileURL);
+
+ SbxVariableRef Run(const css::uno::Sequence<css::uno::Any>& rArgs);
+
+ SbxVariableRef Run();
+
+ bool Compile();
+
+ DECL_LINK(BasicErrorHdl, StarBASIC*, bool);
+
+ bool HasError() const;
+ const ErrCodeMsg& getError() const;
+};
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basic/qa/cppunit/test_append.cxx b/basic/qa/cppunit/test_append.cxx
new file mode 100644
index 0000000000..aa3280a4ad
--- /dev/null
+++ b/basic/qa/cppunit/test_append.cxx
@@ -0,0 +1,78 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * 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/.
+ */
+
+#include "basictest.hxx"
+
+namespace
+{
+ class EnableTest : public test::BootstrapFixture
+ {
+ public:
+ EnableTest() : BootstrapFixture(true, false) {};
+ void testDimEnable();
+ void testWin64();
+ void testEnableRuntime();
+ // Adds code needed to register the test suite
+ CPPUNIT_TEST_SUITE(EnableTest);
+
+ // Declares the method as a test to call
+ CPPUNIT_TEST(testDimEnable);
+ CPPUNIT_TEST(testWin64);
+ CPPUNIT_TEST(testEnableRuntime);
+
+ // End of test suite definition
+ CPPUNIT_TEST_SUITE_END();
+ };
+
+OUString sTestEnableRuntime(
+ "Function doUnitTest as Integer\n"
+ "Dim Enable as Integer\n"
+ "Enable = 1\n"
+ "Enable = Enable + 2\n"
+ "doUnitTest = Enable\n"
+ "End Function\n"
+);
+
+OUString sTestDimEnable(
+ "Sub doUnitTest\n"
+ "Dim Enable as String\n"
+ "End Sub\n"
+);
+
+void EnableTest::testEnableRuntime()
+{
+ MacroSnippet myMacro(sTestEnableRuntime);
+ myMacro.Compile();
+ CPPUNIT_ASSERT_MESSAGE("testEnableRuntime fails with compile error",!myMacro.HasError() );
+ SbxVariableRef pNew = myMacro.Run();
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(3), pNew->GetInteger());
+}
+
+void EnableTest::testDimEnable()
+{
+ MacroSnippet myMacro(sTestDimEnable);
+ myMacro.Compile();
+ CPPUNIT_ASSERT_MESSAGE("Dim causes compile error", !myMacro.HasError() );
+}
+
+void EnableTest::testWin64()
+{
+ MacroSnippet myMacro(" #If Win64\n"
+ "Declare PtrSafe Function aht_apiGetOpenFileName Lib \"comdlg32.dll\""
+ "\n"
+ "#End if\n");
+ myMacro.Compile();
+ CPPUNIT_ASSERT_MESSAGE("#if Win64 Declare PtrSafe causes compile error", !myMacro.HasError() );
+}
+
+ // Put the test suite in the registry
+ CPPUNIT_TEST_SUITE_REGISTRATION(EnableTest);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basic/qa/cppunit/test_compiler_checks.cxx b/basic/qa/cppunit/test_compiler_checks.cxx
new file mode 100644
index 0000000000..773719e9fd
--- /dev/null
+++ b/basic/qa/cppunit/test_compiler_checks.cxx
@@ -0,0 +1,117 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * 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/.
+ */
+
+#include <sal/config.h>
+#include "basictest.hxx"
+#include <basic/sberrors.hxx>
+#include <unotest/bootstrapfixturebase.hxx>
+
+CPPUNIT_TEST_FIXTURE(CppUnit::TestFixture, testRedefineArgument)
+{
+ MacroSnippet aMacro("Sub doUnitTest(argName)\n"
+ " If False Then\n"
+ " Dim argName\n"
+ " End If\n"
+ "End Sub\n");
+ aMacro.Compile();
+ CPPUNIT_ASSERT(aMacro.HasError());
+ CPPUNIT_ASSERT_EQUAL(ERRCODE_BASIC_VAR_DEFINED, aMacro.getError().GetCode());
+}
+
+CPPUNIT_TEST_FIXTURE(CppUnit::TestFixture, testDoubleArgument)
+{
+ MacroSnippet aMacro("Sub doUnitTest(argName, argName)\n"
+ "End Sub\n");
+ aMacro.Compile();
+ CPPUNIT_ASSERT(aMacro.HasError());
+ CPPUNIT_ASSERT_EQUAL(ERRCODE_BASIC_VAR_DEFINED, aMacro.getError().GetCode());
+}
+
+CPPUNIT_TEST_FIXTURE(CppUnit::TestFixture, testTdf149157)
+{
+ MacroSnippet aMacro("Function extentComment() As Integer\n"
+ " ' _\n"
+ " If Not extentComment Then\n"
+ " extentComment = 1\n"
+ " End If\n"
+ "End Function\n");
+ aMacro.Compile();
+ CPPUNIT_ASSERT(!aMacro.HasError());
+}
+
+CPPUNIT_TEST_FIXTURE(CppUnit::TestFixture, testTdf149157_compatible)
+{
+ MacroSnippet aMacro("Option Compatible\n"
+ "Function extentComment() As Integer\n"
+ " ' _\n"
+ "\n"
+ " If Not extentComment Then\n"
+ " extentComment = 1\n"
+ " End If\n"
+ "End Function\n");
+ aMacro.Compile();
+ CPPUNIT_ASSERT(!aMacro.HasError());
+}
+
+CPPUNIT_TEST_FIXTURE(CppUnit::TestFixture, testTdf149157_vba)
+{
+ MacroSnippet aMacro("Option VBASupport 1\n"
+ "Function extentComment() As Integer\n"
+ " ' _\n"
+ "\n"
+ " If Not extentComment Then\n"
+ " extentComment = 1\n"
+ " End If\n"
+ "End Function\n");
+ aMacro.Compile();
+ CPPUNIT_ASSERT(!aMacro.HasError());
+}
+
+CPPUNIT_TEST_FIXTURE(CppUnit::TestFixture, testTdf149402)
+{
+ MacroSnippet aMacro("Function extentComment() As Integer\n"
+ " ' _ \n"
+ " If Not extentComment Then\n"
+ " extentComment = 1\n"
+ " Else\n"
+ " End If\n"
+ "End Function\n");
+ aMacro.Compile();
+ CPPUNIT_ASSERT(!aMacro.HasError());
+}
+
+CPPUNIT_TEST_FIXTURE(CppUnit::TestFixture, testTdf149402_compatible)
+{
+ MacroSnippet aMacro("Option Compatible\n"
+ "Function extentComment() As Integer\n"
+ " ' _ \n"
+ " If Not extentComment Then\n"
+ " extentComment = 1\n"
+ " Else\n"
+ " End If\n"
+ "End Function\n");
+ aMacro.Compile();
+ CPPUNIT_ASSERT(!aMacro.HasError());
+}
+
+CPPUNIT_TEST_FIXTURE(CppUnit::TestFixture, testTdf149402_vba)
+{
+ MacroSnippet aMacro("Option VBASupport 1\n"
+ "Function extentComment() As Integer\n"
+ " ' _ \n"
+ " If Not extentComment Then\n"
+ " extentComment = 1\n"
+ " Else\n"
+ " End If\n"
+ "End Function\n");
+ aMacro.Compile();
+ CPPUNIT_ASSERT(!aMacro.HasError());
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/basic/qa/cppunit/test_global_array.cxx b/basic/qa/cppunit/test_global_array.cxx
new file mode 100644
index 0000000000..d2dafcfbda
--- /dev/null
+++ b/basic/qa/cppunit/test_global_array.cxx
@@ -0,0 +1,86 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * 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/.
+ */
+
+#include <basic/sbstar.hxx>
+#include <basic/sbmeth.hxx>
+#include <basic/basrdll.hxx>
+#include <cppunit/extensions/HelperMacros.h>
+
+namespace
+{
+class GlobalArrayTest : public CppUnit::TestFixture
+{
+ void testMaintainsValueAcrossCalls();
+
+ CPPUNIT_TEST_SUITE(GlobalArrayTest);
+ CPPUNIT_TEST(testMaintainsValueAcrossCalls);
+ CPPUNIT_TEST_SUITE_END();
+
+ BasicDLL lib;
+ StarBASICRef interpreter;
+
+ SbModuleRef Module()
+ {
+ interpreter = new StarBASIC();
+ auto mod = interpreter->MakeModule("GlobalArray", R"BAS(
+
+Type testType
+ iNr As Integer
+ sType As String
+End Type
+
+Global aTestTypes(2) As New testType
+
+Function Macro1 As String
+ aTestTypes(0).iNr = 1
+ aTestTypes(0).sType = "A"
+ Macro1 = aTestTypes(0).iNr & aTestTypes(0).sType
+End Function
+
+Function Macro2 As String
+ aTestTypes(1).iNr = 2
+ aTestTypes(1).sType = "B"
+ Macro2 = aTestTypes(0).iNr & aTestTypes(0).sType & aTestTypes(1).iNr & aTestTypes(1).sType
+End Function
+
+ )BAS");
+ CPPUNIT_ASSERT(mod->Compile());
+ CPPUNIT_ASSERT_EQUAL(ERRCODE_NONE, StarBASIC::GetErrBasic());
+ CPPUNIT_ASSERT_EQUAL(ERRCODE_NONE, SbxBase::GetError());
+ CPPUNIT_ASSERT(mod->IsCompiled());
+ return mod;
+ }
+};
+
+void GlobalArrayTest::testMaintainsValueAcrossCalls()
+{
+ auto m = Module();
+ auto Macro1 = m->FindMethod("Macro1", SbxClassType::Method);
+ CPPUNIT_ASSERT_MESSAGE("Could not Find Macro1 in module", Macro1 != nullptr);
+
+ // There is no SbxMethod::call(), the basic code is exercised here in the copy ctor
+ SbxVariableRef returned = new SbxMethod{ *Macro1 };
+ CPPUNIT_ASSERT(returned->IsString());
+ CPPUNIT_ASSERT_EQUAL(OUString{ "1A" }, returned->GetOUString());
+
+ auto Macro2 = m->FindMethod("Macro2", SbxClassType::Method);
+ CPPUNIT_ASSERT_MESSAGE("Could not Find Macro2 in module", Macro2 != nullptr);
+ returned = new SbxMethod{ *Macro2 };
+ CPPUNIT_ASSERT(returned->IsString());
+ // tdf#145371 - check if the global array has maintained its state
+ // Without the fix in place, this test would have failed with:
+ // - Expected: 1A2B
+ // - Actual : 02B
+ CPPUNIT_ASSERT_EQUAL(OUString("1A2B"), returned->GetOUString());
+}
+
+// Put the test suite in the registry
+CPPUNIT_TEST_SUITE_REGISTRATION(GlobalArrayTest);
+
+} // namespace
diff --git a/basic/qa/cppunit/test_global_as_new.cxx b/basic/qa/cppunit/test_global_as_new.cxx
new file mode 100644
index 0000000000..868f62d3ec
--- /dev/null
+++ b/basic/qa/cppunit/test_global_as_new.cxx
@@ -0,0 +1,83 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * 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/.
+ */
+
+#include <basic/sbstar.hxx>
+#include <basic/sbmeth.hxx>
+#include <basic/basrdll.hxx>
+#include <cppunit/extensions/HelperMacros.h>
+
+namespace
+{
+class GlobalAsNewTest : public CppUnit::TestFixture
+{
+ void testMaintainsValueAcrossCalls();
+
+ CPPUNIT_TEST_SUITE(GlobalAsNewTest);
+ CPPUNIT_TEST(testMaintainsValueAcrossCalls);
+ CPPUNIT_TEST_SUITE_END();
+
+ BasicDLL lib;
+ StarBASICRef interpreter;
+
+ SbModuleRef Module()
+ {
+ interpreter = new StarBASIC();
+ auto mod = interpreter->MakeModule("GlobalAsNew", R"BAS(
+Global aDate As New "com.sun.star.util.Date"
+
+Function GetDateAsString As String
+ DIM local_Date As New "com.sun.star.util.Date"
+ GetDateAsString = TRIM(STR(aDate.Year)) + "-" + TRIM(STR(local_Date.Year)) + TRIM(STR(aDate.Month)) + "-" + TRIM(STR(aDate.Day))
+End Function
+
+Function SetDate
+ aDate.Month = 6
+ aDate.Day = 30
+ aDate.Year = 2019
+ SetDate = GetDateAsString()
+End Function
+
+ )BAS");
+ CPPUNIT_ASSERT(mod->Compile());
+ CPPUNIT_ASSERT_EQUAL(ERRCODE_NONE, StarBASIC::GetErrBasic());
+ CPPUNIT_ASSERT_EQUAL(ERRCODE_NONE, SbxBase::GetError());
+ CPPUNIT_ASSERT(mod->IsCompiled());
+ return mod;
+ }
+};
+
+void GlobalAsNewTest::testMaintainsValueAcrossCalls()
+{
+ auto m = Module();
+ auto GetDateAsString = m->FindMethod("GetDateAsString", SbxClassType::Method);
+ CPPUNIT_ASSERT_MESSAGE("Could not Find GetDateAsString in module", GetDateAsString != nullptr);
+
+ // There is no SbxMethod::call(), the basic code is exercised here in the copy ctor
+ SbxVariableRef returned = new SbxMethod{ *GetDateAsString };
+ CPPUNIT_ASSERT(returned->IsString());
+ //0-00-0 is the result of reading the default-initialized date
+ CPPUNIT_ASSERT_EQUAL(OUString{ "0-00-0" }, returned->GetOUString());
+
+ auto SetDate = m->FindMethod("SetDate", SbxClassType::Method);
+ CPPUNIT_ASSERT_MESSAGE("Could not Find SetDate in module", SetDate != nullptr);
+ returned = new SbxMethod{ *SetDate };
+ CPPUNIT_ASSERT(returned->IsString());
+ OUString set_val("2019-06-30");
+ CPPUNIT_ASSERT_EQUAL(set_val, returned->GetOUString());
+
+ returned = new SbxMethod{ *GetDateAsString };
+ CPPUNIT_ASSERT(returned->IsString());
+ //tdf#88442 The global should have maintained its state!
+ CPPUNIT_ASSERT_EQUAL(set_val, returned->GetOUString());
+}
+
+// Put the test suite in the registry
+CPPUNIT_TEST_SUITE_REGISTRATION(GlobalAsNewTest);
+
+} // namespace
diff --git a/basic/qa/cppunit/test_language_conditionals.cxx b/basic/qa/cppunit/test_language_conditionals.cxx
new file mode 100644
index 0000000000..c35d5571e9
--- /dev/null
+++ b/basic/qa/cppunit/test_language_conditionals.cxx
@@ -0,0 +1,166 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */
+/*
+ * 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/.
+ */
+
+#include "basictest.hxx"
+
+#include <cppunit/TestAssert.h>
+#include <cppunit/TestFixture.h>
+#include <cppunit/extensions/HelperMacros.h>
+
+namespace
+{
+class Language_Conditionals : public CppUnit::TestFixture
+{
+public:
+ void testIfNot();
+ void testIfAndNot();
+ void testNENot();
+
+ CPPUNIT_TEST_SUITE(Language_Conditionals);
+
+ CPPUNIT_TEST(testIfNot);
+ CPPUNIT_TEST(testIfAndNot);
+ CPPUNIT_TEST(testNENot);
+
+ CPPUNIT_TEST_SUITE_END();
+};
+
+void Language_Conditionals::testIfNot()
+{
+ { // need a block to ensure MacroSnippet is cleaned properly
+ MacroSnippet myMacro("Option VBASupport 1\n"
+ "Option Explicit\n"
+ "\n"
+ "Function doUnitTest() As Integer\n"
+ "Dim op1 As Boolean\n"
+ "op1 = False\n"
+ "If Not op1 Then\n"
+ "doUnitTest = 1\n"
+ "Else\n"
+ "doUnitTest = 0\n"
+ "End If\n"
+ "End Function\n");
+ myMacro.Compile();
+ CPPUNIT_ASSERT(!myMacro.HasError());
+ SbxVariableRef pNew = myMacro.Run();
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(1), pNew->GetInteger());
+ }
+ { // need a block to ensure MacroSnippet is cleaned properly
+ MacroSnippet myMacro("Option VBASupport 0\n"
+ "Option Explicit\n"
+ "\n"
+ "Function doUnitTest() As Integer\n"
+ "Dim op1 As Boolean\n"
+ "op1 = False\n"
+ "If Not op1 Then\n"
+ "doUnitTest = 1\n"
+ "Else\n"
+ "doUnitTest = 0\n"
+ "End If\n"
+ "End Function\n");
+ myMacro.Compile();
+ CPPUNIT_ASSERT(!myMacro.HasError());
+ SbxVariableRef pNew = myMacro.Run();
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(1), pNew->GetInteger());
+ }
+}
+
+void Language_Conditionals::testIfAndNot()
+{
+ { // need a block to ensure MacroSnippet is cleaned properly
+ MacroSnippet myMacro("Option VBASupport 1\n"
+ "Option Explicit\n"
+ "\n"
+ "Function doUnitTest() As Integer\n"
+ "Dim op1 As Boolean\n"
+ "Dim op2 As Boolean\n"
+ "op1 = True\n"
+ "op2 = False\n"
+ "If op1 And Not op2 Then\n"
+ "doUnitTest = 1\n"
+ "Else\n"
+ "doUnitTest = 0\n"
+ "End If\n"
+ "End Function\n");
+ myMacro.Compile();
+ CPPUNIT_ASSERT(!myMacro.HasError());
+ SbxVariableRef pNew = myMacro.Run();
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(1), pNew->GetInteger());
+ }
+ { // need a block to ensure MacroSnippet is cleaned properly
+ MacroSnippet myMacro("Option VBASupport 0\n"
+ "Option Explicit\n"
+ "\n"
+ "Function doUnitTest() As Integer\n"
+ "Dim op1 As Boolean\n"
+ "Dim op2 As Boolean\n"
+ "op1 = True\n"
+ "op2 = False\n"
+ "If op1 And Not op2 Then\n"
+ "doUnitTest = 1\n"
+ "Else\n"
+ "doUnitTest = 0\n"
+ "End If\n"
+ "End Function\n");
+ myMacro.Compile();
+ CPPUNIT_ASSERT(!myMacro.HasError());
+ SbxVariableRef pNew = myMacro.Run();
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(1), pNew->GetInteger());
+ }
+}
+
+void Language_Conditionals::testNENot()
+{
+ { // need a block to ensure MacroSnippet is cleaned properly
+ MacroSnippet myMacro("Option VBASupport 1\n"
+ "Option Explicit\n"
+ "\n"
+ "Function doUnitTest() As Integer\n"
+ "Dim op1 As Boolean\n"
+ "Dim op2 As Boolean\n"
+ "op1 = False\n"
+ "op2 = False\n"
+ "If op1 <> Not op2 Then\n"
+ "doUnitTest = 1\n"
+ "Else\n"
+ "doUnitTest = 0\n"
+ "End If\n"
+ "End Function\n");
+ myMacro.Compile();
+ CPPUNIT_ASSERT(!myMacro.HasError());
+ SbxVariableRef pNew = myMacro.Run();
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(1), pNew->GetInteger());
+ }
+ { // need a block to ensure MacroSnippet is cleaned properly
+ MacroSnippet myMacro("Option VBASupport 0\n"
+ "Option Explicit\n"
+ "\n"
+ "Function doUnitTest() As Integer\n"
+ "Dim op1 As Boolean\n"
+ "Dim op2 As Boolean\n"
+ "op1 = False\n"
+ "op2 = False\n"
+ "If op1 <> Not op2 Then\n"
+ "doUnitTest = 1\n"
+ "Else\n"
+ "doUnitTest = 0\n"
+ "End If\n"
+ "End Function\n");
+ myMacro.Compile();
+ CPPUNIT_ASSERT(!myMacro.HasError());
+ SbxVariableRef pNew = myMacro.Run();
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(1), pNew->GetInteger());
+ }
+}
+
+CPPUNIT_TEST_SUITE_REGISTRATION(Language_Conditionals);
+
+} // namespace
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */
diff --git a/basic/qa/cppunit/test_nested_struct.cxx b/basic/qa/cppunit/test_nested_struct.cxx
new file mode 100644
index 0000000000..daced48ba2
--- /dev/null
+++ b/basic/qa/cppunit/test_nested_struct.cxx
@@ -0,0 +1,323 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * 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/.
+ */
+#include "basictest.hxx"
+
+#include <com/sun/star/awt/WindowDescriptor.hpp>
+#include <com/sun/star/table/TableBorder.hpp>
+#include <basic/sbuno.hxx>
+
+namespace
+{
+ using namespace com::sun::star;
+ class Nested_Struct : public test::BootstrapFixture
+ {
+ public:
+ Nested_Struct(): BootstrapFixture(true, false) {};
+ void testAssign1();
+ void testAssign1Alt(); // result is uno-ised and tested
+ void testOldAssign();
+ void testOldAssignAlt(); // result is uno-ised and tested
+ void testUnfixedVarAssign();
+ void testUnfixedVarAssignAlt(); // result is uno-ised and tested
+ void testFixedVarAssign();
+ void testFixedVarAssignAlt(); // result is uno-ised and tested
+ void testUnoAccess(); // fdo#60117 specific test
+ void testTdf134576();
+
+ // Adds code needed to register the test suite
+ CPPUNIT_TEST_SUITE(Nested_Struct);
+
+ // Declares the method as a test to call
+ CPPUNIT_TEST(testAssign1);
+ CPPUNIT_TEST(testAssign1Alt);
+ CPPUNIT_TEST(testOldAssign);
+ CPPUNIT_TEST(testOldAssignAlt);
+ CPPUNIT_TEST(testUnfixedVarAssign);
+ CPPUNIT_TEST(testUnfixedVarAssignAlt);
+ CPPUNIT_TEST(testFixedVarAssign);
+ CPPUNIT_TEST(testFixedVarAssignAlt);
+ CPPUNIT_TEST(testUnoAccess);
+ CPPUNIT_TEST(testTdf134576);
+
+ // End of test suite definition
+ CPPUNIT_TEST_SUITE_END();
+ };
+
+// tests the new behaviour, we should be able to
+// directly modify the value of the nested 'HorizontalLine' struct
+OUString sTestSource1(
+ "Function doUnitTest() as Integer\n"
+ "Dim b0 as new \"com.sun.star.table.TableBorder\"\n"
+ "b0.HorizontalLine.OuterLineWidth = 9\n"
+ "doUnitTest = b0.HorizontalLine.OuterLineWidth\n"
+ "End Function\n"
+);
+
+OUString sTestSource1Alt(
+ "Function doUnitTest() as Object\n"
+ "Dim b0 as new \"com.sun.star.table.TableBorder\"\n"
+ "b0.HorizontalLine.OuterLineWidth = 9\n"
+ "doUnitTest = b0\n"
+ "End Function\n"
+);
+
+// tests the old behaviour, we should still be able
+// to use the old workaround of
+// a) creating a new instance BorderLine,
+// b) cloning the new instance with the value of b0.HorizontalLine
+// c) modifying the new instance
+// d) setting b0.HorizontalLine with the value of the new instance
+OUString sTestSource2(
+ "Function doUnitTest()\n"
+ "Dim b0 as new \"com.sun.star.table.TableBorder\", l as new \"com.sun.star.table.BorderLine\"\n"
+ "l = b0.HorizontalLine\n"
+ "l.OuterLineWidth = 9\n"
+ "b0.HorizontalLine = l\n"
+ "doUnitTest = b0.HorizontalLine.OuterLineWidth\n"
+"End Function\n"
+);
+
+OUString sTestSource2Alt(
+ "Function doUnitTest()\n"
+ "Dim b0 as new \"com.sun.star.table.TableBorder\", l as new \"com.sun.star.table.BorderLine\"\n"
+ "l = b0.HorizontalLine\n"
+ "l.OuterLineWidth = 9\n"
+ "b0.HorizontalLine = l\n"
+ "doUnitTest = b0\n"
+"End Function\n"
+);
+// it should be legal to assign a variant to a struct ( and copy by val )
+// make sure we aren't copying by reference, we make sure that l is not
+// a reference copy of b0.HorizontalLine, each one should have an
+// OuterLineWidth of 4 & 9 respectively and we should be returning
+// 13 the sum of the two ( hopefully unique values if we haven't copied by reference )
+OUString sTestSource3(
+ "Function doUnitTest()\n"
+ "Dim b0 as new \"com.sun.star.table.TableBorder\"\n"
+ "l = b0.HorizontalLine\n"
+ "l.OuterLineWidth = 9\n"
+ "b0.HorizontalLine = l\n"
+ "l.OuterLineWidth = 4\n"
+ "doUnitTest = b0.HorizontalLine.OuterLineWidth + l.OuterLineWidth\n"
+"End Function\n"
+);
+
+OUString sTestSource3Alt(
+ "Function doUnitTest()\n"
+ "Dim b0 as new \"com.sun.star.table.TableBorder\"\n"
+ "l = b0.HorizontalLine\n"
+ "l.OuterLineWidth = 9\n"
+ "b0.HorizontalLine = l\n"
+ "l.OuterLineWidth = 4\n"
+ "Dim result(1)\n"
+ "result(0) = b0\n"
+ "result(1) = l\n"
+ "doUnitTest = result\n"
+"End Function\n"
+);
+
+// nearly the same as above but this time for a fixed type
+// variable
+OUString sTestSource4(
+ "Function doUnitTest()\n"
+ "Dim b0 as new \"com.sun.star.table.TableBorder\", l as new \"com.sun.star.table.BorderLine\"\n"
+ "l = b0.HorizontalLine\n"
+ "l.OuterLineWidth = 9\n"
+ "b0.HorizontalLine = l\n"
+ "l.OuterLineWidth = 4\n"
+ "doUnitTest = b0.HorizontalLine.OuterLineWidth + l.OuterLineWidth\n"
+"End Function\n"
+);
+
+OUString sTestSource4Alt(
+ "Function doUnitTest()\n"
+ "Dim b0 as new \"com.sun.star.table.TableBorder\", l as new \"com.sun.star.table.BorderLine\"\n"
+ "l = b0.HorizontalLine\n"
+ "l.OuterLineWidth = 9\n"
+ "b0.HorizontalLine = l\n"
+ "l.OuterLineWidth = 4\n"
+ "Dim result(1)\n"
+ "result(0) = b0\n"
+ "result(1) = l\n"
+ "doUnitTest = result\n"
+"End Function\n"
+);
+
+// Although basic might appear to correctly change nested struct elements
+// fdo#60117 shows that basic can be fooled ( and even the watch(ed) variable
+// in the debugger shows the expected values )
+// We need to additionally check the actual uno struct to see if the
+// changes made are *really* reflected in the object
+OUString sTestSource5(
+ "Function doUnitTest() as Object\n"
+ "Dim aWinDesc as new \"com.sun.star.awt.WindowDescriptor\"\n"
+ "Dim aRect as new \"com.sun.star.awt.Rectangle\"\n"
+ "aRect.X = 200\n"
+ "aWinDesc.Bounds = aRect\n"
+ "doUnitTest = aWinDesc\n"
+"End Function\n"
+);
+
+
+void Nested_Struct::testAssign1()
+{
+ MacroSnippet myMacro( sTestSource1 );
+ myMacro.Compile();
+ CPPUNIT_ASSERT_MESSAGE("testAssign1 fails with compile error",!myMacro.HasError() );
+ SbxVariableRef pNew = myMacro.Run();
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(9), pNew->GetInteger());
+}
+
+void Nested_Struct::testAssign1Alt()
+{
+ MacroSnippet myMacro( sTestSource1Alt );
+ myMacro.Compile();
+ CPPUNIT_ASSERT_MESSAGE("testAssign1Alt fails with compile error",!myMacro.HasError() );
+ SbxVariableRef pNew = myMacro.Run();
+ uno::Any aRet = sbxToUnoValue( pNew.get() );
+ table::TableBorder aBorder;
+ aRet >>= aBorder;
+
+ int result = aBorder.HorizontalLine.OuterLineWidth;
+ CPPUNIT_ASSERT_EQUAL( 9, result );
+}
+
+void Nested_Struct::testOldAssign()
+{
+ MacroSnippet myMacro( sTestSource2 );
+ myMacro.Compile();
+ CPPUNIT_ASSERT_MESSAGE("testOldAssign fails with compile error",!myMacro.HasError() );
+ SbxVariableRef pNew = myMacro.Run();
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(9), pNew->GetInteger());
+}
+
+void Nested_Struct::testOldAssignAlt()
+{
+ MacroSnippet myMacro( sTestSource2Alt );
+ myMacro.Compile();
+ CPPUNIT_ASSERT_MESSAGE("testOldAssign fails with compile error",!myMacro.HasError() );
+ SbxVariableRef pNew = myMacro.Run();
+ uno::Any aRet = sbxToUnoValue( pNew.get() );
+ table::TableBorder aBorder;
+ aRet >>= aBorder;
+
+ int result = aBorder.HorizontalLine.OuterLineWidth;
+ CPPUNIT_ASSERT_EQUAL( 9, result );
+}
+
+void Nested_Struct::testUnfixedVarAssign()
+{
+ MacroSnippet myMacro( sTestSource3 );
+ myMacro.Compile();
+ CPPUNIT_ASSERT_MESSAGE("testUnfixedVarAssign fails with compile error",!myMacro.HasError() );
+ // forces a broadcast
+ SbxVariableRef pNew = myMacro.Run();
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(13), pNew->GetInteger());
+}
+
+void Nested_Struct::testUnfixedVarAssignAlt()
+{
+ MacroSnippet myMacro( sTestSource3Alt );
+ myMacro.Compile();
+ CPPUNIT_ASSERT_MESSAGE("testUnfixedVarAssignAlt fails with compile error",!myMacro.HasError() );
+ SbxVariableRef pNew = myMacro.Run();
+ uno::Any aRet = sbxToUnoValue( pNew.get() );
+
+ uno::Sequence< uno::Any > aResult;
+ bool bRes = aRet >>= aResult;
+ CPPUNIT_ASSERT_EQUAL(true, bRes );
+
+ int result = aResult.getLength();
+ // should have 2 elements in a sequence returned
+ CPPUNIT_ASSERT_EQUAL(2, result );
+
+ table::TableBorder aBorder;
+ aResult[0] >>= aBorder;
+
+ table::BorderLine aBorderLine;
+ aResult[1] >>= aBorderLine;
+ result = aBorder.HorizontalLine.OuterLineWidth;
+ CPPUNIT_ASSERT_EQUAL(9, result );
+ result = aBorderLine.OuterLineWidth;
+ CPPUNIT_ASSERT_EQUAL(4, result );
+}
+
+void Nested_Struct::testFixedVarAssign()
+{
+ MacroSnippet myMacro( sTestSource4 );
+ myMacro.Compile();
+ CPPUNIT_ASSERT_MESSAGE("testFixedVarAssign fails with compile error",!myMacro.HasError() );
+ SbxVariableRef pNew = myMacro.Run();
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(13), pNew->GetInteger());
+}
+
+void Nested_Struct::testFixedVarAssignAlt()
+{
+ MacroSnippet myMacro( sTestSource4Alt );
+ myMacro.Compile();
+ CPPUNIT_ASSERT_MESSAGE("testFixedVarAssignAlt fails with compile error",!myMacro.HasError() );
+ SbxVariableRef pNew = myMacro.Run();
+ uno::Any aRet = sbxToUnoValue( pNew.get() );
+
+ uno::Sequence< uno::Any > aResult;
+ bool bRes = aRet >>= aResult;
+ CPPUNIT_ASSERT_EQUAL(true, bRes );
+
+ int result = aResult.getLength();
+ // should have 2 elements in a sequence returned
+ CPPUNIT_ASSERT_EQUAL(2, result );
+
+ table::TableBorder aBorder;
+ aResult[0] >>= aBorder;
+
+ table::BorderLine aBorderLine;
+ aResult[1] >>= aBorderLine;
+ result = aBorder.HorizontalLine.OuterLineWidth;
+ CPPUNIT_ASSERT_EQUAL(9, result );
+ result = aBorderLine.OuterLineWidth;
+ CPPUNIT_ASSERT_EQUAL(4, result );
+}
+
+void Nested_Struct::testUnoAccess()
+{
+ MacroSnippet myMacro( sTestSource5 );
+ myMacro.Compile();
+ CPPUNIT_ASSERT_MESSAGE("testUnoAccess fails with compile error",!myMacro.HasError() );
+ SbxVariableRef pNew = myMacro.Run();
+ uno::Any aRet = sbxToUnoValue( pNew.get() );
+ awt::WindowDescriptor aWinDesc;
+ aRet >>= aWinDesc;
+
+ int result = aWinDesc.Bounds.X;
+ CPPUNIT_ASSERT_EQUAL(200, result );
+}
+
+void Nested_Struct::testTdf134576()
+{
+ MacroSnippet myMacro("Function doUnitTest()\n"
+ " On Error Resume Next\n"
+ " For Each a In b\n"
+ " c.d\n"
+ " Next\n"
+ " doUnitTest = 1\n"
+ "End Function\n");
+
+ myMacro.Compile();
+ CPPUNIT_ASSERT(!myMacro.HasError());
+
+ // Without the fix in place, it would have crashed here
+ SbxVariableRef pNew = myMacro.Run();
+ CPPUNIT_ASSERT_EQUAL(static_cast<sal_Int16>(1), pNew->GetInteger());
+}
+
+ // Put the test suite in the registry
+ CPPUNIT_TEST_SUITE_REGISTRATION(Nested_Struct);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basic/qa/cppunit/test_scanner.cxx b/basic/qa/cppunit/test_scanner.cxx
new file mode 100644
index 0000000000..f17750c89a
--- /dev/null
+++ b/basic/qa/cppunit/test_scanner.cxx
@@ -0,0 +1,1165 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * 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/.
+ */
+
+#include <sal/types.h>
+#include <cppunit/TestAssert.h>
+#include <cppunit/TestFixture.h>
+#include <cppunit/extensions/HelperMacros.h>
+#include <cppunit/plugin/TestPlugIn.h>
+
+#include <limits>
+
+#include <scanner.hxx>
+
+namespace
+{
+struct Symbol
+{
+ sal_uInt16 line;
+ sal_uInt16 col1;
+ OUString text;
+ double number;
+ SbxDataType type;
+ bool ws;
+};
+
+/**
+ * Perform tests on Scanner.
+ */
+class ScannerTest : public CppUnit::TestFixture
+{
+private:
+ void testBlankLines();
+ void testOperators();
+ void testAlphanum();
+ void testComments();
+ void testGoto();
+ void testGotoCompatible();
+ void testExclamation();
+ void testNumbers();
+ void testDataType();
+ void testHexOctal();
+ void testTdf103104();
+ void testTdf136032();
+
+ // Adds code needed to register the test suite
+ CPPUNIT_TEST_SUITE(ScannerTest);
+
+ // Declares the method as a test to call
+ CPPUNIT_TEST(testBlankLines);
+ CPPUNIT_TEST(testOperators);
+ CPPUNIT_TEST(testAlphanum);
+ CPPUNIT_TEST(testComments);
+ CPPUNIT_TEST(testGoto);
+ CPPUNIT_TEST(testGotoCompatible);
+ CPPUNIT_TEST(testExclamation);
+ CPPUNIT_TEST(testNumbers);
+ CPPUNIT_TEST(testDataType);
+ CPPUNIT_TEST(testHexOctal);
+ CPPUNIT_TEST(testTdf103104);
+ CPPUNIT_TEST(testTdf136032);
+
+ // End of test suite definition
+ CPPUNIT_TEST_SUITE_END();
+};
+
+constexpr OUString cr = u"\n"_ustr;
+constexpr OUString rem = u"REM"_ustr;
+constexpr OUString asdf = u"asdf"_ustr;
+constexpr OUString dot = u"."_ustr;
+constexpr OUString goto_ = u"goto"_ustr;
+constexpr OUString excl = u"!"_ustr;
+
+std::vector<Symbol> getSymbols(const OUString& source, sal_Int32& errors, bool bCompatible = false)
+{
+ std::vector<Symbol> symbols;
+ SbiScanner scanner(source);
+ scanner.EnableErrors();
+ scanner.SetCompatible(bCompatible);
+ while (scanner.NextSym())
+ {
+ Symbol symbol;
+ symbol.line = scanner.GetLine();
+ symbol.col1 = scanner.GetCol1();
+ symbol.text = scanner.GetSym();
+ symbol.number = scanner.GetDbl();
+ symbol.type = scanner.GetType();
+ symbol.ws = scanner.WhiteSpace();
+ symbols.push_back(symbol);
+ }
+ errors = scanner.GetErrors();
+ return symbols;
+}
+
+std::vector<Symbol> getSymbols(const OUString& source, bool bCompatible = false)
+{
+ sal_Int32 i;
+ return getSymbols(source, i, bCompatible);
+}
+
+void ScannerTest::testBlankLines()
+{
+ std::vector<Symbol> symbols;
+ symbols = getSymbols("");
+ CPPUNIT_ASSERT(symbols.empty());
+
+ symbols = getSymbols("\r\n");
+ CPPUNIT_ASSERT_EQUAL(size_t(1), symbols.size());
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[0].text);
+ CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[0].type);
+
+ symbols = getSymbols("\n");
+ CPPUNIT_ASSERT_EQUAL(size_t(1), symbols.size());
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[0].text);
+ CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[0].type);
+
+ symbols = getSymbols("\r");
+ CPPUNIT_ASSERT_EQUAL(size_t(1), symbols.size());
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[0].text);
+ CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[0].type);
+
+ symbols = getSymbols("\r\n\r\n");
+ CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[0].text);
+ CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[0].type);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
+ CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[1].type);
+
+ symbols = getSymbols("\n\r");
+ CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[0].text);
+ CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[0].type);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
+ CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[1].type);
+
+ symbols = getSymbols("\n\r\n");
+ CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[0].text);
+ CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[0].type);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
+ CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[1].type);
+
+ symbols = getSymbols("\r\n\r");
+ CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[0].text);
+ CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[0].type);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
+ CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[1].type);
+
+ symbols = getSymbols(" ");
+ CPPUNIT_ASSERT_EQUAL(size_t(1), symbols.size());
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[0].text);
+ CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[0].type);
+}
+
+void ScannerTest::testOperators()
+{
+ constexpr OUString sourceE(u"="_ustr);
+ constexpr OUString sourceLT(u"<"_ustr);
+ constexpr OUString sourceGT(u">"_ustr);
+ constexpr OUString sourceLTE(u"<="_ustr);
+ constexpr OUString sourceGTE(u">="_ustr);
+ constexpr OUString sourceNE(u"<>"_ustr);
+ constexpr OUString sourceA(u":="_ustr);
+ constexpr OUString sourceNot(u"Not"_ustr);
+
+ std::vector<Symbol> symbols;
+
+ symbols = getSymbols(sourceE);
+ CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
+ CPPUNIT_ASSERT_EQUAL(sourceE, symbols[0].text);
+ CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[0].type);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
+ CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[1].type);
+
+ symbols = getSymbols(sourceLT);
+ CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
+ CPPUNIT_ASSERT_EQUAL(sourceLT, symbols[0].text);
+ CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[0].type);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
+ CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[1].type);
+
+ symbols = getSymbols(sourceGT);
+ CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
+ CPPUNIT_ASSERT_EQUAL(sourceGT, symbols[0].text);
+ CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[0].type);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
+ CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[1].type);
+
+ symbols = getSymbols(sourceLTE);
+ CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
+ CPPUNIT_ASSERT_EQUAL(sourceLTE, symbols[0].text);
+ CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[0].type);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
+ CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[1].type);
+
+ symbols = getSymbols(sourceGTE);
+ CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
+ CPPUNIT_ASSERT_EQUAL(sourceGTE, symbols[0].text);
+ CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[0].type);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
+ CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[1].type);
+
+ symbols = getSymbols("==");
+ CPPUNIT_ASSERT_EQUAL(size_t(3), symbols.size());
+ CPPUNIT_ASSERT_EQUAL(sourceE, symbols[0].text);
+ CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[0].type);
+ CPPUNIT_ASSERT_EQUAL(sourceE, symbols[1].text);
+ CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[1].type);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[2].text);
+ CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[2].type);
+
+ symbols = getSymbols(sourceNE);
+ CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
+ CPPUNIT_ASSERT_EQUAL(sourceNE, symbols[0].text);
+ CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[0].type);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
+ CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[1].type);
+
+ symbols = getSymbols(sourceA);
+ CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
+ CPPUNIT_ASSERT_EQUAL(sourceA, symbols[0].text);
+ CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[0].type);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
+ CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[1].type);
+
+ symbols = getSymbols(sourceNot);
+ CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
+ CPPUNIT_ASSERT_EQUAL(sourceNot, symbols[0].text);
+ CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[0].type);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
+ CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[1].type);
+}
+
+void ScannerTest::testAlphanum()
+{
+ constexpr OUString source1(u"asdfghefg"_ustr);
+ constexpr OUString source3(u"AdfsaAUdsl10987"_ustr);
+ constexpr OUString source4(u"asdfa_mnvcnm"_ustr);
+ constexpr OUString source5(u"_asdf1"_ustr);
+ constexpr OUString source6(u"_6"_ustr);
+ constexpr OUString source7(u"joxclk_"_ustr);
+
+ std::vector<Symbol> symbols;
+
+ symbols = getSymbols(source1);
+ CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
+ CPPUNIT_ASSERT_EQUAL(source1, symbols[0].text);
+ CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[0].type);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
+ CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[1].type);
+
+ symbols = getSymbols("1asfdasfd");
+ CPPUNIT_ASSERT_EQUAL(size_t(3), symbols.size());
+ CPPUNIT_ASSERT(symbols[0].text.isEmpty()); // Can't start symbol with a digit
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.0, symbols[0].number, 1E-12);
+ CPPUNIT_ASSERT_EQUAL(SbxINTEGER, symbols[0].type);
+ CPPUNIT_ASSERT_EQUAL(OUString("asfdasfd"), symbols[1].text);
+ CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[1].type);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[2].text);
+ CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[2].type);
+
+ symbols = getSymbols(source3);
+ CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
+ CPPUNIT_ASSERT_EQUAL(source3, symbols[0].text);
+ CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[0].type);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
+ CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[1].type);
+
+ symbols = getSymbols(source4);
+ CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
+ CPPUNIT_ASSERT_EQUAL(source4, symbols[0].text);
+ CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[0].type);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
+ CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[1].type);
+
+ symbols = getSymbols(source5);
+ CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
+ CPPUNIT_ASSERT_EQUAL(source5, symbols[0].text);
+ CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[0].type);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
+ CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[1].type);
+
+ symbols = getSymbols(source6);
+ CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
+ CPPUNIT_ASSERT_EQUAL(source6, symbols[0].text);
+ CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[0].type);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
+ CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[1].type);
+
+ symbols = getSymbols(source7);
+ CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
+ CPPUNIT_ASSERT_EQUAL(OUString("joxclk_"), symbols[0].text);
+ CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[0].type);
+ // tdf#125637 - don't change underscore to space
+ CPPUNIT_ASSERT_EQUAL(OUString("joxclk_"), source7);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
+ CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[1].type);
+
+ symbols = getSymbols(" asdf ");
+ CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
+ CPPUNIT_ASSERT_EQUAL(OUString("asdf"), symbols[0].text);
+ CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[0].type);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
+ CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[1].type);
+
+ symbols = getSymbols(" 19395 asdfa ");
+ CPPUNIT_ASSERT_EQUAL(size_t(3), symbols.size());
+ CPPUNIT_ASSERT(symbols[0].text.isEmpty());
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(19395.0, symbols[0].number, 1E-12);
+ CPPUNIT_ASSERT_EQUAL(SbxINTEGER, symbols[0].type);
+ CPPUNIT_ASSERT_EQUAL(OUString("asdfa"), symbols[1].text);
+ CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[1].type);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[2].text);
+ CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[2].type);
+
+ symbols = getSymbols("\n1\n2\na sdf");
+ CPPUNIT_ASSERT_EQUAL(size_t(8), symbols.size());
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[0].text);
+ CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[0].type);
+ CPPUNIT_ASSERT(symbols[1].text.isEmpty());
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.0, symbols[1].number, 1E-12);
+ CPPUNIT_ASSERT_EQUAL(SbxINTEGER, symbols[1].type);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[2].text);
+ CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[2].type);
+ CPPUNIT_ASSERT(symbols[3].text.isEmpty());
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(2.0, symbols[3].number, 1E-12);
+ CPPUNIT_ASSERT_EQUAL(SbxINTEGER, symbols[3].type);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[4].text);
+ CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[4].type);
+ CPPUNIT_ASSERT_EQUAL(1u, static_cast<unsigned int>(symbols[5].text.getLength()));
+ CPPUNIT_ASSERT_EQUAL('a', static_cast<char>(symbols[5].text[0]));
+ CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[5].type);
+ CPPUNIT_ASSERT_EQUAL(OUString("sdf"), symbols[6].text);
+ CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[6].type);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[7].text);
+ CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[7].type);
+
+ symbols = getSymbols("asdf.asdf");
+ CPPUNIT_ASSERT_EQUAL(size_t(4), symbols.size());
+ CPPUNIT_ASSERT_EQUAL(asdf, symbols[0].text);
+ CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[0].type);
+ CPPUNIT_ASSERT_EQUAL(dot, symbols[1].text);
+ CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[1].type);
+ CPPUNIT_ASSERT_EQUAL(asdf, symbols[2].text);
+ CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[2].type);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[3].text);
+ CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[3].type);
+
+ symbols = getSymbols("..");
+ CPPUNIT_ASSERT_EQUAL(size_t(3), symbols.size());
+ CPPUNIT_ASSERT_EQUAL(dot, symbols[0].text);
+ CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[0].type);
+ CPPUNIT_ASSERT_EQUAL(dot, symbols[1].text);
+ CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[1].type);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[2].text);
+ CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[2].type);
+}
+
+void ScannerTest::testComments()
+{
+ std::vector<Symbol> symbols;
+
+ symbols = getSymbols("REM asdf");
+ CPPUNIT_ASSERT_EQUAL(size_t(1), symbols.size());
+ CPPUNIT_ASSERT_EQUAL(rem, symbols[0].text);
+ CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[0].type);
+
+ symbols = getSymbols("REMasdf");
+ CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
+ CPPUNIT_ASSERT_EQUAL(OUString("REMasdf"), symbols[0].text);
+ CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[0].type);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
+ CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[1].type);
+
+ symbols = getSymbols("'asdf");
+ CPPUNIT_ASSERT_EQUAL(size_t(1), symbols.size());
+ CPPUNIT_ASSERT_EQUAL(rem, symbols[0].text);
+ CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[0].type);
+
+ symbols = getSymbols("asdf _\n'100");
+ CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
+ CPPUNIT_ASSERT_EQUAL(asdf, symbols[0].text);
+ CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[0].type);
+ CPPUNIT_ASSERT_EQUAL(rem, symbols[1].text);
+ CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[1].type);
+
+ symbols = getSymbols("'asdf _\n100");
+ CPPUNIT_ASSERT_EQUAL(size_t(3), symbols.size());
+ CPPUNIT_ASSERT_EQUAL(rem, symbols[0].text);
+ CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[0].type);
+ CPPUNIT_ASSERT(symbols[1].text.isEmpty());
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(100.0, symbols[1].number, 1E-12);
+ CPPUNIT_ASSERT_EQUAL(SbxINTEGER, symbols[1].type);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[2].text);
+ CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[2].type);
+
+ symbols = getSymbols("'asdf _\n'100");
+ CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
+ CPPUNIT_ASSERT_EQUAL(rem, symbols[0].text);
+ CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[0].type);
+ CPPUNIT_ASSERT_EQUAL(rem, symbols[1].text);
+ CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[1].type);
+
+ symbols = getSymbols("'asdf _\n 1234 _\n asdf'");
+ CPPUNIT_ASSERT_EQUAL(size_t(4), symbols.size());
+ CPPUNIT_ASSERT_EQUAL(rem, symbols[0].text);
+ CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[0].type);
+ CPPUNIT_ASSERT(symbols[1].text.isEmpty());
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1234.0, symbols[1].number, 1E-12);
+ CPPUNIT_ASSERT_EQUAL(SbxINTEGER, symbols[1].type);
+ CPPUNIT_ASSERT_EQUAL(asdf, symbols[2].text);
+ CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[2].type);
+ CPPUNIT_ASSERT_EQUAL(rem, symbols[3].text);
+ CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[3].type);
+}
+
+void ScannerTest::testGoto()
+{
+ std::vector<Symbol> symbols;
+
+ symbols = getSymbols("goto");
+ CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
+ CPPUNIT_ASSERT_EQUAL(goto_, symbols[0].text);
+ CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[0].type);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
+ CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[1].type);
+
+ symbols = getSymbols("go to");
+ CPPUNIT_ASSERT_EQUAL(size_t(3), symbols.size());
+ CPPUNIT_ASSERT_EQUAL(OUString("go"), symbols[0].text);
+ CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[0].type);
+ CPPUNIT_ASSERT_EQUAL(OUString("to"), symbols[1].text);
+ CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[1].type);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[2].text);
+ CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[2].type);
+
+ symbols = getSymbols("go\nto");
+ CPPUNIT_ASSERT_EQUAL(size_t(4), symbols.size());
+ CPPUNIT_ASSERT_EQUAL(OUString("go"), symbols[0].text);
+ CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[0].type);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
+ CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[1].type);
+ CPPUNIT_ASSERT_EQUAL(OUString("to"), symbols[2].text);
+ CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[2].type);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[3].text);
+ CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[3].type);
+}
+
+void ScannerTest::testGotoCompatible()
+{
+ std::vector<Symbol> symbols;
+
+ symbols = getSymbols("goto", true);
+ CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
+ CPPUNIT_ASSERT_EQUAL(goto_, symbols[0].text);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
+
+ symbols = getSymbols("go to", true);
+ CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
+ CPPUNIT_ASSERT_EQUAL(goto_, symbols[0].text);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
+
+ symbols = getSymbols("go\nto", true);
+ CPPUNIT_ASSERT_EQUAL(size_t(4), symbols.size());
+ CPPUNIT_ASSERT_EQUAL(OUString("go"), symbols[0].text);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
+ CPPUNIT_ASSERT_EQUAL(OUString("to"), symbols[2].text);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[3].text);
+}
+
+void ScannerTest::testExclamation()
+{
+ std::vector<Symbol> symbols;
+
+ symbols = getSymbols("asdf!asdf");
+ CPPUNIT_ASSERT_EQUAL(size_t(4), symbols.size());
+ CPPUNIT_ASSERT_EQUAL(asdf, symbols[0].text);
+ CPPUNIT_ASSERT_EQUAL(excl, symbols[1].text);
+ CPPUNIT_ASSERT_EQUAL(asdf, symbols[2].text);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[3].text);
+
+ symbols = getSymbols("!1234");
+ CPPUNIT_ASSERT_EQUAL(size_t(3), symbols.size());
+ CPPUNIT_ASSERT_EQUAL(excl, symbols[0].text);
+ CPPUNIT_ASSERT(symbols[1].text.isEmpty());
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1234.0, symbols[1].number, 1E-12);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[2].text);
+
+ symbols = getSymbols("!_3");
+ CPPUNIT_ASSERT_EQUAL(size_t(3), symbols.size());
+ CPPUNIT_ASSERT_EQUAL(excl, symbols[0].text);
+ CPPUNIT_ASSERT_EQUAL(OUString("_3"), symbols[1].text);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[2].text);
+
+ symbols = getSymbols("!$");
+ CPPUNIT_ASSERT_EQUAL(size_t(3), symbols.size());
+ CPPUNIT_ASSERT_EQUAL(excl, symbols[0].text);
+ CPPUNIT_ASSERT_EQUAL(OUString("$"), symbols[1].text);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[2].text);
+
+ symbols = getSymbols("!%");
+ CPPUNIT_ASSERT_EQUAL(size_t(3), symbols.size());
+ CPPUNIT_ASSERT_EQUAL(excl, symbols[0].text);
+ CPPUNIT_ASSERT_EQUAL(OUString("%"), symbols[1].text);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[2].text);
+
+ symbols = getSymbols("!\n");
+ CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
+ CPPUNIT_ASSERT_EQUAL(excl, symbols[0].text);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
+}
+
+void ScannerTest::testNumbers()
+{
+ std::vector<Symbol> symbols;
+ sal_Int32 errors;
+
+ symbols = getSymbols("12345", errors);
+ CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(12345.0, symbols[0].number, 1E-12);
+ CPPUNIT_ASSERT_EQUAL(SbxINTEGER, symbols[0].type);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
+ CPPUNIT_ASSERT_EQUAL(0u, static_cast<unsigned int>(errors));
+
+ symbols = getSymbols("1.2.3", errors);
+ CPPUNIT_ASSERT_EQUAL(size_t(3), symbols.size());
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.2, symbols[0].number, 1E-12);
+ CPPUNIT_ASSERT_EQUAL(SbxDOUBLE, symbols[0].type);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(.3, symbols[1].number, 1E-12);
+ CPPUNIT_ASSERT_EQUAL(SbxDOUBLE, symbols[1].type);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[2].text);
+ CPPUNIT_ASSERT_EQUAL(1u, static_cast<unsigned int>(errors));
+
+ symbols = getSymbols("123.4", errors);
+ CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(123.4, symbols[0].number, 1E-12);
+ CPPUNIT_ASSERT_EQUAL(SbxDOUBLE, symbols[0].type);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
+ CPPUNIT_ASSERT_EQUAL(0u, static_cast<unsigned int>(errors));
+
+ symbols = getSymbols("0.5", errors);
+ CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(.5, symbols[0].number, 1E-12);
+ CPPUNIT_ASSERT_EQUAL(SbxDOUBLE, symbols[0].type);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
+ CPPUNIT_ASSERT_EQUAL(0u, static_cast<unsigned int>(errors));
+
+ symbols = getSymbols("5.0", errors);
+ CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(5.0, symbols[0].number, 1E-12);
+ CPPUNIT_ASSERT_EQUAL(SbxDOUBLE, symbols[0].type);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
+ CPPUNIT_ASSERT_EQUAL(0u, static_cast<unsigned int>(errors));
+
+ symbols = getSymbols("0.0", errors);
+ CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0, symbols[0].number, 1E-12);
+ CPPUNIT_ASSERT_EQUAL(SbxDOUBLE, symbols[0].type);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
+ CPPUNIT_ASSERT_EQUAL(0u, static_cast<unsigned int>(errors));
+
+ symbols = getSymbols("-3", errors);
+ CPPUNIT_ASSERT_EQUAL(size_t(3), symbols.size());
+ CPPUNIT_ASSERT_EQUAL(OUString("-"), symbols[0].text);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(3.0, symbols[1].number, 1E-12);
+ CPPUNIT_ASSERT_EQUAL(SbxINTEGER, symbols[1].type);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[2].text);
+ CPPUNIT_ASSERT_EQUAL(0u, static_cast<unsigned int>(errors));
+
+ symbols = getSymbols("-0.0", errors);
+ CPPUNIT_ASSERT_EQUAL(size_t(3), symbols.size());
+ CPPUNIT_ASSERT_EQUAL(OUString("-"), symbols[0].text);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0, symbols[1].number, 1E-12);
+ CPPUNIT_ASSERT_EQUAL(SbxDOUBLE, symbols[1].type);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[2].text);
+ CPPUNIT_ASSERT_EQUAL(0u, static_cast<unsigned int>(errors));
+
+ symbols = getSymbols("12dE3", errors);
+ CPPUNIT_ASSERT_EQUAL(size_t(3), symbols.size());
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(12.0, symbols[0].number, 1E-12);
+ CPPUNIT_ASSERT_EQUAL(SbxDOUBLE, symbols[0].type);
+ CPPUNIT_ASSERT_EQUAL(OUString("dE3"), symbols[1].text);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[2].text);
+ CPPUNIT_ASSERT_EQUAL(1u, static_cast<unsigned int>(errors));
+
+ symbols = getSymbols("12e3", errors);
+ CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(12000.0, symbols[0].number, 1E-12);
+ CPPUNIT_ASSERT_EQUAL(SbxDOUBLE, symbols[0].type);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
+ CPPUNIT_ASSERT_EQUAL(0u, static_cast<unsigned int>(errors));
+
+ symbols = getSymbols("12D+3", errors);
+ CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(12000.0, symbols[0].number, 1E-12);
+ CPPUNIT_ASSERT_EQUAL(SbxDOUBLE, symbols[0].type);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
+ CPPUNIT_ASSERT_EQUAL(0u, static_cast<unsigned int>(errors));
+
+ symbols = getSymbols("12e++3", errors);
+ CPPUNIT_ASSERT_EQUAL(size_t(6), symbols.size());
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(12.0, symbols[0].number, 1E-12);
+ CPPUNIT_ASSERT_EQUAL(SbxDOUBLE, symbols[0].type);
+ CPPUNIT_ASSERT_EQUAL(OUString("e"), symbols[1].text);
+ CPPUNIT_ASSERT_EQUAL(OUString("+"), symbols[2].text);
+ CPPUNIT_ASSERT_EQUAL(OUString("+"), symbols[3].text);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(3.0, symbols[4].number, 1E-12);
+ CPPUNIT_ASSERT_EQUAL(SbxINTEGER, symbols[4].type);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[5].text);
+ CPPUNIT_ASSERT_EQUAL(1u, static_cast<unsigned int>(errors));
+
+ symbols = getSymbols("12e-3", errors);
+ CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(.012, symbols[0].number, 1E-12);
+ CPPUNIT_ASSERT_EQUAL(SbxDOUBLE, symbols[0].type);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
+ CPPUNIT_ASSERT_EQUAL(0u, static_cast<unsigned int>(errors));
+
+ symbols = getSymbols("12e-3+", errors);
+ CPPUNIT_ASSERT_EQUAL(size_t(3), symbols.size());
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(.012, symbols[0].number, 1E-12);
+ CPPUNIT_ASSERT_EQUAL(SbxDOUBLE, symbols[0].type);
+ CPPUNIT_ASSERT_EQUAL(OUString("+"), symbols[1].text);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[2].text);
+ CPPUNIT_ASSERT_EQUAL(0u, static_cast<unsigned int>(errors));
+
+ symbols = getSymbols("1,2,3", errors);
+ CPPUNIT_ASSERT_EQUAL(size_t(6), symbols.size());
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.0, symbols[0].number, 1E-12);
+ CPPUNIT_ASSERT_EQUAL(SbxINTEGER, symbols[0].type);
+ CPPUNIT_ASSERT_EQUAL(OUString(","), symbols[1].text);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(2.0, symbols[2].number, 1E-12);
+ CPPUNIT_ASSERT_EQUAL(SbxINTEGER, symbols[2].type);
+ CPPUNIT_ASSERT_EQUAL(OUString(","), symbols[3].text);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(3.0, symbols[4].number, 1E-12);
+ CPPUNIT_ASSERT_EQUAL(SbxINTEGER, symbols[4].type);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[5].text);
+ CPPUNIT_ASSERT_EQUAL(0u, static_cast<unsigned int>(errors));
+
+ symbols = getSymbols("1."
+ "0000000000000000000000000000000000000000000000000000000000000000000000000"
+ "000000000000000000000000000000000000000000000000000",
+ errors);
+ CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.0, symbols[0].number, 1E-12);
+ CPPUNIT_ASSERT_EQUAL(SbxDOUBLE, symbols[0].type);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
+ // This error is from a "buffer overflow" which is stupid because
+ // the buffer is artificially constrained by the scanner.
+ CPPUNIT_ASSERT_EQUAL(1u, static_cast<unsigned int>(errors)); // HACK
+
+ symbols = getSymbols("10e308", errors);
+ CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
+ CPPUNIT_ASSERT_EQUAL(std::numeric_limits<double>::infinity(), symbols[0].number);
+ CPPUNIT_ASSERT_EQUAL(SbxDOUBLE, symbols[0].type);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
+ CPPUNIT_ASSERT_EQUAL(1u, static_cast<unsigned int>(errors)); // math error, overflow
+
+ // trailing data type character % = SbxINTEGER
+ symbols = getSymbols("1.23%");
+ CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.23, symbols[0].number, 1E-12);
+ CPPUNIT_ASSERT_EQUAL(OUString(), symbols[0].text);
+ CPPUNIT_ASSERT_EQUAL(SbxINTEGER, symbols[0].type);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
+
+ // trailing data type character & = SbxLONG
+ symbols = getSymbols("1.23&");
+ CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.23, symbols[0].number, 1E-12);
+ CPPUNIT_ASSERT_EQUAL(OUString(), symbols[0].text);
+ CPPUNIT_ASSERT_EQUAL(SbxLONG, symbols[0].type);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
+
+ // trailing data type character ! = SbxSINGLE
+ symbols = getSymbols("1.23!");
+ CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.23, symbols[0].number, 1E-12);
+ CPPUNIT_ASSERT_EQUAL(OUString(), symbols[0].text);
+ CPPUNIT_ASSERT_EQUAL(SbxSINGLE, symbols[0].type);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
+
+ // trailing data type character # = SbxDOUBLE
+ symbols = getSymbols("1.23#");
+ CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.23, symbols[0].number, 1E-12);
+ CPPUNIT_ASSERT_EQUAL(OUString(), symbols[0].text);
+ CPPUNIT_ASSERT_EQUAL(SbxDOUBLE, symbols[0].type);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
+
+ // trailing data type character @ = SbxCURRENCY
+ symbols = getSymbols("1.23@");
+ CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.23, symbols[0].number, 1E-12);
+ CPPUNIT_ASSERT_EQUAL(OUString(), symbols[0].text);
+ CPPUNIT_ASSERT_EQUAL(SbxCURRENCY, symbols[0].type);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
+
+ // trailing data type character $ = SbxSTRING
+ symbols = getSymbols("1.23$", errors);
+ CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.23, symbols[0].number, 1E-12);
+ CPPUNIT_ASSERT_EQUAL(OUString(), symbols[0].text);
+ CPPUNIT_ASSERT_EQUAL(SbxSTRING, symbols[0].type);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
+ // ERRCODE_BASIC_SYNTAX
+ CPPUNIT_ASSERT_EQUAL(1u, static_cast<unsigned int>(errors));
+}
+
+void ScannerTest::testDataType()
+{
+ std::vector<Symbol> symbols;
+
+ symbols = getSymbols("asdf%");
+ CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
+ CPPUNIT_ASSERT_EQUAL(SbxINTEGER, symbols[0].type);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
+
+ symbols = getSymbols("asdf&");
+ CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
+ CPPUNIT_ASSERT_EQUAL(SbxLONG, symbols[0].type);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
+
+ symbols = getSymbols("asdf!");
+ CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
+ CPPUNIT_ASSERT_EQUAL(SbxSINGLE, symbols[0].type);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
+
+ symbols = getSymbols("asdf#");
+ CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
+ CPPUNIT_ASSERT_EQUAL(SbxDOUBLE, symbols[0].type);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
+
+ symbols = getSymbols("asdf@");
+ CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
+ CPPUNIT_ASSERT_EQUAL(SbxCURRENCY, symbols[0].type);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
+
+ symbols = getSymbols("asdf$");
+ CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
+ CPPUNIT_ASSERT_EQUAL(SbxSTRING, symbols[0].type);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
+
+ symbols = getSymbols("asdf ");
+ CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
+ CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[0].type);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
+}
+
+void ScannerTest::testHexOctal()
+{
+ sal_Int32 errors;
+ std::vector<Symbol> symbols;
+
+ symbols = getSymbols("&HA");
+ CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(10.0, symbols[0].number, 1E-12);
+ CPPUNIT_ASSERT_EQUAL(OUString(), symbols[0].text);
+ CPPUNIT_ASSERT_EQUAL(SbxINTEGER, symbols[0].type);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
+
+ symbols = getSymbols("&HASDF");
+ CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(2783.0, symbols[0].number, 1E-12);
+ CPPUNIT_ASSERT_EQUAL(OUString(), symbols[0].text);
+ CPPUNIT_ASSERT_EQUAL(SbxINTEGER, symbols[0].type);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
+
+ symbols = getSymbols("&H10");
+ CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(16.0, symbols[0].number, 1E-12);
+ CPPUNIT_ASSERT_EQUAL(OUString(), symbols[0].text);
+ CPPUNIT_ASSERT_EQUAL(SbxINTEGER, symbols[0].type);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
+
+ symbols = getSymbols("&&H&1H1&H1");
+ CPPUNIT_ASSERT_EQUAL(size_t(6), symbols.size());
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0, symbols[0].number, 1E-12);
+ CPPUNIT_ASSERT_EQUAL(OUString("&"), symbols[0].text);
+ CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[0].type);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0, symbols[1].number, 1E-12);
+ CPPUNIT_ASSERT_EQUAL(OUString(), symbols[1].text);
+ CPPUNIT_ASSERT_EQUAL(SbxLONG, symbols[1].type);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.0, symbols[2].number, 1E-12);
+ CPPUNIT_ASSERT_EQUAL(OUString(), symbols[2].text);
+ CPPUNIT_ASSERT_EQUAL(SbxINTEGER, symbols[2].type);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.0, symbols[3].number, 1E-12);
+ CPPUNIT_ASSERT_EQUAL(OUString("H1"), symbols[3].text);
+ CPPUNIT_ASSERT_EQUAL(SbxLONG, symbols[3].type);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.0, symbols[4].number, 1E-12);
+ CPPUNIT_ASSERT_EQUAL(OUString("H1"), symbols[4].text);
+ CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[4].type);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[5].text);
+
+ symbols = getSymbols("&O&O12");
+ CPPUNIT_ASSERT_EQUAL(size_t(3), symbols.size());
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0, symbols[0].number, 1E-12);
+ CPPUNIT_ASSERT_EQUAL(OUString(), symbols[0].text);
+ CPPUNIT_ASSERT_EQUAL(SbxLONG, symbols[0].type);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0, symbols[1].number, 1E-12);
+ CPPUNIT_ASSERT_EQUAL(OUString("O12"), symbols[1].text);
+ CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[1].type);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[2].text);
+
+ symbols = getSymbols("&O10");
+ CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(8.0, symbols[0].number, 1E-12);
+ CPPUNIT_ASSERT_EQUAL(OUString(), symbols[0].text);
+ CPPUNIT_ASSERT_EQUAL(SbxINTEGER, symbols[0].type);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
+
+ symbols = getSymbols("&HO");
+ CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0, symbols[0].number, 1E-12);
+ CPPUNIT_ASSERT_EQUAL(OUString(), symbols[0].text);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
+
+ symbols = getSymbols("&O123000000000000000000000");
+ CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
+ // TODO: this line fails on 64 bit systems!!!
+ // CPPUNIT_ASSERT_EQUAL(symbols[0].number, -1744830464);
+ CPPUNIT_ASSERT_EQUAL(OUString(), symbols[0].text);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
+
+ symbols = getSymbols("&H1.23");
+ CPPUNIT_ASSERT_EQUAL(size_t(3), symbols.size());
+ CPPUNIT_ASSERT_EQUAL(OUString(), symbols[0].text);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(1.0, symbols[0].number, 1E-12);
+ CPPUNIT_ASSERT_EQUAL(SbxINTEGER, symbols[0].type);
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(.23, symbols[1].number, 1E-12);
+ CPPUNIT_ASSERT_EQUAL(OUString(), symbols[1].text);
+ CPPUNIT_ASSERT_EQUAL(SbxDOUBLE, symbols[1].type);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[2].text);
+
+ /* tdf#62323, tdf#62326 - conversion of Hex literals to basic signed Integers */
+
+ // &H0 = 0
+ symbols = getSymbols("&H0");
+ CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0, symbols[0].number, 1E-12);
+ CPPUNIT_ASSERT_EQUAL(OUString(), symbols[0].text);
+ CPPUNIT_ASSERT_EQUAL(SbxINTEGER, symbols[0].type);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
+
+ // &H8000 = -32768
+ symbols = getSymbols("&H8000");
+ CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(SbxMININT, symbols[0].number, 1E-12);
+ CPPUNIT_ASSERT_EQUAL(OUString(), symbols[0].text);
+ CPPUNIT_ASSERT_EQUAL(SbxINTEGER, symbols[0].type);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
+
+ // &H80000000 = -2147483648
+ symbols = getSymbols("&H80000000");
+ CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(SbxMINLNG, symbols[0].number, 1E-12);
+ CPPUNIT_ASSERT_EQUAL(OUString(), symbols[0].text);
+ CPPUNIT_ASSERT_EQUAL(SbxLONG, symbols[0].type);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
+
+ // &HFFFF = -1
+ symbols = getSymbols("&HFFFF");
+ CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(-1.0, symbols[0].number, 1E-12);
+ CPPUNIT_ASSERT_EQUAL(OUString(), symbols[0].text);
+ CPPUNIT_ASSERT_EQUAL(SbxINTEGER, symbols[0].type);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
+
+ // &HFFFFFFFF = -1
+ symbols = getSymbols("&HFFFFFFFF");
+ CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(-1.0, symbols[0].number, 1E-12);
+ CPPUNIT_ASSERT_EQUAL(OUString(), symbols[0].text);
+ CPPUNIT_ASSERT_EQUAL(SbxINTEGER, symbols[0].type);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
+
+ // &H7FFF = 32767
+ symbols = getSymbols("&H7FFF");
+ CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(SbxMAXINT, symbols[0].number, 1E-12);
+ CPPUNIT_ASSERT_EQUAL(OUString(), symbols[0].text);
+ CPPUNIT_ASSERT_EQUAL(SbxINTEGER, symbols[0].type);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
+
+ // &H7FFFFFFF = 2147483647
+ symbols = getSymbols("&H7FFFFFFF");
+ CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(SbxMAXLNG, symbols[0].number, 1E-12);
+ CPPUNIT_ASSERT_EQUAL(OUString(), symbols[0].text);
+ CPPUNIT_ASSERT_EQUAL(SbxLONG, symbols[0].type);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
+
+ /* tdf#130476 - trailing data type characters */
+
+ // % = SbxINTEGER
+ symbols = getSymbols("&H0%");
+ CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0, symbols[0].number, 1E-12);
+ CPPUNIT_ASSERT_EQUAL(OUString(), symbols[0].text);
+ CPPUNIT_ASSERT_EQUAL(SbxINTEGER, symbols[0].type);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
+
+ // & = SbxLONG
+ symbols = getSymbols("&H0&");
+ CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0, symbols[0].number, 1E-12);
+ CPPUNIT_ASSERT_EQUAL(OUString(), symbols[0].text);
+ CPPUNIT_ASSERT_EQUAL(SbxLONG, symbols[0].type);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
+
+ // ! = SbxSINGLE
+ symbols = getSymbols("&H0!");
+ CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0, symbols[0].number, 1E-12);
+ CPPUNIT_ASSERT_EQUAL(OUString(), symbols[0].text);
+ CPPUNIT_ASSERT_EQUAL(SbxSINGLE, symbols[0].type);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
+
+ // # = SbxDOUBLE
+ symbols = getSymbols("&H0#");
+ CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0, symbols[0].number, 1E-12);
+ CPPUNIT_ASSERT_EQUAL(OUString(), symbols[0].text);
+ CPPUNIT_ASSERT_EQUAL(SbxDOUBLE, symbols[0].type);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
+
+ // @ = SbxCURRENCY
+ symbols = getSymbols("&H0@");
+ CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0, symbols[0].number, 1E-12);
+ CPPUNIT_ASSERT_EQUAL(OUString(), symbols[0].text);
+ CPPUNIT_ASSERT_EQUAL(SbxCURRENCY, symbols[0].type);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
+
+ // $ = SbxSTRING
+ symbols = getSymbols("&H0$", errors);
+ CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0, symbols[0].number, 1E-12);
+ CPPUNIT_ASSERT_EQUAL(OUString(), symbols[0].text);
+ CPPUNIT_ASSERT_EQUAL(SbxSTRING, symbols[0].type);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
+ // ERRCODE_BASIC_SYNTAX
+ CPPUNIT_ASSERT_EQUAL(1u, static_cast<unsigned int>(errors));
+
+ // % = SbxINTEGER
+ symbols = getSymbols("&O0%");
+ CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0, symbols[0].number, 1E-12);
+ CPPUNIT_ASSERT_EQUAL(OUString(), symbols[0].text);
+ CPPUNIT_ASSERT_EQUAL(SbxINTEGER, symbols[0].type);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
+
+ // & = SbxLONG
+ symbols = getSymbols("&O0&");
+ CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0, symbols[0].number, 1E-12);
+ CPPUNIT_ASSERT_EQUAL(OUString(), symbols[0].text);
+ CPPUNIT_ASSERT_EQUAL(SbxLONG, symbols[0].type);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
+
+ // ! = SbxSINGLE
+ symbols = getSymbols("&O0!");
+ CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0, symbols[0].number, 1E-12);
+ CPPUNIT_ASSERT_EQUAL(OUString(), symbols[0].text);
+ CPPUNIT_ASSERT_EQUAL(SbxSINGLE, symbols[0].type);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
+
+ // # = SbxDOUBLE
+ symbols = getSymbols("&O0#");
+ CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0, symbols[0].number, 1E-12);
+ CPPUNIT_ASSERT_EQUAL(OUString(), symbols[0].text);
+ CPPUNIT_ASSERT_EQUAL(SbxDOUBLE, symbols[0].type);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
+
+ // @ = SbxCURRENCY
+ symbols = getSymbols("&O0@");
+ CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0, symbols[0].number, 1E-12);
+ CPPUNIT_ASSERT_EQUAL(OUString(), symbols[0].text);
+ CPPUNIT_ASSERT_EQUAL(SbxCURRENCY, symbols[0].type);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
+
+ // $ = SbxSTRING
+ symbols = getSymbols("&O0$", errors);
+ CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0, symbols[0].number, 1E-12);
+ CPPUNIT_ASSERT_EQUAL(OUString(), symbols[0].text);
+ CPPUNIT_ASSERT_EQUAL(SbxSTRING, symbols[0].type);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
+ // ERRCODE_BASIC_SYNTAX
+ CPPUNIT_ASSERT_EQUAL(1u, static_cast<unsigned int>(errors));
+
+ // maximum for Hex % = SbxINTEGER
+ symbols = getSymbols("&HFFFF%");
+ CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(-1.0, symbols[0].number, 1E-12);
+ CPPUNIT_ASSERT_EQUAL(OUString(), symbols[0].text);
+ CPPUNIT_ASSERT_EQUAL(SbxINTEGER, symbols[0].type);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
+
+ // overflow for Hex % = SbxINTEGER
+ symbols = getSymbols("&H10000%", errors);
+ CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0, symbols[0].number, 1E-12);
+ CPPUNIT_ASSERT_EQUAL(OUString(), symbols[0].text);
+ CPPUNIT_ASSERT_EQUAL(SbxINTEGER, symbols[0].type);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
+ // ERRCODE_BASIC_MATH_OVERFLOW
+ CPPUNIT_ASSERT_EQUAL(1u, static_cast<unsigned int>(errors));
+
+ // maximum for Octal % = SbxINTEGER
+ symbols = getSymbols("&O177777%");
+ CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(-1.0, symbols[0].number, 1E-12);
+ CPPUNIT_ASSERT_EQUAL(OUString(), symbols[0].text);
+ CPPUNIT_ASSERT_EQUAL(SbxINTEGER, symbols[0].type);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
+
+ // overflow for Octal % = SbxINTEGER
+ symbols = getSymbols("&O200000%", errors);
+ CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0, symbols[0].number, 1E-12);
+ CPPUNIT_ASSERT_EQUAL(OUString(), symbols[0].text);
+ CPPUNIT_ASSERT_EQUAL(SbxINTEGER, symbols[0].type);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
+ // ERRCODE_BASIC_MATH_OVERFLOW
+ CPPUNIT_ASSERT_EQUAL(1u, static_cast<unsigned int>(errors));
+
+ // maximum for Hex & = SbxLONG
+ symbols = getSymbols("&H7FFFFFFF&");
+ CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(2147483647.0, symbols[0].number, 1E-12);
+ CPPUNIT_ASSERT_EQUAL(OUString(), symbols[0].text);
+ CPPUNIT_ASSERT_EQUAL(SbxLONG, symbols[0].type);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
+
+ // minimum for Hex & = SbxLONG
+ symbols = getSymbols("&H80000000&");
+ CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(-2147483648.0, symbols[0].number, 1E-12);
+ CPPUNIT_ASSERT_EQUAL(OUString(), symbols[0].text);
+ CPPUNIT_ASSERT_EQUAL(SbxLONG, symbols[0].type);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
+
+ // overflow for Hex & = SbxLONG
+ symbols = getSymbols("&H100000000&", errors);
+ CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0, symbols[0].number, 1E-12);
+ CPPUNIT_ASSERT_EQUAL(OUString(), symbols[0].text);
+ CPPUNIT_ASSERT_EQUAL(SbxLONG, symbols[0].type);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
+ // ERRCODE_BASIC_MATH_OVERFLOW
+ CPPUNIT_ASSERT_EQUAL(1u, static_cast<unsigned int>(errors));
+
+ // maximum for Octal & = SbxLONG
+ symbols = getSymbols("&O17777777777&");
+ CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(2147483647.0, symbols[0].number, 1E-12);
+ CPPUNIT_ASSERT_EQUAL(OUString(), symbols[0].text);
+ CPPUNIT_ASSERT_EQUAL(SbxLONG, symbols[0].type);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
+
+ // minimum for Octal & = SbxLONG
+ symbols = getSymbols("&O20000000000&", errors);
+ CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(-2147483648.0, symbols[0].number, 1E-12);
+ CPPUNIT_ASSERT_EQUAL(OUString(), symbols[0].text);
+ CPPUNIT_ASSERT_EQUAL(SbxLONG, symbols[0].type);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
+
+ // overflow for Octal & = SbxLONG
+ symbols = getSymbols("&O40000000000&", errors);
+ CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(0, symbols[0].number, 1E-12);
+ CPPUNIT_ASSERT_EQUAL(OUString(), symbols[0].text);
+ CPPUNIT_ASSERT_EQUAL(SbxLONG, symbols[0].type);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
+ // ERRCODE_BASIC_MATH_OVERFLOW
+ CPPUNIT_ASSERT_EQUAL(1u, static_cast<unsigned int>(errors));
+
+ /* test for leading zeros */
+
+ // &H0000000FFFF = 65535
+ symbols = getSymbols("&H0000000FFFF");
+ CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(-1.0, symbols[0].number, 1E-12);
+ CPPUNIT_ASSERT_EQUAL(OUString(), symbols[0].text);
+ CPPUNIT_ASSERT_EQUAL(SbxINTEGER, symbols[0].type);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
+
+ // &O00000123 = 83
+ symbols = getSymbols("&O00000123");
+ CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(83.0, symbols[0].number, 1E-12);
+ CPPUNIT_ASSERT_EQUAL(OUString(), symbols[0].text);
+ CPPUNIT_ASSERT_EQUAL(SbxINTEGER, symbols[0].type);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
+
+ symbols = getSymbols("&O7777777");
+ CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
+ CPPUNIT_ASSERT_DOUBLES_EQUAL(2097151.0, symbols[0].number, 1E-12);
+ CPPUNIT_ASSERT_EQUAL(OUString(), symbols[0].text);
+ CPPUNIT_ASSERT_EQUAL(SbxLONG, symbols[0].type);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
+}
+
+void ScannerTest::testTdf103104()
+{
+ std::vector<Symbol> symbols;
+
+ symbols = getSymbols("asdf _\n asdf");
+ CPPUNIT_ASSERT_EQUAL(size_t(3), symbols.size());
+ CPPUNIT_ASSERT_EQUAL(asdf, symbols[0].text);
+ CPPUNIT_ASSERT_EQUAL(asdf, symbols[1].text);
+ CPPUNIT_ASSERT(symbols[1].ws);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[2].text);
+
+ symbols = getSymbols("asdf. _\n asdf");
+ CPPUNIT_ASSERT_EQUAL(size_t(4), symbols.size());
+ CPPUNIT_ASSERT_EQUAL(asdf, symbols[0].text);
+ CPPUNIT_ASSERT_EQUAL(dot, symbols[1].text);
+ CPPUNIT_ASSERT(!symbols[1].ws);
+ CPPUNIT_ASSERT_EQUAL(asdf, symbols[2].text);
+ CPPUNIT_ASSERT(symbols[2].ws);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[3].text);
+
+ symbols = getSymbols("asdf _\n .asdf");
+ CPPUNIT_ASSERT_EQUAL(size_t(4), symbols.size());
+ CPPUNIT_ASSERT_EQUAL(asdf, symbols[0].text);
+ CPPUNIT_ASSERT_EQUAL(dot, symbols[1].text);
+ CPPUNIT_ASSERT(!symbols[1].ws);
+ CPPUNIT_ASSERT_EQUAL(asdf, symbols[2].text);
+ CPPUNIT_ASSERT(!symbols[2].ws);
+ CPPUNIT_ASSERT_EQUAL(cr, symbols[3].text);
+}
+
+void ScannerTest::testTdf136032()
+{
+ std::vector<Symbol> symbols;
+ sal_Int32 errors;
+
+ // tdf#136032 - abort scan of a string beginning with a hashtag,
+ // if a comma/whitespace is found. Otherwise, the compiler raises a syntax error.
+ symbols = getSymbols("Print #i,\"A#B\"", errors);
+ CPPUNIT_ASSERT_EQUAL(size_t(5), symbols.size());
+ CPPUNIT_ASSERT_EQUAL(0u, static_cast<unsigned int>(errors));
+ symbols = getSymbols("Print #i, \"A#B\"", errors);
+ CPPUNIT_ASSERT_EQUAL(size_t(5), symbols.size());
+ CPPUNIT_ASSERT_EQUAL(0u, static_cast<unsigned int>(errors));
+}
+
+// Put the test suite in the registry
+CPPUNIT_TEST_SUITE_REGISTRATION(ScannerTest);
+} // namespace
+CPPUNIT_PLUGIN_IMPLEMENT();
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basic/qa/cppunit/test_vba.cxx b/basic/qa/cppunit/test_vba.cxx
new file mode 100644
index 0000000000..8a15ba7234
--- /dev/null
+++ b/basic/qa/cppunit/test_vba.cxx
@@ -0,0 +1,267 @@
+/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
+/*
+ * 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/.
+ */
+#include "basictest.hxx"
+#include <unotools/syslocaleoptions.hxx>
+
+#ifdef _WIN32
+#include <string.h>
+#include <comphelper/processfactory.hxx>
+#include <o3tl/char16_t2wchar_t.hxx>
+
+#include <systools/win32/odbccp32.hxx>
+#endif
+
+using namespace ::com::sun::star;
+
+namespace
+{
+ class VBATest : public test::BootstrapFixture
+ {
+ public:
+ VBATest() : BootstrapFixture(true, false) {}
+ void testMiscVBAFunctions();
+ void testMiscOLEStuff();
+ // Adds code needed to register the test suite
+ CPPUNIT_TEST_SUITE(VBATest);
+
+ // Declares the method as a test to call
+ CPPUNIT_TEST(testMiscVBAFunctions);
+ CPPUNIT_TEST(testMiscOLEStuff);
+
+ // End of test suite definition
+ CPPUNIT_TEST_SUITE_END();
+
+ };
+
+void VBATest::testMiscVBAFunctions()
+{
+ const char* macroSource[] = {
+ "bytearraystring.vb",
+#ifdef _WIN32
+ "cdec.vb", // currently CDec is implemented only on Windows
+#endif
+ "constants.vb",
+// datevalue test seems to depend on both locale and language
+// settings, should try and rewrite the test to deal with that
+// for some reason tinderboxes don't seem to complain leaving enabled
+// for the moment
+ "datevalue.vb",
+ "partition.vb",
+ "strconv.vb",
+ "dateserial.vb",
+ "format.vb",
+ "replace.vb",
+ "stringplusdouble.vb",
+ "chr.vb",
+ "chrw.vb",
+ "abs.vb",
+ "array.vb",
+ "asc.vb",
+ "atn.vb",
+ "booltypename.vb",
+ "cbool.vb",
+ "cdate.vb",
+ "cdbl.vb",
+ "choose.vb",
+ "cos.vb",
+ "cint.vb",
+ "clng.vb",
+ "collection.vb",
+ "csng.vb",
+ "cstr.vb",
+ "cvdate.vb",
+ "cverr.vb",
+ "dateadd.vb",
+ "datediff.vb",
+ "datepart.vb",
+ "day.vb",
+ "enum.vb",
+ "error.vb",
+ "error_message.vb",
+ "Err.Raise.vb",
+ "exp.vb",
+ "fix.vb",
+ "hex.vb",
+ "hour.vb",
+ "formatnumber.vb",
+ "formatpercent.vb",
+ "iif.vb",
+ "instr.vb",
+ "instrrev.vb",
+ "int.vb",
+ "iserror.vb",
+ "ismissing.vb",
+ "isnull.vb",
+ "isobject.vb",
+ "join.vb",
+ "lbound.vb",
+ "isarray.vb",
+ "isdate.vb",
+ "isempty.vb",
+ "isnumeric.vb",
+ "lcase.vb",
+ "left.vb",
+ "len.vb",
+ "log.vb",
+ "ltrim.vb",
+ "mid.vb",
+ "minute.vb",
+ "month.vb",
+ "monthname.vb",
+ "like.vb",
+ "oct.vb",
+ "optional_paramters.vb",
+ "qbcolor.vb",
+ "rgb.vb",
+ "rtrim.vb",
+ "right.vb",
+ "second.vb",
+ "sgn.vb",
+ "sin.vb",
+ "space.vb",
+ "split.vb",
+ "sqr.vb",
+ "str.vb",
+ "strcomp.vb",
+ "string.vb",
+ "strreverse.vb",
+ "switch.vb",
+ "tdf147089_idiv.vb",
+ "tdf147529_optional_parameters_msgbox.vb",
+ "tdf148358_non_ascii_names.vb",
+ "timeserial.vb",
+ "timevalue.vb",
+ "trim.vb",
+ "typename.vb",
+ "ubound.vb",
+ "ucase.vb",
+ "val.vb",
+ "vartype.vb",
+ "weekday.vb",
+ "weekdayname.vb",
+ "year.vb",
+#ifndef _WIN32 // missing 64bit Currency marshalling.
+ "win32compat.vb", // windows compatibility hooks.
+#endif
+ "win32compatb.vb" // same methods, different signatures.
+ };
+ OUString sMacroPathURL = m_directories.getURLFromSrc(u"/basic/qa/vba_tests/");
+ OUString sMacroUtilsURL = m_directories.getURLFromSrc(u"/basic/qa/cppunit/_test_asserts.vb");
+ // Some test data expects the uk locale
+ LanguageTag aLocale(LANGUAGE_ENGLISH_UK);
+ SvtSysLocaleOptions aLocalOptions;
+ aLocalOptions.SetLocaleConfigString( aLocale.getBcp47() );
+
+ for ( size_t i=0; i<std::size( macroSource ); ++i )
+ {
+ OUString sMacroURL = sMacroPathURL
+ + OUString::createFromAscii( macroSource[ i ] );
+
+ MacroSnippet myMacro;
+ myMacro.LoadSourceFromFile("TestUtil", sMacroUtilsURL);
+ myMacro.LoadSourceFromFile("TestModule", sMacroURL);
+ SbxVariableRef pReturn = myMacro.Run();
+ CPPUNIT_ASSERT_MESSAGE("No return variable huh?", pReturn.is());
+ fprintf(stderr, "macro result for %s\n", macroSource[i]);
+ fprintf(stderr, "macro returned:\n%s\n",
+ OUStringToOString(pReturn->GetOUString(), RTL_TEXTENCODING_UTF8).getStr());
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Result not as expected", OUString("OK"),
+ pReturn->GetOUString());
+ }
+}
+
+void VBATest::testMiscOLEStuff()
+{
+// Not much point even trying to run except on Windows.
+// (Without Excel doesn't really do anything anyway,
+// see "so skip test" below.)
+
+// Since some time, on a properly updated Windows 10, this works
+// only with a 64-bit LibreOffice
+
+#if defined(_WIN64)
+ // test if we have the necessary runtime environment
+ // to run the OLE tests.
+ uno::Reference< lang::XMultiServiceFactory > xOLEFactory;
+ uno::Reference< uno::XComponentContext > xContext(
+ comphelper::getProcessComponentContext() );
+ if( xContext.is() )
+ {
+ uno::Reference<lang::XMultiComponentFactory> xSMgr = xContext->getServiceManager();
+ xOLEFactory.set( xSMgr->createInstanceWithContext( "com.sun.star.bridge.OleObjectFactory", xContext ),
+ uno::UNO_QUERY );
+ }
+ bool bOk = false;
+ if( xOLEFactory.is() )
+ {
+ uno::Reference< uno::XInterface > xADODB = xOLEFactory->createInstance( "ADODB.Connection" );
+ bOk = xADODB.is();
+ }
+ if ( !bOk )
+ return; // can't do anything, skip test
+
+ const int nBufSize = 1024 * 4;
+ wchar_t sBuf[nBufSize];
+ if (!sal::systools::odbccp32().SQLGetInstalledDrivers(sBuf, nBufSize))
+ return;
+
+ const wchar_t *pODBCDriverName = sBuf;
+ bool bFound = false;
+ for (; wcslen( pODBCDriverName ) != 0; pODBCDriverName += wcslen( pODBCDriverName ) + 1 ) {
+ if( wcscmp( pODBCDriverName, L"Microsoft Excel Driver (*.xls)" ) == 0 ||
+ wcscmp( pODBCDriverName, L"Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)" ) == 0 ) {
+ bFound = true;
+ break;
+ }
+ }
+ if ( !bFound )
+ return; // can't find ODBC driver needed test, so skip test
+
+ const char* macroSource[] = {
+ "ole_ObjAssignNoDflt.vb",
+ "ole_ObjAssignToNothing.vb",
+ };
+
+ OUString sMacroPathURL = m_directories.getURLFromSrc(u"/basic/qa/vba_tests/");
+
+ // path to test document
+ OUString sPath = m_directories.getPathFromSrc(u"/basic/qa/vba_tests/data/ADODBdata.xls");
+ sPath = sPath.replaceAll( "/", "\\" );
+
+ uno::Sequence< uno::Any > aArgs
+ {
+ uno::Any(sPath),
+ uno::Any(OUString(o3tl::toU(pODBCDriverName)))
+ };
+
+ for ( sal_uInt32 i=0; i<std::size( macroSource ); ++i )
+ {
+ OUString sMacroURL = sMacroPathURL
+ + OUString::createFromAscii( macroSource[ i ] );
+ MacroSnippet myMacro;
+ myMacro.LoadSourceFromFile("TestModule", sMacroURL);
+ SbxVariableRef pReturn = myMacro.Run( aArgs );
+ CPPUNIT_ASSERT_MESSAGE("No return variable huh?", pReturn.is());
+ fprintf(stderr, "macro result for %s\n", macroSource[i]);
+ fprintf(stderr, "macro returned:\n%s\n",
+ OUStringToOString(pReturn->GetOUString(), RTL_TEXTENCODING_UTF8).getStr());
+ CPPUNIT_ASSERT_EQUAL_MESSAGE("Result not as expected", OUString("OK"),
+ pReturn->GetOUString());
+ }
+#else
+ // Avoid "this method is empty and should be removed" warning
+ (void) 42;
+#endif
+}
+
+ // Put the test suite in the registry
+ CPPUNIT_TEST_SUITE_REGISTRATION(VBATest);
+}
+
+/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
diff --git a/basic/qa/vba_tests/Err.Raise.vb b/basic/qa/vba_tests/Err.Raise.vb
new file mode 100644
index 0000000000..d7714facb3
--- /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 0000000000..c6f1b8fff9
--- /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 0000000000..608974462b
--- /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 0000000000..8da24e349e
--- /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 0000000000..826165e296
--- /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 0000000000..202c2370e7
--- /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 0000000000..6218716936
--- /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 0000000000..54334a23eb
--- /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 0000000000..227c29d0f7
--- /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 0000000000..8a7d09cd5a
--- /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 0000000000..0436256835
--- /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 0000000000..b258af984d
--- /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 0000000000..f9bc7ea12a
--- /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 0000000000..47bd28d7e1
--- /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 0000000000..42e41e5356
--- /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 0000000000..ae9421686d
--- /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 0000000000..774f3c4c79
--- /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 0000000000..c31444889f
--- /dev/null
+++ b/basic/qa/vba_tests/constants.vb
@@ -0,0 +1,51 @@
+'
+' 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#153543 - check for vba shell constants
+ ' See https://learn.microsoft.com/en-us/office/vba/language/reference/user-interface-help/shell-constants
+ TestUtil.AssertEqual(vbHide, 0, "vbHide")
+ TestUtil.AssertEqual(vbNormalFocus, 1, "vbNormalFocus")
+ TestUtil.AssertEqual(vbMinimizedFocus, 2, "vbMinimizedFocus")
+ TestUtil.AssertEqual(vbMaximizedFocus, 3, "vbMaximizedFocus")
+ TestUtil.AssertEqual(vbNormalNoFocus, 4, "vbNormalNoFocus")
+ TestUtil.AssertEqual(vbMinimizedNoFocus, 6, "vbMinimizedNoFocus")
+
+ ' 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 0000000000..2dc88df31e
--- /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 0000000000..3e18d0282b
--- /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 0000000000..5eb43738f1
--- /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 0000000000..0b71d7fe99
--- /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 0000000000..3a314de761
--- /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 0000000000..655b38a902
--- /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 0000000000..8b0e6312e9
--- /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 0000000000..01b798a33a
--- /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 0000000000..28989c27ab
--- /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 0000000000..8e961aefbb
--- /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 0000000000..e433eba461
--- /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 0000000000..525ad455c3
--- /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 0000000000..72f0c4fb8f
--- /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 0000000000..9b10ff8ffe
--- /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 0000000000..7f96057359
--- /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 0000000000..7c2a7a861a
--- /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 0000000000..9f2af40088
--- /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 0000000000..4e62e87e49
--- /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+000"), "1.09838E+000", "Format(1.09837555, ""#.#####E+000"")")
+ 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 0000000000..6ddcf95942
--- /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 0000000000..0a8c551c27
--- /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 0000000000..6c0cd145b6
--- /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 0000000000..860096ccad
--- /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 0000000000..8db7e48de0
--- /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 0000000000..cda19712b2
--- /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 0000000000..3849d60c5f
--- /dev/null
+++ b/basic/qa/vba_tests/instrrev.vb
@@ -0,0 +1,50 @@
+'
+' 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)")
+
+ ' tdf#141474 keyword names need to match that of VBA
+ Const vbBinaryCompare = 0, vbTextCompare = 1
+ TestUtil.AssertEqual(InStrRev(stringMatch:="Star", stringCheck:="LibreOffice"), 0, "InStrRev(stringMatch:=""Star"", stringCheck:=""LibreOffice"")")
+ TestUtil.AssertEqual(InStrRev(Start:=-1, stringMatch:="Libre", stringCheck:="LibreOfficeLibre"), 12, "InStrRev(Start:=-1, stringMatch:=""Libre"", stringCheck:=""LibreOfficeLibre"")")
+ TestUtil.AssertEqual(InStrRev(Start:=12, stringMatch:="Libre", stringCheck:="LibreOfficeLibre"), 1, "InStrRev(Start:=12, stringMatch:=""Libre"", stringCheck:=""LibreOfficeLibre"")")
+ TestUtil.AssertEqual(InStrRev(Compare:=vbBinaryCompare, Start:=12, stringMatch:="Libre", stringCheck:="LibreOfficeLibre"), 1, "InStrRev(Compare:=vbBinaryCompare, Start:=12, stringMatch:=""Libre"", stringCheck:=""LibreOfficeLibre"")")
+
+ 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 0000000000..632999d345
--- /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 0000000000..b028d85244
--- /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 0000000000..5d66bf7d84
--- /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 0000000000..22a71804a6
--- /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 0000000000..0250933caa
--- /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 0000000000..febe0339f6
--- /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 0000000000..7550238895
--- /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 0000000000..ead7e83e14
--- /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 0000000000..beec43f790
--- /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 0000000000..8d6dd46dcd
--- /dev/null
+++ b/basic/qa/vba_tests/join.vb
@@ -0,0 +1,38 @@
+'
+' 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, """")")
+
+ ' tdf#141474 keyword names need to match that of VBA
+ Dim aList(0 to 7) As String : aList = Array("(", "Star", "|", "Open", "|", "Libre", ")", "Office")
+ TestUtil.AssertEqual(Join(sourceArray:=aList), "( Star | Open | Libre ) Office", "Join() with 1 keyword name")
+ TestUtil.AssertEqual(Join(delimiter:="", sourceArray:=aList), "(Star|Open|Libre)Office", "Join() with 2 keyword names")
+
+ 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 0000000000..5e40d709ee
--- /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 0000000000..0553f338b1
--- /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 0000000000..21ce3cefc6
--- /dev/null
+++ b/basic/qa/vba_tests/left.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_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)")
+
+ ' tdf#141474 keyword names need to match that of VBA
+ TestUtil.AssertEqual(Left(Length:=4, String:="sometext"), "some", "Left(Length:=4, String:=""sometext"")")
+
+ 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 0000000000..f91ebd04c9
--- /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/like.vb b/basic/qa/vba_tests/like.vb
new file mode 100644
index 0000000000..c3be1e081b
--- /dev/null
+++ b/basic/qa/vba_tests/like.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_testLike
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testLike()
+ On Error GoTo errorHandler
+ ' Negation test
+ TestUtil.AssertEqual("!" Like "[.!?]", True, "Negation1")
+ TestUtil.AssertEqual("a" Like "[!abc]", False, "Negation2")
+ TestUtil.AssertEqual("!" Like "[!!?]", False, "Negation3")
+ TestUtil.AssertEqual("^" Like "[.!?]", False, "Negation4")
+ TestUtil.AssertEqual("^" Like "[.^?]", True, "Negation5")
+ ' Like test from microsoft vba
+ TestUtil.AssertEqual("aBBBa" Like "a*a", True, "Like1")
+ TestUtil.AssertEqual("F" Like "[A-Z]", True, "Like2")
+ TestUtil.AssertEqual("F" Like "[!A-Z]", False, "Like3")
+ TestUtil.AssertEqual("a2a" Like "a#a", True, "Like4")
+ TestUtil.AssertEqual("aM5b" Like "a[L-P]#[!c-e]", True, "Like5")
+ TestUtil.AssertEqual("BAT123khg" Like "B?T*", True, "Like6")
+ TestUtil.AssertEqual("CAT123khg" Like "B?T*", False, "Like7")
+ TestUtil.AssertEqual("ab" Like "a*b", True, "Like8")
+ TestUtil.AssertEqual("a*b" Like "a [*]b", False, "Like9")
+ TestUtil.AssertEqual("axxxxxb" Like "a [*]b", False, "Like10")
+ TestUtil.AssertEqual("a [xyz" Like "a [[]*", True, "Like11")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_testLike", 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 0000000000..431bea642d
--- /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 0000000000..c265e68461
--- /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 0000000000..ebd326109f
--- /dev/null
+++ b/basic/qa/vba_tests/mid.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_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)")
+
+ ' tdf#141474 keyword names need to match that of VBA
+ TestUtil.AssertEqual(Mid(start:=6, string:="LibreOffice" ), "Office", "Mid() with 2 keyword names" )
+ TestUtil.AssertEqual(Mid(length:=5, start:=1, string:="LibreOffice" ), "Libre", "Mid() with 3 keyword names" )
+
+ 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 0000000000..70deb12520
--- /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 0000000000..05222071f4
--- /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 0000000000..6c01de5116
--- /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 0000000000..d733bb763d
--- /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 0000000000..9817aa7437
--- /dev/null
+++ b/basic/qa/vba_tests/ole_ObjAssignNoDflt.vb
@@ -0,0 +1,38 @@
+'
+' 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(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 0000000000..9a0a557cdf
--- /dev/null
+++ b/basic/qa/vba_tests/ole_ObjAssignToNothing.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
+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 0000000000..d47854d2fb
--- /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 0000000000..a31b7a6c83
--- /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 0000000000..64e213ad1a
--- /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 0000000000..76f38cdb8d
--- /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 0000000000..9355b28da9
--- /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 0000000000..ca1fde9c17
--- /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 0000000000..448d19d064
--- /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 0000000000..742fc43c3b
--- /dev/null
+++ b/basic/qa/vba_tests/right.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_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)")
+
+ ' tdf#141474 keyword names need to match that of VBA
+ TestUtil.AssertEqual(Right(Length:=4, String:="sometext"), "text", "Right(Length:=4, String:=""sometext"")")
+
+ 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 0000000000..aaa078925d
--- /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 0000000000..1daf40e564
--- /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 0000000000..b192ef5d41
--- /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 0000000000..e0475cb7f6
--- /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 0000000000..0f416a05c3
--- /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 0000000000..70d09c3ea7
--- /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 0000000000..13f4d66a95
--- /dev/null
+++ b/basic/qa/vba_tests/split.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_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))")
+
+ ' tdf#141474 keyword names need to match that of VBA
+ TestUtil.AssertEqual(Split(expression:="LibreOffice StarOffice")(1), "StarOffice", "Split with 1 keyword name" )
+ Dim txt As String : txt = "Libre_Office_Star_Office"
+ TestUtil.AssertEqual(Split(delimiter:="_", expression:=txt)(2), "Star", "Split with 2 keyword names" )
+ TestUtil.AssertEqual(Split(limit:=3, delimiter:="_", expression:=txt)(2), "Star_Office", "Split with 3 keyword names" )
+
+ 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 0000000000..f7df49148b
--- /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 0000000000..1a336e9e37
--- /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 0000000000..0c77577c19
--- /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 0000000000..9b7dfaf218
--- /dev/null
+++ b/basic/qa/vba_tests/strconv.vb
@@ -0,0 +1,64 @@
+'
+' 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)")
+ TestUtil.AssertEqual(StrConv("ABCDEVB¥ì¥¹¥­¥å©", vbWide + vbLowerCase), "abcdevb¥ì¥¹¥­¥å©", "StrConv(""ABCDEVB¥ì¥¹¥­¥å©"", vbWide + vbLowerCase)")
+
+ ' 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)")
+ TestUtil.AssertEqual(StrConv("ABCD@$%23'?EG", vbNarrow + vbLowerCase), "abcd@$%23'?eg", "StrConv(""ABCD@$%23'?EG"", vbNarrow + vbLowerCase)")
+
+ ' Converts Hiragana characters in string to Katakana characters
+ TestUtil.AssertEqual(StrConv("かたかな", vbKatakana), "カタカナ", "StrConv(""かたかな"", vbKatakana)")
+ TestUtil.AssertEqual(StrConv("かたかな abc", vbKatakana + vbUpperCase + vbWide), "カタカナ ABC", "StrConv(""かたかな abc"", vbKatakana + vbUpperCase + vbWide)")
+
+ ' Converts Katakana characters in string to Hiragana characters
+ TestUtil.AssertEqual(StrConv("カタカナ", vbHiragana), "かたかな", "StrConv(""カタカナ"", vbHiragana)")
+ TestUtil.AssertEqual(StrConv("カタカナ ABC", vbLowerCase + vbNarrow), "カタカナ abc", "StrConv(""カタカナ ABC"", vbLowerCase + vbNarrow)")
+
+ Dim x() As Byte
+ Const Cp1252TestString = "ÉϺ£ÊÐABC"
+
+ x = StrConv(Cp1252TestString, vbFromUnicode, &h0409)' CP-1252 encoding associated with en-US locale
+ 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, &h0409), Cp1252TestString, "StrConv(x, vbUnicode, &h0409)")
+
+ x = StrConv(Cp1252TestString, vbUnicode, &h0409)
+ TestUtil.AssertEqual(UBound(x), 35, "UBound(x)")
+ TestUtil.AssertEqual(StrConv(x, vbFromUnicode, &h0409), Cp1252TestString, "StrConv(x, vbFromUnicode, &h0409)")
+
+ 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 0000000000..239141d817
--- /dev/null
+++ b/basic/qa/vba_tests/string.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_String
+ doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_String()
+ 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"")")
+
+ TestUtil.AssertEqual(String(5.8, "à"), "àààààà", "String(5.8, ""à"")")
+ TestUtil.AssertEqual(String(Number:=3.45, Character:="test"), "ttt", "String(Number:=3.45, Character:=""test"")")
+ TestUtil.AssertEqual(String(Character:="☺😎", Number:=7), "☺☺☺☺☺☺☺", "String(Character:=""☺😎"", Number:=7)")
+
+ Exit Sub
+errorHandler:
+ TestUtil.ReportErrorHandler("verify_String", 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 0000000000..7c5045eadd
--- /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 0000000000..ad78bdf8d4
--- /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 0000000000..45b1bc05ac
--- /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 0000000000..515f1e00cf
--- /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 100644
index 0000000000..e599f46eed
--- /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 0000000000..95e7105407
--- /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 0000000000..be2c9d2bc8
--- /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 0000000000..e53d55b272
--- /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 0000000000..d5f3a32ac9
--- /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 0000000000..b21d34cc4e
--- /dev/null
+++ b/basic/qa/vba_tests/typename.vb
@@ -0,0 +1,71 @@
+'
+' 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(varname:=s1), "String", "TypeName(varname:=s1")
+
+ 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 0000000000..5879406996
--- /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 0000000000..7f898ea7ef
--- /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 0000000000..473f161230
--- /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 0000000000..066255b2b7
--- /dev/null
+++ b/basic/qa/vba_tests/vartype.vb
@@ -0,0 +1,65 @@
+'
+' 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(varname:=TestStr), vbString, "VarType(varname:=TestStr)")
+
+ 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 0000000000..2ff4fbe470
--- /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 0000000000..bddbdb7732
--- /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 0000000000..020c1245ba
--- /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 0000000000..f729725ea5
--- /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 0000000000..3ba0df62d5
--- /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