[Libreoffice-commits] core.git: basic/qa include/xmloff schema/libreoffice sc/qa svl/qa svl/source xmloff/source

2023-11-01 Thread Laurent Balland (via logerrit)
 basic/qa/vba_tests/format.vb|2 
 include/xmloff/xmlnumfe.hxx |2 
 include/xmloff/xmltoken.hxx |1 
 sc/qa/unit/data/ods/tdf156449-Blank-In-Exponent.ods |binary
 sc/qa/unit/subsequent_export_test4.cxx  |   31 
 schema/libreoffice/OpenDocument-v1.3+libreoffice-schema.rng |9 +++
 svl/qa/unit/svl.cxx |8 +++
 svl/source/numbers/zformat.cxx  |8 +--
 xmloff/source/core/xmltoken.cxx |1 
 xmloff/source/style/xmlnumfe.cxx|   20 ++-
 xmloff/source/style/xmlnumfi.cxx|   16 +-
 xmloff/source/token/tokens.txt  |1 
 12 files changed, 89 insertions(+), 10 deletions(-)

New commits:
commit 443027cd71aef3eb45bbf3631869ea63457f2c81
Author: Laurent Balland 
AuthorDate: Wed Jul 26 17:58:00 2023 +0200
Commit: Laurent Balland 
CommitDate: Wed Nov 1 11:43:54 2023 +0100

tdf#156449 Preserve '0' or '?' in exponent

Exponent in scientific number may use '?' as blank like in format "0.00E+?0"
This change:
- adds interpreatation of '0' and '?' in exponent
- adds "blank-exponent-digits" attribute to scientific number for import
  and export to ODF
- prevents using exponent with only '?'. There must be at least one '0'
  in exponent
- adds QA test of such format and test import/export/import to ODF and OOXML
- corrects one basic test

Change-Id: If52edc632a161f842270bb2fd77af535e2b978d4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/154986
Tested-by: Jenkins
Reviewed-by: Laurent Balland 

diff --git a/basic/qa/vba_tests/format.vb b/basic/qa/vba_tests/format.vb
index 0e997ca824db..4e62e87e498e 100644
--- a/basic/qa/vba_tests/format.vb
+++ b/basic/qa/vba_tests/format.vb
@@ -135,7 +135,7 @@ Sub Custom_Number_Format_Sample()
 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(100, "#,###"),   "1,000,000",
"Format(100, ""#,###"")")
-TestUtil.AssertEqual(Format(1.09837555, "#.#E+###"), "1.09838E+000", 
"Format(1.09837555, ""#.#E+###"")")
+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#"")")
diff --git a/include/xmloff/xmlnumfe.hxx b/include/xmloff/xmlnumfe.hxx
index 8421c5f7e323..d96f40c53a04 100644
--- a/include/xmloff/xmlnumfe.hxx
+++ b/include/xmloff/xmlnumfe.hxx
@@ -71,7 +71,7 @@ private:
 bool bGrouping, sal_Int32 
nTrailingThousands,
 const SvXMLEmbeddedTextEntryArr& 
rEmbeddedEntries );
 SAL_DLLPRIVATE void WriteScientificElement_Impl( sal_Int32 nDecimals, 
sal_Int32 nMinDecimals, sal_Int32 nInteger, sal_Int32 nBlankInteger,
-bool bGrouping, sal_Int32 nExp, 
sal_Int32 nExpInterval, bool bExpSign, bool bExponentLowercase,
+bool bGrouping, sal_Int32 nExp, 
sal_Int32 nExpInterval, bool bExpSign, bool bExponentLowercase, sal_Int32 
nBlankExp,
 const SvXMLEmbeddedTextEntryArr& 
rEmbeddedEntries );
 SAL_DLLPRIVATE void WriteFractionElement_Impl( sal_Int32 nInteger, 
sal_Int32 nBlankInteger, bool bGrouping,
const SvNumberformat& 
rFormat, sal_uInt16 nPart );
diff --git a/include/xmloff/xmltoken.hxx b/include/xmloff/xmltoken.hxx
index 62f3ebcd613d..4e6441841774 100644
--- a/include/xmloff/xmltoken.hxx
+++ b/include/xmloff/xmltoken.hxx
@@ -3469,6 +3469,7 @@ namespace xmloff::token {
 XML_EXPONENT_INTERVAL,
 XML_EXPONENT_LOWERCASE,
 XML_FORCED_EXPONENT_SIGN,
+XML_BLANK_EXPONENT_DIGITS,
 XML_MIN_DECIMAL_PLACES,
 XML_MAX_DENOMINATOR_VALUE,
 XML_MAX_NUMERATOR_DIGITS,
diff --git a/sc/qa/unit/data/ods/tdf156449-Blank-In-Exponent.ods 
b/sc/qa/unit/data/ods/tdf156449-Blank-In-Exponent.ods
new file mode 100644
index ..73647881e73d
Binary files /dev/null and 
b/sc/qa/unit/data/ods/tdf156449-Blank-In-Exponent.ods differ
diff --git a/sc/qa/unit/subsequent_export_test4.cxx 
b/sc/qa/unit/subsequent_export_test4.cxx
index 2b4141425136..390783131733 100644
--- 

[Libreoffice-commits] core.git: basic/qa chart2/source comphelper/source compilerplugins/clang connectivity/source cui/source editeng/qa i18npool/qa sal/osl sal/qa sc/qa sc/source sdext/source sd/qa s

2023-10-15 Thread Stephan Bergmann (via logerrit)
 basic/qa/cppunit/test_scanner.cxx |   40 ++---
 chart2/source/tools/ObjectIdentifier.cxx  |2 
 comphelper/source/misc/backupfilehelper.cxx   |2 
 compilerplugins/clang/stringstatic.cxx|  142 --
 compilerplugins/clang/test/stringstatic.cxx   |   21 +-
 compilerplugins/clang/test/stringstatic.hxx   |   23 --
 connectivity/source/commontools/filtermanager.cxx |2 
 connectivity/source/commontools/sqlerror.cxx  |2 
 cui/source/options/optgdlg.cxx|2 
 editeng/qa/unit/core-test.cxx |   16 +-
 i18npool/qa/cppunit/test_breakiterator.cxx|2 
 sal/osl/all/debugbase.cxx |6 
 sal/osl/unx/process_impl.cxx  |4 
 sal/qa/osl/socket.cxx |5 
 sal/qa/rtl/strings/test_ostring.cxx   |2 
 sal/qa/rtl/strings/test_strings_defaultstringview.cxx |2 
 sc/qa/unit/subsequent_export_test.cxx |   10 -
 sc/qa/unit/subsequent_export_test2.cxx|6 
 sc/qa/unit/subsequent_export_test4.cxx|2 
 sc/qa/unit/subsequent_filters_test.cxx|3 
 sc/qa/unit/subsequent_filters_test3.cxx   |2 
 sc/qa/unit/tiledrendering/tiledrendering.cxx  |2 
 sc/qa/unit/ucalc_copypaste.cxx|4 
 sc/qa/unit/ucalc_formula2.cxx |   14 -
 sc/qa/unit/uicalc/uicalc2.cxx |2 
 sc/source/core/tool/compiler.cxx  |2 
 sc/source/filter/ftools/ftools.cxx|8 -
 sd/qa/unit/export-tests-ooxml2.cxx|7 
 sd/qa/unit/export-tests.cxx   |2 
 sdext/source/pdfimport/inc/wrapper.hxx|   58 +++
 sfx2/source/view/classificationhelper.cxx |   22 +-
 svl/qa/unit/test_lngmisc.cxx  |2 
 svx/qa/unit/gallery/test_gallery.cxx  |   10 -
 sw/qa/core/test_ToxWhitespaceStripper.cxx |2 
 sw/qa/extras/htmlexport/htmlexport.cxx|2 
 sw/qa/extras/odfexport/odfexport.cxx  |2 
 sw/qa/extras/ooxmlexport/ooxmlexport9.cxx |2 
 sw/qa/extras/uiwriter/uiwriter3.cxx   |6 
 sw/qa/extras/uiwriter/uiwriter4.cxx   |   12 -
 sw/qa/extras/uiwriter/uiwriter6.cxx   |2 
 sw/source/filter/ww8/ww8par2.cxx  |4 
 toolkit/source/helper/accessibilityclient.cxx |6 
 tools/qa/cppunit/test_stream.cxx  |2 
 vcl/source/app/svapp.cxx  |2 
 vcl/source/helper/svtaccessiblefactory.cxx|6 
 vcl/unx/gtk3_kde5/gtk3_kde5_filepicker_ipc.cxx|3 
 writerperfect/qa/unit/EPUBExportTest.cxx  |2 
 xmloff/source/forms/layerexport.cxx   |2 
 xmloff/source/text/XMLRedlineExport.cxx   |2 
 xmlsecurity/qa/unit/signing/signing.cxx   |4 
 50 files changed, 164 insertions(+), 326 deletions(-)

New commits:
commit b4844c310bd9897fef59e8a4da0513100ea86096
Author: Stephan Bergmann 
AuthorDate: Fri Oct 13 08:44:49 2023 +0200
Commit: Stephan Bergmann 
CommitDate: Sun Oct 15 21:15:49 2023 +0200

Repurpose loplugin:stringstatic for O[U]String vars that can be constexpr

...now that warning about O[U]String vars that could be O[U]StringLiteral 
is no
longer useful

Change-Id: I389e72038171f28482049b41f6224257dd11f452
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/157992
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann 

diff --git a/basic/qa/cppunit/test_scanner.cxx 
b/basic/qa/cppunit/test_scanner.cxx
index 6559b3e35d48..f17750c89a6e 100644
--- a/basic/qa/cppunit/test_scanner.cxx
+++ b/basic/qa/cppunit/test_scanner.cxx
@@ -69,12 +69,12 @@ private:
 CPPUNIT_TEST_SUITE_END();
 };
 
-const OUString cr = "\n";
-const OUString rem = "REM";
-const OUString asdf = "asdf";
-const OUString dot = ".";
-const OUString goto_ = "goto";
-const OUString excl = "!";
+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 getSymbols(const OUString& source, sal_Int32& errors, bool 
bCompatible = false)
 {
@@ -160,14 +160,14 @@ void ScannerTest::testBlankLines()
 
 void ScannerTest::testOperators()
 {
-const OUString sourceE("=");
-const OUString sourceLT("<");
-const OUString sourceGT(">");
-const OUString sourceLTE("<=");
-const OUString sourceGTE(">=");
-const OUString sourceNE("<>");
-const OUString sourceA(":=");
-const OUString sourceNot("Not");
+

[Libreoffice-commits] core.git: basic/qa include/sal

2023-09-03 Thread Ilmari Lauhakangas (via logerrit)
 basic/qa/cppunit/basic_coverage.cxx |7 ---
 basic/qa/cppunit/basictest.cxx  |8 
 basic/qa/cppunit/test_vba.cxx   |   11 ++-
 include/sal/log-areas.dox   |1 -
 4 files changed, 14 insertions(+), 13 deletions(-)

New commits:
commit 115c8b42b8db7882f3e10e7ff1ef2f48d3ef973c
Author: Ilmari Lauhakangas 
AuthorDate: Sun Sep 3 13:33:13 2023 +0300
Commit: Ilmari Lauhakangas 
CommitDate: Sun Sep 3 13:22:55 2023 +0200

Revert "tdf#130924 replace '*printf' with 'SAL_*' logging macros."

My mistake, did not notice
https://bugs.documentfoundation.org/show_bug.cgi?id=130924#c5

We shouldn't hide test output.

This reverts commit df0db4132428e95d276e923d8d5fb603dbb7f7bb.

Change-Id: Ieac40effb5722f8db8ead093a83765d17a09
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156479
Tested-by: Jenkins
Tested-by: Ilmari Lauhakangas 
Reviewed-by: Ilmari Lauhakangas 

diff --git a/basic/qa/cppunit/basic_coverage.cxx 
b/basic/qa/cppunit/basic_coverage.cxx
index ee36f2d1309f..0f0722917232 100644
--- a/basic/qa/cppunit/basic_coverage.cxx
+++ b/basic/qa/cppunit/basic_coverage.cxx
@@ -81,15 +81,16 @@ void Coverage::process_directory(const OUString& sDirName)
 testMacro.LoadSourceFromFile("TestModule", sFileURL);
 SbxVariableRef pReturn = testMacro.Run();
 CPPUNIT_ASSERT_MESSAGE("No return variable huh?", 
pReturn.is());
-SAL_INFO("basic.qa", "macro result for " << sFileURL);
-SAL_INFO("basic.qa", "macro returned:\n" << 
pReturn->GetOUString());
+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());
 }
 }
 }
 }
-SAL_INFO("basic.qa", "end process directory");
+fprintf(stderr,"end process directory\n");
 }
 
 void Coverage::Coverage_Iterator()
diff --git a/basic/qa/cppunit/basictest.cxx b/basic/qa/cppunit/basictest.cxx
index ebf39635620a..8cf9812d5212 100644
--- a/basic/qa/cppunit/basictest.cxx
+++ b/basic/qa/cppunit/basictest.cxx
@@ -7,7 +7,6 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
-#include 
 #include "basictest.hxx"
 #include 
 #include 
@@ -43,7 +42,7 @@ MacroSnippet::MacroSnippet()
 void MacroSnippet::LoadSourceFromFile(const OUString& sModuleName, const 
OUString& sMacroFileURL)
 {
 OUString sSource;
-SAL_INFO("basic.qa", "loadSource opening macro file" << sMacroFileURL);
+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)
@@ -113,8 +112,9 @@ const ErrCode& MacroSnippet::getError() const { return 
maErrCode; }
 
 IMPL_LINK( MacroSnippet, BasicErrorHdl, StarBASIC *, /*pBasic*/, bool)
 {
-SAL_INFO("basic.qa", '(' << StarBASIC::GetLine() << ':' << 
StarBASIC::GetCol1() << ")");
-SAL_INFO("basic.qa", "Basic error: " << StarBASIC::GetErrorText());
+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;
diff --git a/basic/qa/cppunit/test_vba.cxx b/basic/qa/cppunit/test_vba.cxx
index a95e2db6a7bd..8a15ba7234e8 100644
--- a/basic/qa/cppunit/test_vba.cxx
+++ b/basic/qa/cppunit/test_vba.cxx
@@ -6,7 +6,6 @@
  * License, v. 2.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 
 #include "basictest.hxx"
 #include 
 
@@ -169,8 +168,9 @@ void VBATest::testMiscVBAFunctions()
 myMacro.LoadSourceFromFile("TestModule", sMacroURL);
 SbxVariableRef pReturn = myMacro.Run();
 CPPUNIT_ASSERT_MESSAGE("No return variable huh?", pReturn.is());
-SAL_INFO("basic.qa", "macro result for" << macroSource[i]);
-SAL_INFO("basic.qa", "macro returned:\n" << pReturn->GetOUString());
+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());
 }
@@ -248,8 +248,9 @@ void VBATest::testMiscOLEStuff()
 

[Libreoffice-commits] core.git: basic/qa include/sal

2023-08-31 Thread sahil (via logerrit)
 basic/qa/cppunit/basic_coverage.cxx |7 +++
 basic/qa/cppunit/basictest.cxx  |8 
 basic/qa/cppunit/test_vba.cxx   |   11 +--
 include/sal/log-areas.dox   |1 +
 4 files changed, 13 insertions(+), 14 deletions(-)

New commits:
commit df0db4132428e95d276e923d8d5fb603dbb7f7bb
Author: sahil 
AuthorDate: Wed Aug 30 17:25:08 2023 +0530
Commit: Ilmari Lauhakangas 
CommitDate: Thu Aug 31 19:50:23 2023 +0200

tdf#130924 replace '*printf' with 'SAL_*' logging macros.

Change-Id: I5bb4052ded82c355f7d71e4f38ebdefe3fcc25da
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/156283
Tested-by: Jenkins
Tested-by: Ilmari Lauhakangas 
Reviewed-by: Ilmari Lauhakangas 

diff --git a/basic/qa/cppunit/basic_coverage.cxx 
b/basic/qa/cppunit/basic_coverage.cxx
index 0f0722917232..ee36f2d1309f 100644
--- a/basic/qa/cppunit/basic_coverage.cxx
+++ b/basic/qa/cppunit/basic_coverage.cxx
@@ -81,16 +81,15 @@ void Coverage::process_directory(const OUString& sDirName)
 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());
+SAL_INFO("basic.qa", "macro result for " << sFileURL);
+SAL_INFO("basic.qa", "macro returned:\n" << 
pReturn->GetOUString());
 CPPUNIT_ASSERT_EQUAL_MESSAGE("Result not as expected", 
OUString("OK"),
  pReturn->GetOUString());
 }
 }
 }
 }
-fprintf(stderr,"end process directory\n");
+SAL_INFO("basic.qa", "end process directory");
 }
 
 void Coverage::Coverage_Iterator()
diff --git a/basic/qa/cppunit/basictest.cxx b/basic/qa/cppunit/basictest.cxx
index 8cf9812d5212..ebf39635620a 100644
--- a/basic/qa/cppunit/basictest.cxx
+++ b/basic/qa/cppunit/basictest.cxx
@@ -7,6 +7,7 @@
  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
  */
 
+#include 
 #include "basictest.hxx"
 #include 
 #include 
@@ -42,7 +43,7 @@ MacroSnippet::MacroSnippet()
 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() );
+SAL_INFO("basic.qa", "loadSource opening macro file" << sMacroFileURL);
 
 osl::File aFile(sMacroFileURL);
 if(aFile.open(osl_File_OpenFlag_Read) == osl::FileBase::E_None)
@@ -112,9 +113,8 @@ const ErrCode& 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() );
+SAL_INFO("basic.qa", '(' << StarBASIC::GetLine() << ':' << 
StarBASIC::GetCol1() << ")");
+SAL_INFO("basic.qa", "Basic error: " << StarBASIC::GetErrorText());
 mbError = true;
 maErrCode = StarBASIC::GetErrorCode();
 return false;
diff --git a/basic/qa/cppunit/test_vba.cxx b/basic/qa/cppunit/test_vba.cxx
index 8a15ba7234e8..a95e2db6a7bd 100644
--- a/basic/qa/cppunit/test_vba.cxx
+++ b/basic/qa/cppunit/test_vba.cxx
@@ -6,6 +6,7 @@
  * License, v. 2.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 
 #include "basictest.hxx"
 #include 
 
@@ -168,9 +169,8 @@ void VBATest::testMiscVBAFunctions()
 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());
+SAL_INFO("basic.qa", "macro result for" << macroSource[i]);
+SAL_INFO("basic.qa", "macro returned:\n" << pReturn->GetOUString());
 CPPUNIT_ASSERT_EQUAL_MESSAGE("Result not as expected", OUString("OK"),
  pReturn->GetOUString());
 }
@@ -248,9 +248,8 @@ void VBATest::testMiscOLEStuff()
 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]);
-

[Libreoffice-commits] core.git: basic/qa sax/source

2023-08-07 Thread Aron Budea (via logerrit)
 basic/qa/basic_coverage/test_tdf150137_parse_fail.bas |   37 ++
 sax/source/fastparser/fastparser.cxx  |8 ++-
 2 files changed, 42 insertions(+), 3 deletions(-)

New commits:
commit c9e863801509fb37b125a8fb07358fb1b235496d
Author: Aron Budea 
AuthorDate: Sun Aug 6 05:08:23 2023 +0200
Commit: Aron Budea 
CommitDate: Mon Aug 7 17:38:30 2023 +0200

tdf#150137 fastparser: don't crash on undeclared namespace

Change-Id: Icc8bbb391c7e34754b7274d67d73ff509827a3d0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155381
Tested-by: Aron Budea 
Reviewed-by: Aron Budea 

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 ..fdf9f1e9948e
--- /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 = ""
+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/sax/source/fastparser/fastparser.cxx 
b/sax/source/fastparser/fastparser.cxx
index fd1b147f044e..3c67010ad1cb 100644
--- a/sax/source/fastparser/fastparser.cxx
+++ b/sax/source/fastparser/fastparser.cxx
@@ -1264,12 +1264,14 @@ void FastSaxParserImpl::callbackStartElement(const 
xmlChar *localName , const xm
 OUString aElementPrefix;
 if( prefix != nullptr )
 {
-if ( !m_bIgnoreMissingNSDecl || URI != nullptr )
+aElementPrefix = OUString( XML_CAST( prefix ), strlen( 
XML_CAST( prefix )), RTL_TEXTENCODING_UTF8 );
+if ( URI != nullptr )
 sNamespace = OUString( XML_CAST( URI ), strlen( XML_CAST( 
URI )), RTL_TEXTENCODING_UTF8 );
-else
+else if ( m_bIgnoreMissingNSDecl )
 sNamespace.clear();
+else
+throw SAXException("No namespace defined for " + 
aElementPrefix, {}, {});
 nNamespaceToken = GetNamespaceToken( sNamespace );
-aElementPrefix = OUString( XML_CAST( prefix ), strlen( 
XML_CAST( prefix )), RTL_TEXTENCODING_UTF8 );
 }
 OUString aElementLocalName( XML_CAST( localName ), strlen( 
XML_CAST( localName )), RTL_TEXTENCODING_UTF8 );
 rEvent.msNamespace = sNamespace;


[Libreoffice-commits] core.git: basic/qa

2023-08-04 Thread Mike Kaganski (via logerrit)
 basic/qa/cppunit/_test_asserts.bas |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

New commits:
commit e59780c1e0670c4a79bd465da08d5cf51d421f62
Author: Mike Kaganski 
AuthorDate: Fri Aug 4 12:04:20 2023 +0300
Commit: Mike Kaganski 
CommitDate: Fri Aug 4 15:34:24 2023 +0200

Reduce differences between _test_asserts.bas and _test_asserts.vb

Change-Id: Ic546f6454f2b8581300320e1690644152d44eb83
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/155341
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/basic/qa/cppunit/_test_asserts.bas 
b/basic/qa/cppunit/_test_asserts.bas
index 68865755bdcd..0c3e0b371f14 100644
--- a/basic/qa/cppunit/_test_asserts.bas
+++ b/basic/qa/cppunit/_test_asserts.bas
@@ -54,8 +54,8 @@ 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:")
+AssertEqual actual, expected, testName
+AssertEqual TypeName(actual), TypeName(expected), testName & " type 
mismatch:"
 End Sub
 
 Sub AssertEqualApprox(actual, expected, epsilon, testName As String)


[Libreoffice-commits] core.git: basic/qa basic/source

2023-05-09 Thread Andreas Heinisch (via logerrit)
 basic/qa/vba_tests/constants.vb |9 +
 basic/source/comp/parser.cxx|9 +
 2 files changed, 18 insertions(+)

New commits:
commit fa0a1f6462c050bdd14a4f75589eb324c6575a91
Author: Andreas Heinisch 
AuthorDate: Tue May 9 11:43:45 2023 +0200
Commit: Andreas Heinisch 
CommitDate: Tue May 9 14:12:54 2023 +0200

tdf#153543 - Add vba shell constants

Change-Id: Ifa73050f6892ce8ce95d16dedc166e68d1809491
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/151567
Tested-by: Jenkins
Reviewed-by: Andreas Heinisch 

diff --git a/basic/qa/vba_tests/constants.vb b/basic/qa/vba_tests/constants.vb
index be7add515e83..c31444889fae 100644
--- a/basic/qa/vba_tests/constants.vb
+++ b/basic/qa/vba_tests/constants.vb
@@ -25,6 +25,15 @@ Sub verify_testConstants()
 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")
diff --git a/basic/source/comp/parser.cxx b/basic/source/comp/parser.cxx
index 70bc27dcd16b..97bd27675fa8 100644
--- a/basic/source/comp/parser.cxx
+++ b/basic/source/comp/parser.cxx
@@ -849,6 +849,15 @@ static void addNumericConst(SbiSymPool& rPool, const 
OUString& pSym, double nVal
 
 void SbiParser::AddConstants()
 {
+// tdf#153543 - shell constants
+// See 
https://learn.microsoft.com/en-us/office/vba/language/reference/user-interface-help/shell-constants
+addNumericConst(aPublics, "vbHide", 0);
+addNumericConst(aPublics, "vbNormalFocus", 1);
+addNumericConst(aPublics, "vbMinimizedFocus", 2);
+addNumericConst(aPublics, "vbMaximizedFocus", 3);
+addNumericConst(aPublics, "vbNormalNoFocus", 4);
+addNumericConst(aPublics, "vbMinimizedNoFocus", 6);
+
 // tdf#131563 - add vba color constants
 // See 
https://docs.microsoft.com/en-us/office/vba/language/reference/user-interface-help/color-constants
 addNumericConst(aPublics, "vbBlack", 0x0);


[Libreoffice-commits] core.git: basic/qa basic/source

2023-03-21 Thread Mike Kaganski (via logerrit)
 basic/qa/vba_tests/strconv.vb|   21 ++-
 basic/source/runtime/methods.cxx |  210 ---
 2 files changed, 124 insertions(+), 107 deletions(-)

New commits:
commit 458f2b8f69fbf0a220f18fbf250e4369fd0491cd
Author: Mike Kaganski 
AuthorDate: Wed Mar 15 16:30:26 2023 +0300
Commit: Mike Kaganski 
CommitDate: Wed Mar 22 04:31:07 2023 +

Refactor and fix VBA StrConv

This properly handles null bytes that are expected
when converting between byte strings and Unicode.

It properly handles TransliterationFlags, which are
not a bitset.

In vbProperCase, it uses the correct method to
lowercase the string, working not only with ASCII.

Change-Id: I04e8cdca66ef9863a6516b15205a2a543ed97680
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/149224
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/basic/qa/vba_tests/strconv.vb b/basic/qa/vba_tests/strconv.vb
index b0295df428b2..9b7dfaf21866 100644
--- a/basic/qa/vba_tests/strconv.vb
+++ b/basic/qa/vba_tests/strconv.vb
@@ -18,25 +18,30 @@ 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)")
+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)")
 
-' Assumes CP-1252 encoding associated with en-US locale used in unit tests.
 Dim x() As Byte
-x = StrConv("ÉϺ£ÊÐABC", vbFromUnicode)
+Const Cp1252TestString = "ÉϺ£ÊÐABC"
+
+x = StrConv(Cp1252TestString, vbFromUnicode, )' 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)")
@@ -47,7 +52,11 @@ Sub verify_testStrConv()
 TestUtil.AssertEqual(x(6), 65, "x(6)")
 TestUtil.AssertEqual(x(7), 66, "x(7)")
 TestUtil.AssertEqual(x(8), 67, "x(8)")
-TestUtil.AssertEqual(StrConv(x, vbUnicode), "ÉϺ£ÊÐABC", "StrConv(x, 
vbUnicode)")
+TestUtil.AssertEqual(StrConv(x, vbUnicode, ), Cp1252TestString, 
"StrConv(x, vbUnicode, )")
+
+x = StrConv(Cp1252TestString, vbUnicode, )
+TestUtil.AssertEqual(UBound(x), 35, "UBound(x)")
+TestUtil.AssertEqual(StrConv(x, vbFromUnicode, ), Cp1252TestString, 
"StrConv(x, vbFromUnicode, )")
 
 Exit Sub
 errorHandler:
diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx
index b6d9383d5b37..0b4f89d40115 100644
--- a/basic/source/runtime/methods.cxx
+++ b/basic/source/runtime/methods.cxx
@@ -59,6 +59,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -4084,6 +4085,40 @@ void SbRtl_QBColor(StarBASIC *, SbxArray & rPar, bool)
 rPar.Get(0)->PutLong(nRGB);
 }
 
+static std::vector byteArray2Vec(SbxArray* pArr)
+{
+std::vector result;
+if (pArr)
+{
+const sal_uInt32 nCount = pArr->Count();
+result.reserve(nCount + 1); // to avoid 

[Libreoffice-commits] core.git: basic/qa basic/source

2023-03-16 Thread Baole Fang (via logerrit)
 basic/qa/basic_coverage/test_like.bas |   41 +
 basic/qa/cppunit/test_vba.cxx |1 
 basic/qa/vba_tests/like.vb|   42 ++
 basic/source/runtime/runtime.cxx  |7 +++--
 4 files changed, 88 insertions(+), 3 deletions(-)

New commits:
commit e12fff12b66561bc46a0e22f58919efa443e7e17
Author: Baole Fang 
AuthorDate: Sat Mar 11 21:39:23 2023 -0500
Commit: Mike Kaganski 
CommitDate: Thu Mar 16 21:14:20 2023 +

tdf#152690: Fix "!" behavior when it is not the first in a group

Fix "!" behavior when it is not the first in a group.
Add testcases for "!" and Like.

Change-Id: Ia76fa26722b6546d08dd8842d83f55bb0c0ea5ac
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/148720
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/basic/qa/basic_coverage/test_like.bas 
b/basic/qa/basic_coverage/test_like.bas
new file mode 100644
index ..2d018bf64f01
--- /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("axb" 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/cppunit/test_vba.cxx b/basic/qa/cppunit/test_vba.cxx
index b778d393019b..8a15ba7234e8 100644
--- a/basic/qa/cppunit/test_vba.cxx
+++ b/basic/qa/cppunit/test_vba.cxx
@@ -114,6 +114,7 @@ void VBATest::testMiscVBAFunctions()
 "minute.vb",
 "month.vb",
 "monthname.vb",
+"like.vb",
 "oct.vb",
 "optional_paramters.vb",
 "qbcolor.vb",
diff --git a/basic/qa/vba_tests/like.vb b/basic/qa/vba_tests/like.vb
new file mode 100644
index ..c3be1e081b16
--- /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("axb" Like "a [*]b", False, "Like10")
+TestUtil.AssertEqual("a [xyz" Like "a [[]*", True, "Like11")
+
+Exit Sub
+errorHandler:
+TestUtil.ReportErrorHandler("verify_testLike", Err, Error$, Erl)

[Libreoffice-commits] core.git: basic/qa basic/source

2023-02-26 Thread Alain Romedenne (via logerrit)
 basic/qa/basic_coverage/string_left_01.bas |   26 -
 basic/qa/basic_coverage/string_right_01.bas|   26 -
 basic/qa/basic_coverage/test_join_method.bas   |   30 +++
 basic/qa/basic_coverage/test_left_method.bas   |   28 ++
 basic/qa/basic_coverage/test_mid_keyword_names.bas |   26 +
 basic/qa/basic_coverage/test_right_method.bas  |   28 ++
 basic/qa/basic_coverage/test_split_method.bas  |6 +++
 basic/qa/basic_coverage/test_string_method.bas |   28 ++
 basic/qa/basic_coverage/test_typename_method.bas   |2 +
 basic/qa/basic_coverage/test_vartype_method.bas|2 +
 basic/qa/vba_tests/instrrev.vb |7 +++
 basic/qa/vba_tests/join.vb |5 ++
 basic/qa/vba_tests/left.vb |3 +
 basic/qa/vba_tests/mid.vb  |4 ++
 basic/qa/vba_tests/right.vb|3 +
 basic/qa/vba_tests/split.vb|6 +++
 basic/qa/vba_tests/string.vb   |   10 +++--
 basic/qa/vba_tests/typename.vb |2 +
 basic/qa/vba_tests/vartype.vb  |2 +
 basic/source/runtime/stdobj.cxx|   42 ++---
 20 files changed, 195 insertions(+), 91 deletions(-)

New commits:
commit fd19bc83cfd49937da8585b9ab938b2086ecf74a
Author: Alain Romedenne 
AuthorDate: Wed Jan 18 16:07:09 2023 +
Commit: Andreas Heinisch 
CommitDate: Sun Feb 26 16:14:47 2023 +

tdf#141474 tdf#151901 BASIC functions argument names do not match that of 
VBA

Basic function argument names can be used either by position either by 
name, keyword arguments ae called 'named arguments' in VBA
- VBA doc:

https://learn.microsoft.com/en-us/office/vba/language/concepts/getting-started/understanding-named-arguments-and-optional-arguments
- libO Basic function signatures:

https://help.libreoffice.org/latest/en-US/text/sbasic/shared/03090401.html?DbPAR=BASIC#bm_id3154422

This patch attempts to correct - all in one - malformed keyword names in 
BASIC function signatures.

It reflects keyword arguments usage inside QA BASIC unit tests.

In the end Online help pages may incorporate such practice.

Change-Id: Iab0c92b2c152d2564662e51e68f1f736b8deefd0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145720
Tested-by: Jenkins
Reviewed-by: Andreas Heinisch 

diff --git a/basic/qa/basic_coverage/string_left_01.bas 
b/basic/qa/basic_coverage/string_left_01.bas
deleted file mode 100644
index d2ae7ae45ff8..
--- a/basic/qa/basic_coverage/string_left_01.bas
+++ /dev/null
@@ -1,26 +0,0 @@
-'
-' This file is part of the LibreOffice project.
-'
-' This Source Code Form is subject to the terms of the Mozilla Public
-' License, v. 2.0. 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 s1 As String
-Dim s2 As String
-
-s1 = "abc"
-
-s2 = Left(s1, 2)
-
-If s2 = "ab" Then
-doUnitTest = "OK"
-Else
-doUnitTest = "FAIL"
-End If
-
-End Function
diff --git a/basic/qa/basic_coverage/string_right_01.bas 
b/basic/qa/basic_coverage/string_right_01.bas
deleted file mode 100644
index a291d0704bf3..
--- a/basic/qa/basic_coverage/string_right_01.bas
+++ /dev/null
@@ -1,26 +0,0 @@
-'
-' This file is part of the LibreOffice project.
-'
-' This Source Code Form is subject to the terms of the Mozilla Public
-' License, v. 2.0. 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 s1 As String
-Dim s2 As String
-
-s1 = "abc"
-
-s2 = Right(s1, 2)
-
-If s2 = "bc" Then
-doUnitTest = "OK"
-Else
-doUnitTest = "FAIL"
-End If
-
-End Function
diff --git a/basic/qa/basic_coverage/test_join_method.bas 
b/basic/qa/basic_coverage/test_join_method.bas
index 9076a0f8d83e..a3769ae188ff 100644
--- a/basic/qa/basic_coverage/test_join_method.bas
+++ b/basic/qa/basic_coverage/test_join_method.bas
@@ -7,14 +7,28 @@
 
 Option Explicit
 
-Function doUnitTest as String
-' Join
+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"
-If ( Join( aStrings, " " ) <> "Hello world " ) Then
-doUnitTest = "FAIL"
-Else
-doUnitTest = "OK"
-End If
-End Function
+TestUtil.AssertEqual(Join( aStrings, " " ), "Hello world ", 
"Join(aStrings, "" "" is not ""Hello world """)
+
+' tdf#141474 keyword names need to match 

[Libreoffice-commits] core.git: basic/qa

2023-01-25 Thread Andreas Heinisch (via logerrit)
 basic/qa/vba_tests/chr.vb |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 263c15ee238e04c7b25d36cdbb9ab21c0bdf518d
Author: Andreas Heinisch 
AuthorDate: Wed Jan 25 11:16:00 2023 +
Commit: Andreas Heinisch 
CommitDate: Thu Jan 26 07:45:25 2023 +

Delete extra whitespaces inserted by the editor

Change-Id: I89ef4d04e27e52f5ee6168f368e23f96e112a8be
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/146085
Tested-by: Jenkins
Reviewed-by: Andreas Heinisch 

diff --git a/basic/qa/vba_tests/chr.vb b/basic/qa/vba_tests/chr.vb
index 5dc85a0c9157..f9bc7ea12aa5 100644
--- a/basic/qa/vba_tests/chr.vb
+++ b/basic/qa/vba_tests/chr.vb
@@ -21,7 +21,7 @@ Sub verify_testCHR()
 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)")
 


[Libreoffice-commits] core.git: basic/qa

2023-01-09 Thread Xisco Fauli (via logerrit)
 basic/qa/basic_coverage/test_converttofromurl_methods.bas |   29 +++---
 1 file changed, 23 insertions(+), 6 deletions(-)

New commits:
commit 3c7cba927bb5d234d6d72f65e063754590a7b584
Author: Xisco Fauli 
AuthorDate: Mon Jan 9 10:05:05 2023 +0100
Commit: Xisco Fauli 
CommitDate: Mon Jan 9 19:08:03 2023 +

tdf#152917: basic_macros: Add unittest

Change-Id: I69050ae0e6607ed4a1d1da0e89b45125e2c06e3b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/145190
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 

diff --git a/basic/qa/basic_coverage/test_converttofromurl_methods.bas 
b/basic/qa/basic_coverage/test_converttofromurl_methods.bas
index d1dbcfc5ff73..c17d17e631e3 100644
--- a/basic/qa/basic_coverage/test_converttofromurl_methods.bas
+++ b/basic/qa/basic_coverage/test_converttofromurl_methods.bas
@@ -7,11 +7,28 @@
 
 Option Explicit
 
-Function doUnitTest as String
-' ConvertFromUrl ConvertToUrl
-If ( ConvertToUrl( ConvertFromUrl("") ) <> "") Then
-doUnitTest = "FAIL"
+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
-doUnitTest = "OK"
+'Windows
+TestUtil.AssertEqual( ConvertFromUrl("file://foo/bar/test.txt"), 
"\\foo\bar\test.txt", "ConvertFromUrl(""file://foo/bar/test.txt"")")
 End If
-End Function
+
+Exit Sub
+errorHandler:
+TestUtil.ReportErrorHandler("verify_testConvertToFromUrl", Err, Error$, 
Erl)
+End Sub


[Libreoffice-commits] core.git: basic/qa

2022-12-20 Thread Xisco Fauli (via logerrit)
 basic/qa/vba_tests/ole_ObjAssignNoDflt.vb|8 
 basic/qa/vba_tests/ole_ObjAssignToNothing.vb |8 
 2 files changed, 16 insertions(+)

New commits:
commit a179da299a7daaa13f7d6fa3612f82eeb186f0d1
Author: Xisco Fauli 
AuthorDate: Tue Dec 20 10:49:04 2022 +0100
Commit: Xisco Fauli 
CommitDate: Tue Dec 20 12:50:41 2022 +

basic: add missing license statement in .vb test files

Change-Id: I304615540edad3d3486bcdb17d7d6ae12fc084b4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144584
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 

diff --git a/basic/qa/vba_tests/ole_ObjAssignNoDflt.vb 
b/basic/qa/vba_tests/ole_ObjAssignNoDflt.vb
index b1a591b0c94d..9817aa7437dc 100644
--- a/basic/qa/vba_tests/ole_ObjAssignNoDflt.vb
+++ b/basic/qa/vba_tests/ole_ObjAssignNoDflt.vb
@@ -1,3 +1,11 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. 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
diff --git a/basic/qa/vba_tests/ole_ObjAssignToNothing.vb 
b/basic/qa/vba_tests/ole_ObjAssignToNothing.vb
index d68664b41b72..9a0a557cdf31 100644
--- a/basic/qa/vba_tests/ole_ObjAssignToNothing.vb
+++ b/basic/qa/vba_tests/ole_ObjAssignToNothing.vb
@@ -1,3 +1,11 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. 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


[Libreoffice-commits] core.git: basic/qa

2022-12-20 Thread Xisco Fauli (via logerrit)
 basic/qa/basic_coverage/test_CallByName.bas|7 
 basic/qa/basic_coverage/test_ismissing_basic.bas   |7 
 basic/qa/basic_coverage/test_ismissing_cascade.bas |7 
 basic/qa/basic_coverage/test_ismissing_compatible.bas  |7 
 basic/qa/basic_coverage/test_option_base.bas   |7 
 basic/qa/basic_coverage/test_option_base_compatible.bas|7 
 basic/qa/basic_coverage/test_optional_paramter_type.bas|   74 
+-
 basic/qa/basic_coverage/test_optional_paramters_basic.bas  |7 
 basic/qa/basic_coverage/test_optional_paramters_compatible.bas |7 
 basic/qa/basic_coverage/test_string_overflow_safe.bas  |7 
 basic/qa/basic_coverage/test_string_replace.bas|7 
 basic/qa/basic_coverage/test_tdf134692.bas |7 
 basic/qa/basic_coverage/test_tdf98778.bas  |7 
 13 files changed, 124 insertions(+), 34 deletions(-)

New commits:
commit 5f0cf6e7aa75e8724e13e731be09271c7e536e93
Author: Xisco Fauli 
AuthorDate: Mon Dec 19 17:53:00 2022 +0100
Commit: Xisco Fauli 
CommitDate: Tue Dec 20 08:41:11 2022 +

basic: add missing license statement in test files

While at it, convert test_optional_paramter_type.bas
to Unix format

Change-Id: I141fa0a00d6b6784c3a84c8b3041086d51e5cdbc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144540
Tested-by: Xisco Fauli 
Reviewed-by: Xisco Fauli 

diff --git a/basic/qa/basic_coverage/test_CallByName.bas 
b/basic/qa/basic_coverage/test_CallByName.bas
index 35578ee475c0..3eca805fb1a9 100644
--- a/basic/qa/basic_coverage/test_CallByName.bas
+++ b/basic/qa/basic_coverage/test_CallByName.bas
@@ -1,3 +1,10 @@
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. 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
diff --git a/basic/qa/basic_coverage/test_ismissing_basic.bas 
b/basic/qa/basic_coverage/test_ismissing_basic.bas
index ed43a3ad19ee..0996da0f82a4 100644
--- a/basic/qa/basic_coverage/test_ismissing_basic.bas
+++ b/basic/qa/basic_coverage/test_ismissing_basic.bas
@@ -1,3 +1,10 @@
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.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
diff --git a/basic/qa/basic_coverage/test_ismissing_cascade.bas 
b/basic/qa/basic_coverage/test_ismissing_cascade.bas
index f2f3a8b20564..3c6d9a71c09a 100644
--- a/basic/qa/basic_coverage/test_ismissing_cascade.bas
+++ b/basic/qa/basic_coverage/test_ismissing_cascade.bas
@@ -1,3 +1,10 @@
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. 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
diff --git a/basic/qa/basic_coverage/test_ismissing_compatible.bas 
b/basic/qa/basic_coverage/test_ismissing_compatible.bas
index fb7e6981d74c..6d11ab0902be 100644
--- a/basic/qa/basic_coverage/test_ismissing_compatible.bas
+++ b/basic/qa/basic_coverage/test_ismissing_compatible.bas
@@ -1,3 +1,10 @@
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. 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
diff --git a/basic/qa/basic_coverage/test_option_base.bas 
b/basic/qa/basic_coverage/test_option_base.bas
index 11afea50d75b..69282f80bec6 100644
--- a/basic/qa/basic_coverage/test_option_base.bas
+++ b/basic/qa/basic_coverage/test_option_base.bas
@@ -1,3 +1,10 @@
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. 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
 
diff --git a/basic/qa/basic_coverage/test_option_base_compatible.bas 
b/basic/qa/basic_coverage/test_option_base_compatible.bas
index 8001106a7bfc..296b208f582b 100644
--- a/basic/qa/basic_coverage/test_option_base_compatible.bas
+++ b/basic/qa/basic_coverage/test_option_base_compatible.bas
@@ -1,3 +1,10 @@
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You 

[Libreoffice-commits] core.git: basic/qa

2022-12-19 Thread Xisco Fauli (via logerrit)
 basic/qa/basic_coverage/test_transliteration.bas |   52 +++
 1 file changed, 52 insertions(+)

New commits:
commit c6dc676306d2e507bf57369d02dcaf2408d43eb0
Author: Xisco Fauli 
AuthorDate: Mon Dec 19 17:42:36 2022 +0100
Commit: Xisco Fauli 
CommitDate: Tue Dec 20 07:47:34 2022 +

tdf#152520: basic_macros: Add unittest

Change-Id: I30f6badc620f3932cacff07bd37ef4da96f1bafd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/144539
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 

diff --git a/basic/qa/basic_coverage/test_transliteration.bas 
b/basic/qa/basic_coverage/test_transliteration.bas
new file mode 100644
index ..01a5705d0a0d
--- /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


[Libreoffice-commits] core.git: basic/qa basic/source

2022-10-14 Thread Andreas Heinisch (via logerrit)
 basic/qa/basic_coverage/test_optional_paramters_basic.bas  |   15 
++
 basic/qa/basic_coverage/test_optional_paramters_compatible.bas |   15 
++
 basic/source/runtime/runtime.cxx   |8 +
 3 files changed, 38 insertions(+)

New commits:
commit bdfcad586d7b1d4d26bcba50058af7fcb279558d
Author: Andreas Heinisch 
AuthorDate: Thu Oct 13 14:20:00 2022 +0200
Commit: Andreas Heinisch 
CommitDate: Fri Oct 14 10:06:38 2022 +0200

tdf#151503 - Do not evaluate a missing optional variable to a boolean

Change-Id: I671f857344f91de63612eabcbbdb2cab9b94cc0d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/141296
Tested-by: Jenkins
Reviewed-by: Andreas Heinisch 

diff --git a/basic/qa/basic_coverage/test_optional_paramters_basic.bas 
b/basic/qa/basic_coverage/test_optional_paramters_basic.bas
index a684fc256054..40475664fb7a 100644
--- a/basic/qa/basic_coverage/test_optional_paramters_basic.bas
+++ b/basic/qa/basic_coverage/test_optional_paramters_basic.bas
@@ -125,6 +125,12 @@ Sub verify_testOptionalsBasic()
 ' - 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)
@@ -229,6 +235,15 @@ 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
diff --git a/basic/qa/basic_coverage/test_optional_paramters_compatible.bas 
b/basic/qa/basic_coverage/test_optional_paramters_compatible.bas
index 56b314288e7a..fc3ca385951c 100644
--- a/basic/qa/basic_coverage/test_optional_paramters_compatible.bas
+++ b/basic/qa/basic_coverage/test_optional_paramters_compatible.bas
@@ -127,6 +127,12 @@ Sub verify_testOptionalsCompatible()
 ' - 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)
@@ -231,6 +237,15 @@ 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
diff --git a/basic/source/runtime/runtime.cxx b/basic/source/runtime/runtime.cxx
index 5ff568140c75..4f77fecb56e2 100644
--- a/basic/source/runtime/runtime.cxx
+++ b/basic/source/runtime/runtime.cxx
@@ -3022,6 +3022,14 @@ bool SbiRuntime::EvaluateTopOfStackAsBool()
 {
 return false;
 }
+
+// tdf#151503 - do not evaluate a missing optional variable to a boolean
+if (tos->GetType() == SbxERROR && IsMissing(tos.get(), 1))
+{
+Error(ERRCODE_BASIC_NOT_OPTIONAL);
+return false;
+}
+
 if ( tos->IsObject() )
 {
 //GetBool applied to an Object attempts to dereference and evaluate


[Libreoffice-commits] core.git: basic/qa basic/source

2022-09-25 Thread Andreas Heinisch (via logerrit)
 basic/qa/basic_coverage/test_tdf147529_optional_parameters_msgbox.bas |4 
 basic/qa/vba_tests/tdf147529_optional_parameters_msgbox.vb|4 
 basic/source/runtime/methods.cxx  |   49 
++
 3 files changed, 32 insertions(+), 25 deletions(-)

New commits:
commit 6f3532f6aaafb6ad58a9e32dc0eff43a0d54862b
Author: Andreas Heinisch 
AuthorDate: Sun Sep 18 21:57:21 2022 +0200
Commit: Andreas Heinisch 
CommitDate: Sun Sep 25 11:39:33 2022 +0200

tdf#151012 - Initialize optional parameters with their default values

Change-Id: I3ed3eb904b50892e5946abe684e801819ba296e6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/140128
Tested-by: Jenkins
Reviewed-by: Andreas Heinisch 

diff --git 
a/basic/qa/basic_coverage/test_tdf147529_optional_parameters_msgbox.bas 
b/basic/qa/basic_coverage/test_tdf147529_optional_parameters_msgbox.bas
index dabb23c0faf1..67378213e287 100644
--- a/basic/qa/basic_coverage/test_tdf147529_optional_parameters_msgbox.bas
+++ b/basic/qa/basic_coverage/test_tdf147529_optional_parameters_msgbox.bas
@@ -18,9 +18,7 @@ Sub verify_testOptionalParametersMsgBox
 On Error GoTo errorHandler
 
 ' tdf#147529 - check for missing optional parameters
-TestUtil.AssertEqual(TestOptionalParametersMsgBox(),  True, 
"TestOptionalParametersMsgBox()")
-TestUtil.AssertEqual(TestOptionalParametersMsgBox("test"),True, 
"TestOptionalParametersMsgBox(""test"")")
-TestUtil.AssertEqual(TestOptionalParametersMsgBox("test", 1), True, 
"TestOptionalParametersMsgBox(""test"", 1)")
+TestUtil.AssertEqual(TestOptionalParametersMsgBox(), True, 
"TestOptionalParametersMsgBox()")
 
 Exit Sub
 errorHandler:
diff --git a/basic/qa/vba_tests/tdf147529_optional_parameters_msgbox.vb 
b/basic/qa/vba_tests/tdf147529_optional_parameters_msgbox.vb
index dabe552a821b..e599f46eedf1 100644
--- a/basic/qa/vba_tests/tdf147529_optional_parameters_msgbox.vb
+++ b/basic/qa/vba_tests/tdf147529_optional_parameters_msgbox.vb
@@ -19,9 +19,7 @@ Sub verify_testOptionalParametersMsgBox
 On Error GoTo errorHandler
 
 ' tdf#147529 - check for missing optional parameters
-TestUtil.AssertEqual(TestOptionalParametersMsgBox(),  True, 
"TestOptionalParametersMsgBox()")
-TestUtil.AssertEqual(TestOptionalParametersMsgBox("test"),True, 
"TestOptionalParametersMsgBox(""test"")")
-TestUtil.AssertEqual(TestOptionalParametersMsgBox("test", 1), True, 
"TestOptionalParametersMsgBox(""test"", 1)")
+TestUtil.AssertEqual(TestOptionalParametersMsgBox(), True, 
"TestOptionalParametersMsgBox()")
 
 Exit Sub
 errorHandler:
diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx
index 3b718d78a9af..9cc839a1e154 100644
--- a/basic/source/runtime/methods.cxx
+++ b/basic/source/runtime/methods.cxx
@@ -3285,6 +3285,28 @@ void SbRtl_Format(StarBASIC *, SbxArray & rPar, bool)
 }
 }
 
+static bool IsMissing(SbxArray& rPar, const sal_uInt32 i)
+{
+const sal_uInt32 nArgCount = rPar.Count();
+if (nArgCount <= i)
+return true;
+
+SbxVariable* aPar = rPar.Get(i);
+return (aPar->GetType() == SbxERROR && SbiRuntime::IsMissing(aPar, 1));
+}
+
+static sal_Int16 GetOptionalIntegerParamOrDefault(SbxArray& rPar, const 
sal_uInt32 i,
+  const sal_Int16 defaultValue)
+{
+return IsMissing(rPar, i) ? defaultValue : rPar.Get(i)->GetInteger();
+}
+
+static OUString GetOptionalOUStringParamOrDefault(SbxArray& rPar, const 
sal_uInt32 i,
+  const OUString& defaultValue)
+{
+return IsMissing(rPar, i) ? defaultValue : rPar.Get(i)->GetOUString();
+}
+
 static void lcl_FormatNumberPercent(SbxArray& rPar, bool isPercent)
 {
 const sal_uInt32 nArgCount = rPar.Count();
@@ -4328,19 +4350,15 @@ void SbRtl_MsgBox(StarBASIC *, SbxArray & rPar, bool)
 return;
 }
 
-// tdf#147529 - check for missing optional parameters
-for (sal_uInt32 i = 2; i < nArgCount; i++)
+// tdf#147529 - check for missing parameters
+if (IsMissing(rPar, 1))
 {
-if (rPar.Get(i)->GetType() == SbxERROR && 
SbiRuntime::IsMissing(rPar.Get(i), 1))
-{
-StarBASIC::Error(ERRCODE_BASIC_NOT_OPTIONAL);
-return;
-}
+StarBASIC::Error(ERRCODE_BASIC_NOT_OPTIONAL);
+return;
 }
 
-WinBits nType = 0; // MB_OK
-if( nArgCount >= 3 )
-nType = static_cast(rPar.Get(2)->GetInteger());
+// tdf#151012 - initialize optional parameters with their default values 
(number of buttons)
+WinBits nType = 
static_cast(GetOptionalIntegerParamOrDefault(rPar, 2, 0)); // MB_OK
 WinBits nStyle = nType;
 nStyle &= 15; // delete bits 4-16
 if (nStyle > 5)
@@ -4358,15 +4376,8 @@ void SbRtl_MsgBox(StarBASIC *, SbxArray & rPar, bool)
 };
 
 OUString aMsg = rPar.Get(1)->GetOUString();
-OUString aTitle;
-if( 

[Libreoffice-commits] core.git: basic/qa

2022-06-28 Thread Andrea Gelmini (via logerrit)
 0 files changed

New commits:
commit d477d2eb37fe552a56d6b34be3ce7f773caab125
Author: Andrea Gelmini 
AuthorDate: Tue Jun 28 06:25:13 2022 +0200
Commit: Julien Nabet 
CommitDate: Tue Jun 28 20:55:42 2022 +0200

Removed executable bits on files

Change-Id: I8508d26067084ff7bb15bbf2326a1ff7bc61a6ae
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136521
Tested-by: Jenkins
Reviewed-by: Julien Nabet 

diff --git 
a/basic/qa/basic_coverage/test_tdf147529_optional_parameters_msgbox.bas 
b/basic/qa/basic_coverage/test_tdf147529_optional_parameters_msgbox.bas
old mode 100755
new mode 100644
diff --git a/basic/qa/vba_tests/tdf147529_optional_parameters_msgbox.vb 
b/basic/qa/vba_tests/tdf147529_optional_parameters_msgbox.vb
old mode 100755
new mode 100644


[Libreoffice-commits] core.git: basic/qa basic/source

2022-06-24 Thread Andreas Heinisch (via logerrit)
 basic/qa/basic_coverage/test_tdf147529_optional_parameters_msgbox.bas |   38 
+
 basic/qa/cppunit/test_vba.cxx |1 
 basic/qa/vba_tests/tdf147529_optional_parameters_msgbox.vb|   39 
++
 basic/source/runtime/methods.cxx  |   13 
+++
 4 files changed, 90 insertions(+), 1 deletion(-)

New commits:
commit 522f5ad4d8c92624fffa869143aa869662a48589
Author: Andreas Heinisch 
AuthorDate: Thu Jun 23 15:07:18 2022 +0200
Commit: Andreas Heinisch 
CommitDate: Fri Jun 24 09:20:45 2022 +0200

tdf#147529 - BASIC MsgBox: Check for missing optional parameters

Change-Id: Iecb47e0005c609ee1117d6fb141e810c0166806a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136339
Tested-by: Jenkins
Reviewed-by: Andreas Heinisch 

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 100755
index ..dabb23c0faf1
--- /dev/null
+++ b/basic/qa/basic_coverage/test_tdf147529_optional_parameters_msgbox.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
+
+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()")
+TestUtil.AssertEqual(TestOptionalParametersMsgBox("test"),True, 
"TestOptionalParametersMsgBox(""test"")")
+TestUtil.AssertEqual(TestOptionalParametersMsgBox("test", 1), True, 
"TestOptionalParametersMsgBox(""test"", 1)")
+
+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/cppunit/test_vba.cxx b/basic/qa/cppunit/test_vba.cxx
index 07e4287e17b1..f048fee6dfda 100644
--- a/basic/qa/cppunit/test_vba.cxx
+++ b/basic/qa/cppunit/test_vba.cxx
@@ -136,6 +136,7 @@ void VBATest::testMiscVBAFunctions()
 "strreverse.vb",
 "switch.vb",
 "tdf147089_idiv.vb",
+"tdf147529_optional_parameters_msgbox.vb",
 "tdf148358_non_ascii_names.vb",
 "timeserial.vb",
 "timevalue.vb",
diff --git a/basic/qa/vba_tests/tdf147529_optional_parameters_msgbox.vb 
b/basic/qa/vba_tests/tdf147529_optional_parameters_msgbox.vb
new file mode 100755
index ..dabe552a821b
--- /dev/null
+++ b/basic/qa/vba_tests/tdf147529_optional_parameters_msgbox.vb
@@ -0,0 +1,39 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. 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()")
+TestUtil.AssertEqual(TestOptionalParametersMsgBox("test"),True, 
"TestOptionalParametersMsgBox(""test"")")
+TestUtil.AssertEqual(TestOptionalParametersMsgBox("test", 1), True, 
"TestOptionalParametersMsgBox(""test"", 1)")
+
+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/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx
index 2761caba0309..fe654bbe6fd5 100644
--- a/basic/source/runtime/methods.cxx
+++ b/basic/source/runtime/methods.cxx
@@ 

[Libreoffice-commits] core.git: basic/qa basic/source include/basic

2022-06-20 Thread Mike Kaganski (via logerrit)
 basic/qa/basic_coverage/test_tdf149622.bas |   48 +
 basic/qa/cppunit/_test_asserts.bas |   10 --
 basic/qa/cppunit/_test_asserts.vb  |   10 --
 basic/source/classes/sbxmod.cxx|3 -
 basic/source/sbx/sbxobj.cxx|   34 
 include/basic/sbxmeth.hxx  |1 
 6 files changed, 99 insertions(+), 7 deletions(-)

New commits:
commit f4ff0ed55707078868415541c4a1aebd3db1e142
Author: Mike Kaganski 
AuthorDate: Sun Jun 19 23:10:57 2022 +0300
Commit: Mike Kaganski 
CommitDate: Mon Jun 20 12:46:27 2022 +0200

tdf#149622: also clear return value before calling method from 
SbxObject::Call

Moves the custom cleanup logic to overridden SbxMethod::Clear, to simplify
the cleanup code and make sure it restores empty Variant correctly.

Change-Id: I01fa0529acd9ac787ffcda60fd6836ade4afdcb1
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/136108
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/basic/qa/basic_coverage/test_tdf149622.bas 
b/basic/qa/basic_coverage/test_tdf149622.bas
new file mode 100644
index ..5c4738c068b2
--- /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/cppunit/_test_asserts.bas 
b/basic/qa/cppunit/_test_asserts.bas
index 51442a0590a6..68865755bdcd 100644
--- a/basic/qa/cppunit/_test_asserts.bas
+++ b/basic/qa/cppunit/_test_asserts.bas
@@ -34,8 +34,8 @@ Sub Assert(Assertion As Boolean, Optional testId As String, 
Optional testComment
 If Not IsMissing(testId) Then
 testMsg = " " + testId
 End If
-If Not IsMissing(testComment) And Not (testComment = "") Then
-testMsg = testMsg + " (" + testComment + ")"
+If Not IsMissing(testComment) Then
+If Not (testComment = "") Then testMsg = testMsg + " (" + 
testComment + ")"
 End If
 
 result = result & Chr$(10) & " Failed:" & testMsg
@@ -52,6 +52,12 @@ Sub AssertEqual(actual As Variant, expected As Variant, 
testName As String)
 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
diff --git a/basic/qa/cppunit/_test_asserts.vb 
b/basic/qa/cppunit/_test_asserts.vb
index 0f1d0d88610f..2130ce02f454 100644
--- a/basic/qa/cppunit/_test_asserts.vb
+++ b/basic/qa/cppunit/_test_asserts.vb
@@ -35,8 +35,8 @@ Sub Assert(Assertion As Boolean, Optional testId As String, 
Optional testComment
 If Not IsMissing(testId) Then
 testMsg = " " + testId
 End If
-If Not IsMissing(testComment) And Not (testComment = "") Then
-testMsg = testMsg + 

[Libreoffice-commits] core.git: basic/qa basic/source

2022-06-06 Thread Andreas Heinisch (via logerrit)
 basic/qa/cppunit/test_compiler_checks.cxx |   41 ++
 basic/source/comp/scanner.cxx |7 -
 basic/source/inc/scanner.hxx  |1 
 3 files changed, 48 insertions(+), 1 deletion(-)

New commits:
commit fbce18558a58cddf910b788a67c2f2d4d25d68e9
Author: Andreas Heinisch 
AuthorDate: Fri Jun 3 09:41:05 2022 +0200
Commit: Andreas Heinisch 
CommitDate: Mon Jun 6 10:24:20 2022 +0200

tdf#149402 - BASIC: Don't extend comment if line ends in a whitespace

Change-Id: I8adf530e77a0e65329fa59ac2873b99f48befac4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135336
Tested-by: Jenkins
Reviewed-by: Andreas Heinisch 

diff --git a/basic/qa/cppunit/test_compiler_checks.cxx 
b/basic/qa/cppunit/test_compiler_checks.cxx
index e2882f3f694c..044977670e62 100644
--- a/basic/qa/cppunit/test_compiler_checks.cxx
+++ b/basic/qa/cppunit/test_compiler_checks.cxx
@@ -73,4 +73,45 @@ CPPUNIT_TEST_FIXTURE(CppUnit::TestFixture, testTdf149157_vba)
 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/source/comp/scanner.cxx b/basic/source/comp/scanner.cxx
index af87757b2282..b5a923969bfd 100644
--- a/basic/source/comp/scanner.cxx
+++ b/basic/source/comp/scanner.cxx
@@ -55,6 +55,7 @@ SbiScanner::SbiScanner(OUString _aBuf, StarBASIC* p)
 , bVBASupportOn(false)
 , bPrevLineExtentsComment(false)
 , bClosingUnderscore(false)
+, bLineEndsWithWhitespace(false)
 , bInStatement(false)
 {
 }
@@ -188,6 +189,8 @@ bool SbiScanner::readLine()
 while(nBufPos < nEnd && BasicCharClass::isWhitespace(aBuf[nEnd - 1]))
 --nEnd;
 
+// tdf#149402 - check if line ends with a whitespace
+bLineEndsWithWhitespace = (n > nEnd);
 aLine = aBuf.copy(nBufPos, nEnd - nBufPos);
 
 // Fast-forward past the line ending
@@ -665,7 +668,9 @@ PrevLineCommentLbl:
 bPrevLineExtentsComment = false;
 aSym = "REM";
 sal_Int32 nLen = aLine.getLength() - nLineIdx;
-if( bCompatible && aLine[nLineIdx + nLen - 1] == '_' && aLine[nLineIdx 
+ nLen - 2] == ' ' )
+// tdf#149402 - don't extend comment if line ends in a whitespace 
(asicCharClass::isWhitespace)
+if (bCompatible && !bLineEndsWithWhitespace && aLine[nLineIdx + nLen - 
1] == '_'
+&& aLine[nLineIdx + nLen - 2] == ' ')
 bPrevLineExtentsComment = true;
 nCol2 = nCol2 + nLen;
 nLineIdx = -1;
diff --git a/basic/source/inc/scanner.hxx b/basic/source/inc/scanner.hxx
index c10d809055a6..3f2c7e2e2cff 100644
--- a/basic/source/inc/scanner.hxx
+++ b/basic/source/inc/scanner.hxx
@@ -62,6 +62,7 @@ protected:
 bool   bVBASupportOn;   // true: OPTION VBASupport 1 otherwise 
default False
 bool   bPrevLineExtentsComment; // true: Previous line is comment and 
ends on "... _"
 bool   bClosingUnderscore;  // true: Closing underscore followed 
by end of line
+bool   bLineEndsWithWhitespace; // true: Line ends with whitespace 
(BasicCharClass::isWhitespace)
 
 bool   bInStatement;
 void   GenError( ErrCode );


[Libreoffice-commits] core.git: basic/qa basic/source

2022-05-31 Thread Andreas Heinisch (via logerrit)
 basic/qa/cppunit/test_compiler_checks.cxx |   40 ++
 basic/source/comp/scanner.cxx |2 +
 2 files changed, 42 insertions(+)

New commits:
commit b94275f6d2cb4dc28d1563fd7994251042b6d51a
Author: Andreas Heinisch 
AuthorDate: Wed May 25 12:42:23 2022 +0200
Commit: Andreas Heinisch 
CommitDate: Tue May 31 12:30:21 2022 +0200

tdf#149157 - Break multiline continuation in a comment after a new line

Change-Id: I3dd875152a6f2cfafb67f13f597c36f01a4759b4
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/135018
Tested-by: Jenkins
Reviewed-by: Andreas Heinisch 

diff --git a/basic/qa/cppunit/test_compiler_checks.cxx 
b/basic/qa/cppunit/test_compiler_checks.cxx
index 24b380ed2a9a..e2882f3f694c 100644
--- a/basic/qa/cppunit/test_compiler_checks.cxx
+++ b/basic/qa/cppunit/test_compiler_checks.cxx
@@ -33,4 +33,44 @@ CPPUNIT_TEST_FIXTURE(CppUnit::TestFixture, 
testDoubleArgument)
 CPPUNIT_ASSERT_EQUAL(ERRCODE_BASIC_VAR_DEFINED, 
aMacro.getError().StripDynamic());
 }
 
+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());
+}
+
 /* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s 
cinkeys+=0=break: */
diff --git a/basic/source/comp/scanner.cxx b/basic/source/comp/scanner.cxx
index 63d525939459..4cb2e34e3285 100644
--- a/basic/source/comp/scanner.cxx
+++ b/basic/source/comp/scanner.cxx
@@ -702,6 +702,8 @@ eoln:
 aSym = "\n";
 nColLock = 0;
 bClosingUnderscore = false;
+// tdf#149157 - break multiline continuation in a comment after a new 
line
+bPrevLineExtentsComment = false;
 return true;
 }
 }


[Libreoffice-commits] core.git: basic/qa basic/source

2022-05-07 Thread Andreas Heinisch (via logerrit)
 basic/qa/basic_coverage/test_non_ascii_names.bas|9 ++
 basic/qa/basic_coverage/test_non_ascii_names_compatible.bas |   45 
 basic/qa/cppunit/test_vba.cxx   |1 
 basic/qa/vba_tests/tdf148358_non_ascii_names.vb |   33 
 basic/source/sbx/sbxarray.cxx   |5 +
 5 files changed, 92 insertions(+), 1 deletion(-)

New commits:
commit 90d33f5945336fa46b7c02f425100af794768b15
Author: Andreas Heinisch 
AuthorDate: Tue May 3 20:38:37 2022 +0200
Commit: Andreas Heinisch 
CommitDate: Sat May 7 16:00:50 2022 +0200

tdf#148358 - Compare Non-ASCII variable names case-insensitive

Change-Id: I761eb27b16c92d58df1be8e6011fc9b94db2a59c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133774
Tested-by: Jenkins
Reviewed-by: Andreas Heinisch 

diff --git a/basic/qa/basic_coverage/test_non_ascii_names.bas 
b/basic/qa/basic_coverage/test_non_ascii_names.bas
index a9ef0f159da2..c85c9cae12cb 100644
--- a/basic/qa/basic_coverage/test_non_ascii_names.bas
+++ b/basic/qa/basic_coverage/test_non_ascii_names.bas
@@ -17,11 +17,20 @@ 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)
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 ..1abc272443c5
--- /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/cppunit/test_vba.cxx b/basic/qa/cppunit/test_vba.cxx
index 6ac6974fc081..07e4287e17b1 100644
--- a/basic/qa/cppunit/test_vba.cxx
+++ b/basic/qa/cppunit/test_vba.cxx
@@ -136,6 +136,7 @@ void VBATest::testMiscVBAFunctions()
 "strreverse.vb",
 "switch.vb",
 "tdf147089_idiv.vb",
+"tdf148358_non_ascii_names.vb",
 "timeserial.vb",
 "timevalue.vb",
 "trim.vb",
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 ..95e7105407f5
--- /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/source/sbx/sbxarray.cxx b/basic/source/sbx/sbxarray.cxx
index d8f16f5891c1..5f70345e6f2a 100644
--- a/basic/source/sbx/sbxarray.cxx
+++ b/basic/source/sbx/sbxarray.cxx
@@ -277,6 +277,8 @@ SbxVariable* SbxArray::Find( const OUString& 

[Libreoffice-commits] core.git: basic/qa basic/source

2022-05-04 Thread Stephan Bergmann (via logerrit)
 basic/qa/cppunit/test_vba.cxx |4 -
 basic/source/classes/sbxmod.cxx   |6 +-
 basic/source/runtime/methods1.cxx |  108 +++---
 basic/source/uno/namecont.cxx |2 
 4 files changed, 60 insertions(+), 60 deletions(-)

New commits:
commit b5ab864096c6b099e6a79587f881f287234278f9
Author: Stephan Bergmann 
AuthorDate: Wed May 4 22:33:03 2022 +0200
Commit: Stephan Bergmann 
CommitDate: Thu May 5 07:13:54 2022 +0200

Just use Any ctor instead of makeAny in basic

Change-Id: I21d9679064c4e68a1492d3550f083c3c91b5b43b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133848
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann 

diff --git a/basic/qa/cppunit/test_vba.cxx b/basic/qa/cppunit/test_vba.cxx
index 68d9bbaf2570..6ac6974fc081 100644
--- a/basic/qa/cppunit/test_vba.cxx
+++ b/basic/qa/cppunit/test_vba.cxx
@@ -236,8 +236,8 @@ void VBATest::testMiscOLEStuff()
 
 uno::Sequence< uno::Any > aArgs
 {
-uno::makeAny(sPath),
-uno::makeAny(OUString(o3tl::toU(pODBCDriverName)))
+uno::Any(sPath),
+uno::Any(OUString(o3tl::toU(pODBCDriverName)))
 };
 
 for ( sal_uInt32  i=0; i aArgs
 {
 uno::Any(),
-makeAny(m_xDialog),
-makeAny(m_xModel),
-makeAny(GetParent()->GetName())
+Any(m_xDialog),
+Any(m_xModel),
+Any(GetParent()->GetName())
 };
 pDocObject = new SbUnoObject( GetName(), uno::Any( 
xVBAFactory->createInstanceWithArguments( "ooo.vba.msforms.UserForm", aArgs  ) 
) );
 
diff --git a/basic/source/runtime/methods1.cxx 
b/basic/source/runtime/methods1.cxx
index 8fbe9ff65a7f..6ce744dbe034 100644
--- a/basic/source/runtime/methods1.cxx
+++ b/basic/source/runtime/methods1.cxx
@@ -2446,10 +2446,10 @@ void SbRtl_SYD(StarBASIC *, SbxArray & rPar, bool)
 
 Sequence< Any > aParams
 {
-makeAny(rPar.Get(1)->GetDouble()),
-makeAny(rPar.Get(2)->GetDouble()),
-makeAny(rPar.Get(3)->GetDouble()),
-makeAny(rPar.Get(4)->GetDouble())
+Any(rPar.Get(1)->GetDouble()),
+Any(rPar.Get(2)->GetDouble()),
+Any(rPar.Get(3)->GetDouble()),
+Any(rPar.Get(4)->GetDouble())
 };
 
 CallFunctionAccessFunction(aParams, "SYD", rPar.Get(0));
@@ -2469,9 +2469,9 @@ void SbRtl_SLN(StarBASIC *, SbxArray & rPar, bool)
 
 Sequence< Any > aParams
 {
-makeAny(rPar.Get(1)->GetDouble()),
-makeAny(rPar.Get(2)->GetDouble()),
-makeAny(rPar.Get(3)->GetDouble())
+Any(rPar.Get(1)->GetDouble()),
+Any(rPar.Get(2)->GetDouble()),
+Any(rPar.Get(3)->GetDouble())
 };
 
 CallFunctionAccessFunction(aParams, "SLN", rPar.Get(0));
@@ -2511,11 +2511,11 @@ void SbRtl_Pmt(StarBASIC *, SbxArray & rPar, bool)
 
 Sequence< Any > aParams
 {
-makeAny(rate),
-makeAny(nper),
-makeAny(pmt),
-makeAny(fv),
-makeAny(type)
+Any(rate),
+Any(nper),
+Any(pmt),
+Any(fv),
+Any(type)
 };
 
 CallFunctionAccessFunction(aParams, "Pmt", rPar.Get(0));
@@ -2556,12 +2556,12 @@ void SbRtl_PPmt(StarBASIC *, SbxArray & rPar, bool)
 
 Sequence< Any > aParams
 {
-makeAny(rate),
-makeAny(per),
-makeAny(nper),
-makeAny(pv),
-makeAny(fv),
-makeAny(type)
+Any(rate),
+Any(per),
+Any(nper),
+Any(pv),
+Any(fv),
+Any(type)
 };
 
 CallFunctionAccessFunction(aParams, "PPmt", rPar.Get(0));
@@ -2601,11 +2601,11 @@ void SbRtl_PV(StarBASIC *, SbxArray & rPar, bool)
 
 Sequence< Any > aParams
 {
-makeAny(rate),
-makeAny(nper),
-makeAny(pmt),
-makeAny(fv),
-makeAny(type)
+Any(rate),
+Any(nper),
+Any(pmt),
+Any(fv),
+Any(type)
 };
 
 CallFunctionAccessFunction(aParams, "PV", rPar.Get(0));
@@ -2631,7 +2631,7 @@ void SbRtl_NPV(StarBASIC *, SbxArray & rPar, bool)
 
 Sequence< Any > aParams
 {
-makeAny(rPar.Get(1)->GetDouble()),
+Any(rPar.Get(1)->GetDouble()),
 aValues
 };
 
@@ -2672,11 +2672,11 @@ void SbRtl_NPer(StarBASIC *, SbxArray & rPar, bool)
 
 Sequence< Any > aParams
 {
-makeAny(rate),
-makeAny(pmt),
-makeAny(pv),
-makeAny(fv),
-makeAny(type)
+Any(rate),
+Any(pmt),
+Any(pv),
+Any(fv),
+Any(type)
 };
 
 CallFunctionAccessFunction(aParams, "NPer", rPar.Get(0));
@@ -2705,8 +2705,8 @@ void SbRtl_MIRR(StarBASIC *, SbxArray & rPar, bool)
 Sequence< Any > aParams
 {
 aValues,
-makeAny(rPar.Get(2)->GetDouble()),
-makeAny(rPar.Get(3)->GetDouble())
+Any(rPar.Get(2)->GetDouble()),
+Any(rPar.Get(3)->GetDouble())
 };
 
 

[Libreoffice-commits] core.git: basic/qa

2022-04-21 Thread Xisco Fauli (via logerrit)
 basic/qa/cppunit/test_vba.cxx   |1 +
 basic/qa/vba_tests/formatpercent.vb |   31 +++
 2 files changed, 32 insertions(+)

New commits:
commit 07bf0ce4e7f04a79910cbe1340264863451f1926
Author: Xisco Fauli 
AuthorDate: Thu Apr 21 13:50:01 2022 +0200
Commit: Xisco Fauli 
CommitDate: Thu Apr 21 19:52:16 2022 +0200

tdf#148651: basic_macros: Add unittest

Change-Id: Iadbe470de5a33dc633fe8f53083520988e497df0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133255
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 

diff --git a/basic/qa/cppunit/test_vba.cxx b/basic/qa/cppunit/test_vba.cxx
index a420568f8b7c..68d9bbaf2570 100644
--- a/basic/qa/cppunit/test_vba.cxx
+++ b/basic/qa/cppunit/test_vba.cxx
@@ -94,6 +94,7 @@ void VBATest::testMiscVBAFunctions()
 "hex.vb",
 "hour.vb",
 "formatnumber.vb",
+"formatpercent.vb",
 "iif.vb",
 "instr.vb",
 "instrrev.vb",
diff --git a/basic/qa/vba_tests/formatpercent.vb 
b/basic/qa/vba_tests/formatpercent.vb
new file mode 100644
index ..0a8c551c27f1
--- /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


[Libreoffice-commits] core.git: basic/qa

2022-04-17 Thread Mike Kaganski (via logerrit)
 basic/qa/basic_coverage/test_non_ascii_names.bas |   28 +++
 1 file changed, 28 insertions(+)

New commits:
commit fe597a337914decd62480d3eba84258333116db9
Author: Mike Kaganski 
AuthorDate: Sun Apr 17 10:18:32 2022 +0300
Commit: Mike Kaganski 
CommitDate: Sun Apr 17 10:08:08 2022 +0200

Test StarBasic's native non-ASCII name syntax

Change-Id: Ie9f0cd21e59ffc1e3fbe2616e2ae7abbd0169424
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/133103
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

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 ..a9ef0f159da2
--- /dev/null
+++ b/basic/qa/basic_coverage/test_non_ascii_names.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
+  [Prüfung]
+  doUnitTest = TestUtil.GetResult()
+End Function
+
+Function [Функция]([])
+  [Функция] = [] & " and some text"
+End Function
+
+Sub [Prüfung]
+  On Error GoTo errorHandler
+
+  TestUtil.AssertEqual([Функция]("Smiley"), "Smiley and some text", 
"[Функция](""Smiley"")")
+
+  Exit Sub
+errorHandler:
+  TestUtil.ReportErrorHandler("Prüfung", Err, Error$, Erl)
+End Sub


[Libreoffice-commits] core.git: basic/qa

2022-03-31 Thread Alain Romedenne (via logerrit)
 basic/qa/basic_coverage/test_Collection_class.bas |   71 ++
 1 file changed, 71 insertions(+)

New commits:
commit da27693800bd05a2bba092800d1b6a8e5dfaae7d
Author: Alain Romedenne 
AuthorDate: Thu Jan 20 11:29:36 2022 +0100
Commit: Mike Kaganski 
CommitDate: Thu Mar 31 17:26:55 2022 +0200

Basic Collection class unit test

Change-Id: I7b67727ab8c3f7f67c2038500434ab44fa7d1949
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128544
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

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 ..06ed6b66588d
--- /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


[Libreoffice-commits] core.git: basic/qa

2022-03-31 Thread Stephan Bergmann (via logerrit)
 basic/qa/basic_coverage/test_tdf132388_ReplacePerformance.bas |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit e2ba6f5dfe989db0c287e3cb0d54e868939c
Author: Stephan Bergmann 
AuthorDate: Wed Mar 30 21:40:07 2022 +0200
Commit: Stephan Bergmann 
CommitDate: Thu Mar 31 14:06:56 2022 +0200

Adapt test to even slower builds

...like my local ASan+UBSan build, which now happened to fail once with

>  Failed: TestReplacePerformance (t = 60 s)
> Tests passed: 0
> Tests failed: 1

when the machine was under load during a parallelizing `make check`, 
following
up on 3564b5c6e93b2bf5881b359015efae351dbe8342 "Adapt test to slow builds"

Change-Id: I8f0c8f7e6e145b6d5009f48d2af865ea5caab375
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/132335
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann 

diff --git a/basic/qa/basic_coverage/test_tdf132388_ReplacePerformance.bas 
b/basic/qa/basic_coverage/test_tdf132388_ReplacePerformance.bas
index 531cdec5c622..1bb3b3de21c9 100644
--- a/basic/qa/basic_coverage/test_tdf132388_ReplacePerformance.bas
+++ b/basic/qa/basic_coverage/test_tdf132388_ReplacePerformance.bas
@@ -21,7 +21,7 @@ Sub TestReplacePerformance()
 t = Now
 s = Replace(s, " ", "*", 1, -1, 1)
 t = Now - t
-TestUtil.Assert(t <= TimeSerial(0, 1, 0), "TestReplacePerformance", 
Format(t, """t = ""[s]"" s"""))
+TestUtil.Assert(t <= TimeSerial(0, 2, 0), "TestReplacePerformance", 
Format(t, """t = ""[s]"" s"""))
 Exit Sub
 errorHandler:
 TestUtil.ReportErrorHandler("TestReplacePerformance", Err, Error$, Erl)


[Libreoffice-commits] core.git: basic/qa

2022-03-30 Thread Alain Romedenne (via logerrit)
 basic/qa/basic_coverage/test_CallByName.bas |   36 
 1 file changed, 36 insertions(+)

New commits:
commit b9b9b3afde384d2e24dcbf9a60fa9ee227576114
Author: Alain Romedenne 
AuthorDate: Mon Feb 7 18:12:57 2022 +0100
Commit: Mike Kaganski 
CommitDate: Wed Mar 30 09:04:38 2022 +0200

tdf#114263 tdf#147262 CallByName() function LibO Basic test unit

Change-Id: Ia9bd38c0da4d3f94b824ebb1f98ac912758e8d38
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129610
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/basic/qa/basic_coverage/test_CallByName.bas 
b/basic/qa/basic_coverage/test_CallByName.bas
new file mode 100644
index ..35578ee475c0
--- /dev/null
+++ b/basic/qa/basic_coverage/test_CallByName.bas
@@ -0,0 +1,36 @@
+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


[Libreoffice-commits] core.git: basic/qa

2022-03-02 Thread Andreas Heinisch (via logerrit)
 basic/qa/basic_coverage/test_cstr_method.bas |1 +
 basic/qa/vba_tests/cstr.vb   |1 +
 2 files changed, 2 insertions(+)

New commits:
commit aa54ea23233a54e32450138a07f2d6d2257149d9
Author: Andreas Heinisch 
AuthorDate: Mon Feb 14 09:49:17 2022 +0100
Commit: Andreas Heinisch 
CommitDate: Wed Mar 2 21:42:09 2022 +0100

Change the comment of the test cases to clarify the textual representation 
of the calculated string

Change-Id: I98478297a577f723864b37514bbd432a6224350d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129844
Tested-by: Jenkins
Reviewed-by: Andreas Heinisch 

diff --git a/basic/qa/basic_coverage/test_cstr_method.bas 
b/basic/qa/basic_coverage/test_cstr_method.bas
index 48b27640c275..c2ac003e8c8c 100644
--- a/basic/qa/basic_coverage/test_cstr_method.bas
+++ b/basic/qa/basic_coverage/test_cstr_method.bas
@@ -21,6 +21,7 @@ Sub verify_testCStr
 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.20001
diff --git a/basic/qa/vba_tests/cstr.vb b/basic/qa/vba_tests/cstr.vb
index dfa77b7db1f0..5eb43738f10c 100644
--- a/basic/qa/vba_tests/cstr.vb
+++ b/basic/qa/vba_tests/cstr.vb
@@ -24,6 +24,7 @@ Sub verify_testCStr()
 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.20001


[Libreoffice-commits] core.git: basic/qa basic/source

2022-02-21 Thread Andreas Heinisch (via logerrit)
 basic/qa/basic_coverage/test_tdf147089_idiv.bas |   30 +++
 basic/qa/cppunit/test_vba.cxx   |1 
 basic/qa/vba_tests/tdf147089_idiv.vb|   31 
 basic/source/comp/exprnode.cxx  |4 +--
 4 files changed, 64 insertions(+), 2 deletions(-)

New commits:
commit 3ba8b56b32c203326b776b940d20b16eb2340835
Author: Andreas Heinisch 
AuthorDate: Mon Feb 21 19:34:57 2022 +0100
Commit: Andreas Heinisch 
CommitDate: Mon Feb 21 23:10:46 2022 +0100

tdf#147089 - Round Integral Division (IDIV) literals to Integer values

Change-Id: Ia243c6117a437d0c6efb33a4e76c5e9ee539fbdc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/130302
Tested-by: Jenkins
Reviewed-by: Andreas Heinisch 

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 ..3d5e2271140c
--- /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/cppunit/test_vba.cxx b/basic/qa/cppunit/test_vba.cxx
index 868dc15891e3..a420568f8b7c 100644
--- a/basic/qa/cppunit/test_vba.cxx
+++ b/basic/qa/cppunit/test_vba.cxx
@@ -134,6 +134,7 @@ void VBATest::testMiscVBAFunctions()
 "string.vb",
 "strreverse.vb",
 "switch.vb",
+"tdf147089_idiv.vb",
 "timeserial.vb",
 "timevalue.vb",
 "trim.vb",
diff --git a/basic/qa/vba_tests/tdf147089_idiv.vb 
b/basic/qa/vba_tests/tdf147089_idiv.vb
new file mode 100644
index ..515f1e00cf63
--- /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/source/comp/exprnode.cxx b/basic/source/comp/exprnode.cxx
index 17bdbca25258..a5fd8dde3cfc 100644
--- a/basic/source/comp/exprnode.cxx
+++ b/basic/source/comp/exprnode.cxx
@@ -296,8 +296,8 @@ void SbiExprNode::FoldConstantsBinaryNode(SbiParser* 
pParser)
 {
 double nl = pLeft->nVal;
 double nr = pRight->nVal;
-// tdf#141201 - round MOD literals to Integer values
-if (eTok == MOD)
+// tdf#141201, tdf#147089 - round MOD/IDIV literals to Integer values
+if (eTok == MOD || eTok == IDIV)
 {
 nl = rtl::math::round(nl);
 nr = rtl::math::round(nr);


[Libreoffice-commits] core.git: basic/qa

2022-02-12 Thread Alain Romedenne (via logerrit)
 basic/qa/vba_tests/Err.Raise.vb |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 9654c8e4bd87259d5fd198132cfa557cd314c707
Author: Alain Romedenne 
AuthorDate: Fri Feb 4 14:30:54 2022 +0100
Commit: Mike Kaganski 
CommitDate: Sat Feb 12 10:00:15 2022 +0100

Basic compiler undetected typo

Change-Id: I53add0bbb14e084978e3582083978924d1c11c88
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129434
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/basic/qa/vba_tests/Err.Raise.vb b/basic/qa/vba_tests/Err.Raise.vb
index 914906c342c0..d7714facb3bb 100644
--- a/basic/qa/vba_tests/Err.Raise.vb
+++ b/basic/qa/vba_tests/Err.Raise.vb
@@ -45,7 +45,7 @@ catch:
 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(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$)
 


[Libreoffice-commits] core.git: basic/qa basic/source

2022-02-11 Thread Mike Kaganski (via logerrit)
 basic/qa/basic_coverage/test_declare_from_dll.bas |   36 ++
 basic/source/runtime/dllmgr-x64.cxx   |   56 +++---
 2 files changed, 46 insertions(+), 46 deletions(-)

New commits:
commit 5276177877cc53c53653a87f3038eb208a5580ab
Author: Mike Kaganski 
AuthorDate: Fri Feb 11 10:28:44 2022 +0300
Commit: Mike Kaganski 
CommitDate: Fri Feb 11 12:56:03 2022 +0100

tdf#147364: fix function signature to account to calling convention

First, the integer function result is returned in a 64-bit register (RAX),
and truncation it to sal_Int32 breaks any pointer return value.

Second, using explicit (not vararg) first function double argument would
pass it through XMM0, without also copying it to RCX (which is guaranteed
for varargs).

Ref: https://docs.microsoft.com/en-us/cpp/build/x64-calling-convention
Change-Id: I08212c44d8690d6910068b13c16af2ce899c94f2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129808
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

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 ..7bdd1b170492
--- /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 0xc005 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/source/runtime/dllmgr-x64.cxx 
b/basic/source/runtime/dllmgr-x64.cxx
index dad4bea8794a..b2ddbb890da1 100644
--- a/basic/source/runtime/dllmgr-x64.cxx
+++ b/basic/source/runtime/dllmgr-x64.cxx
@@ -512,8 +512,6 @@ ErrCode call(
 // We fake all calls as being to a varargs function,
 // as this means any floating-point argument among the first four
 // ones will end up in a XMM register where the callee expects it.
-sal_Int32 (*proc_i)(double d, ...) = reinterpret_cast(proc.proc);
-double (*proc_d)(double d, ...) = reinterpret_cast(proc.proc);
 
 sal_Int64 iRetVal = 0;
 double dRetVal = 0.0;
@@ -527,55 +525,21 @@ ErrCode call(
 case SbxBOOL:
 case SbxBYTE:
 {
-auto const st = stack.data();
-iRetVal =
-proc_i(*reinterpret_cast(st + 0),
-   *reinterpret_cast(st + 1*8),
-   *reinterpret_cast(st + 2*8),
-   *reinterpret_cast(st + 3*8),
-   *reinterpret_cast(st + 4*8),
-   *reinterpret_cast(st + 5*8),
-   *reinterpret_cast(st + 6*8),
-   *reinterpret_cast(st + 7*8),
-   *reinterpret_cast(st + 8*8),
-   *reinterpret_cast(st + 9*8),
-   *reinterpret_cast(st + 10*8),
-   *reinterpret_cast(st + 11*8),
-   *reinterpret_cast(st + 12*8),
-   *reinterpret_cast(st + 13*8),
-   *reinterpret_cast(st + 14*8),
-   *reinterpret_cast(st + 15*8),
-   *reinterpret_cast(st + 16*8),
-   *reinterpret_cast(st + 17*8),
-   *reinterpret_cast(st + 18*8),
-   *reinterpret_cast(st + 19*8));
+auto p = reinterpret_cast(proc.proc);
+auto const st = reinterpret_cast(stack.data());
+iRetVal
+= p(st[0], st[1], st[2], st[3], st[4], st[5], st[6], st[7], 
st[8], st[9], st[10],
+st[11], st[12], st[13], st[14], st[15], st[16], st[17], 
st[18], st[19]);
 break;
 }
 case SbxSINGLE:
 case SbxDOUBLE:
 {
-auto const st = stack.data();
-dRetVal =
-proc_d(*reinterpret_cast(st + 0),
-   *reinterpret_cast(st + 1*8),
-   *reinterpret_cast(st + 2*8),

[Libreoffice-commits] core.git: basic/qa basic/source

2022-02-09 Thread Andreas Heinisch (via logerrit)
 basic/qa/basic_coverage/test_cdbl_method.bas |   42 +--
 basic/qa/vba_tests/cdbl.vb   |5 +++
 basic/source/sbx/sbxscan.cxx |3 +
 3 files changed, 35 insertions(+), 15 deletions(-)

New commits:
commit a79e7dc9e8097c199e91288027861e3883e14d1b
Author: Andreas Heinisch 
AuthorDate: Mon Feb 7 22:02:30 2022 +0100
Commit: Andreas Heinisch 
CommitDate: Wed Feb 9 11:09:01 2022 +0100

tdf#146672 - CDbl: skip spaces and tabs at the end of the scanned string

Change-Id: Ib7a4e8c7145b549a5327de23549d39d11f8590cf
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129648
Tested-by: Jenkins
Reviewed-by: Andreas Heinisch 

diff --git a/basic/qa/basic_coverage/test_cdbl_method.bas 
b/basic/qa/basic_coverage/test_cdbl_method.bas
index 1c7837fcaa4b..e44c23456ff1 100644
--- a/basic/qa/basic_coverage/test_cdbl_method.bas
+++ b/basic/qa/basic_coverage/test_cdbl_method.bas
@@ -1,18 +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/.
-'
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. 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 Explicit
+Function doUnitTest() As String
+TestUtil.TestInit
+verify_testCdbl
+doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testCdbl
+On Error GoTo errorHandler
 
-Function doUnitTest as String
 ' CDBL
-If (CDbl("100") <> 100) Then
-doUnitTest = "FAIL"
-Else
-doUnitTest = "OK"
-End If
-End Function
+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/vba_tests/cdbl.vb b/basic/qa/vba_tests/cdbl.vb
index f29271f082d6..8a7d09cd5a2e 100644
--- a/basic/qa/vba_tests/cdbl.vb
+++ b/basic/qa/vba_tests/cdbl.vb
@@ -23,6 +23,11 @@ Sub verify_testCdbl()
 TestUtil.AssertEqual(CDbl(0.005 * 0.01),  0.5, "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)
diff --git a/basic/source/sbx/sbxscan.cxx b/basic/source/sbx/sbxscan.cxx
index d8c1582af52d..108b5d56c499 100644
--- a/basic/source/sbx/sbxscan.cxx
+++ b/basic/source/sbx/sbxscan.cxx
@@ -250,6 +250,9 @@ ErrCode ImpScan( const OUString& rWSrc, double& nVal, 
SbxDataType& rType,
 return ERRCODE_BASIC_CONVERSION;
 }
 #endif
+// tdf#146672 - skip whitespaces and tabs at the end of the scanned string
+while (*p == ' ' || *p == '\t')
+p++;
 if( pLen )
 *pLen = static_cast( p - pStart );
 if( !bRes )


[Libreoffice-commits] core.git: basic/qa

2022-01-31 Thread Stephan Bergmann (via logerrit)
 basic/qa/basic_coverage/test_tdf132388_ReplacePerformance.bas |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

New commits:
commit 3564b5c6e93b2bf5881b359015efae351dbe8342
Author: Stephan Bergmann 
AuthorDate: Mon Jan 31 19:53:04 2022 +0100
Commit: Stephan Bergmann 
CommitDate: Mon Jan 31 23:34:32 2022 +0100

Adapt test to slow builds

...like my local ASan+UBSan build, which kept failing with

>  Failed: TestReplacePerformance (t = 35 s)
> Tests passed: 0
> Tests failed: 1

when the machine was under load during a parallelizing `make check`

Change-Id: I59c81a61a29df7165f6fad33e3fe3da975f05ed2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129237
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann 

diff --git a/basic/qa/basic_coverage/test_tdf132388_ReplacePerformance.bas 
b/basic/qa/basic_coverage/test_tdf132388_ReplacePerformance.bas
index 8fcdd06e0773..531cdec5c622 100644
--- a/basic/qa/basic_coverage/test_tdf132388_ReplacePerformance.bas
+++ b/basic/qa/basic_coverage/test_tdf132388_ReplacePerformance.bas
@@ -14,14 +14,14 @@ End Function
 
 Sub TestReplacePerformance()
 On Error GoTo errorHandler
-' Assume the normal case to be much faster than 20 s even on slow boxes, 
and the test string
+' 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 = 1000
 s = Space(n)
 t = Now
 s = Replace(s, " ", "*", 1, -1, 1)
 t = Now - t
-TestUtil.Assert(t <= TimeSerial(0, 0, 20), "TestReplacePerformance", 
Format(t, """t = ""[s]"" s"""))
+TestUtil.Assert(t <= TimeSerial(0, 1, 0), "TestReplacePerformance", 
Format(t, """t = ""[s]"" s"""))
 Exit Sub
 errorHandler:
 TestUtil.ReportErrorHandler("TestReplacePerformance", Err, Error$, Erl)


[Libreoffice-commits] core.git: basic/qa

2022-01-31 Thread Mike Kaganski (via logerrit)
 basic/qa/basic_coverage/test_tdf132388_ReplacePerformance.bas |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

New commits:
commit 24afbaab3a916df567589d2e5c1d56eaa1990ffe
Author: Mike Kaganski 
AuthorDate: Mon Jan 31 12:02:19 2022 +0100
Commit: Mike Kaganski 
CommitDate: Mon Jan 31 14:08:17 2022 +0100

Fix format string

Change-Id: I18952bf6641175d25128b512ddfb56fd51767038
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129083
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/basic/qa/basic_coverage/test_tdf132388_ReplacePerformance.bas 
b/basic/qa/basic_coverage/test_tdf132388_ReplacePerformance.bas
index e5837ea52b28..8fcdd06e0773 100644
--- a/basic/qa/basic_coverage/test_tdf132388_ReplacePerformance.bas
+++ b/basic/qa/basic_coverage/test_tdf132388_ReplacePerformance.bas
@@ -20,8 +20,8 @@ Sub TestReplacePerformance()
 s = Space(n)
 t = Now
 s = Replace(s, " ", "*", 1, -1, 1)
-t = Now - t
-TestUtil.Assert(t <= TimeSerial(0, 0, 20), "TestReplacePerformance", 
Format(t, """t = ""s"" s"""))
+t = Now - t
+TestUtil.Assert(t <= TimeSerial(0, 0, 20), "TestReplacePerformance", 
Format(t, """t = ""[s]"" s"""))
 Exit Sub
 errorHandler:
 TestUtil.ReportErrorHandler("TestReplacePerformance", Err, Error$, Erl)


[Libreoffice-commits] core.git: basic/qa

2022-01-31 Thread Mike Kaganski (via logerrit)
 basic/qa/basic_coverage/test_tdf132388_ReplacePerformance.bas |   28 ++
 1 file changed, 28 insertions(+)

New commits:
commit 81a3d9b4bf471158de00d2fbb63fca420da94a38
Author: Mike Kaganski 
AuthorDate: Mon Jan 31 11:56:21 2022 +0300
Commit: Mike Kaganski 
CommitDate: Mon Jan 31 11:24:00 2022 +0100

tdf#132388: add unit test

I hope that this performance test is OK. I chose 20 s threshold, as
it works much faster on my system (under 4 s); it shouldn't be much
slower elsewhere; and both the original bug, and the regression that
followed the initial fix, made it execute orders of magnitute slower
(I expect hours on fast systems).

Change-Id: I75ee4c60e562473fe70a203faa94b48c5fbfb4fe
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/129203
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

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 ..e5837ea52b28
--- /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 20 s even on slow boxes, 
and the test string
+' is long enough to cause serious performance regressions make it perform 
much longer
+n = 1000
+s = Space(n)
+t = Now
+s = Replace(s, " ", "*", 1, -1, 1)
+t = Now - t
+TestUtil.Assert(t <= TimeSerial(0, 0, 20), "TestReplacePerformance", 
Format(t, """t = ""s"" s"""))
+Exit Sub
+errorHandler:
+TestUtil.ReportErrorHandler("TestReplacePerformance", Err, Error$, Erl)
+End Sub


[Libreoffice-commits] core.git: basic/qa basic/source

2022-01-08 Thread Andreas Heinisch (via logerrit)
 basic/qa/basic_coverage/test_chr_method.bas |   30 +++
 basic/qa/cppunit/test_vba.cxx   |1 
 basic/qa/vba_tests/chr.vb   |3 ++
 basic/qa/vba_tests/chrw.vb  |   31 
 basic/source/runtime/stdobj.cxx |4 +--
 5 files changed, 67 insertions(+), 2 deletions(-)

New commits:
commit 35aa82ef1c8047087e7eb76fe5abccbe48fbac1e
Author: Andreas Heinisch 
AuthorDate: Fri Jan 7 10:19:28 2022 +0100
Commit: Andreas Heinisch 
CommitDate: Sat Jan 8 11:48:32 2022 +0100

tdf#145693 - Argument name should be 'charcode' instead of 'string'

In addition, changed argument datatype from Int to Long.

Change-Id: I702e09b6b8061d7cf00dd403e4681a0ab348d4c5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128100
Tested-by: Andreas Heinisch 
Reviewed-by: Andreas Heinisch 

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 ..96d6fe3d9968
--- /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/cppunit/test_vba.cxx b/basic/qa/cppunit/test_vba.cxx
index 089da748addb..818ba1c5f4c0 100644
--- a/basic/qa/cppunit/test_vba.cxx
+++ b/basic/qa/cppunit/test_vba.cxx
@@ -63,6 +63,7 @@ void VBATest::testMiscVBAFunctions()
 "replace.vb",
 "stringplusdouble.vb",
 "chr.vb",
+"chrw.vb",
 "abs.vb",
 "array.vb",
 "asc.vb",
diff --git a/basic/qa/vba_tests/chr.vb b/basic/qa/vba_tests/chr.vb
index a561d7cd6545..5dc85a0c9157 100644
--- a/basic/qa/vba_tests/chr.vb
+++ b/basic/qa/vba_tests/chr.vb
@@ -21,6 +21,9 @@ Sub verify_testCHR()
 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:
diff --git a/basic/qa/vba_tests/chrw.vb b/basic/qa/vba_tests/chrw.vb
new file mode 100644
index ..47bd28d7e1e3
--- /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/source/runtime/stdobj.cxx b/basic/source/runtime/stdobj.cxx
index 1a2499cde2da..0bb572bbcd33 100644
--- a/basic/source/runtime/stdobj.cxx
+++ b/basic/source/runtime/stdobj.cxx
@@ -200,10 +200,10 @@ constexpr Method aMethods[] = {
 arg(u"Expression", SbxVARIANT),
 
 { u"Chr",   SbxSTRING,   1 | FUNCTION_,
SbRtl_Chr  },
-arg(u"string", SbxINTEGER),
+arg(u"charcode", SbxLONG),
 
 { u"ChrW",  SbxSTRING,   1 | FUNCTION_ | COMPATONLY_, 
SbRtl_ChrW  },
-arg(u"string", SbxINTEGER),
+arg(u"charcode", SbxLONG),
 
 { u"CInt",  SbxINTEGER,  1 | FUNCTION_,
SbRtl_CInt },
 arg(u"expression", SbxVARIANT),


[Libreoffice-commits] core.git: basic/qa

2022-01-07 Thread Andreas Heinisch (via logerrit)
 0 files changed

New commits:
commit 260a2036d688afddc6e6e477764e1196cc915194
Author: Andreas Heinisch 
AuthorDate: Fri Jan 7 10:16:02 2022 +0100
Commit: Andreas Heinisch 
CommitDate: Fri Jan 7 12:17:50 2022 +0100

tdf#130426 - Rename file for tdf#145693

Change-Id: I1435f3e8c8ecf41ecd6b2766e19009c6b1783326
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/128099
Tested-by: Jenkins
Reviewed-by: Andreas Heinisch 

diff --git a/basic/qa/basic_coverage/test_chr_method.bas 
b/basic/qa/basic_coverage/test_chr_overflow_method.bas
similarity index 100%
rename from basic/qa/basic_coverage/test_chr_method.bas
rename to basic/qa/basic_coverage/test_chr_overflow_method.bas


[Libreoffice-commits] core.git: basic/qa basic/source

2021-12-28 Thread Andreas Heinisch (via logerrit)
 basic/qa/basic_coverage/test_booltypename.bas |   46 ++
 basic/qa/cppunit/test_vba.cxx |1 
 basic/qa/vba_tests/booltypename.vb|   16 +++--
 basic/source/sbx/sbxvalue.cxx |3 +
 4 files changed, 62 insertions(+), 4 deletions(-)

New commits:
commit 565a5fdee3c00b383b4d36180be845d48fd42556
Author: Andreas Heinisch 
AuthorDate: Tue Dec 28 13:01:22 2021 +0100
Commit: Andreas Heinisch 
CommitDate: Tue Dec 28 19:54:58 2021 +0100

tdf#145960 - Return type of boolean operators should be of type boolean

In addition, added missing vba test to the test routine.

Change-Id: I3ee837e1eab30f10e0a4169d11014f9b6574ad1c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/127631
Tested-by: Jenkins
Reviewed-by: Andreas Heinisch 

diff --git a/basic/qa/basic_coverage/test_booltypename.bas 
b/basic/qa/basic_coverage/test_booltypename.bas
new file mode 100644
index ..f8ed1f13e2a9
--- /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/cppunit/test_vba.cxx b/basic/qa/cppunit/test_vba.cxx
index 87d29f63e464..089da748addb 100644
--- a/basic/qa/cppunit/test_vba.cxx
+++ b/basic/qa/cppunit/test_vba.cxx
@@ -67,6 +67,7 @@ void VBATest::testMiscVBAFunctions()
 "array.vb",
 "asc.vb",
 "atn.vb",
+"booltypename.vb",
 "cbool.vb",
 "cdate.vb",
 "cdbl.vb",
diff --git a/basic/qa/vba_tests/booltypename.vb 
b/basic/qa/vba_tests/booltypename.vb
index 8c1fd17c211b..202c2370e712 100644
--- a/basic/qa/vba_tests/booltypename.vb
+++ b/basic/qa/vba_tests/booltypename.vb
@@ -18,9 +18,9 @@ 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(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)")
@@ -31,6 +31,16 @@ Sub verify_testTypeNameBoolean()
 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)")
+

[Libreoffice-commits] core.git: basic/qa basic/source officecfg/registry

2021-12-09 Thread Tor Lillqvist (via logerrit)
 basic/qa/basic_coverage/test_types_conversion.bas |   30 --
 basic/source/inc/rtlproto.hxx |1 
 basic/source/runtime/methods1.cxx |   10 +++
 basic/source/sbx/sbxbool.cxx  |3 -
 basic/source/sbx/sbxbyte.cxx  |3 -
 basic/source/sbx/sbxchar.cxx  |3 -
 basic/source/sbx/sbxdbl.cxx   |3 -
 basic/source/sbx/sbxint.cxx   |7 +-
 basic/source/sbx/sbxlng.cxx   |3 -
 basic/source/sbx/sbxscan.cxx  |3 -
 basic/source/sbx/sbxsng.cxx   |3 -
 basic/source/sbx/sbxuint.cxx  |3 -
 basic/source/sbx/sbxulng.cxx  |3 -
 basic/source/sbx/sbxvalue.cxx |5 +
 basic/source/sbx/sbxvar.cxx   |5 +
 officecfg/registry/schema/org/openoffice/Office/Scripting.xcs |   26 
 16 files changed, 90 insertions(+), 21 deletions(-)

New commits:
commit 47aabde053a1472dc32770da29d68c8de5bd7919
Author: Tor Lillqvist 
AuthorDate: Thu Dec 2 12:37:07 2021 +0200
Commit: Mike Kaganski 
CommitDate: Thu Dec 9 12:06:49 2021 +0100

Make the tdf#97983 changes to BASIC optional

If you want to keep the string to floating point conversion semantics
in BASIC as they were in LibreOffice 6, you can either set the
LIBREOFFICE6FLOATINGPOINTMODE environment variable to some non-empty
value, or set the org.openoffice.Office.Scripting/Basic/Compatibility/
UseLibreOffice6FloatingPointConversion flag in the Expert
Configuration. (Or use a registry modification file with that effect.)

Adapt the relevant unit test accordingly. Thanks to Mike Kaganski for
showing how to access the setting in the LibreOffice registry from
Basic.

Change-Id: I13d6d5d834e1bb81ef8df489db2b1da79f01dfc5
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/125756
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/basic/qa/basic_coverage/test_types_conversion.bas 
b/basic/qa/basic_coverage/test_types_conversion.bas
index 1b923ad8c197..2d931145336c 100644
--- a/basic/qa/basic_coverage/test_types_conversion.bas
+++ b/basic/qa/basic_coverage/test_types_conversion.bas
@@ -11,6 +11,21 @@ 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
@@ -39,10 +54,17 @@ Function doUnitTest() As String
 nVal = " -123.456 "
 AssertTest(nVal = -123.456)
 
-' Wrong decimal separator (interpreted as group separator)
-StartTest()
-nVal = " -123,456 "
-AssertTest(nVal = -123456)
+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"
diff --git a/basic/source/inc/rtlproto.hxx b/basic/source/inc/rtlproto.hxx
index b20fa9afab45..06f0bd8b0c30 100644
--- a/basic/source/inc/rtlproto.hxx
+++ b/basic/source/inc/rtlproto.hxx
@@ -354,6 +354,7 @@ extern void SbRtl_CDec(StarBASIC * pBasic, SbxArray & rPar, 
bool bWrite);
 
 extern void SbRtl_Partition(StarBASIC * pBasic, SbxArray & rPar, bool bWrite);
 
+extern bool LibreOffice6FloatingPointMode();
 extern double Now_Impl();
 extern void Wait_Impl( bool bDurationBased, SbxArray& rPar );
 
diff --git a/basic/source/runtime/methods1.cxx 
b/basic/source/runtime/methods1.cxx
index 117e84d73000..8e78776bc7f8 100644
--- 

[Libreoffice-commits] core.git: basic/qa i18nutil/source

2021-11-10 Thread Eike Rathke (via logerrit)
 basic/qa/vba_tests/collection.vb   |   10 ++
 i18nutil/source/utility/casefolding_data.h |   10 ++
 2 files changed, 12 insertions(+), 8 deletions(-)

New commits:
commit 07a2afa4904ac51c9c61aaf41a9d6c7d41126531
Author: Eike Rathke 
AuthorDate: Wed Nov 10 16:00:42 2021 +0100
Commit: Eike Rathke 
CommitDate: Thu Nov 11 01:27:47 2021 +0100

Resolves: tdf#110003 tdf#143128 handle lowercase ß vs uppercase ẞ folding

Change lowercase ß U+00DF LATIN SMALL LETTER SHARP S from
LowerToUpper, ToUpper: SS
ToTitle: Ss
FullFolding: ss
to
LowerToUpper, ToUpper: ẞ  U+1E9E
ToTitle: ẞ  U+1E9E
FullFolding: ss

Add uppercase ẞ U+1E9E LATIN CAPITAL LETTER SHARP S
UpperToLower, ToLower: ß  U+00DF
FullFolding: ss

Adjust BASIC Collection test to new reality.

Change-Id: I198e06985b81a71e5de94bf7fab7a0dbaf10baef
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/124988
Reviewed-by: Eike Rathke 
Tested-by: Jenkins

diff --git a/basic/qa/vba_tests/collection.vb b/basic/qa/vba_tests/collection.vb
index 0f0c47a262d9..774f3c4c7904 100644
--- a/basic/qa/vba_tests/collection.vb
+++ b/basic/qa/vba_tests/collection.vb
@@ -56,16 +56,18 @@ Sub verify_testCollection()
 ' 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.
-TestUtil.AssertEqual(b.Count, 3, "b.Count")
+' 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.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(""ẞ"")")
-TestUtil.AssertEqual(b.Item("ß"), 4, "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(""ß"")")
+TestUtil.AssertEqual(b.Item("ß"), 3, "b.Item(""ß"")")
 
 Exit Sub
 errorHandler:
diff --git a/i18nutil/source/utility/casefolding_data.h 
b/i18nutil/source/utility/casefolding_data.h
index debacdf8c40d..3ea677e83405 100644
--- a/i18nutil/source/utility/casefolding_data.h
+++ b/i18nutil/source/utility/casefolding_data.h
@@ -307,7 +307,7 @@ const Value CaseMappingValue[] = {
 {0x6a, 0x1E81}, {0x15, 0x1E80}, {0x6a, 0x1E83}, {0x15, 0x1E82}, {0x6a, 
0x1E85}, {0x15, 0x1E84}, {0x6a, 0x1E87}, {0x15, 0x1E86}, // 1e80 - 1e87
 {0x6a, 0x1E89}, {0x15, 0x1E88}, {0x6a, 0x1E8B}, {0x15, 0x1E8A}, {0x6a, 
0x1E8D}, {0x15, 0x1E8C}, {0x6a, 0x1E8F}, {0x15, 0x1E8E}, // 1e88 - 1e8f
 {0x6a, 0x1E91}, {0x15, 0x1E90}, {0x6a, 0x1E93}, {0x15, 0x1E92}, {0x6a, 
0x1E95}, {0x15, 0x1E94}, {0xd5, 0x004F}, {0xd5, 0x0051}, // 1e90 - 1e97
-{0xd5, 0x0053}, {0xd5, 0x0055}, {0xd5, 0x0057}, {0xf5, 0x0059}, {0x00, 
0x}, {0x00, 0x}, {0x00, 0x}, {0x00, 0x}, // 1e98 - 1e9f
+{0xd5, 0x0053}, {0xd5, 0x0055}, {0xd5, 0x0057}, {0xf5, 0x0059}, {0x00, 
0x}, {0x00, 0x}, {0xea, 0x015E}, {0x00, 0x}, // 1e98 - 1e9f
 {0x6a, 0x1EA1}, {0x15, 0x1EA0}, {0x6a, 0x1EA3}, {0x15, 0x1EA2}, {0x6a, 
0x1EA5}, {0x15, 0x1EA4}, {0x6a, 0x1EA7}, {0x15, 0x1EA6}, // 1ea0 - 1ea7
 {0x6a, 0x1EA9}, {0x15, 0x1EA8}, {0x6a, 0x1EAB}, {0x15, 0x1EAA}, {0x6a, 
0x1EAD}, {0x15, 0x1EAC}, {0x6a, 0x1EAF}, {0x15, 0x1EAE}, // 1ea8 - 1eaf
 {0x6a, 0x1EB1}, {0x15, 0x1EB0}, {0x6a, 0x1EB3}, {0x15, 0x1EB2}, {0x6a, 
0x1EB5}, {0x15, 0x1EB4}, {0x6a, 0x1EB7}, {0x15, 0x1EB6}, // 1eb0 - 1eb7
@@ -700,9 +700,9 @@ Mapping const CaseMappingExtra[] = {
 {0x8a, 0, {0x, 0x, 0x}}, // 0x00cc (8   0x0008)
 {0x60, 1, {0x00ED, 0x, 0x}}, // 0x00cd (9   0x0009)
 {0x8a, 0, {0x, 0x, 0x}}, // 0x00cd (10  0x000A)
-{0x05, 2, {0x0053, 0x0053, 0x}}, // 0x00df (11  0x000B)
-{0x10, 2, {0x0053, 0x0073, 0x}}, // 0x00df (12  0x000C)
-{0x40, 2, {0x0073, 0x0073, 0x}}, // 0x00df (13  0x000D)
+{0x15, 1, {0x1E9E, 0x, 0x}}, // 0x00df (11  0x000B)
+{0x40, 2, {0x0073, 0x0073, 0x}}, // 0x00df (12  0x000C)
+{0x20, 1, {0x00DF, 0x, 0x}}, // 0x00df (13  0x000D) not hit, 
CaseMappingValue.type is 0xd5=0x80+0x55 not 0xf5=0x80+0x75, but keep slot
 {0x60, 1, {0x0129, 0x, 0x}}, // 0x0128 (14  0x000E)
 {0x8a, 0, {0x, 0x, 0x}}, // 0x0128 (15  0x000F)
 {0x60, 1, {0x012F, 0x, 0x}}, // 0x012e (16  0x0010)
@@ -1039,6 +1039,8 @@ Mapping const CaseMappingExtra[] = {
 {0x05, 2, {0x0544, 0x053D, 0x}}, // 0xfb17 (347 0x015B)
 {0x10, 2, {0x0544, 0x056D, 0x}}, // 0xfb17 (348 0x015C)
 {0x40, 2, {0x0574, 0x056D, 0x}}, // 0xfb17 (349 0x015D)
+{0x2a, 1, {0x00DF, 0x, 

[Libreoffice-commits] core.git: basic/qa basic/source

2021-10-20 Thread Andreas Heinisch (via logerrit)
 basic/qa/basic_coverage/test_tdf125637.bas |   34 +
 basic/qa/cppunit/test_scanner.cxx  |3 +-
 basic/source/comp/scanner.cxx  |   16 -
 basic/source/inc/scanner.hxx   |1 
 4 files changed, 42 insertions(+), 12 deletions(-)

New commits:
commit 67c15910606575b862410179698f81e7a598aa44
Author: Andreas Heinisch 
AuthorDate: Tue Oct 19 20:09:21 2021 +0200
Commit: Andreas Heinisch 
CommitDate: Wed Oct 20 20:27:59 2021 +0200

tdf#125637 - Correctly hand names ending with an underscore

If a name is ending with an underscore at the end of the line, it won't
be recognized correctly and it will be wrongly interpreted as the
respective name without the underscore at the end. Instead of changing
the macro source, use a flag in order to correclty identify the line end.

Change-Id: I6f933d7382b510bffed3e2692d32c232b7084624
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123833
Tested-by: Jenkins
Reviewed-by: Andreas Heinisch 

diff --git a/basic/qa/basic_coverage/test_tdf125637.bas 
b/basic/qa/basic_coverage/test_tdf125637.bas
new file mode 100644
index ..e4eff75c27b3
--- /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/cppunit/test_scanner.cxx 
b/basic/qa/cppunit/test_scanner.cxx
index 6459ab45f6b1..6559b3e35d48 100644
--- a/basic/qa/cppunit/test_scanner.cxx
+++ b/basic/qa/cppunit/test_scanner.cxx
@@ -297,7 +297,8 @@ void ScannerTest::testAlphanum()
 CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
 CPPUNIT_ASSERT_EQUAL(OUString("joxclk_"), symbols[0].text);
 CPPUNIT_ASSERT_EQUAL(SbxVARIANT, symbols[0].type);
-CPPUNIT_ASSERT_EQUAL(OUString("joxclk "), source7); // Change the trailing 
'_' to a ' '
+// 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);
 
diff --git a/basic/source/comp/scanner.cxx b/basic/source/comp/scanner.cxx
index 9523597721bd..a0d9b9ab6c76 100644
--- a/basic/source/comp/scanner.cxx
+++ b/basic/source/comp/scanner.cxx
@@ -52,6 +52,7 @@ SbiScanner::SbiScanner(const OUString& rBuf, StarBASIC* p)
 , bCompatible(false)
 , bVBASupportOn(false)
 , bPrevLineExtentsComment(false)
+, bClosingUnderscore(false)
 , bInStatement(false)
 {
 }
@@ -287,19 +288,11 @@ bool SbiScanner::NextSym()
 if(nCol < aLine.getLength() && bCompatible && 
aSym.equalsIgnoreAsciiCase("go"))
 scanGoto();
 
-// replace closing '_' by space when end of line is following
-// (wrong line continuation otherwise)
+// tdf#125637 - check for closing underscore
 if (nCol == aLine.getLength() && aLine[nCol - 1] == '_')
 {
-// We are going to modify a potentially shared string, so force
-// a copy, so that aSym is not modified by the following operation
-OUString aSymCopy( aSym.getStr(), aSym.getLength() );
-aSym = aSymCopy;
-
-// HACK: modifying a potentially shared string here!
-const_cast(aLine.getStr())[nLineIdx - 1] = ' ';
+bClosingUnderscore = true;
 }
-
 // type recognition?
 // don't test the exclamation mark
 // if there's a symbol behind it
@@ -686,7 +679,7 @@ PrevLineCommentLbl:
 
 
 eoln:
-if( nCol && aLine[--nLineIdx] == '_' )
+if (nCol && aLine[--nLineIdx] == '_' && !bClosingUnderscore)
 {
 nLineIdx = -1;
 bool bRes = NextSym();
@@ -707,6 +700,7 @@ eoln:
 nCol2 = nOldCol2;
 aSym = "\n";
 nColLock = 0;
+bClosingUnderscore = false;
 return true;
 }
 }
diff --git a/basic/source/inc/scanner.hxx b/basic/source/inc/scanner.hxx
index 19ee31947120..39dda9fa391c 100644
--- a/basic/source/inc/scanner.hxx
+++ b/basic/source/inc/scanner.hxx
@@ -61,6 +61,7 @@ 

[Libreoffice-commits] core.git: basic/qa

2021-10-19 Thread Stephan Bergmann (via logerrit)
 basic/qa/cppunit/test_vba.cxx |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

New commits:
commit af2d15a494b42faf4367096af07c7a2b2d22642e
Author: Stephan Bergmann 
AuthorDate: Tue Oct 19 07:56:00 2021 +0200
Commit: Stephan Bergmann 
CommitDate: Tue Oct 19 09:14:47 2021 +0200

Fix Windows build

...after cf3971a9414f52b116c1c21f267128ffa67f171b "Simplify Sequence in b*"

Change-Id: If8650faa7a45258729e54b3df37e9084221babfc
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123792
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann 

diff --git a/basic/qa/cppunit/test_vba.cxx b/basic/qa/cppunit/test_vba.cxx
index e4436632fd84..87d29f63e464 100644
--- a/basic/qa/cppunit/test_vba.cxx
+++ b/basic/qa/cppunit/test_vba.cxx
@@ -232,8 +232,8 @@ void VBATest::testMiscOLEStuff()
 
 uno::Sequence< uno::Any > aArgs
 {
-makeAny(sPath),
-makeAny(OUString(o3tl::toU(pODBCDriverName)))
+uno::makeAny(sPath),
+uno::makeAny(OUString(o3tl::toU(pODBCDriverName)))
 };
 
 for ( sal_uInt32  i=0; i

[Libreoffice-commits] core.git: basic/qa basic/source

2021-10-07 Thread Andreas Heinisch (via logerrit)
 basic/qa/basic_coverage/test_split_method.bas |   45 +++-
 basic/qa/cppunit/test_vba.cxx |1 
 basic/qa/vba_tests/split.vb   |   57 ++
 basic/source/runtime/methods1.cxx |6 ++
 4 files changed, 99 insertions(+), 10 deletions(-)

New commits:
commit e090afc29bdff4303f1235080fb169011220be4a
Author: Andreas Heinisch 
AuthorDate: Tue Oct 5 21:10:22 2021 +0200
Commit: Andreas Heinisch 
CommitDate: Thu Oct 7 08:21:58 2021 +0200

tdf#144924 - Change return type of array elements of the split function

If VBA is not enabled, allow the assignment of variables with different
data types to the individual array elements created by the split
function.

Change-Id: I7bdd432cdebbfded5f7fb3acc0216474eb6b6821
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/123122
Tested-by: Andreas Heinisch 
Reviewed-by: Andreas Heinisch 

diff --git a/basic/qa/basic_coverage/test_split_method.bas 
b/basic/qa/basic_coverage/test_split_method.bas
index 2742fcf52301..52ba91fe3a65 100644
--- a/basic/qa/basic_coverage/test_split_method.bas
+++ b/basic/qa/basic_coverage/test_split_method.bas
@@ -7,28 +7,53 @@
 
 Option Explicit
 
-Function doUnitTest as String
+Function doUnitTest() As String
+TestUtil.TestInit
+verify_testSplit
+doUnitTest = TestUtil.GetResult()
+End Function
 
-doUnitTest = "FAIL"
+Sub verify_testSplit
+On Error GoTo errorHandler
 
 ' SPLIT
-If ( Split( "Hello world" )(1) <> "world" ) Then Exit Function
+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", "/")
-If ( arr(0) <> "a" Or arr(1) <> "b" ) Then Exit Function
+TestUtil.AssertEqual(arr(0), "a", "Split(""a/b"", ""/"")(0)")
+TestUtil.AssertEqual(arr(1), "b", "Split(""a/b"", ""/"")(1)")
 ReDim Preserve arr(1)
-If ( arr(0) <> "a" Or arr(1) <> "b" ) Then Exit Function
+TestUtil.AssertEqual(arr(0), "a", "ReDim Preserve arr(1)(0)")
+TestUtil.AssertEqual(arr(1), "b", "ReDim Preserve arr(1)(1)")
 ReDim arr(1)
-If ( arr(0) <> "" Or arr(1) <> "" ) Then Exit Function
+TestUtil.AssertEqual(arr(0), "", "ReDim arr(1)(0)")
+TestUtil.AssertEqual(arr(1), "", "ReDim arr(1)(1)")
+
 arr(0) = "a"
 arr(1) = "b"
-If ( arr(0) <> "a" Or arr(1) <> "b" ) Then Exit Function
+TestUtil.AssertEqual(arr(0), "a", "arr(0)")
+TestUtil.AssertEqual(arr(1), "b", "arr(1)")
 ReDim Preserve arr(1)
-If ( arr(0) <> "a" Or arr(1) <> "b" ) Then Exit Function
+TestUtil.AssertEqual(arr(0), "a", "ReDim Preserve arr(1)(0) after 
assignment")
+TestUtil.AssertEqual(arr(1), "b", "ReDim Preserve arr(1)(1) after 
assignment")
 
-doUnitTest = "OK"
+' tdf#144924 - allow the assignment of different data types to the 
individual elements
+Dim splitArr
+splitArr = Split("a/b&/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
 
-End Function
+Exit Sub
+errorHandler:
+TestUtil.ReportErrorHandler("verify_testSplit", Err, Error$, Erl)
+End Sub
diff --git a/basic/qa/cppunit/test_vba.cxx b/basic/qa/cppunit/test_vba.cxx
index 036d3b52cfe4..9ea572201a30 100644
--- a/basic/qa/cppunit/test_vba.cxx
+++ b/basic/qa/cppunit/test_vba.cxx
@@ -125,6 +125,7 @@ void VBATest::testMiscVBAFunctions()
 "sgn.vb",
 "sin.vb",
 "space.vb",
+"split.vb",
 "sqr.vb",
 "str.vb",
 "strcomp.vb",
diff --git a/basic/qa/vba_tests/split.vb b/basic/qa/vba_tests/split.vb
new file mode 100644
index ..56d4522180b0
--- /dev/null
+++ b/basic/qa/vba_tests/split.vb
@@ -0,0 +1,57 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Option VBASupport 1
+Option Explicit
+
+Function doUnitTest() As String
+TestUtil.TestInit
+verify_testSplit
+doUnitTest = TestUtil.GetResult()
+End Function
+
+Sub verify_testSplit
+On Error GoTo errorHandler
+
+' SPLIT
+TestUtil.AssertEqual(Split( "Hello world" )(1), "world", "Split( ""Hello 
world"" )(1)")
+
+' tdf#123025 - split function sets the datatype of the array to empty,
+' preventing any subsequent 

[Libreoffice-commits] core.git: basic/qa basic/source

2021-09-30 Thread Andreas Heinisch (via logerrit)
 basic/qa/basic_coverage/test_cstr_method.bas |   32 -
 basic/qa/vba_tests/cstr.vb   |   10 +
 basic/source/sbx/sbxscan.cxx |  157 +--
 3 files changed, 43 insertions(+), 156 deletions(-)

New commits:
commit ed166025123a403fbd679377387a45e097f09d6e
Author: Andreas Heinisch 
AuthorDate: Wed Sep 29 18:19:35 2021 +0200
Commit: Andreas Heinisch 
CommitDate: Thu Sep 30 09:26:54 2021 +0200

tdf#143575, tdf#143974 - Use rtl::math::doubleToUString to convert numbers 
to strings

Change-Id: I1427dbd49af680a1bf386410977c9cb2b0a3961e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122831
Reviewed-by: Mike Kaganski 
Reviewed-by: Andreas Heinisch 
Tested-by: Andreas Heinisch 

diff --git a/basic/qa/basic_coverage/test_cstr_method.bas 
b/basic/qa/basic_coverage/test_cstr_method.bas
index ba326770198e..48b27640c275 100644
--- a/basic/qa/basic_coverage/test_cstr_method.bas
+++ b/basic/qa/basic_coverage/test_cstr_method.bas
@@ -8,11 +8,29 @@
 
 Option Explicit
 
-Function doUnitTest as String
-' CSTR
-If (CStr(100) <> "100") Then
-doUnitTest = "FAIL"
-Else
-doUnitTest = "OK"
-End If
+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
+' Without the fix in place, this test would have failed with:
+' - Expected: 691.2
+' - Actual  : 691.20001
+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.1
+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/cstr.vb b/basic/qa/vba_tests/cstr.vb
index 55e1ab049fab..dfa77b7db1f0 100644
--- a/basic/qa/vba_tests/cstr.vb
+++ b/basic/qa/vba_tests/cstr.vb
@@ -23,6 +23,16 @@ Sub verify_testCStr()
 TestUtil.AssertEqual(CStr(n),   "437.324", "CStr(n)")
 TestUtil.AssertEqual(CStr(500), "500", "CStr(500)")
 
+' tdf#143575 - round string to their nearest double representation
+' Without the fix in place, this test would have failed with:
+' - Expected: 691.2
+' - Actual  : 691.20001
+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.1
+TestUtil.AssertEqual(CStr(123.4 + 567.8), "691.2", "CStr(123.4 + 567.8)")
+
 Exit Sub
 errorHandler:
 TestUtil.ReportErrorHandler("verify_testCStr", Err, Error$, Erl)
diff --git a/basic/source/sbx/sbxscan.cxx b/basic/source/sbx/sbxscan.cxx
index a017b66744a9..c3edcac0810e 100644
--- a/basic/source/sbx/sbxscan.cxx
+++ b/basic/source/sbx/sbxscan.cxx
@@ -298,134 +298,6 @@ ErrCode SbxValue::ScanNumIntnl( const OUString& rSrc, 
double& nVal, bool bSingle
 return nRetError;
 }
 
-
-const double roundArray[] = {
-5.0e+0, 0.5e+0, 0.5e-1, 0.5e-2, 0.5e-3, 0.5e-4, 0.5e-5, 0.5e-6, 0.5e-7,
-0.5e-8, 0.5e-9, 0.5e-10,0.5e-11,0.5e-12,0.5e-13,0.5e-14,0.5e-15 };
-
-/*
-|*
-|*  void myftoa( double, char *, short, short, bool, bool )
-|*
-|*  description:conversion double --> ASCII
-|*  parameters: double  the number
-|*  char *  target buffer
-|*  short   number of positions after decimal 
point
-|*  short   range of the exponent ( 0=no E )
-|*  booltrue: with 1000-separators
-|*  booltrue: output without formatting
-|*
- */
-
-static void myftoa( double nNum, char * pBuf, short nPrec, short nExpWidth )
-{
-
-short nExp = 0;
-short nDig = nPrec + 1;
-short nDec; // number of positions before decimal 
point
-int i;
-
-sal_Unicode cDecimalSep, cThousandSep, cDecimalSepAlt;
-ImpGetIntntlSep( cDecimalSep, cThousandSep, cDecimalSepAlt );
-
-// compute exponent
-nExp = 0;
-if( nNum > 0.0 )
-{
-while( nNum <   1.0 )
-{
-nNum *= 10.0;
-nExp--;
-}
-while( nNum >= 10.0 )
-{
-nNum /= 10.0;
-nExp++;
-}
-}
-if( !nPrec )
-nDig = nExp + 1;
-
-// round number
-if( (nNum += roundArray [std::min( nDig, 16 )] ) >= 10.0 )
-{
-nNum = 1.0;
-++nExp;
-if( !nExpWidth ) ++nDig;
-}
-
-// determine positions before decimal point
-if( !nExpWidth )
-{
-if( nExp < 0 )
- 

[Libreoffice-commits] core.git: basic/qa basic/source

2021-09-27 Thread Andreas Heinisch (via logerrit)
 basic/qa/vba_tests/constants.vb |   11 +++
 basic/source/comp/parser.cxx|   18 ++
 2 files changed, 29 insertions(+)

New commits:
commit d6063f416c78f30f1fb717f3ab05f9691bb3461d
Author: Andreas Heinisch 
AuthorDate: Sat Sep 25 16:42:37 2021 +0200
Commit: Andreas Heinisch 
CommitDate: Mon Sep 27 15:31:54 2021 +0200

tdf#131563 - Add vba color constants

Change-Id: I59bcd11b5da1450fced77671c2cf6ed44e299a06
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/122607
Tested-by: Jenkins
Reviewed-by: Andreas Heinisch 

diff --git a/basic/qa/vba_tests/constants.vb b/basic/qa/vba_tests/constants.vb
index d03fdda95afe..be7add515e83 100644
--- a/basic/qa/vba_tests/constants.vb
+++ b/basic/qa/vba_tests/constants.vb
@@ -25,6 +25,17 @@ Sub verify_testConstants()
 TestUtil.AssertEqual(vbNewLine, vbLf, "vbNewline")
 End If
 
+' tdf#131563 - check for vba color constants
+' See 
https://docs.microsoft.com/en-us/office/vba/language/reference/user-interface-help/color-constants
+TestUtil.AssertEqual(vbBlack,   RGB(0, 0, 0),   "vbBlack")
+TestUtil.AssertEqual(vbRed, RGB(255, 0, 0), "vbRed")
+TestUtil.AssertEqual(vbGreen,   RGB(0, 255, 0), "vbGreen")
+TestUtil.AssertEqual(vbYellow,  RGB(255, 255, 0),   "vbYellow")
+TestUtil.AssertEqual(vbBlue,RGB(0, 0, 255), "vbBlue")
+TestUtil.AssertEqual(vbMagenta, RGB(255, 0, 255),   "vbMagenta")
+TestUtil.AssertEqual(vbCyan,RGB(0, 255, 255),   "vbCyan")
+TestUtil.AssertEqual(vbWhite,   RGB(255, 255, 255), "vbWhite")
+
 Exit Sub
 errorHandler:
 TestUtil.ReportErrorHandler("verify_testConstants", Err, Error$, Erl)
diff --git a/basic/source/comp/parser.cxx b/basic/source/comp/parser.cxx
index 6ebc2208ae42..dc0b3b16b348 100644
--- a/basic/source/comp/parser.cxx
+++ b/basic/source/comp/parser.cxx
@@ -841,8 +841,26 @@ static void addStringConst( SbiSymPool& rPool, const 
OUString& pSym, const OUStr
 rPool.Add( pConst );
 }
 
+static void addNumericConst(SbiSymPool& rPool, const OUString& pSym, double 
nVal)
+{
+SbiConstDef* pConst = new SbiConstDef(pSym);
+pConst->Set(nVal, SbxDOUBLE);
+rPool.Add(pConst);
+}
+
 void SbiParser::AddConstants()
 {
+// tdf#131563 - add vba color constants
+// See 
https://docs.microsoft.com/en-us/office/vba/language/reference/user-interface-help/color-constants
+addNumericConst(aPublics, "vbBlack", 0x0);
+addNumericConst(aPublics, "vbRed", 0xFF);
+addNumericConst(aPublics, "vbGreen", 0xFF00);
+addNumericConst(aPublics, "vbYellow", 0x);
+addNumericConst(aPublics, "vbBlue", 0xFF);
+addNumericConst(aPublics, "vbMagenta", 0xFF00FF);
+addNumericConst(aPublics, "vbCyan", 0x00);
+addNumericConst(aPublics, "vbWhite", 0xFF);
+
 // #113063 Create constant RTL symbols
 addStringConst( aPublics, "vbCr", "\x0D" );
 addStringConst( aPublics, "vbCrLf", "\x0D\x0A" );


[Libreoffice-commits] core.git: basic/qa basic/source

2021-09-10 Thread Andreas Heinisch (via logerrit)
 basic/qa/basic_coverage/test_optional_paramters_basic.bas  |   63 
++
 basic/qa/basic_coverage/test_optional_paramters_compatible.bas |   63 
++
 basic/source/runtime/runtime.cxx   |   29 
 basic/source/sbx/sbxvar.cxx|3 
 4 files changed, 158 insertions(+)

New commits:
commit e32d864dbe086d630a8b17c2d376e320aee0253a
Author: Andreas Heinisch 
AuthorDate: Tue Sep 7 22:23:43 2021 +0200
Commit: Andreas Heinisch 
CommitDate: Fri Sep 10 13:28:33 2021 +0200

tdf#144353 - Handling of missing optional parameters

Don't assign a missing optional variable to a property and don't allow
the computation/comparision including missing optional attributes.

In the previous cases a ERRCODE_BASIC_NOT_OPTIONAL is raised.

Change-Id: Iab391286fcace16c271ae511304075e2a0c5c651
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121794
Tested-by: Jenkins
Reviewed-by: Andreas Heinisch 

diff --git a/basic/qa/basic_coverage/test_optional_paramters_basic.bas 
b/basic/qa/basic_coverage/test_optional_paramters_basic.bas
index ed2cdc7720b2..a684fc256054 100644
--- a/basic/qa/basic_coverage/test_optional_paramters_basic.bas
+++ b/basic/qa/basic_coverage/test_optional_paramters_basic.bas
@@ -1,5 +1,9 @@
 Option Explicit
 
+Type testObject
+testInt As Integer
+End Type
+
 Function doUnitTest() As String
 TestUtil.TestInit
 verify_testOptionalsBasic
@@ -97,6 +101,30 @@ Sub verify_testOptionalsBasic()
 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")
+
 Exit Sub
 errorHandler:
 TestUtil.ReportErrorHandler("verify_testOptionalsBasic", Err, Error$, Erl)
@@ -166,6 +194,41 @@ Function OptStringConcat(is_missingA As Boolean, A, 
is_missingB As Boolean, B)
 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 CollectionSum(C)
 Dim idx As Integer
 CollectionSum = 0
diff --git a/basic/qa/basic_coverage/test_optional_paramters_compatible.bas 
b/basic/qa/basic_coverage/test_optional_paramters_compatible.bas
index 00aada0698ea..56b314288e7a 100644
--- a/basic/qa/basic_coverage/test_optional_paramters_compatible.bas
+++ b/basic/qa/basic_coverage/test_optional_paramters_compatible.bas
@@ -1,6 +1,10 @@
 Option Compatible
 Option Explicit
 
+Type testObject
+testInt As Integer
+End Type
+
 Function doUnitTest() As String
 TestUtil.TestInit
 verify_testOptionalsCompatible
@@ -99,6 +103,30 @@ 

[Libreoffice-commits] core.git: basic/qa

2021-09-07 Thread Andreas Heinisch (via logerrit)
 basic/qa/vba_tests/collection.vb |   10 +-
 1 file changed, 5 insertions(+), 5 deletions(-)

New commits:
commit 409abb1fca4d360295304e1efff471d63a51e436
Author: Andreas Heinisch 
AuthorDate: Tue Sep 7 21:31:13 2021 +0200
Commit: Andreas Heinisch 
CommitDate: Tue Sep 7 22:25:13 2021 +0200

Fixed a copy paste error in the test cases

Change-Id: Ib11b6cfe385542664b28de35897caee67099d22c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121792
Tested-by: Jenkins
Reviewed-by: Andreas Heinisch 

diff --git a/basic/qa/vba_tests/collection.vb b/basic/qa/vba_tests/collection.vb
index d98ad9d1d237..0f0c47a262d9 100644
--- a/basic/qa/vba_tests/collection.vb
+++ b/basic/qa/vba_tests/collection.vb
@@ -60,12 +60,12 @@ Sub verify_testCollection()
 ' After the fix of tdf#110003
 ' TestUtil.AssertEqual(b.Count, 2, "b.Count")
 
-TestUtil.AssertEqual(b.Item("SS"), 1, "a.Item(""SS"")")
-TestUtil.AssertEqual(b.Item("ss"), 1, "a.Item(""ss"")")
-TestUtil.AssertEqual(b.Item("ẞ"), 3, "a.Item(""ẞ"")")
-TestUtil.AssertEqual(b.Item("ß"), 4, "a.Item(""ß"")")
+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(""ẞ"")")
+TestUtil.AssertEqual(b.Item("ß"), 4, "b.Item(""ß"")")
 ' After the fix of tdf#110003
-' TestUtil.AssertEqual(a.Item("ß"), 3, "a.Item(""ß"")")
+' TestUtil.AssertEqual(b.Item("ß"), 3, "b.Item(""ß"")")
 
 Exit Sub
 errorHandler:


[Libreoffice-commits] core.git: basic/qa

2021-09-07 Thread Andreas Heinisch (via logerrit)
 basic/qa/cppunit/test_vba.cxx|1 +
 basic/qa/vba_tests/collection.vb |8 
 2 files changed, 5 insertions(+), 4 deletions(-)

New commits:
commit 092740eddd9d2e9b19e4c08f4980a59402e676e1
Author: Andreas Heinisch 
AuthorDate: Tue Sep 7 19:49:41 2021 +0200
Commit: Andreas Heinisch 
CommitDate: Tue Sep 7 20:52:00 2021 +0200

tdf#144245 - Added test file to automatic test

Change-Id: I92b71b7e7ac8c2262d36875e4b04ed91e17bc495
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121791
Tested-by: Jenkins
Reviewed-by: Andreas Heinisch 

diff --git a/basic/qa/cppunit/test_vba.cxx b/basic/qa/cppunit/test_vba.cxx
index 8c43575f8f51..64875b9e1c46 100644
--- a/basic/qa/cppunit/test_vba.cxx
+++ b/basic/qa/cppunit/test_vba.cxx
@@ -74,6 +74,7 @@ void VBATest::testMiscVBAFunctions()
 "cos.vb",
 "cint.vb",
 "clng.vb",
+"collection.vb",
 "csng.vb",
 "cstr.vb",
 "cvdate.vb",
diff --git a/basic/qa/vba_tests/collection.vb b/basic/qa/vba_tests/collection.vb
index 0b765905290a..d98ad9d1d237 100644
--- a/basic/qa/vba_tests/collection.vb
+++ b/basic/qa/vba_tests/collection.vb
@@ -60,10 +60,10 @@ Sub verify_testCollection()
 ' After the fix of tdf#110003
 ' TestUtil.AssertEqual(b.Count, 2, "b.Count")
 
-TestUtil.AssertEqual(a.Item("SS"), 1, "a.Item(""SS"")")
-TestUtil.AssertEqual(a.Item("ss"), 1, "a.Item(""ss"")")
-TestUtil.AssertEqual(a.Item("ẞ"), 3, "a.Item(""ẞ"")")
-TestUtil.AssertEqual(a.Item("ß"), 4, "a.Item(""ß"")")
+TestUtil.AssertEqual(b.Item("SS"), 1, "a.Item(""SS"")")
+TestUtil.AssertEqual(b.Item("ss"), 1, "a.Item(""ss"")")
+TestUtil.AssertEqual(b.Item("ẞ"), 3, "a.Item(""ẞ"")")
+TestUtil.AssertEqual(b.Item("ß"), 4, "a.Item(""ß"")")
 ' After the fix of tdf#110003
 ' TestUtil.AssertEqual(a.Item("ß"), 3, "a.Item(""ß"")")
 


[Libreoffice-commits] core.git: basic/qa basic/source

2021-09-07 Thread Andreas Heinisch (via logerrit)
 basic/qa/vba_tests/collection.vb |   73 +++
 basic/source/classes/sb.cxx  |   11 -
 2 files changed, 82 insertions(+), 2 deletions(-)

New commits:
commit ef32c3b4f9b80918d6018e14297fa41245afd381
Author: Andreas Heinisch 
AuthorDate: Thu Sep 2 20:54:40 2021 +0200
Commit: Andreas Heinisch 
CommitDate: Tue Sep 7 09:51:26 2021 +0200

tdf#144245 - Case-insensitive operation for non-ASCII characters

Support case-insensitive operation for non-ASCII characters in the
Collection object (VBA).

Change-Id: Ie17560cb9aac5bfb32aa04175dd4839681d6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/121534
Tested-by: Jenkins
Reviewed-by: Eike Rathke 
Reviewed-by: Andreas Heinisch 

diff --git a/basic/qa/vba_tests/collection.vb b/basic/qa/vba_tests/collection.vb
new file mode 100644
index ..0b765905290a
--- /dev/null
+++ b/basic/qa/vba_tests/collection.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
+
+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.
+TestUtil.AssertEqual(b.Count, 3, "b.Count")
+' After the fix of tdf#110003
+' TestUtil.AssertEqual(b.Count, 2, "b.Count")
+
+TestUtil.AssertEqual(a.Item("SS"), 1, "a.Item(""SS"")")
+TestUtil.AssertEqual(a.Item("ss"), 1, "a.Item(""ss"")")
+TestUtil.AssertEqual(a.Item("ẞ"), 3, "a.Item(""ẞ"")")
+TestUtil.AssertEqual(a.Item("ß"), 4, "a.Item(""ß"")")
+' After the fix of tdf#110003
+' TestUtil.AssertEqual(a.Item("ß"), 3, "a.Item(""ß"")")
+
+Exit Sub
+errorHandler:
+TestUtil.ReportErrorHandler("verify_testCollection", Err, Error$, Erl)
+End Sub
diff --git a/basic/source/classes/sb.cxx b/basic/source/classes/sb.cxx
index f0ab981d62a5..8f2155e6d218 100644
--- a/basic/source/classes/sb.cxx
+++ b/basic/source/classes/sb.cxx
@@ -47,6 +47,9 @@
 #include 
 #include 
 
+#include 
+#include 
+
 #include 
 #include 
 
@@ -2058,11 +2061,15 @@ sal_Int32 
BasicCollection::implGetIndexForName(std::u16string_view rName)
 sal_Int32 nIndex = -1;
 sal_Int32 nCount = xItemArray->Count();
 sal_Int32 nNameHash = MakeHashCode( rName );
+
+// tdf#144245 - case-insensitive operation for non-ASCII characters
+utl::TransliterationWrapper& rTransliteration = 
SbGlobal::GetTransliteration();
+
 for( sal_Int32 i = 0 ; i < nCount ; i++ )
 {
 SbxVariable* pVar = xItemArray->Get(i);
-if( pVar->GetHashCode() == nNameHash &&
-pVar->GetName().equalsIgnoreAsciiCase( rName ) )
+if (pVar->GetHashCode() == nNameHash
+&& rTransliteration.isEqual(pVar->GetName(), OUString(rName)))
 {
 nIndex = i;
 break;


[Libreoffice-commits] core.git: basic/qa basic/source

2021-08-10 Thread Andreas Heinisch (via logerrit)
 basic/qa/vba_tests/optional_paramters.vb |   10 +++
 basic/qa/vba_tests/typename.vb   |   10 +++
 basic/source/classes/image.cxx   |   33 ---
 basic/source/comp/symtbl.cxx |   43 ---
 basic/source/inc/image.hxx   |2 -
 basic/source/runtime/runtime.cxx |   20 --
 6 files changed, 101 insertions(+), 17 deletions(-)

New commits:
commit 3bcfb1aac1f43f16c579486264103ebd4f3f829b
Author: Andreas Heinisch 
AuthorDate: Tue Aug 3 20:56:22 2021 +0200
Commit: Andreas Heinisch 
CommitDate: Tue Aug 10 12:23:19 2021 +0200

tdf#143707 - Change strategy to support suffix type characters

In order to support the correct data type of numeric constants,
booleans, and default values for strings, the strategy to transport the
data type character to the runtime has been changed.

The type character will be added after the literal and the string
termination symbol in order to keep compatibility. This allows to
retrieve the correct type in StepLOADNC and in StepPARAM.

Any legacy written images are still possible to process, since if there
is a suffix type character where the data type character was directly
written after the numeric constant, it will be processed in StepLOADNC.

Without this fix, an optional parameter of type Variant, would still
include the suffixe type character, and will not be converted to the
correct type in StepPARAM.

Change-Id: I86c8192c6dc28457053fa7b23a073420e45407b2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119945
Tested-by: Jenkins
Reviewed-by: Andreas Heinisch 

diff --git a/basic/qa/vba_tests/optional_paramters.vb 
b/basic/qa/vba_tests/optional_paramters.vb
index 9001ab952de9..d47854d2fb69 100644
--- a/basic/qa/vba_tests/optional_paramters.vb
+++ b/basic/qa/vba_tests/optional_paramters.vb
@@ -22,6 +22,12 @@ End Function
 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)")
@@ -113,6 +119,10 @@ 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
diff --git a/basic/qa/vba_tests/typename.vb b/basic/qa/vba_tests/typename.vb
index 4442cba55e98..98bfd58feda4 100644
--- a/basic/qa/vba_tests/typename.vb
+++ b/basic/qa/vba_tests/typename.vb
@@ -53,7 +53,17 @@ Sub verify_testTypeName()
 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/source/classes/image.cxx b/basic/source/classes/image.cxx
index 69e30bb11954..73d65e98eab9 100644
--- a/basic/source/classes/image.cxx
+++ b/basic/source/classes/image.cxx
@@ -20,6 +20,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -647,18 +648,18 @@ void SbiImage::AddEnum(SbxObject* pObject) // Register 
enum type
 }
 
 // Note: IDs start with 1
-OUString SbiImage::GetString( short nId ) const
+OUString SbiImage::GetString( short nId, SbxDataType *eType ) const
 {
 if( nId && nId <= short(mvStringOffsets.size()) )
 {
 sal_uInt32 nOff = mvStringOffsets[ nId - 1 ];
 sal_Unicode* pStr = pStrings.get() + nOff;
 
+sal_uInt32 nNextOff = (nId < short(mvStringOffsets.size())) ? 
mvStringOffsets[ nId ] : nStringOff;
+sal_uInt32 nLen = nNextOff - nOff - 1;
 // #i42467: Special treatment for vbNullChar
-if( *pStr == 0 )
+if (*pStr == 0)
 {
-sal_uInt32 nNextOff = (nId < short(mvStringOffsets.size())) ? 
mvStringOffsets[ nId ] : nStringOff;
-sal_uInt32 nLen = nNextOff - nOff - 1;
 if( nLen == 1 )
 {
 

[Libreoffice-commits] core.git: basic/qa basic/source

2021-07-28 Thread Andreas Heinisch (via logerrit)
 basic/qa/basic_coverage/test_optional_paramters_basic.bas  |   36 
+-
 basic/qa/basic_coverage/test_optional_paramters_compatible.bas |   32 
 basic/qa/cppunit/_test_asserts.bas |9 ++
 basic/qa/vba_tests/optional_paramters.vb   |   32 
 basic/source/sbx/sbxdbl.cxx|3 
 basic/source/sbx/sbxsng.cxx|3 
 6 files changed, 63 insertions(+), 52 deletions(-)

New commits:
commit a330732cf8aaa5770bef0b49c113a57ca5e85e10
Author: Andreas Heinisch 
AuthorDate: Mon Jul 26 19:45:12 2021 +0200
Commit: Andreas Heinisch 
CommitDate: Wed Jul 28 09:57:31 2021 +0200

tdf#107953 - Extend significant digits

According to

https://randomascii.wordpress.com/2012/03/08/float-precisionfrom-zero-to-100-digits-2/
show at least 9 / 17 significant digits for a single / double data type
in order to identify the contained value.

Change-Id: Id2833fc51ca005bc78b68d6b4cca28f2d95f5a85
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119526
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 
Reviewed-by: Andreas Heinisch 

diff --git a/basic/qa/basic_coverage/test_optional_paramters_basic.bas 
b/basic/qa/basic_coverage/test_optional_paramters_basic.bas
index 24da0ab20a3b..ed2cdc7720b2 100644
--- a/basic/qa/basic_coverage/test_optional_paramters_basic.bas
+++ b/basic/qa/basic_coverage/test_optional_paramters_basic.bas
@@ -21,21 +21,21 @@ Sub verify_testOptionalsBasic()
 
 ' optionals with variant datatypes (ByRef and ByVal)
 TestUtil.AssertEqual(TestOptVariantByRefByVal(), 0, 
"TestOptVariantByRefByVal()")
-TestUtil.AssertEqual(TestOptVariantByRefByVal(123), 123, 
"TestOptVariantByRefByVal(123)")
-TestUtil.AssertEqual(TestOptVariantByRefByVal(, 456), 456, 
"TestOptVariantByRefByVal(, 456)")
-TestUtil.AssertEqual(TestOptVariantByRefByVal(123, 456), 579, 
"TestOptVariantByRefByVal(123, 456)")
+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.AssertEqual(TestOptDouble(123.4), 123.4, "TestOptDouble(123.4)")
-TestUtil.AssertEqual(TestOptDouble(, 567.8), 567.8, "TestOptDouble(, 
567.8)")
-TestUtil.AssertEqual(CDbl(Format(TestOptDouble(123.4, 567.8), "0.0")), 
691.2, "TestOptDouble(123.4, 567.8)")
+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, "TestOptDouble()")
-TestUtil.AssertEqual(TestOptDoubleByRefByVal(123.4), 123.4, 
"TestOptDouble(123.4)")
-TestUtil.AssertEqual(TestOptDoubleByRefByVal(, 567.8), 567.8, 
"TestOptDoubleByRefByVal(, 567.8)")
-TestUtil.AssertEqual(CDbl(Format(TestOptDoubleByRefByVal(123.4, 567.8), 
"0.0")), 691.2, "TestOptDoubleByRefByVal(123.4, 567.8)")
+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()")
@@ -70,14 +70,14 @@ Sub verify_testOptionalsBasic()
 cB.Add (567.8)
 TestUtil.AssertEqual(TestOptObject(), 0, "TestOptObject()")
 TestUtil.AssertEqual(TestOptObject(cA), 579, "TestOptObject(A)")
-TestUtil.AssertEqual(CDbl(Format(TestOptObject(, cB), "0.0")), 691.2, 
"TestOptObject(, B)")
-TestUtil.AssertEqual(CDbl(Format(TestOptObject(cA, cB), "0.0")), 1270.2, 
"TestOptObject(A, B)")
+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.AssertEqual(CDbl(Format(TestOptObjectByRefByVal(, cB), "0.0")), 
691.2, "TestOptObjectByRefByVal(, B)")
-

[Libreoffice-commits] core.git: basic/qa basic/source

2021-07-19 Thread Andreas Heinisch (via logerrit)
 basic/qa/vba_tests/instrrev.vb   |9 -
 basic/source/runtime/methods.cxx |   18 --
 2 files changed, 20 insertions(+), 7 deletions(-)

New commits:
commit f5e030a343bec9f0f2c7b30e2dfb21ba5c94e5e8
Author: Andreas Heinisch 
AuthorDate: Sat Jul 17 10:42:58 2021 +0200
Commit: Andreas Heinisch 
CommitDate: Mon Jul 19 13:03:22 2021 +0200

tdf#143332 - Use utl::TextSearch to implement the InStrRev function

Change-Id: I2dae038d061f036b3b7c0fbbcb6a821305d4839e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/119094
Tested-by: Jenkins
Reviewed-by: Andreas Heinisch 

diff --git a/basic/qa/vba_tests/instrrev.vb b/basic/qa/vba_tests/instrrev.vb
index 506d40733cdb..7d047fc74aa6 100644
--- a/basic/qa/vba_tests/instrrev.vb
+++ b/basic/qa/vba_tests/instrrev.vb
@@ -28,7 +28,14 @@ Sub verify_testInStrRev()
 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)")
+TestUtil.AssertEqual(InStrRev(SearchString, "W", 1), 0, 
"InStrRev(SearchString, ""W"", 1)")
+
+' tdf#143332 - case-insensitive operation for non-ASCII characters
+TestUtil.AssertEqual(InStrRev("α", "Α", -1, 1),  1, "InStrRev(""α"", 
""Α"", -1, 1)")
+TestUtil.AssertEqual(InStrRev("abc", "d", -1, 1),0, "InStrRev(""abc"", 
""d"", -1, 1)")
+' tdf#143332 - German Eszett is uppercased to a two-character 'SS'.
+' This test should fail after tdf#110003 has been fixed.
+TestUtil.AssertEqual(InStrRev("Straße", "s", -1, 1), 5, 
"InStrRev(""Straße"", ""s"", -1, 1)")
 
 Exit Sub
 errorHandler:
diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx
index 1055aab142d2..39309f06a4f4 100644
--- a/basic/source/runtime/methods.cxx
+++ b/basic/source/runtime/methods.cxx
@@ -929,8 +929,8 @@ void SbRtl_InStrRev(StarBASIC *, SbxArray & rPar, bool)
 }
 else
 {
-OUString aStr1 = rPar.Get(1)->GetOUString();
-OUString aToken = rPar.Get(2)->GetOUString();
+const OUString aStr1 = rPar.Get(1)->GetOUString();
+const OUString aToken = rPar.Get(2)->GetOUString();
 
 sal_Int32 nStartPos = -1;
 if ( nArgCount >= 3 )
@@ -959,7 +959,7 @@ void SbRtl_InStrRev(StarBASIC *, SbxArray & rPar, bool)
 {
 bTextMode = rPar.Get(4)->GetInteger();
 }
-sal_Int32 nStrLen = aStr1.getLength();
+const sal_Int32 nStrLen = aStr1.getLength();
 if( nStartPos == -1 )
 {
 nStartPos = nStrLen;
@@ -982,10 +982,16 @@ void SbRtl_InStrRev(StarBASIC *, SbxArray & rPar, bool)
 }
 else
 {
-aStr1 = aStr1.toAsciiUpperCase();
-aToken = aToken.toAsciiUpperCase();
+// tdf#143332 - case-insensitive operation for non-ASCII 
characters
+i18nutil::SearchOptions2 aSearchOptions;
+aSearchOptions.searchString = aToken;
+aSearchOptions.AlgorithmType2 = 
util::SearchAlgorithms2::ABSOLUTE;
+aSearchOptions.transliterateFlags |= 
TransliterationFlags::IGNORE_CASE;
+utl::TextSearch textSearch(aSearchOptions);
 
-nPos = aStr1.lastIndexOf( aToken, nStartPos ) + 1;
+sal_Int32 nStart = 0;
+sal_Int32 nEnd = nStartPos;
+nPos = textSearch.SearchBackward(aStr1, , ) ? 
nStart : 0;
 }
 }
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: basic/qa basic/source

2021-07-16 Thread Andreas Heinisch (via logerrit)
 basic/qa/basic_coverage/test_instr_method.bas |6 
 basic/qa/vba_tests/instr.vb   |6 
 basic/source/runtime/methods.cxx  |   37 +++---
 3 files changed, 34 insertions(+), 15 deletions(-)

New commits:
commit afddd56a8049957b9c0e025992d47c04342dbb88
Author: Andreas Heinisch 
AuthorDate: Thu Jul 15 20:43:32 2021 +0200
Commit: Andreas Heinisch 
CommitDate: Fri Jul 16 09:29:16 2021 +0200

tdf#139840 - Use utl::TextSearch to implement the InStr function

In addtion, fixed a crash if the start position is greater than the
length of the string being searched.

Change-Id: I9bcda1131324bdfac6957018e91b3a36dd2dc3d6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118996
Tested-by: Jenkins
Reviewed-by: Andreas Heinisch 

diff --git a/basic/qa/basic_coverage/test_instr_method.bas 
b/basic/qa/basic_coverage/test_instr_method.bas
index ff763cb4226c..9e4545bb3b44 100644
--- a/basic/qa/basic_coverage/test_instr_method.bas
+++ b/basic/qa/basic_coverage/test_instr_method.bas
@@ -18,6 +18,12 @@ Function doUnitTest as String
 
 ' 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"
 
diff --git a/basic/qa/vba_tests/instr.vb b/basic/qa/vba_tests/instr.vb
index 3ced2a07c8ca..cda19712b296 100644
--- a/basic/qa/vba_tests/instr.vb
+++ b/basic/qa/vba_tests/instr.vb
@@ -32,6 +32,12 @@ Sub verify_testInStr()
 
 ' 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:
diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx
index e745fa2fd1c6..1055aab142d2 100644
--- a/basic/source/runtime/methods.cxx
+++ b/basic/source/runtime/methods.cxx
@@ -885,25 +885,32 @@ void SbRtl_InStr(StarBASIC *, SbxArray & rPar, bool)
 }
 else
 {
-if( !bTextMode )
+const OUString& rStr1 = rPar.Get(nFirstStringPos)->GetOUString();
+const sal_Int32 nrStr1Len = rStr1.getLength();
+if (nStartPos > nrStr1Len)
 {
-const OUString& rStr1 = 
rPar.Get(nFirstStringPos)->GetOUString();
-nPos = rStr1.indexOf( rToken, nStartPos - 1 ) + 1;
+// Start position is greater than the string being searched
+nPos = 0;
 }
 else
 {
-OUString aStr1 = rPar.Get(nFirstStringPos)->GetOUString();
-OUString aToken = rToken;
-
-// tdf#139840 - case-insensitive operation for non-ASCII 
characters
-const css::lang::Locale& rLocale
-= Application::GetSettings().GetLanguageTag().getLocale();
-css::uno::Reference xCharClass
-= vcl::unohelper::CreateCharacterClassification();
-aStr1 = xCharClass->toUpper(aStr1, 0, aStr1.getLength(), 
rLocale);
-aToken = xCharClass->toUpper(aToken, 0, aToken.getLength(), 
rLocale);
-
-nPos = aStr1.indexOf( aToken, nStartPos-1 ) + 1;
+if( !bTextMode )
+{
+nPos = rStr1.indexOf( rToken, nStartPos - 1 ) + 1;
+}
+else
+{
+// tdf#139840 - case-insensitive operation for non-ASCII 
characters
+i18nutil::SearchOptions2 aSearchOptions;
+aSearchOptions.searchString = rToken;
+aSearchOptions.AlgorithmType2 = 
util::SearchAlgorithms2::ABSOLUTE;
+aSearchOptions.transliterateFlags |= 
TransliterationFlags::IGNORE_CASE;
+utl::TextSearch textSearch(aSearchOptions);
+
+sal_Int32 nStart = nStartPos - 1;
+sal_Int32 nEnd = nrStr1Len;
+nPos = textSearch.SearchForward(rStr1, , ) ? 
nStart + 1 : 0;
+}
 }
 }
 rPar.Get(0)->PutLong(nPos);
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org

[Libreoffice-commits] core.git: basic/qa

2021-07-15 Thread Xisco Fauli (via logerrit)
 basic/qa/basic_coverage/test_tdf111313.bas |   19 +++
 1 file changed, 19 insertions(+)

New commits:
commit 0ce3a9dcc071094121252a286aa88529ee09a4eb
Author: Xisco Fauli 
AuthorDate: Wed Jul 14 18:54:33 2021 +0200
Commit: Xisco Fauli 
CommitDate: Thu Jul 15 10:02:00 2021 +0200

tdf#111313: basic_macros: Add unittest

Change-Id: Id6f8bc0998d4f79434d46017b998917dcc53ac6d
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118949
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 

diff --git a/basic/qa/basic_coverage/test_tdf111313.bas 
b/basic/qa/basic_coverage/test_tdf111313.bas
new file mode 100644
index ..3a2604732e7c
--- /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
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: basic/qa

2021-07-14 Thread Xisco Fauli (via logerrit)
 basic/qa/basic_coverage/test_tdf98778.bas |   22 ++
 1 file changed, 22 insertions(+)

New commits:
commit f7d128f1223a28d5fdae53ceaad55bf3166a9036
Author: Xisco Fauli 
AuthorDate: Wed Jul 14 17:48:32 2021 +0200
Commit: Xisco Fauli 
CommitDate: Wed Jul 14 19:39:07 2021 +0200

tdf#98778: basic_macros: Add unittest

Change-Id: I35468fb35f5c24af2138688d99af0e41ba672334
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118944
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 

diff --git a/basic/qa/basic_coverage/test_tdf98778.bas 
b/basic/qa/basic_coverage/test_tdf98778.bas
new file mode 100644
index ..0228e5060ba8
--- /dev/null
+++ b/basic/qa/basic_coverage/test_tdf98778.bas
@@ -0,0 +1,22 @@
+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
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: basic/qa

2021-07-14 Thread Xisco Fauli (via logerrit)
 basic/qa/basic_coverage/dateadd.bas |5 +
 1 file changed, 5 insertions(+)

New commits:
commit c3fc5aaa654b649be9adec8904f76272cd50bb16
Author: Xisco Fauli 
AuthorDate: Wed Jul 14 17:30:01 2021 +0200
Commit: Xisco Fauli 
CommitDate: Wed Jul 14 18:15:28 2021 +0200

tdf#114011: basic_macros: Add unittest

Change-Id: Ib9a7e87b4c8159fd5fb66705cddae138fcdd
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118942
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 

diff --git a/basic/qa/basic_coverage/dateadd.bas 
b/basic/qa/basic_coverage/dateadd.bas
index 84b796db3cba..409a55a9b76c 100644
--- a/basic/qa/basic_coverage/dateadd.bas
+++ b/basic/qa/basic_coverage/dateadd.bas
@@ -20,6 +20,11 @@ Sub verify_testDateAdd()
 ' 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)
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: basic/qa

2021-07-07 Thread Xisco Fauli (via logerrit)
 basic/qa/basic_coverage/da-DK/cdbl-2.bas   
 |   10 ++
 basic/qa/basic_coverage/da-DK/cdbl.bas 
 |   10 ++
 basic/qa/basic_coverage/dateadd.bas
 |2 ++
 basic/qa/basic_coverage/string_left_01.bas 
 |1 +
 basic/qa/basic_coverage/string_right_01.bas
 |2 ++
 basic/qa/basic_coverage/test_Date.bas  
 |2 ++
 basic/qa/basic_coverage/test_Property.GetLet.bas   
 |1 +
 basic/qa/basic_coverage/test_Property.GetSet.bas   
 |1 +
 basic/qa/basic_coverage/test_abs_method.bas
 |2 ++
 basic/qa/basic_coverage/test_array_method.bas  
 |2 ++
 basic/qa/basic_coverage/test_asc_method.bas
 |2 ++
 basic/qa/basic_coverage/test_atn_method.bas
 |2 ++
 basic/qa/basic_coverage/test_beep_method.bas   
 |2 ++
 basic/qa/basic_coverage/test_cbool_method.bas  
 |2 ++
 basic/qa/basic_coverage/test_cbyte_method.bas  
 |2 ++
 basic/qa/basic_coverage/test_ccur_method.bas   
 |2 ++
 basic/qa/basic_coverage/test_cdate_method.bas  
 |2 ++
 basic/qa/basic_coverage/test_cdatetofromiso_methods.bas
 |2 ++
 basic/qa/basic_coverage/test_cdatetounodatecdatefromunodate_methods.bas
 |2 ++
 
basic/qa/basic_coverage/test_cdatetounodatetimecdatefromunodatetime_methods.bas 
|2 ++
 basic/qa/basic_coverage/test_cdatetounotimecdatefromunotime_methods.bas
 |2 ++
 basic/qa/basic_coverage/test_cdbl_method.bas   
 |2 ++
 basic/qa/basic_coverage/test_chdircurdir_methods.bas   
 |2 ++
 basic/qa/basic_coverage/test_choose_method.bas 
 |2 ++
 basic/qa/basic_coverage/test_chr_method.bas
 |2 ++
 basic/qa/basic_coverage/test_cint_method.bas   
 |2 ++
 basic/qa/basic_coverage/test_compatibilitymode_method.bas  
 |2 ++
 basic/qa/basic_coverage/test_converttofromurl_methods.bas  
 |2 ++
 basic/qa/basic_coverage/test_cossin_methods.bas
 |2 ++
 basic/qa/basic_coverage/test_createobject_method.bas   
 |1 +
 basic/qa/basic_coverage/test_createunolistener_method.bas  
 |2 ++
 basic/qa/basic_coverage/test_createunoservice_method.bas   
 |2 ++
 basic/qa/basic_coverage/test_createunostruct_method.bas
 |2 ++
 basic/qa/basic_coverage/test_createunovalue_method.bas 
 |2 ++
 basic/qa/basic_coverage/test_csng_method.bas   
 |2 ++
 basic/qa/basic_coverage/test_cstr_method.bas   
 |2 ++
 basic/qa/basic_coverage/test_cvar_method.bas   
 |2 ++
 basic/qa/basic_coverage/test_cverr_method.bas  
 |2 ++
 basic/qa/basic_coverage/test_date_literal.bas  
 |1 +
 basic/qa/basic_coverage/test_datedateadddatediff_methods.bas   
 |2 ++
 basic/qa/basic_coverage/test_datedatepartday_methods.bas   
 |2 ++
 basic/qa/basic_coverage/test_dimarray_method.bas   
 |2 ++
 basic/qa/basic_coverage/test_environ_method.bas
 |2 ++
 basic/qa/basic_coverage/test_err_method.bas
 |2 ++
 basic/qa/basic_coverage/test_falsetrue_method.bas  
 |2 ++
 basic/qa/basic_coverage/test_filedatetime_nonexistent.bas  
 |3 +++
 basic/qa/basic_coverage/test_filedatetime_nonexistent2.bas 
 |3 +++
 basic/qa/basic_coverage/test_fix_method.bas
 |2 ++
 basic/qa/basic_coverage/test_frac_method.bas   
 |2 ++
 basic/qa/basic_coverage/test_freefile_method.bas   
 |2 ++
 basic/qa/basic_coverage/test_freelibrary_method.bas
 |2 ++
 basic/qa/basic_coverage/test_getdefaultcontext_method.bas  
 |2 ++
 basic/qa/basic_coverage/test_getdialogzoomfactorx_method.bas   
 |2 ++
 basic/qa/basic_coverage/test_getdialogzoomfactory_method.bas   
 |2 ++
 

[Libreoffice-commits] core.git: basic/qa basic/source

2021-07-06 Thread baltasarq (via logerrit)
 basic/qa/vba_tests/roundcompatibility.vb |   29 +
 basic/source/runtime/methods1.cxx|   23 ++-
 2 files changed, 31 insertions(+), 21 deletions(-)

New commits:
commit 0eacbfa75132724faaeeb9ea22a1c3e44eefb515
Author: baltasarq 
AuthorDate: Mon Jul 5 17:17:54 2021 +0200
Commit: Mike Kaganski 
CommitDate: Tue Jul 6 14:50:09 2021 +0200

tdf#142922 fixes Round to follow half-to-even rounding

The LibreOffice's Basic Round function does not return values
that are compatible with VBA's Round. This can be easily fixed
using rtl/round, which has a flag parameter called
rtl_math_RoundingMode_HalfEven which rounds real numbers
exactly in the expected way.

Change-Id: I2215f08427e5777fc2d35f054b635dfa6247af8c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118444
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/basic/qa/vba_tests/roundcompatibility.vb 
b/basic/qa/vba_tests/roundcompatibility.vb
new file mode 100644
index ..aaa078925d3b
--- /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/source/runtime/methods1.cxx 
b/basic/source/runtime/methods1.cxx
index 9addf7140adf..b20b3fce3775 100644
--- a/basic/source/runtime/methods1.cxx
+++ b/basic/source/runtime/methods1.cxx
@@ -51,6 +51,7 @@
 #include 
 #include 
 #include 
+#include 
 
 #include 
 #include 
@@ -2388,13 +2389,6 @@ void SbRtl_Round(StarBASIC *, SbxArray & rPar, bool)
 double dRes = 0.0;
 if( dVal != 0.0 )
 {
-bool bNeg = false;
-if( dVal < 0.0 )
-{
-bNeg = true;
-dVal = -dVal;
-}
-
 sal_Int16 numdecimalplaces = 0;
 if( nParCount == 3 )
 {
@@ -2406,20 +2400,7 @@ void SbRtl_Round(StarBASIC *, SbxArray & rPar, bool)
 }
 }
 
-if( numdecimalplaces == 0 )
-{
-dRes = floor( dVal + 0.5 );
-}
-else
-{
-double dFactor = pow( 10.0, numdecimalplaces );
-dVal *= dFactor;
-dRes = floor( dVal + 0.5 );
-dRes /= dFactor;
-}
-
-if( bNeg )
-dRes = -dRes;
+dRes = rtl_math_round(dVal, numdecimalplaces, 
rtl_math_RoundingMode_HalfEven);
 }
 rPar.Get(0)->PutDouble(dRes);
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: basic/qa

2021-07-06 Thread Xisco Fauli (via logerrit)
 basic/qa/basic_coverage/test_tdf134692.bas |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit faaf95859c0b6f0cea105b8a85551b8afbc56f21
Author: Xisco Fauli 
AuthorDate: Tue Jul 6 09:56:59 2021 +0200
Commit: Xisco Fauli 
CommitDate: Tue Jul 6 11:18:15 2021 +0200

basic: remove unneeded variable in test

Kudos to M. Kaganski for spotting it
Change-Id: I04ceea4607cf94a5a84af4f171d6f2b204ef8653

Change-Id: Ie9064d3c12da657ecd82fdab6891bc8703ee6f37
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118464
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 

diff --git a/basic/qa/basic_coverage/test_tdf134692.bas 
b/basic/qa/basic_coverage/test_tdf134692.bas
index b3ff937e7d9b..ddb25758e6e5 100644
--- a/basic/qa/basic_coverage/test_tdf134692.bas
+++ b/basic/qa/basic_coverage/test_tdf134692.bas
@@ -21,7 +21,7 @@ Sub verify_tdf134692()
 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: " & retStr)
+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:
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: basic/qa

2021-07-05 Thread Xisco Fauli (via logerrit)
 basic/qa/basic_coverage/dateadd.bas |   24 
 1 file changed, 24 insertions(+)

New commits:
commit 3be3a020d4c243f9b12d90fe75be103337002be6
Author: Xisco Fauli 
AuthorDate: Mon Jul 5 16:37:43 2021 +0200
Commit: Xisco Fauli 
CommitDate: Mon Jul 5 17:48:49 2021 +0200

tdf#117612: basic_macros: Add unittest

Change-Id: I4189b52be788deafe921c860f807ec5cee8ec667
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118443
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 

diff --git a/basic/qa/basic_coverage/dateadd.bas 
b/basic/qa/basic_coverage/dateadd.bas
new file mode 100644
index ..1fc65e205715
--- /dev/null
+++ b/basic/qa/basic_coverage/dateadd.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/.
+'
+
+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"")")
+
+Exit Sub
+errorHandler:
+TestUtil.ReportErrorHandler("verify_testDateAdd", Err, Error$, Erl)
+End Sub
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: basic/qa

2021-07-05 Thread Xisco Fauli (via logerrit)
 basic/qa/basic_coverage/test_tdf134692.bas |   29 +
 1 file changed, 29 insertions(+)

New commits:
commit c6cc94ea781699b899ad92ca6ceab2e8f59d1606
Author: Xisco Fauli 
AuthorDate: Mon Jul 5 16:11:27 2021 +0200
Commit: Xisco Fauli 
CommitDate: Mon Jul 5 17:35:30 2021 +0200

tdf#134692: basic_macros: Add unittest

Change-Id: I9115eca2fce784cd55a8eb4f1cfd6e614fd3612b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118442
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 

diff --git a/basic/qa/basic_coverage/test_tdf134692.bas 
b/basic/qa/basic_coverage/test_tdf134692.bas
new file mode 100644
index ..b3ff937e7d9b
--- /dev/null
+++ b/basic/qa/basic_coverage/test_tdf134692.bas
@@ -0,0 +1,29 @@
+Option VBASupport 0
+
+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)
+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: " & retStr)
+
+Exit Sub
+errorHandler:
+TestUtil.ReportErrorHandler("verify_tdf134692", Err, Error$, Erl)
+End Sub
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: basic/qa

2021-07-02 Thread Mike Kaganski (via logerrit)
 basic/qa/cppunit/basic_coverage.cxx |4 ++--
 basic/qa/cppunit/test_vba.cxx   |2 +-
 2 files changed, 3 insertions(+), 3 deletions(-)

New commits:
commit 357c0e2a4a07aca48a69fbc2616b7002401b3267
Author: Mike Kaganski 
AuthorDate: Fri Jul 2 20:44:27 2021 +0300
Commit: Mike Kaganski 
CommitDate: Fri Jul 2 21:53:39 2021 +0200

Move utility code out of test directories

This simplifies iteration over the test files, and avoids relying
on file URLs being the same (e.g., having no /./ segments).

Change-Id: I227785806e474a3a2dffeb46df21617eae43327e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118329
Reviewed-by: Xisco Fauli 
Reviewed-by: Mike Kaganski 
Tested-by: Jenkins

diff --git a/basic/qa/basic_coverage/_test_asserts.bas 
b/basic/qa/cppunit/_test_asserts.bas
similarity index 100%
rename from basic/qa/basic_coverage/_test_asserts.bas
rename to basic/qa/cppunit/_test_asserts.bas
diff --git a/basic/qa/vba_tests/_test_asserts.vb 
b/basic/qa/cppunit/_test_asserts.vb
similarity index 100%
rename from basic/qa/vba_tests/_test_asserts.vb
rename to basic/qa/cppunit/_test_asserts.vb
diff --git a/basic/qa/cppunit/basic_coverage.cxx 
b/basic/qa/cppunit/basic_coverage.cxx
index 22ce4e52b6b5..0f0722917232 100644
--- a/basic/qa/cppunit/basic_coverage.cxx
+++ b/basic/qa/cppunit/basic_coverage.cxx
@@ -64,7 +64,7 @@ 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/basic_coverage/") + "_test_asserts.bas";
+OUString sMacroUtilsURL = 
m_directories.getURLFromSrc(u"basic/qa/cppunit/_test_asserts.bas");
 
 if(aDir.open() == osl::FileBase::E_None)
 {
@@ -74,7 +74,7 @@ void Coverage::process_directory(const OUString& sDirName)
 if(aFileStatus.isRegular())
 {
 OUString sFileURL = aFileStatus.getFileURL();
-if(sFileURL.endsWith(".bas") && sFileURL != sMacroUtilsURL)
+if (sFileURL.endsWith(".bas"))
 {
 MacroSnippet testMacro;
 testMacro.LoadSourceFromFile("TestUtil", sMacroUtilsURL);
diff --git a/basic/qa/cppunit/test_vba.cxx b/basic/qa/cppunit/test_vba.cxx
index 9a3cbe8baab9..8c43575f8f51 100644
--- a/basic/qa/cppunit/test_vba.cxx
+++ b/basic/qa/cppunit/test_vba.cxx
@@ -146,7 +146,7 @@ void VBATest::testMiscVBAFunctions()
 "win32compatb.vb" // same methods, different signatures.
 };
 OUString sMacroPathURL = 
m_directories.getURLFromSrc(u"/basic/qa/vba_tests/");
-OUString sMacroUtilsURL = sMacroPathURL + "_test_asserts.vb";
+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;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: basic/qa

2021-07-02 Thread Mike Kaganski (via logerrit)
 basic/qa/cppunit/basic_coverage.cxx |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

New commits:
commit 9258f7009e6ad28dc3fc06a0b66c4cd3d0f658a9
Author: Mike Kaganski 
AuthorDate: Fri Jul 2 20:41:06 2021 +0300
Commit: Mike Kaganski 
CommitDate: Fri Jul 2 20:48:34 2021 +0200

Rename LibreOffice Basic test files from .vb to .bas: they are not VBA

Change-Id: I4ff8a8dc855da2c60084318e067d4ec8149d055e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118330
Reviewed-by: Xisco Fauli 
Reviewed-by: Mike Kaganski 
Tested-by: Jenkins

diff --git a/basic/qa/basic_coverage/_test_asserts.vb 
b/basic/qa/basic_coverage/_test_asserts.bas
similarity index 100%
rename from basic/qa/basic_coverage/_test_asserts.vb
rename to basic/qa/basic_coverage/_test_asserts.bas
diff --git a/basic/qa/basic_coverage/da-DK/cdbl-2.vb 
b/basic/qa/basic_coverage/da-DK/cdbl-2.bas
similarity index 100%
rename from basic/qa/basic_coverage/da-DK/cdbl-2.vb
rename to basic/qa/basic_coverage/da-DK/cdbl-2.bas
diff --git a/basic/qa/basic_coverage/da-DK/cdbl.vb 
b/basic/qa/basic_coverage/da-DK/cdbl.bas
similarity index 100%
rename from basic/qa/basic_coverage/da-DK/cdbl.vb
rename to basic/qa/basic_coverage/da-DK/cdbl.bas
diff --git a/basic/qa/basic_coverage/string_left_01.vb 
b/basic/qa/basic_coverage/string_left_01.bas
similarity index 100%
rename from basic/qa/basic_coverage/string_left_01.vb
rename to basic/qa/basic_coverage/string_left_01.bas
diff --git a/basic/qa/basic_coverage/string_right_01.vb 
b/basic/qa/basic_coverage/string_right_01.bas
similarity index 100%
rename from basic/qa/basic_coverage/string_right_01.vb
rename to basic/qa/basic_coverage/string_right_01.bas
diff --git a/basic/qa/basic_coverage/test_Date.vb 
b/basic/qa/basic_coverage/test_Date.bas
similarity index 100%
rename from basic/qa/basic_coverage/test_Date.vb
rename to basic/qa/basic_coverage/test_Date.bas
diff --git a/basic/qa/basic_coverage/test_Property.GetLet.vb 
b/basic/qa/basic_coverage/test_Property.GetLet.bas
similarity index 100%
rename from basic/qa/basic_coverage/test_Property.GetLet.vb
rename to basic/qa/basic_coverage/test_Property.GetLet.bas
diff --git a/basic/qa/basic_coverage/test_Property.GetSet.vb 
b/basic/qa/basic_coverage/test_Property.GetSet.bas
similarity index 100%
rename from basic/qa/basic_coverage/test_Property.GetSet.vb
rename to basic/qa/basic_coverage/test_Property.GetSet.bas
diff --git a/basic/qa/basic_coverage/test_abs_method.vb 
b/basic/qa/basic_coverage/test_abs_method.bas
similarity index 100%
rename from basic/qa/basic_coverage/test_abs_method.vb
rename to basic/qa/basic_coverage/test_abs_method.bas
diff --git a/basic/qa/basic_coverage/test_array_method.vb 
b/basic/qa/basic_coverage/test_array_method.bas
similarity index 100%
rename from basic/qa/basic_coverage/test_array_method.vb
rename to basic/qa/basic_coverage/test_array_method.bas
diff --git a/basic/qa/basic_coverage/test_asc_method.vb 
b/basic/qa/basic_coverage/test_asc_method.bas
similarity index 100%
rename from basic/qa/basic_coverage/test_asc_method.vb
rename to basic/qa/basic_coverage/test_asc_method.bas
diff --git a/basic/qa/basic_coverage/test_atn_method.vb 
b/basic/qa/basic_coverage/test_atn_method.bas
similarity index 100%
rename from basic/qa/basic_coverage/test_atn_method.vb
rename to basic/qa/basic_coverage/test_atn_method.bas
diff --git a/basic/qa/basic_coverage/test_beep_method.vb 
b/basic/qa/basic_coverage/test_beep_method.bas
similarity index 100%
rename from basic/qa/basic_coverage/test_beep_method.vb
rename to basic/qa/basic_coverage/test_beep_method.bas
diff --git a/basic/qa/basic_coverage/test_cbool_method.vb 
b/basic/qa/basic_coverage/test_cbool_method.bas
similarity index 100%
rename from basic/qa/basic_coverage/test_cbool_method.vb
rename to basic/qa/basic_coverage/test_cbool_method.bas
diff --git a/basic/qa/basic_coverage/test_cbyte_method.vb 
b/basic/qa/basic_coverage/test_cbyte_method.bas
similarity index 100%
rename from basic/qa/basic_coverage/test_cbyte_method.vb
rename to basic/qa/basic_coverage/test_cbyte_method.bas
diff --git a/basic/qa/basic_coverage/test_ccur_method.vb 
b/basic/qa/basic_coverage/test_ccur_method.bas
similarity index 100%
rename from basic/qa/basic_coverage/test_ccur_method.vb
rename to basic/qa/basic_coverage/test_ccur_method.bas
diff --git a/basic/qa/basic_coverage/test_cdate_method.vb 
b/basic/qa/basic_coverage/test_cdate_method.bas
similarity index 100%
rename from basic/qa/basic_coverage/test_cdate_method.vb
rename to basic/qa/basic_coverage/test_cdate_method.bas
diff --git a/basic/qa/basic_coverage/test_cdatetofromiso_methods.vb 
b/basic/qa/basic_coverage/test_cdatetofromiso_methods.bas
similarity index 100%
rename from basic/qa/basic_coverage/test_cdatetofromiso_methods.vb
rename to basic/qa/basic_coverage/test_cdatetofromiso_methods.bas
diff --git 
a/basic/qa/basic_coverage/test_cdatetounodatecdatefromunodate_methods.vb 

[Libreoffice-commits] core.git: basic/qa

2021-07-02 Thread Xisco Fauli (via logerrit)
 basic/qa/basic_coverage/test_string_replace.vb |4 
 1 file changed, 4 insertions(+)

New commits:
commit 79657c9f5392a9c243d3f3c14fa190b04b6806e9
Author: Xisco Fauli 
AuthorDate: Fri Jul 2 18:04:48 2021 +0200
Commit: Xisco Fauli 
CommitDate: Fri Jul 2 19:36:56 2021 +0200

tdf#143081: basic_macros: Add unittest

Change-Id: I2d9fa23627f40a2398288b1ee7f5bfd4de4a6131
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118326
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 

diff --git a/basic/qa/basic_coverage/test_string_replace.vb 
b/basic/qa/basic_coverage/test_string_replace.vb
index a2a5f541b3ff..ec51740e17a2 100644
--- a/basic/qa/basic_coverage/test_string_replace.vb
+++ b/basic/qa/basic_coverage/test_string_replace.vb
@@ -20,6 +20,10 @@ Sub verify_stringReplace()
 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""", , "")
+TestUtil.AssertEqual(retStr, "Straße""", "replace doesn't 
crash: " & retStr)
+
 Exit Sub
 errorHandler:
 TestUtil.ReportErrorHandler("verify_stringReplace", Err, Error$, Erl)
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: basic/qa chart2/source sc/inc sc/source

2021-06-30 Thread BaiXiaochun (via logerrit)
 basic/qa/cppunit/test_scanner.cxx |6 +--
 chart2/source/view/axes/MinimumAndMaximumSupplier.cxx |   21 +++
 chart2/source/view/axes/VCoordinateSystem.cxx |9 ++--
 chart2/source/view/charttypes/Splines.cxx |   15 +++-
 chart2/source/view/charttypes/VSeriesPlotter.cxx  |   33 --
 chart2/source/view/main/VDataSeries.cxx   |7 +--
 sc/inc/math.hxx   |   12 +-
 sc/source/core/data/dpitemdata.cxx|4 +-
 sc/source/core/data/dputil.cxx|   10 +
 9 files changed, 43 insertions(+), 74 deletions(-)

New commits:
commit 3964e0854507b2696ae0fbe48a4fb005c779947e
Author: BaiXiaochun 
AuthorDate: Tue Jun 29 20:31:30 2021 +0200
Commit: Mike Kaganski 
CommitDate: Thu Jul 1 00:39:17 2021 +0200

Purge out rtl::math::setInf

Change-Id: I71af8273c672a4cbcbfefafffd0003ab266dcce6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/118132
Tested-by: Mike Kaganski 
Reviewed-by: Mike Kaganski 

diff --git a/basic/qa/cppunit/test_scanner.cxx 
b/basic/qa/cppunit/test_scanner.cxx
index 5663c44d027e..6459ab45f6b1 100644
--- a/basic/qa/cppunit/test_scanner.cxx
+++ b/basic/qa/cppunit/test_scanner.cxx
@@ -13,7 +13,7 @@
 #include 
 #include 
 
-#include 
+#include 
 
 #include 
 
@@ -654,11 +654,9 @@ void ScannerTest::testNumbers()
 // the buffer is artificially constrained by the scanner.
 CPPUNIT_ASSERT_EQUAL(1u, static_cast(errors)); // HACK
 
-double fInf = 0.0;
-rtl::math::setInf(, false);
 symbols = getSymbols("10e308", errors);
 CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
-CPPUNIT_ASSERT_EQUAL(fInf, symbols[0].number);
+CPPUNIT_ASSERT_EQUAL(std::numeric_limits::infinity(), 
symbols[0].number);
 CPPUNIT_ASSERT_EQUAL(SbxDOUBLE, symbols[0].type);
 CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
 CPPUNIT_ASSERT_EQUAL(1u, static_cast(errors)); // math 
error, overflow
diff --git a/chart2/source/view/axes/MinimumAndMaximumSupplier.cxx 
b/chart2/source/view/axes/MinimumAndMaximumSupplier.cxx
index 422d08e64029..eaf5c4347379 100644
--- a/chart2/source/view/axes/MinimumAndMaximumSupplier.cxx
+++ b/chart2/source/view/axes/MinimumAndMaximumSupplier.cxx
@@ -21,8 +21,7 @@
 
 #include 
 
-#include 
-
+#include 
 #include 
 
 namespace chart
@@ -49,8 +48,7 @@ bool 
MergedMinimumAndMaximumSupplier::hasMinimumAndMaximumSupplier( MinimumAndMa
 
 double MergedMinimumAndMaximumSupplier::getMinimumX()
 {
-double fGlobalExtremum;
-::rtl::math::setInf(, false);
+double fGlobalExtremum = std::numeric_limits::infinity();
 for (auto const& elem : m_aMinimumAndMaximumSupplierList)
 {
 double fLocalExtremum = elem->getMinimumX();
@@ -64,8 +62,7 @@ double MergedMinimumAndMaximumSupplier::getMinimumX()
 
 double MergedMinimumAndMaximumSupplier::getMaximumX()
 {
-double fGlobalExtremum;
-::rtl::math::setInf(, true);
+double fGlobalExtremum = -std::numeric_limits::infinity();
 for (auto const& elem : m_aMinimumAndMaximumSupplierList)
 {
 double fLocalExtremum = elem->getMaximumX();
@@ -79,8 +76,7 @@ double MergedMinimumAndMaximumSupplier::getMaximumX()
 
 double MergedMinimumAndMaximumSupplier::getMinimumYInRange( double fMinimumX, 
double fMaximumX, sal_Int32 nAxisIndex )
 {
-double fGlobalExtremum;
-::rtl::math::setInf(, false);
+double fGlobalExtremum = std::numeric_limits::infinity();
 for (auto const& elem : m_aMinimumAndMaximumSupplierList)
 {
 double fLocalExtremum = elem->getMinimumYInRange( fMinimumX, 
fMaximumX, nAxisIndex );
@@ -94,8 +90,7 @@ double MergedMinimumAndMaximumSupplier::getMinimumYInRange( 
double fMinimumX, do
 
 double MergedMinimumAndMaximumSupplier::getMaximumYInRange( double fMinimumX, 
double fMaximumX, sal_Int32 nAxisIndex )
 {
-double fGlobalExtremum;
-::rtl::math::setInf(, true);
+double fGlobalExtremum = -std::numeric_limits::infinity();
 for (auto const& elem : m_aMinimumAndMaximumSupplierList)
 {
 double fLocalExtremum = elem->getMaximumYInRange( fMinimumX, 
fMaximumX, nAxisIndex );
@@ -109,8 +104,7 @@ double MergedMinimumAndMaximumSupplier::getMaximumYInRange( 
double fMinimumX, do
 
 double MergedMinimumAndMaximumSupplier::getMinimumZ()
 {
-double fGlobalExtremum;
-::rtl::math::setInf(, false);
+double fGlobalExtremum = std::numeric_limits::infinity();
 for (auto const& elem : m_aMinimumAndMaximumSupplierList)
 {
 double fLocalExtremum = elem->getMinimumZ();
@@ -124,8 +118,7 @@ double MergedMinimumAndMaximumSupplier::getMinimumZ()
 
 double MergedMinimumAndMaximumSupplier::getMaximumZ()
 {
-double fGlobalExtremum;
-::rtl::math::setInf(, true);
+double fGlobalExtremum = -std::numeric_limits::infinity();
 for (auto const& elem : m_aMinimumAndMaximumSupplierList)
 {
 double fLocalExtremum = 

[Libreoffice-commits] core.git: basic/qa basic/source

2021-06-25 Thread baltasarq (via logerrit)
 basic/qa/vba_tests/booltypename.vb |   37 +
 basic/source/comp/exprnode.cxx |   14 +++---
 basic/source/comp/symtbl.cxx   |2 ++
 basic/source/inc/filefmt.hxx   |3 +++
 basic/source/runtime/runtime.cxx   |2 ++
 5 files changed, 51 insertions(+), 7 deletions(-)

New commits:
commit 5eedb3beeaeed88de0d1ebd041a9f15ceea7e78c
Author: baltasarq 
AuthorDate: Tue Jun 22 12:55:21 2021 +0200
Commit: Mike Kaganski 
CommitDate: Fri Jun 25 16:26:50 2021 +0200

tdf#142460: properly handle boolean values in string pool

This makes sure that results of comparison of literals have proper boolean 
type,
and that this type is properly stored to/read from the string pool.

This introduces a new non-standard "type" character used in the pool: 'b'. 
It is
not a proper type character used in Basic (unlike '%'/'&'/'!'/'@'), but we 
have
to use this trick locally, because we need to pass the type that has no own 
type
character.

The change should be backward-compatible: older versions reading the value 
should
just ignore the 'b', and read the value as double.

Change-Id: Ibd4a70b366331342346eb171c8ed3c7026279596
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/117655
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/basic/qa/vba_tests/booltypename.vb 
b/basic/qa/vba_tests/booltypename.vb
new file mode 100644
index ..8c1fd17c211b
--- /dev/null
+++ b/basic/qa/vba_tests/booltypename.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_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"")")
+
+Exit Sub
+errorHandler:
+TestUtil.ReportErrorHandler("verify_testTypeNameBoolean", Err, Error$, Erl)
+End Sub
diff --git a/basic/source/comp/exprnode.cxx b/basic/source/comp/exprnode.cxx
index 4192ceb8d49d..17bdbca25258 100644
--- a/basic/source/comp/exprnode.cxx
+++ b/basic/source/comp/exprnode.cxx
@@ -262,7 +262,7 @@ void SbiExprNode::FoldConstantsBinaryNode(SbiParser* 
pParser)
 }
 else
 {
-eType = SbxDOUBLE;
+eType = SbxBOOL;
 eNodeType = SbxNUMVAL;
 int eRes = rr.compareTo( rl );
 switch( eTok )
@@ -365,22 +365,22 @@ void SbiExprNode::FoldConstantsBinaryNode(SbiParser* 
pParser)
 nVal = nl - nr; break;
 case EQ:
 nVal = ( nl == nr ) ? SbxTRUE : SbxFALSE;
-eType = SbxINTEGER; break;
+eType = SbxBOOL; break;
 case NE:
 nVal = ( nl != nr ) ? SbxTRUE : SbxFALSE;
-eType = SbxINTEGER; break;
+eType = SbxBOOL; break;
 case LT:
 nVal = ( nl <  nr ) ? SbxTRUE : SbxFALSE;
-eType = SbxINTEGER; break;
+eType = SbxBOOL; break;
 case GT:
 nVal = ( nl >  nr ) ? SbxTRUE : SbxFALSE;
-eType = SbxINTEGER; break;
+eType = SbxBOOL; break;
 case LE:
 nVal = ( nl <= nr ) ? SbxTRUE : SbxFALSE;
-eType = SbxINTEGER; break;
+eType = SbxBOOL; break;
 case GE:
 nVal = ( nl >= nr ) ? SbxTRUE : SbxFALSE;
-eType = SbxINTEGER; break;
+eType = SbxBOOL; break;
 case IDIV:
 if( !lr )
 {
diff --git a/basic/source/comp/symtbl.cxx b/basic/source/comp/symtbl.cxx
index d9e7fcae6abc..ed245a364874 100644
--- a/basic/source/comp/symtbl.cxx
+++ b/basic/source/comp/symtbl.cxx
@@ -66,6 +66,8 @@ short SbiStringPool::Add( double n, SbxDataType t )
 char buf[40]{};
 switch( t )
 {
+// tdf#142460 - properly handle boolean values in string pool
+case SbxBOOL: snprintf( buf, sizeof(buf), "%db", static_cast(n) 
); break;
 // tdf#131296 - store numeric value 

[Libreoffice-commits] core.git: basic/qa basic/source

2021-05-22 Thread Joshua Williams (via logerrit)
 basic/qa/basic_coverage/test_string_literal_comparison.vb |   19 ++
 basic/source/comp/exprnode.cxx|8 ++---
 2 files changed, 23 insertions(+), 4 deletions(-)

New commits:
commit 6cdfd89413eab85dba7b975199358cb8fae44661
Author: Joshua Williams 
AuthorDate: Fri May 21 19:29:52 2021 -0500
Commit: Mike Kaganski 
CommitDate: Sun May 23 07:14:07 2021 +0200

tdf#142180 Swapped comparison operators for static strings

It seems that, for some reason, the comparison operators for
strings in basic were swapped in the code that evaluates
string comparisons at compile-time. This is what caused
bug #142180. This commit simply swaps the operators and
should fix the bug.

Change-Id: I14f90db8598f2f7f8b709e26902986e1f64af576
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115983
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/basic/qa/basic_coverage/test_string_literal_comparison.vb 
b/basic/qa/basic_coverage/test_string_literal_comparison.vb
new file mode 100644
index ..af63ede517dc
--- /dev/null
+++ b/basic/qa/basic_coverage/test_string_literal_comparison.vb
@@ -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 Integer
+' tdf#142180 - Invalid text comparison result in Basic
+
+doUnitTest = 0
+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 = 1
+End Function
diff --git a/basic/source/comp/exprnode.cxx b/basic/source/comp/exprnode.cxx
index 1771da0017f3..4192ceb8d49d 100644
--- a/basic/source/comp/exprnode.cxx
+++ b/basic/source/comp/exprnode.cxx
@@ -274,16 +274,16 @@ void SbiExprNode::FoldConstantsBinaryNode(SbiParser* 
pParser)
 nVal = ( eRes != 0 ) ? SbxTRUE : SbxFALSE;
 break;
 case LT:
-nVal = ( eRes < 0 ) ? SbxTRUE : SbxFALSE;
+nVal = ( eRes > 0 ) ? SbxTRUE : SbxFALSE;
 break;
 case GT:
-nVal = ( eRes > 0 ) ? SbxTRUE : SbxFALSE;
+nVal = ( eRes < 0 ) ? SbxTRUE : SbxFALSE;
 break;
 case LE:
-nVal = ( eRes <= 0 ) ? SbxTRUE : SbxFALSE;
+nVal = ( eRes >= 0 ) ? SbxTRUE : SbxFALSE;
 break;
 case GE:
-nVal = ( eRes >= 0 ) ? SbxTRUE : SbxFALSE;
+nVal = ( eRes <= 0 ) ? SbxTRUE : SbxFALSE;
 break;
 default:
 pParser->Error( ERRCODE_BASIC_CONVERSION );
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: basic/qa basic/source

2021-05-13 Thread Andreas Heinisch (via logerrit)
 basic/qa/basic_coverage/test_instr_method.vb |   17 +++--
 basic/qa/vba_tests/instr.vb  |3 +++
 basic/source/runtime/methods.cxx |9 +++--
 3 files changed, 21 insertions(+), 8 deletions(-)

New commits:
commit 7a578c06352328799c644e0399f14d58b05246f9
Author: Andreas Heinisch 
AuthorDate: Thu May 13 09:38:14 2021 +0200
Commit: Andreas Heinisch 
CommitDate: Thu May 13 18:36:20 2021 +0200

tdf#139840 - Case-insensitive operation for non-ASCII characters

Support case-insensitive operation for non-ASCII characters in the
InStr function in Basic.

Change-Id: Idb2b8e128adf3596fa49e3e86365d5724ea3e11c
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115538
Tested-by: Jenkins
Reviewed-by: Andreas Heinisch 

diff --git a/basic/qa/basic_coverage/test_instr_method.vb 
b/basic/qa/basic_coverage/test_instr_method.vb
index 716aa215878b..47fa7a94ede1 100644
--- a/basic/qa/basic_coverage/test_instr_method.vb
+++ b/basic/qa/basic_coverage/test_instr_method.vb
@@ -6,12 +6,17 @@
 '
 
 Function doUnitTest as Integer
-dim aString as Variant
+
+doUnitTest = 0
+
+Dim aString As Variant
 aString = "Hello"
 ' InStr
-If ( InStr( 1, aString, "l", 1) <> 3 ) Then
-doUnitTest = 0
-Else
-doUnitTest = 1
-End If
+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
+
+doUnitTest = 1
+
 End Function
diff --git a/basic/qa/vba_tests/instr.vb b/basic/qa/vba_tests/instr.vb
index 74f7e2f755d4..3ced2a07c8ca 100644
--- a/basic/qa/vba_tests/instr.vb
+++ b/basic/qa/vba_tests/instr.vb
@@ -30,6 +30,9 @@ Sub verify_testInStr()
 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)")
+
 Exit Sub
 errorHandler:
 TestUtil.ReportErrorHandler("verify_testInStr", Err, Error$, Erl)
diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx
index 843c85b4860f..73bfe7fbc2d0 100644
--- a/basic/source/runtime/methods.cxx
+++ b/basic/source/runtime/methods.cxx
@@ -887,8 +887,13 @@ void SbRtl_InStr(StarBASIC *, SbxArray & rPar, bool)
 OUString aStr1 = rPar.Get(nFirstStringPos)->GetOUString();
 OUString aToken = rToken;
 
-aStr1 = aStr1.toAsciiUpperCase();
-aToken = aToken.toAsciiUpperCase();
+// tdf#139840 - case-insensitive operation for non-ASCII 
characters
+const css::lang::Locale& rLocale
+= Application::GetSettings().GetLanguageTag().getLocale();
+css::uno::Reference xCharClass
+= vcl::unohelper::CreateCharacterClassification();
+aStr1 = xCharClass->toUpper(aStr1, 0, aStr1.getLength(), 
rLocale);
+aToken = xCharClass->toUpper(aToken, 0, aToken.getLength(), 
rLocale);
 
 nPos = aStr1.indexOf( aToken, nStartPos-1 ) + 1;
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: basic/qa i18npool/source

2021-05-05 Thread Eike Rathke (via logerrit)
 basic/qa/vba_tests/weekdayname.vb |5 +++--
 i18npool/source/localedata/data/en_GB.xml |   12 +++-
 2 files changed, 14 insertions(+), 3 deletions(-)

New commits:
commit 9df3aa7ea72d61462e430643f2a80906dce4e15b
Author: Eike Rathke 
AuthorDate: Wed May 5 23:05:34 2021 +0200
Commit: Eike Rathke 
CommitDate: Thu May 6 01:38:55 2021 +0200

Change en_GB calendar StartDayOfWeek to Monday and MinimalDaysInFirstWeek 
to 4

Inherit day, month and era names from en_US but with proper
values. See https://lh.2xlibre.net/locale/en_GB/
- Week definition (week)
- First day of week (first_weekday)

or

% LC_TIME=en_US locale -k LC_TIME
week-ndays=7
week-1stday=19971130
week-1stweek=1
first_weekday=1
first_workday=2

% LC_TIME=en_GB locale -k LC_TIME
week-ndays=7
week-1stday=19971130
week-1stweek=4
first_weekday=2
first_workday=2

This makes it necessary to adapt basic/qa/vba_tests/weekdayname.vb
because basic/qa/cppunit/test_vba.cxx sets LANGUAGE_ENGLISH_UK

Change-Id: I752bf0e59396f0cbd601beb596c07e77e4e4cfaf
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/115160
Tested-by: Jenkins
Reviewed-by: Eike Rathke 

diff --git a/basic/qa/vba_tests/weekdayname.vb 
b/basic/qa/vba_tests/weekdayname.vb
index 5cc7bd9571fe..bddbdb7732d7 100644
--- a/basic/qa/vba_tests/weekdayname.vb
+++ b/basic/qa/vba_tests/weekdayname.vb
@@ -18,10 +18,11 @@ End Function
 Sub verify_testWeekDayName()
 On Error GoTo errorHandler
 
-TestUtil.AssertEqual(WeekdayName(1),"Sunday", 
"WeekdayName(1)")
+' 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),"Monday", 
"WeekdayName(2)")
+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)")
diff --git a/i18npool/source/localedata/data/en_GB.xml 
b/i18npool/source/localedata/data/en_GB.xml
index f12fad0dc56e..2928b62529da 100644
--- a/i18npool/source/localedata/data/en_GB.xml
+++ b/i18npool/source/localedata/data/en_GB.xml
@@ -215,7 +215,17 @@
   
   
   
-  
+  
+
+  
+  
+  
+  
+mon
+  
+  4
+
+  
   
 
   GBP
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: basic/qa basic/source

2021-05-01 Thread tushar (via logerrit)
 basic/qa/vba_tests/strconv.vb|   28 +++-
 basic/source/runtime/methods.cxx |   14 +++---
 2 files changed, 30 insertions(+), 12 deletions(-)

New commits:
commit 6fecdeac5d81a60a479195a62cdc174b919f763b
Author: tushar 
AuthorDate: Mon Mar 15 22:17:46 2021 +0530
Commit: Mike Kaganski 
CommitDate: Sat May 1 13:12:22 2021 +0200

tdf#124184 Fixing StrConv VBA Function

* vbUnicode/vbFromUnicode considers optional third LCID argument.
* LCID is also used for other conversions.
* The encoding is decided based on the language defined in LCID,
  or on program locale when LCID is omitted, using MS default
  ACP mapping for languages.
* Unit testis for vbWide / vbNarrow are changed and enabled.
* Unit tests for vbKatakana / vbHiragana are changed and enabled.
* Unit test for vbFromUnicode / vbUnicode is changed to rely on
  en-US locale used in testing, and is enabled.

Change-Id: Iabd4153db311cd02c3f3e7247f9fc71ad9f5f682
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112539
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/basic/qa/vba_tests/strconv.vb b/basic/qa/vba_tests/strconv.vb
index 9bb6f9649a1d..b0295df428b2 100644
--- a/basic/qa/vba_tests/strconv.vb
+++ b/basic/qa/vba_tests/strconv.vb
@@ -23,21 +23,31 @@ Sub verify_testStrConv()
 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), 
"£Á£Â£Ã£Ä£ÅVB¥ì¥¹¥­¥å©`", "StrConv(""ABCDEVB¥ì¥¹¥­¥å©`"", vbWide)")
+TestUtil.AssertEqual(StrConv("ABCDEVB¥ì¥¹¥­¥å©", vbWide), 
"ABCDEVB¥ì¥¹¥­¥å©", "StrConv(""ABCDEVB¥ì¥¹¥­¥å©"", vbWide)")
 
 ' Converts wide (double-byte) characters in string to narrow (single-byte) 
characters
-'TestUtil.AssertEqual(StrConv("£Á£Â£Ã£Ä£ÅVB¥ì¥¹¥­¥å©`", vbNarrow), 
"ABCDEVB¥ì¥¹¥­¥å©`", "StrConv(""£Á£Â£Ã£Ä£ÅVB¥ì¥¹¥­¥å©`"", vbNarrow)")
+TestUtil.AssertEqual(StrConv("ABCD@$%23'?EG", vbNarrow), "ABCD@$%23'?EG", 
"StrConv(""ABCD@$%23'?EG"", vbNarrow)")
 
 ' Converts Hiragana characters in string to Katakana characters
-'TestUtil.AssertEqual(StrConv("¤Ï¤Ê¤Á¤ã¤ó", vbKatakana), "¥Ï¥Ê¥Á¥ã¥ó", 
"StrConv(""¤Ï¤Ê¤Á¤ã¤ó"", vbKatakana)")
+TestUtil.AssertEqual(StrConv("かたかな", vbKatakana), "カタカナ", 
"StrConv(""かたかな"", vbKatakana)")
 
 ' Converts Katakana characters in string to Hiragana characters
-'TestUtil.AssertEqual(StrConv("¥Ï¥Ê¥Á¥ã¥ó", vbHiragana), "¤Ï¤Ê¤Á¤ã¤ó", 
"StrConv(""¥Ï¥Ê¥Á¥ã¥ó"", vbHiragana)")
-
-'Dim x() As Byte
-'x = StrConv("ÉϺ£ÊÐABC", vbFromUnicode)
-'TestUtil.AssertEqual(UBound(x), 8, "UBound(x)")
-'TestUtil.AssertEqual(StrConv(x, vbUnicode), "ÉϺ£ÊÐABC", "StrConv(x, 
vbUnicode)")
+TestUtil.AssertEqual(StrConv("カタカナ", vbHiragana), "かたかな", 
"StrConv(""カタカナ"", vbHiragana)")
+
+' Assumes CP-1252 encoding associated with en-US locale used in unit tests.
+Dim x() As Byte
+x = StrConv("ÉϺ£ÊÐABC", vbFromUnicode)
+TestUtil.AssertEqual(UBound(x), 8, "UBound(x)")
+TestUtil.AssertEqual(x(0), 201, "x(0)")
+TestUtil.AssertEqual(x(1), 207, "x(1)")
+TestUtil.AssertEqual(x(2), 186, "x(2)")
+TestUtil.AssertEqual(x(3), 163, "x(3)")
+TestUtil.AssertEqual(x(4), 202, "x(4)")
+TestUtil.AssertEqual(x(5), 208, "x(5)")
+TestUtil.AssertEqual(x(6), 65, "x(6)")
+TestUtil.AssertEqual(x(7), 66, "x(7)")
+TestUtil.AssertEqual(x(8), 67, "x(8)")
+TestUtil.AssertEqual(StrConv(x, vbUnicode), "ÉϺ£ÊÐABC", "StrConv(x, 
vbUnicode)")
 
 Exit Sub
 errorHandler:
diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx
index 910b95f084fa..843c85b4860f 100644
--- a/basic/source/runtime/methods.cxx
+++ b/basic/source/runtime/methods.cxx
@@ -39,6 +39,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -4106,6 +4107,14 @@ void SbRtl_StrConv(StarBASIC *, SbxArray & rPar, bool)
 
 OUString aOldStr = rPar.Get(1)->GetOUString();
 sal_Int32 nConversion = rPar.Get(2)->GetLong();
+LanguageType nLanguage = LANGUAGE_SYSTEM;
+if (nArgCount == 3)
+{
+sal_Int32 lcid = rPar.Get(3)->GetLong();
+nLanguage = LanguageType(lcid);
+}
+OUString sLanguage = LanguageTag(nLanguage).getLanguage();
+rtl_TextEncoding encodingVal = 
utl_getWinTextEncodingFromLangStr(sLanguage);
 
 sal_Int32 nOldLen = aOldStr.getLength();
 if( nOldLen == 0 )
@@ -4151,7 +4160,6 @@ void SbRtl_StrConv(StarBASIC *, SbxArray & rPar, bool)
 uno::Reference< uno::XComponentContext > xContext = 
getProcessComponentContext();
 ::utl::TransliterationWrapper aTransliterationWrapper( xContext, nType 
);
 uno::Sequence aOffsets;
-LanguageType nLanguage = LANGUAGE_SYSTEM;
 aTransliterationWrapper.loadModuleIfNeeded( nLanguage );
 aNewStr = 

[Libreoffice-commits] core.git: basic/qa basic/source

2021-04-05 Thread Andreas Heinisch (via logerrit)
 basic/qa/basic_coverage/test_mod_operator.vb |   25 +
 basic/source/comp/exprnode.cxx   |   13 +
 2 files changed, 34 insertions(+), 4 deletions(-)

New commits:
commit a9fcd2cf2bfb42693787e8c4197e5988e155e235
Author: Andreas Heinisch 
AuthorDate: Sun Apr 4 19:34:47 2021 +0200
Commit: Andreas Heinisch 
CommitDate: Mon Apr 5 16:38:44 2021 +0200

tdf#141201 - Round MOD literals to Integer values

(regression from commit I8dbfdf4bb2eceac0b5afbddd3f35e1dcde2db68b
"tdf#84435: Mod operator does not deal with decimals as described in help").

Change-Id: I74b231d3814148579a3be0a92b7602fa4387281f
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/113571
Tested-by: Jenkins
Reviewed-by: Andreas Heinisch 

diff --git a/basic/qa/basic_coverage/test_mod_operator.vb 
b/basic/qa/basic_coverage/test_mod_operator.vb
new file mode 100644
index ..006d97558052
--- /dev/null
+++ b/basic/qa/basic_coverage/test_mod_operator.vb
@@ -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 Integer
+
+doUnitTest = 0
+
+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 = 1
+
+End Function
diff --git a/basic/source/comp/exprnode.cxx b/basic/source/comp/exprnode.cxx
index 02f8801f1aea..1771da0017f3 100644
--- a/basic/source/comp/exprnode.cxx
+++ b/basic/source/comp/exprnode.cxx
@@ -27,6 +27,8 @@
 
 #include 
 
+#include 
+
 SbiExprNode::SbiExprNode( std::unique_ptr l, SbiToken t, 
std::unique_ptr r ) :
 pLeft(std::move(l)),
 pRight(std::move(r)),
@@ -294,8 +296,13 @@ void SbiExprNode::FoldConstantsBinaryNode(SbiParser* 
pParser)
 {
 double nl = pLeft->nVal;
 double nr = pRight->nVal;
+// tdf#141201 - round MOD literals to Integer values
+if (eTok == MOD)
+{
+nl = rtl::math::round(nl);
+nr = rtl::math::round(nr);
+}
 tools::Long ll = 0, lr = 0;
-tools::Long llMod = 0, lrMod = 0;
 if( ( eTok >= AND && eTok <= IMP )
|| eTok == IDIV || eTok == MOD )
 {
@@ -322,8 +329,6 @@ void SbiExprNode::FoldConstantsBinaryNode(SbiParser* 
pParser)
 nr = SbxMINLNG;
 }
 ll = static_cast(nl); lr = 
static_cast(nr);
-llMod = static_cast(nl);
-lrMod = static_cast(nr);
 if( bErr )
 {
 pParser->Error( ERRCODE_BASIC_MATH_OVERFLOW );
@@ -388,7 +393,7 @@ void SbiExprNode::FoldConstantsBinaryNode(SbiParser* 
pParser)
 {
 pParser->Error( ERRCODE_BASIC_ZERODIV ); nVal = HUGE_VAL;
 bError = true;
-} else nVal = llMod - lrMod * (llMod/lrMod);
+} else nVal = ll - lr * (ll/lr);
 eType = SbxLONG; break;
 case AND:
 nVal = static_cast( ll & lr ); eType = SbxLONG; break;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: basic/qa

2021-03-29 Thread Alain Romedenne (via logerrit)
 basic/qa/basic_coverage/test_typelen_method.vb  |   54 +++--
 basic/qa/basic_coverage/test_typename_method.vb |   73 --
 basic/qa/basic_coverage/test_vartype_method.vb  |   95 ++--
 3 files changed, 201 insertions(+), 21 deletions(-)

New commits:
commit 08151f4827cc954188243f06660076534bc30c1f
Author: Alain Romedenne 
AuthorDate: Wed Feb 17 15:50:50 2021 +0100
Commit: Mike Kaganski 
CommitDate: Mon Mar 29 15:29:39 2021 +0200

TypeName, VarType, TypeLen Basic QA test cases

1- exhibiting array type names
2- highlighting supplemental libO Basic constants
3- precising data types internal representations

I intend to document in help:

1- primitive data types array names: Boolean(), Byte(), … as IsArray() 
function does not provide such info
2- Publish extra Basic constants for already published values:
  - V_OBJECT=9, V_BOOLEAN=11, V_VARIANT=12, V_BYTE=17
  - not necessarily V_ARRAY=8192, V_ERROR=10

The latter is conditioned to the creation of an enhancement request.

FYI, published Vartype() values and constants for VBA and other Basic-like 
languages:


https://docs.microsoft.com/en-us/office/vba/language/reference/user-interface-help/vartype-function
https://docs.xojo.com/VarType

https://help.hcltechsw.com/dom_designer/9.0.1/appdev/LSAZ_DATATYPE_FUNCTION.html

Change-Id: I51bac3caf555d94e91de7c6d624b3fca9e73a673
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/111042
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/basic/qa/basic_coverage/test_typelen_method.vb 
b/basic/qa/basic_coverage/test_typelen_method.vb
index 4684790078c5..a9ebb01446bb 100644
--- a/basic/qa/basic_coverage/test_typelen_method.vb
+++ b/basic/qa/basic_coverage/test_typelen_method.vb
@@ -6,11 +6,51 @@
 ' file, You can obtain one at http://mozilla.org/MPL/2.0/.
 '
 
-Function doUnitTest as Integer
-' TYPELEN
-If ( TypeLen("Hello") <> 5 ) Then
-doUnitTest = 0
-Else
-doUnitTest = 1
-End If
+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 = 1 ' 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.vb 
b/basic/qa/basic_coverage/test_typename_method.vb
index eba2d86c404b..ec9dbb408ac5 100644
--- a/basic/qa/basic_coverage/test_typename_method.vb
+++ b/basic/qa/basic_coverage/test_typename_method.vb
@@ -5,12 +5,71 @@
 ' License, v. 2.0. If a copy of the MPL was not distributed with this
 ' file, You can obtain one at http://mozilla.org/MPL/2.0/.
 '
+Type UDF ' User defined type
+l As Object
+s as String
+End Type
+Dim myUDF as UDF
 
-Function doUnitTest as Integer
-' TYPENAME
-If ( TypeName("Hello") <> "String" ) Then
-doUnitTest = 0
-Else
-doUnitTest = 1
-End If
+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_%, 

[Libreoffice-commits] core.git: basic/qa basic/source

2021-03-20 Thread arpit1912 (via logerrit)
 basic/qa/basic_coverage/test_ccur_method.vb |   16 +++-
 basic/source/sbx/sbxcurr.cxx|2 +-
 2 files changed, 12 insertions(+), 6 deletions(-)

New commits:
commit 54b3ada2e5ef9dcbc452509a7bbe39f0920572e2
Author: arpit1912 
AuthorDate: Fri Mar 19 16:10:16 2021 +0530
Commit: Andreas Heinisch 
CommitDate: Sat Mar 20 11:57:48 2021 +0100

tdf#141050 Accept CCur with negative strings

the ImpStringToCurrency now increment the pointer on finding a '+' or '-' 
in sbxcurr.cxx file

Change-Id: I4a1093ae0b4e52b6a61dc412bd5e7b95b1309e7a
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112734
Tested-by: Jenkins
Reviewed-by: Andreas Heinisch 

diff --git a/basic/qa/basic_coverage/test_ccur_method.vb 
b/basic/qa/basic_coverage/test_ccur_method.vb
index b84ddafd5713..e4eef652441f 100644
--- a/basic/qa/basic_coverage/test_ccur_method.vb
+++ b/basic/qa/basic_coverage/test_ccur_method.vb
@@ -7,10 +7,16 @@
 '
 
 Function doUnitTest as Integer
+
+doUnitTest = 0
+
 ' CCUR
-If (CCur("100") <> 100) Then
-doUnitTest = 0
-Else
-doUnitTest = 1
-End If
+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 = 1
+
 End Function
diff --git a/basic/source/sbx/sbxcurr.cxx b/basic/source/sbx/sbxcurr.cxx
index 50b530cda193..416229afbc95 100644
--- a/basic/source/sbx/sbxcurr.cxx
+++ b/basic/source/sbx/sbxcurr.cxx
@@ -106,7 +106,7 @@ static sal_Int64 ImpStringToCurrency( const OUString  )
 OUStringBuffer sNormalisedNumString( sTmp.getLength() +  nFractDigit );
 
 if ( *p == '-'  || *p == '+' )
-sNormalisedNumString.append( *p );
+sNormalisedNumString.append( *p++ );
 
 while ( *p >= '0' && *p <= '9' )
 {
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: basic/qa basic/source

2021-03-15 Thread Andreas Heinisch (via logerrit)
 basic/qa/basic_coverage/test_string_replace.vb |6 ++
 basic/source/runtime/methods.cxx   |2 +-
 2 files changed, 7 insertions(+), 1 deletion(-)

New commits:
commit ac0b6fb3842201e438950ea99a55ad334f8521ab
Author: Andreas Heinisch 
AuthorDate: Mon Mar 15 13:41:58 2021 +0100
Commit: Andreas Heinisch 
CommitDate: Mon Mar 15 15:16:57 2021 +0100

tdf#141045 - fixed copy paste error in the replace function

Change-Id: Id68670fed89e4cc700c5eea395139914bebdb657
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/112509
Tested-by: Jenkins
Reviewed-by: Andreas Heinisch 

diff --git a/basic/qa/basic_coverage/test_string_replace.vb 
b/basic/qa/basic_coverage/test_string_replace.vb
index 99eafdba6b14..e2e9ce35962b 100644
--- a/basic/qa/basic_coverage/test_string_replace.vb
+++ b/basic/qa/basic_coverage/test_string_replace.vb
@@ -23,6 +23,12 @@ Function verify_stringReplace() As String
 retStr = Replace("АБВабв", "б", "*")
 TestLog_ASSERT 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")
+TestLog_ASSERT retStr, "a", "different length of search and replace 
string: " & retStr
+
 result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & 
"Tests failed: " & failCount & Chr$(10)
 verify_stringReplace = result
 End Function
diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx
index 2e2311078a67..0276a41c1b17 100644
--- a/basic/source/runtime/methods.cxx
+++ b/basic/source/runtime/methods.cxx
@@ -1289,7 +1289,7 @@ void SbRtl_Replace(StarBASIC *, SbxArray & rPar, bool)
 const css::lang::Locale& rLocale = 
Application::GetSettings().GetUILanguageTag().getLocale();
 css::uno::Reference < i18n::XCharacterClassification > xCharClass = 
vcl::unohelper::CreateCharacterClassification();
 aSrcStr = xCharClass->toUpper(aSrcStr, 0, aSrcStr.getLength(), 
rLocale);
-aFindStr = xCharClass->toUpper(aFindStr, 0, aSrcStr.getLength(), 
rLocale);
+aFindStr = xCharClass->toUpper(aFindStr, 0, aFindStr.getLength(), 
rLocale);
 }
 
 // Note: the result starts from lStartPos, removing everything to the 
left. See i#94895.
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: basic/qa

2021-02-17 Thread shubham656 (via logerrit)
 basic/qa/cppunit/test_scanner.cxx |   77 ++
 basic/qa/vba_tests/typename.vb|   14 ++
 basic/qa/vba_tests/vartype.vb |   38 +++---
 3 files changed, 123 insertions(+), 6 deletions(-)

New commits:
commit 30ca77c43ba1c8f94d6f34eea763a3d3ca7e72f6
Author: shubham656 
AuthorDate: Tue Jan 26 21:33:53 2021 +0530
Commit: Andreas Heinisch 
CommitDate: Wed Feb 17 15:34:22 2021 +0100

tdf#130677 Write new tests for literals

Change-Id: I22607fdcaab840ca1512abf534712d36d4b5ee9b
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/109964
Reviewed-by: Mike Kaganski 
Reviewed-by: Andreas Heinisch 
Tested-by: Jenkins

diff --git a/basic/qa/cppunit/test_scanner.cxx 
b/basic/qa/cppunit/test_scanner.cxx
index ed340755deba..5663c44d027e 100644
--- a/basic/qa/cppunit/test_scanner.cxx
+++ b/basic/qa/cppunit/test_scanner.cxx
@@ -1034,6 +1034,83 @@ void ScannerTest::testHexOctal()
 CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
 // ERRCODE_BASIC_MATH_OVERFLOW
 CPPUNIT_ASSERT_EQUAL(1u, static_cast(errors));
+
+// maximum for Hex & = SbxLONG
+symbols = getSymbols("&");
+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("&");
+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("&", 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(errors));
+
+// maximum for Octal & = SbxLONG
+symbols = getSymbols("&");
+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("&", 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("&", 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(errors));
+
+/* test for leading zeros */
+
+//  = 65535
+symbols = getSymbols("");
+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);
+
+//  = 83
+symbols = getSymbols("");
+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("");
+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()
diff --git a/basic/qa/vba_tests/typename.vb b/basic/qa/vba_tests/typename.vb
index c8fa5330a8e8..4442cba55e98 100644
--- a/basic/qa/vba_tests/typename.vb
+++ b/basic/qa/vba_tests/typename.vb
@@ -25,6 +25,13 @@ Sub verify_testTypeName()
 Dim l1 As Long
 Dim s1 As String
 
+Dim TestIntSign%
+Dim TestLongSign&
+Dim TestSingleSign!
+Dim TestDoubleSign#
+Dim TestCurrSign@
+Dim TestStrSign$
+
 TestUtil.AssertEqual(TypeName(s1), "String",  "TypeName(s1)")
 

[Libreoffice-commits] core.git: basic/qa basic/source

2021-01-24 Thread Andreas Heinisch (via logerrit)
 basic/qa/basic_coverage/test_redim_objects.vb |   33 
 basic/qa/vba_tests/redim_objects.vb   |   42 ++
 basic/source/comp/dim.cxx |9 -
 3 files changed, 82 insertions(+), 2 deletions(-)

New commits:
commit 0426748927919dbfd4cf5c0bb904e21a90d6c9d7
Author: Andreas Heinisch 
AuthorDate: Sun Nov 29 10:26:56 2020 +0100
Commit: Andreas Heinisch 
CommitDate: Mon Jan 25 07:57:59 2021 +0100

tdf#136755, tdf#124008 - delete the variable beforehand REDIM

If an array of objects is passed as an argument to ReDim, delete the
variable beforehand, otherwise the construction of the new variable
fails, because the old one is still on the stack.

Change-Id: Ic863a36f5f2aca658df369f95d275aa287edf795
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106832
Tested-by: Jenkins
Reviewed-by: Andreas Heinisch 

diff --git a/basic/qa/basic_coverage/test_redim_objects.vb 
b/basic/qa/basic_coverage/test_redim_objects.vb
new file mode 100644
index ..053ba1aa2521
--- /dev/null
+++ b/basic/qa/basic_coverage/test_redim_objects.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/.
+'
+
+Type testType
+iNrAs Integer
+sType  As String
+aValue As Variant
+oColor As Object
+End Type
+
+Function doUnitTest as Integer
+
+doUnitTest = 0
+
+' 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 = 1
+
+End Function
diff --git a/basic/qa/vba_tests/redim_objects.vb 
b/basic/qa/vba_tests/redim_objects.vb
new file mode 100644
index ..9355b28da96c
--- /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
+iNrAs 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/source/comp/dim.cxx b/basic/source/comp/dim.cxx
index 17eef0a263a5..e95e8ee88054 100644
--- a/basic/source/comp/dim.cxx
+++ b/basic/source/comp/dim.cxx
@@ -431,9 +431,14 @@ void SbiParser::DefVar( SbiOpcode eOp, bool bStatic )
 }
 else
 {
-pDef->SetDims( pDim->GetDims() );
-SbiExpression aExpr( this, *pDef, std::move(pDim) );
+// tdf#136755 - delete the variable beforehand REDIM
+SbiExpression aExpr(this, *pDef, nullptr);
 aExpr.Gen();
+aGen.Gen(bVBASupportOn ? SbiOpcode::ERASE_CLEAR_ : 
SbiOpcode::ERASE_);
+
+pDef->SetDims( pDim->GetDims() );
+SbiExpression aExpr2( this, *pDef, std::move(pDim) );
+aExpr2.Gen();
 aGen.Gen( SbiOpcode::DCREATE_, pDef->GetId(), 
pDef->GetTypeId() );
 }
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: basic/qa

2020-12-30 Thread Mike Kaganski (via logerrit)
 basic/qa/cppunit/test_vba.cxx |4 ++--
 1 file changed, 2 insertions(+), 2 deletions(-)

New commits:
commit 97c3280afbb960bd5567bb56af4090fc38030df7
Author: Mike Kaganski 
AuthorDate: Wed Dec 30 09:24:44 2020 +0300
Commit: Stephan Bergmann 
CommitDate: Wed Dec 30 14:55:44 2020 +0100

Fix build after 042033f1e6da22616cb76c8d950c20c9efecbad5

Change-Id: Ifca32f434442f7838aae6f47dc2831dfa6a3f5db
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/108496
Tested-by: Stephan Bergmann 
Reviewed-by: Stephan Bergmann 

diff --git a/basic/qa/cppunit/test_vba.cxx b/basic/qa/cppunit/test_vba.cxx
index a38e4ceaab16..9a3cbe8baab9 100644
--- a/basic/qa/cppunit/test_vba.cxx
+++ b/basic/qa/cppunit/test_vba.cxx
@@ -221,11 +221,11 @@ void VBATest::testMiscOLEStuff()
 "ole_ObjAssignToNothing.vb",
 };
 
-OUString sMacroPathURL = 
m_directories.getURLFromSrc("/basic/qa/vba_tests/");
+OUString sMacroPathURL = 
m_directories.getURLFromSrc(u"/basic/qa/vba_tests/");
 
 uno::Sequence< uno::Any > aArgs(2);
 // path to test document
-OUString sPath = 
m_directories.getPathFromSrc("/basic/qa/vba_tests/data/ADODBdata.xls");
+OUString sPath = 
m_directories.getPathFromSrc(u"/basic/qa/vba_tests/data/ADODBdata.xls");
 sPath = sPath.replaceAll( "/", "\\" );
 
 aArgs[ 0 ] <<= sPath;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: basic/qa

2020-12-21 Thread Mike Kaganski (via logerrit)
 basic/qa/cppunit/test_vba.cxx|2 
 basic/qa/vba_tests/Err.Raise.vb  |   31 +-
 basic/qa/vba_tests/_test_asserts.vb  |   38 +-
 basic/qa/vba_tests/abs.vb|   39 +-
 basic/qa/vba_tests/array.vb  |   64 +---
 basic/qa/vba_tests/asc.vb|   39 +-
 basic/qa/vba_tests/atn.vb|   48 +--
 basic/qa/vba_tests/bytearraystring.vb|   26 -
 basic/qa/vba_tests/cbool.vb  |   80 +
 basic/qa/vba_tests/cdate.vb  |   38 +-
 basic/qa/vba_tests/cdbl.vb   |   43 +-
 basic/qa/vba_tests/cdec.vb   |   63 +---
 basic/qa/vba_tests/choose.vb |   51 +--
 basic/qa/vba_tests/chr.vb|   38 +-
 basic/qa/vba_tests/cint.vb   |   77 +
 basic/qa/vba_tests/clng.vb   |   61 +---
 basic/qa/vba_tests/constants.vb  |   28 +
 basic/qa/vba_tests/cos.vb|   39 +-
 basic/qa/vba_tests/csng.vb   |   43 +-
 basic/qa/vba_tests/cstr.vb   |   37 +-
 basic/qa/vba_tests/cvdate.vb |   40 +-
 basic/qa/vba_tests/cverr.vb  |   67 +---
 basic/qa/vba_tests/dateadd.vb|   92 +-
 basic/qa/vba_tests/datediff.vb   |  124 ++--
 basic/qa/vba_tests/datepart.vb   |   69 +---
 basic/qa/vba_tests/dateserial.vb |   34 +-
 basic/qa/vba_tests/datevalue.vb  |   34 --
 basic/qa/vba_tests/day.vb|   28 -
 basic/qa/vba_tests/enum.vb   |   15 -
 basic/qa/vba_tests/error.vb  |   29 -
 basic/qa/vba_tests/exp.vb|   28 -
 basic/qa/vba_tests/fix.vb|   38 +-
 basic/qa/vba_tests/format.vb |  457 +++
 basic/qa/vba_tests/formatnumber.vb   |   58 +--
 basic/qa/vba_tests/hex.vb|   57 +--
 basic/qa/vba_tests/hour.vb   |   41 +-
 basic/qa/vba_tests/iif.vb|   38 +-
 basic/qa/vba_tests/instr.vb  |   58 +--
 basic/qa/vba_tests/instrrev.vb   |   58 +--
 basic/qa/vba_tests/int.vb|   48 +--
 basic/qa/vba_tests/isarray.vb|   42 +-
 basic/qa/vba_tests/isdate.vb |   38 +-
 basic/qa/vba_tests/isempty.vb|   37 +-
 basic/qa/vba_tests/iserror.vb|   33 --
 basic/qa/vba_tests/ismissing.vb  |  113 ---
 basic/qa/vba_tests/isnull.vb |   33 --
 basic/qa/vba_tests/isnumeric.vb  |   58 +--
 basic/qa/vba_tests/isobject.vb   |   36 +-
 basic/qa/vba_tests/join.vb   |   45 +--
 basic/qa/vba_tests/lbound.vb |   35 +-
 basic/qa/vba_tests/lcase.vb  |   43 +-
 basic/qa/vba_tests/left.vb   |   38 +-
 basic/qa/vba_tests/len.vb|   38 +-
 basic/qa/vba_tests/log.vb|   38 +-
 basic/qa/vba_tests/ltrim.vb  |   28 -
 basic/qa/vba_tests/mid.vb|   38 +-
 basic/qa/vba_tests/minute.vb |   28 -
 basic/qa/vba_tests/month.vb  |   50 +--
 basic/qa/vba_tests/monthname.vb  |   38 +-
 basic/qa/vba_tests/oct.vb|   38 +-
 basic/qa/vba_tests/optional_paramters.vb |  115 ---
 basic/qa/vba_tests/partition.vb  |   46 +--
 basic/qa/vba_tests/qbcolor.vb|   68 +---
 basic/qa/vba_tests/rate.vb   |   56 +--
 basic/qa/vba_tests/replace.vb|   58 +--
 basic/qa/vba_tests/rgb.vb|   41 +-
 basic/qa/vba_tests/right.vb  |   38 +-
 basic/qa/vba_tests/rtrim.vb  |   28 -
 basic/qa/vba_tests/second.vb |   33 --
 basic/qa/vba_tests/sgn.vb|   48 +--
 basic/qa/vba_tests/sin.vb|   28 -
 basic/qa/vba_tests/space.vb  |   28 -
 basic/qa/vba_tests/sqr.vb|   28 -
 basic/qa/vba_tests/str.vb|   43 +-
 basic/qa/vba_tests/strcomp.vb|   71 +---
 basic/qa/vba_tests/strconv.vb|   69 +---
 basic/qa/vba_tests/string.vb |   39 +-
 basic/qa/vba_tests/stringplusdouble.vb   |  149 +++---
 basic/qa/vba_tests/strreverse.vb |   43 +-
 basic/qa/vba_tests/switch.vb |   33 +-
 basic/qa/vba_tests/timeserial.vb |   40 +-
 basic/qa/vba_tests/timevalue.vb  |   31 +-
 basic/qa/vba_tests/trim.vb   |   28 -
 basic/qa/vba_tests/typename.vb   |   67 +---
 basic/qa/vba_tests/ubound.vb |   38 +-
 basic/qa/vba_tests/ucase.vb  |   28 -
 basic/qa/vba_tests/val.vb|   69 +---
 basic/qa/vba_tests/vartype.vb|   53 +--
 basic/qa/vba_tests/weekday.vb|   53 +--
 basic/qa/vba_tests/weekdayname.vb|   58 +--
 basic/qa/vba_tests/win32compat.vb|   26 -
 basic/qa/vba_tests/win32compatb.vb   |   30 --
 basic/qa/vba_tests/year.vb   |   33 --
 93 files changed, 1772 insertions(+), 2989 deletions(-)

New commits:
commit 

[Libreoffice-commits] core.git: basic/qa

2020-12-19 Thread George Bateman (via logerrit)
 basic/qa/cppunit/basic_coverage.cxx  |2 
 basic/qa/cppunit/basictest.cxx   |   10 -
 basic/qa/cppunit/basictest.hxx   |4 
 basic/qa/cppunit/test_vba.cxx|6 
 basic/qa/vba_tests/Err.Raise.vb  |   67 ++---
 basic/qa/vba_tests/_test_asserts.vb  |   51 +++
 basic/qa/vba_tests/abs.vb|   52 +--
 basic/qa/vba_tests/array.vb  |   61 ++--
 basic/qa/vba_tests/asc.vb|   53 +--
 basic/qa/vba_tests/atn.vb|   57 +--
 basic/qa/vba_tests/bytearraystring.vb|   54 +--
 basic/qa/vba_tests/cbool.vb  |   68 ++---
 basic/qa/vba_tests/cdate.vb  |   52 +--
 basic/qa/vba_tests/cdbl.vb   |   55 +--
 basic/qa/vba_tests/cdec.vb   |   66 ++---
 basic/qa/vba_tests/choose.vb |   60 +---
 basic/qa/vba_tests/chr.vb|   53 +--
 basic/qa/vba_tests/cint.vb   |   70 ++---
 basic/qa/vba_tests/clng.vb   |   65 ++--
 basic/qa/vba_tests/constants.vb  |   48 +-
 basic/qa/vba_tests/cos.vb|   54 +--
 basic/qa/vba_tests/csng.vb   |   52 +--
 basic/qa/vba_tests/cstr.vb   |   50 +-
 basic/qa/vba_tests/cvdate.vb |   56 +--
 basic/qa/vba_tests/cverr.vb  |   68 ++---
 basic/qa/vba_tests/dateadd.vb|   70 ++---
 basic/qa/vba_tests/datediff.vb   |   86 +++
 basic/qa/vba_tests/datepart.vb   |   65 ++--
 basic/qa/vba_tests/dateserial.vb |   51 +--
 basic/qa/vba_tests/datevalue.vb  |   46 +-
 basic/qa/vba_tests/day.vb|   48 +-
 basic/qa/vba_tests/enum.vb   |   52 +--
 basic/qa/vba_tests/error.vb  |   50 +-
 basic/qa/vba_tests/exp.vb|   48 +-
 basic/qa/vba_tests/fix.vb|   52 +--
 basic/qa/vba_tests/format.vb |  225 ---
 basic/qa/vba_tests/formatnumber.vb   |   58 +--
 basic/qa/vba_tests/hex.vb|   61 +---
 basic/qa/vba_tests/hour.vb   |   52 +--
 basic/qa/vba_tests/iif.vb|   52 +--
 basic/qa/vba_tests/instr.vb  |   60 +---
 basic/qa/vba_tests/instrrev.vb   |   60 +---
 basic/qa/vba_tests/int.vb|   56 +--
 basic/qa/vba_tests/isarray.vb|   52 +--
 basic/qa/vba_tests/isdate.vb |   52 +--
 basic/qa/vba_tests/isempty.vb|   52 +--
 basic/qa/vba_tests/iserror.vb|   50 +-
 basic/qa/vba_tests/ismissing.vb  |  132 +++---
 basic/qa/vba_tests/isnull.vb |   50 +-
 basic/qa/vba_tests/isnumeric.vb  |   60 +---
 basic/qa/vba_tests/isobject.vb   |   50 +-
 basic/qa/vba_tests/join.vb   |   54 +--
 basic/qa/vba_tests/lbound.vb |   51 +--
 basic/qa/vba_tests/lcase.vb  |   55 +--
 basic/qa/vba_tests/left.vb   |   52 +--
 basic/qa/vba_tests/len.vb|   53 +--
 basic/qa/vba_tests/log.vb|   52 +--
 basic/qa/vba_tests/ltrim.vb  |   48 +-
 basic/qa/vba_tests/mid.vb|   53 +--
 basic/qa/vba_tests/minute.vb |   48 +-
 basic/qa/vba_tests/month.vb  |   57 +--
 basic/qa/vba_tests/monthname.vb  |   52 +--
 basic/qa/vba_tests/oct.vb|   52 +--
 basic/qa/vba_tests/optional_paramters.vb |  132 +++---
 basic/qa/vba_tests/partition.vb  |   55 +--
 basic/qa/vba_tests/qbcolor.vb|   64 ++--
 basic/qa/vba_tests/rate.vb   |   59 +---
 basic/qa/vba_tests/replace.vb|   64 ++--
 basic/qa/vba_tests/rgb.vb|   53 +--
 basic/qa/vba_tests/right.vb  |   52 +--
 basic/qa/vba_tests/rtrim.vb  |   48 +-
 basic/qa/vba_tests/second.vb |   50 +-
 basic/qa/vba_tests/sgn.vb|   56 +--
 basic/qa/vba_tests/sin.vb|   48 +-
 basic/qa/vba_tests/space.vb  |   48 +-
 basic/qa/vba_tests/sqr.vb|   48 +-
 basic/qa/vba_tests/str.vb|   55 +--
 basic/qa/vba_tests/strcomp.vb|   64 ++--
 basic/qa/vba_tests/strconv.vb|   62 ++--
 basic/qa/vba_tests/string.vb |   52 +--
 basic/qa/vba_tests/stringplusdouble.vb   |  118 +---
 basic/qa/vba_tests/strreverse.vb |   54 +--
 basic/qa/vba_tests/switch.vb |   52 +--
 basic/qa/vba_tests/timeserial.vb |   52 +--
 basic/qa/vba_tests/timevalue.vb  |   46 +-
 basic/qa/vba_tests/trim.vb   |   48 +-
 basic/qa/vba_tests/typename.vb   |   68 

[Libreoffice-commits] core.git: basic/qa basic/source

2020-11-27 Thread Anshu (via logerrit)
 basic/qa/vba_tests/cint.vb  |4 
 basic/qa/vba_tests/isnumeric.vb |4 
 basic/source/sbx/sbxscan.cxx|4 +++-
 3 files changed, 11 insertions(+), 1 deletion(-)

New commits:
commit ceb69f85c2c77827642be47aa14cb15ca87f683a
Author: Anshu 
AuthorDate: Wed Nov 25 09:19:31 2020 +0530
Commit: Mike Kaganski 
CommitDate: Fri Nov 27 10:14:56 2020 +0100

tdf#136801 : IsNumeric("+2") and CInt("+2") return correct values

Change-Id: I036f21c8196530973d2cdc366da7654ccd930892
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/106556
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/basic/qa/vba_tests/cint.vb b/basic/qa/vba_tests/cint.vb
index 6c1d53c93c61..a178a0f97d62 100644
--- a/basic/qa/vba_tests/cint.vb
+++ b/basic/qa/vba_tests/cint.vb
@@ -73,6 +73,10 @@ REMTestLog_ASSERT nr1 = nr2, "the return CInt is: " & nr1
 nr1 = CInt("")
 TestLog_ASSERT nr1 = nr2, "the return CInt is: " & nr1
 
+nr2 = 21
+nr1 = CInt("+21")
+TestLog_ASSERT nr1 = nr2, "the return CInt is:" & nr1
+
 result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & 
"Tests failed: " & failCount & Chr$(10)
 verify_testCInt = result
 
diff --git a/basic/qa/vba_tests/isnumeric.vb b/basic/qa/vba_tests/isnumeric.vb
index 2383f4bfe299..511a51bd9106 100644
--- a/basic/qa/vba_tests/isnumeric.vb
+++ b/basic/qa/vba_tests/isnumeric.vb
@@ -51,6 +51,10 @@ remTestLog_ASSERT date1 = date2, "the return IsNumeric 
is: " & date1
 date1 = IsNumeric("123")
 TestLog_ASSERT date1 = date2, "the return IsNumeric is: " & date1
 
+date2 = True
+date1 = IsNumeric("+123")
+TestLog_ASSERT date1 = date2, "the return IsNumeric is: " & date1
+
 result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & 
"Tests failed: " & failCount & Chr$(10)
 verify_testIsNumeric = result
 
diff --git a/basic/source/sbx/sbxscan.cxx b/basic/source/sbx/sbxscan.cxx
index d2f5c91e3483..de3d50dbed38 100644
--- a/basic/source/sbx/sbxscan.cxx
+++ b/basic/source/sbx/sbxscan.cxx
@@ -108,7 +108,9 @@ ErrCode ImpScan( const OUString& rWSrc, double& nVal, 
SbxDataType& rType,
 SbxDataType eScanType = SbxSINGLE;
 while( *p == ' ' || *p == '\t' )
 p++;
-if( *p == '-' )
+if (*p == '+')
+p++;
+else if( *p == '-' )
 {
 p++;
 bMinus = true;
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: basic/qa basic/source

2020-10-29 Thread Andreas Heinisch (via logerrit)
 basic/qa/basic_coverage/test_method_name_variable.vb |   35 
 basic/source/runtime/runtime.cxx |   40 +++
 2 files changed, 75 insertions(+)

New commits:
commit 48d46bcc903aedf0dd82746222c5333e3cd116a1
Author: Andreas Heinisch 
AuthorDate: Thu Oct 22 20:03:44 2020 +0200
Commit: Mike Kaganski 
CommitDate: Fri Oct 30 05:12:25 2020 +0100

tdf#85371 - grant write access to the method used as a variable

During the creation of the parameter list of a method, explicitly grant
write access to the method which will used as a variable. Otherwise, the
name of the method can't be used in certain statements, i.e., index in a
for loop or as a dimension in ReDim.

Change-Id: I3e4c49c21fd3345d5ddd69bc31a5823b5de5b8e7
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104696
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/basic/qa/basic_coverage/test_method_name_variable.vb 
b/basic/qa/basic_coverage/test_method_name_variable.vb
new file mode 100644
index ..ea45366c0f7d
--- /dev/null
+++ b/basic/qa/basic_coverage/test_method_name_variable.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/.
+'
+
+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 Integer
+
+doUnitTest = 0
+
+' 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 = 1
+
+End Function
diff --git a/basic/source/runtime/runtime.cxx b/basic/source/runtime/runtime.cxx
index 498c71628dba..0606b78ca420 100644
--- a/basic/source/runtime/runtime.cxx
+++ b/basic/source/runtime/runtime.cxx
@@ -83,6 +83,34 @@ using namespace ::com::sun::star;
 static void lcl_clearImpl( SbxVariableRef const & refVar, SbxDataType const & 
eType );
 static void lcl_eraseImpl( SbxVariableRef const & refVar, bool bVBAEnabled );
 
+namespace
+{
+class ScopedWritableGuard
+{
+public:
+ScopedWritableGuard(const SbxVariableRef& rVar, bool bMakeWritable)
+: m_rVar(rVar)
+, m_bReset(bMakeWritable && !rVar->CanWrite())
+{
+if (m_bReset)
+{
+m_rVar->SetFlag(SbxFlagBits::Write);
+}
+}
+~ScopedWritableGuard()
+{
+if (m_bReset)
+{
+m_rVar->ResetFlag(SbxFlagBits::Write);
+}
+}
+
+private:
+SbxVariableRef m_rVar;
+bool m_bReset;
+};
+}
+
 bool SbiRuntime::isVBAEnabled()
 {
 bool bResult = false;
@@ -1131,6 +1159,9 @@ void SbiRuntime::PushFor()
 p->refEnd = PopVar();
 SbxVariableRef xBgn = PopVar();
 p->refVar = PopVar();
+// tdf#85371 - grant explicitly write access to the index variable
+// since it could be the name of a method itself used in the next 
statement.
+ScopedWritableGuard aGuard(p->refVar, p->refVar.get() == pMeth);
 *(p->refVar) = *xBgn;
 nForLvl++;
 }
@@ -2583,6 +2614,9 @@ void SbiRuntime::StepNEXT()
 StarBASIC::FatalError( ERRCODE_BASIC_INTERNAL_ERROR );
 return;
 }
+// tdf#85371 - grant explicitly write access to the index variable
+// since it could be the name of a method itself used in the next 
statement.
+ScopedWritableGuard aGuard(pForStk->refVar, pForStk->refVar.get() == 
pMeth);
 pForStk->refVar->Compute( SbxPLUS, *pForStk->refInc );
 }
 
@@ -3360,7 +3394,13 @@ void SbiRuntime::StepBASED( sal_uInt32 nOp1 )
 sal_uInt16 uBase = static_cast(nOp1 & 1);   // Can only be 
0 or 1
 p1->PutInteger( uBase );
 if( !bCompatible )
+{
+// tdf#85371 - grant explicitly write access to the dimension variable
+// since in Star/OpenOffice Basic the upper index border is affected,
+// and the dimension variable could be the name of the method itself.
+ScopedWritableGuard aGuard(x2, x2.get() == pMeth);
 x2->Compute( SbxPLUS, *p1 );
+}
 PushVar( x2.get() );  // first the Expr
 PushVar( p1 );  // then the Base
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: basic/qa basic/source

2020-10-16 Thread Andreas Heinisch (via logerrit)
 basic/qa/basic_coverage/test_split_method.vb |   27 ++-
 basic/source/runtime/methods1.cxx|6 --
 2 files changed, 26 insertions(+), 7 deletions(-)

New commits:
commit d6b7cc3f7c07b98c90194e8b33cf44b94804b525
Author: Andreas Heinisch 
AuthorDate: Tue Oct 6 19:22:44 2020 +0200
Commit: Mike Kaganski 
CommitDate: Fri Oct 16 12:31:02 2020 +0200

tdf#123025 - ReDim Preserve fails if array is filled by Split

The Split function sets the datatype of the array to SbxVARIANT instead
of SbxSTRING preventing any subsequent assignments to the array and to
the elements itself.

Change-Id: Ib099eee7bfd222c97520ac8970352bcf2b44bc3e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/104039
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/basic/qa/basic_coverage/test_split_method.vb 
b/basic/qa/basic_coverage/test_split_method.vb
index d09e8c3e7e3b..8f3701e3d987 100644
--- a/basic/qa/basic_coverage/test_split_method.vb
+++ b/basic/qa/basic_coverage/test_split_method.vb
@@ -6,10 +6,27 @@
 '
 
 Function doUnitTest as Integer
+
+doUnitTest = 0
+
 ' SPLIT
-If ( Split( "Hello world" )(1) <> "world" ) Then
-doUnitTest = 0
-Else
-doUnitTest = 1
-End If
+If ( Split( "Hello world" )(1) <> "world" ) Then Exit Function
+
+' 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", "/")
+If ( arr(0) <> "a" Or arr(1) <> "b" ) Then Exit Function
+ReDim Preserve arr(1)
+If ( arr(0) <> "a" Or arr(1) <> "b" ) Then Exit Function
+ReDim arr(1)
+If ( arr(0) <> "" Or arr(1) <> "" ) Then Exit Function
+arr(0) = "a"
+arr(1) = "b"
+If ( arr(0) <> "a" Or arr(1) <> "b" ) Then Exit Function
+ReDim Preserve arr(1)
+If ( arr(0) <> "a" Or arr(1) <> "b" ) Then Exit Function
+
+doUnitTest = 1
+
 End Function
diff --git a/basic/source/runtime/methods1.cxx 
b/basic/source/runtime/methods1.cxx
index 807806e4cea8..1dee293ef3cf 100644
--- a/basic/source/runtime/methods1.cxx
+++ b/basic/source/runtime/methods1.cxx
@@ -1627,13 +1627,15 @@ void SbRtl_Split(StarBASIC *, SbxArray & rPar, bool)
 }
 }
 
-SbxDimArray* pArray = new SbxDimArray( SbxVARIANT );
+// tdf#123025 - split returns an array of substrings
+SbxDimArray* pArray = new SbxDimArray( SbxSTRING );
 pArray->unoAddDim32( 0, nArraySize-1 );
 
 // insert parameter(s) into the array
 for(sal_Int32 i = 0 ; i < nArraySize ; i++ )
 {
-SbxVariableRef xVar = new SbxVariable( SbxVARIANT );
+// tdf#123025 - split returns an array of substrings
+SbxVariableRef xVar = new SbxVariable( SbxSTRING );
 xVar->PutString( vRet[i] );
 pArray->Put32( xVar.get(),  );
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: basic/qa

2020-10-06 Thread Andreas Heinisch (via logerrit)
 basic/qa/basic_coverage/test_cverr_method.vb |   26 +-
 1 file changed, 9 insertions(+), 17 deletions(-)

New commits:
commit 698e5d54182d96a1fd0c3b864ba0e618f82dd1f1
Author: Andreas Heinisch 
AuthorDate: Mon Oct 5 12:20:50 2020 +0200
Commit: Mike Kaganski 
CommitDate: Tue Oct 6 17:17:55 2020 +0200

tdf#123025 - fixed broken tests for cverr method

Change-Id: I44eb44107a24207764da24b4e01b407570342013
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/103956
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/basic/qa/basic_coverage/test_cverr_method.vb 
b/basic/qa/basic_coverage/test_cverr_method.vb
index f74445c20c6a..9bc8b4f953f1 100644
--- a/basic/qa/basic_coverage/test_cverr_method.vb
+++ b/basic/qa/basic_coverage/test_cverr_method.vb
@@ -7,26 +7,18 @@
 '
 
 Function doUnitTest as Integer
-' CVERR
-If (CVerr(100) <> 100) Then
-doUnitTest = 0
-Else
-doUnitTest = 1
-End If
 
-' tdf#79426 - passing an error object to a function
-if ( TestCVErr( CVErr( 2 ) ) <> 2 ) Then
-doUnitTest = 0
-Else
-doUnitTest = 1
-End If
+doUnitTest = 0
 
+' 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
-doUnitTest = 0
-Else
-doUnitTest = 1
-End If
+If (TestCVErr(CVErr(448)) <> 448) Then Exit Function
+
+doUnitTest = 1
+
 End Function
 
 Function TestCVErr(vErr As Variant)
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: basic/qa

2020-09-08 Thread Alain Romedenne (via logerrit)
 basic/qa/basic_coverage/test_Date.vb |   19 +++
 1 file changed, 19 insertions(+)

New commits:
commit c3c8d2d67174beddb27fc94b10aebed259500133
Author: Alain Romedenne 
AuthorDate: Mon Sep 7 14:55:19 2020 +0200
Commit: Mike Kaganski 
CommitDate: Tue Sep 8 17:18:29 2020 +0200

tdf#136112 Unit test for Date() Basic function

Change-Id: Id6660627e766c6dcd107c3ee483bacb046cae7bf
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102123
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/basic/qa/basic_coverage/test_Date.vb 
b/basic/qa/basic_coverage/test_Date.vb
new file mode 100644
index ..c21d8cc05910
--- /dev/null
+++ b/basic/qa/basic_coverage/test_Date.vb
@@ -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 Integer
+  ''' Return 'text' OR 'date' variable '''
+
+  If ( TypeName(Date$)<>"String" Or Vartype(Date())<>V_DATE) Then
+doUnitTest = 0 ' not successful
+  Else
+doUnitTest = 1 ' Ok
+  End If
+End Function
+
+Sub DEV_TST : MsgBox doUnitTesT : End Sub
\ No newline at end of file
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: basic/qa basic/source

2020-09-06 Thread Andreas Heinisch (via logerrit)
 basic/qa/cppunit/test_scanner.cxx |   17 +
 basic/source/comp/scanner.cxx |3 ++-
 2 files changed, 19 insertions(+), 1 deletion(-)

New commits:
commit 11292d1cc405e7c3b9e1f374cc7581a63a54b994
Author: Andreas Heinisch 
AuthorDate: Sun Sep 6 09:26:47 2020 +0200
Commit: Mike Kaganski 
CommitDate: Sun Sep 6 12:55:43 2020 +0200

tdf#136032 - abort scan of a string beginning with a hashtag

Abort scan of a string beginning with a hashtag, if a comma is found. 
Otherwise, the compiler raises a syntax error. If
the string ends with a hashtag too, it will be parsed later checking for
a date literal.

Change-Id: I078a2302f5c65206367a00fbc584ffa7b9ede031
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/102099
Tested-by: Mike Kaganski 
Reviewed-by: Mike Kaganski 

diff --git a/basic/qa/cppunit/test_scanner.cxx 
b/basic/qa/cppunit/test_scanner.cxx
index 9b80c32512d6..7515b0d07862 100644
--- a/basic/qa/cppunit/test_scanner.cxx
+++ b/basic/qa/cppunit/test_scanner.cxx
@@ -46,6 +46,7 @@ namespace
 void testDataType();
 void testHexOctal();
 void testTdf103104();
+void testTdf136032();
 
 // Adds code needed to register the test suite
 CPPUNIT_TEST_SUITE(ScannerTest);
@@ -62,6 +63,7 @@ namespace
 CPPUNIT_TEST(testDataType);
 CPPUNIT_TEST(testHexOctal);
 CPPUNIT_TEST(testTdf103104);
+CPPUNIT_TEST(testTdf136032);
 
 // End of test suite definition
 CPPUNIT_TEST_SUITE_END();
@@ -1061,6 +1063,21 @@ namespace
 CPPUNIT_ASSERT_EQUAL(cr, symbols[3].text);
   }
 
+  void ScannerTest::testTdf136032()
+  {
+std::vector 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(errors));
+symbols = getSymbols("Print #i, \"A#B\"", errors);
+CPPUNIT_ASSERT_EQUAL(size_t(5), symbols.size());
+CPPUNIT_ASSERT_EQUAL(0u, static_cast(errors));
+  }
+
   // Put the test suite in the registry
   CPPUNIT_TEST_SUITE_REGISTRATION(ScannerTest);
 } // namespace
diff --git a/basic/source/comp/scanner.cxx b/basic/source/comp/scanner.cxx
index 5d93f5362510..0647a72edfff 100644
--- a/basic/source/comp/scanner.cxx
+++ b/basic/source/comp/scanner.cxx
@@ -251,7 +251,8 @@ bool SbiScanner::NextSym()
 do
 {
 nLineTempIdx++;
-} while (nLineTempIdx < aLine.getLength() && 
!BasicCharClass::isWhitespace(aLine[nLineTempIdx]) && aLine[nLineTempIdx] != 
'#');
+} while (nLineTempIdx < aLine.getLength() && 
!BasicCharClass::isWhitespace(aLine[nLineTempIdx])
+&& aLine[nLineTempIdx] != '#' && aLine[nLineTempIdx] != ',');
 // leave it if it is a date literal - it will be handled later
 if (nLineTempIdx >= aLine.getLength() || aLine[nLineTempIdx] != '#')
 {
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: basic/qa basic/source

2020-09-01 Thread Andreas Heinisch (via logerrit)
 basic/qa/basic_coverage/test_option_base.vb|   60 
 basic/qa/basic_coverage/test_option_base_compatible.vb |   61 +
 basic/source/runtime/methods.cxx   |2 
 basic/source/runtime/methods1.cxx  |4 -
 basic/source/sbx/sbxstr.cxx|2 
 5 files changed, 124 insertions(+), 5 deletions(-)

New commits:
commit 40031dd453991b3397f02726bd83cc857bef1044
Author: Andreas Heinisch 
AuthorDate: Mon Aug 24 11:15:59 2020 +0200
Commit: Mike Kaganski 
CommitDate: Tue Sep 1 09:28:46 2020 +0200

tdf#54912 - with option base arrays should start at index 1

Using option base, every array should start at index 1. Previously, it
needed option VBASupport too. Without option compatible, the upper bound
of an array is increased as well in order to preserve the specified
size.

Change-Id: I52885f14914a4636b98258aa428c2123f62482a3
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101269
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/basic/qa/basic_coverage/test_option_base.vb 
b/basic/qa/basic_coverage/test_option_base.vb
new file mode 100644
index ..fff5858a4ee6
--- /dev/null
+++ b/basic/qa/basic_coverage/test_option_base.vb
@@ -0,0 +1,60 @@
+Option Base 1
+
+Dim passCount As Integer
+Dim failCount As Integer
+Dim result As String
+
+Function doUnitTest() As String
+result = verify_optionBase()
+If failCount <> 0 Or passCount = 0 Then
+doUnitTest = 0
+Else
+doUnitTest = 1
+End If
+End Function
+
+Function verify_optionBase() As String
+passCount = 0
+failCount = 0
+
+result = "Test Results" & Chr$(10) & "" & Chr$(10)
+
+' 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
+TestLog_ASSERT LBound(strArray), 1, "Lower bound of a string array (before 
assignment): " & LBound(strArray)
+TestLog_ASSERT UBound(strArray), 3, "Upper bound of a string array (before 
assignment): " & UBound(strArray)
+strArray = Array("a", "b")
+TestLog_ASSERT LBound(strArray), 1, "Lower bound of a string array (after 
assignment): " & LBound(strArray)
+TestLog_ASSERT UBound(strArray), 2, "Upper bound of a string array (after 
assignment): " & UBound(strArray)
+
+Dim intArray(2) As Integer
+TestLog_ASSERT LBound(intArray), 1, "Lower bound of an integer array 
(before assignment): " & LBound(intArray)
+TestLog_ASSERT UBound(intArray), 3, "Upper bound of an integer array 
(before assignment): " & UBound(intArray)
+intArray = Array(1, 2)
+TestLog_ASSERT LBound(intArray), 1, "Lower bound of an integer array 
(after assignment): " & LBound(intArray)
+TestLog_ASSERT UBound(intArray), 2, "Upper bound of an integer array 
(after assignment): " & UBound(intArray)
+
+Dim byteArray(2) As Byte
+TestLog_ASSERT LBound(byteArray), 1, "Lower bound of a byte array (before 
assignment): " & LBound(byteArray)
+TestLog_ASSERT UBound(byteArray), 3, "Upper bound of a byte array (before 
assignment): " & UBound(byteArray)
+byteArray = StrConv("ab", 128)
+TestLog_ASSERT LBound(byteArray), 1, "Lower bound of a byte array 
(StrConv): " & LBound(byteArray)
+TestLog_ASSERT UBound(byteArray), 2, "Upper bound of a byte array 
(StrConv): " & UBound(byteArray)
+
+ReDim byteArray(3)
+TestLog_ASSERT LBound(byteArray), 1, "Lower bound of a byte array (ReDim): 
" & LBound(byteArray)
+TestLog_ASSERT UBound(byteArray), 4, "Upper bound of a byte array (ReDim): 
" & UBound(byteArray)
+
+result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & 
"Tests failed: " & failCount & Chr$(10)
+verify_optionBase = result
+End Function
+
+Sub TestLog_ASSERT(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
diff --git a/basic/qa/basic_coverage/test_option_base_compatible.vb 
b/basic/qa/basic_coverage/test_option_base_compatible.vb
new file mode 100644
index ..37644e59faa4
--- /dev/null
+++ b/basic/qa/basic_coverage/test_option_base_compatible.vb
@@ -0,0 +1,61 @@
+Option Base 1
+Option Compatible
+
+Dim passCount As Integer
+Dim failCount As Integer
+Dim result As String
+
+Function doUnitTest() As String
+result = verify_optionBase()
+If failCount <> 0 Or passCount = 0 Then
+doUnitTest = 0
+Else
+doUnitTest = 1
+End If
+End Function
+
+Function verify_optionBase() As String
+passCount = 0
+failCount = 0
+
+result = "Test Results" & Chr$(10) & "" & Chr$(10)
+
+' tdf#54912 - with option base arrays should start at 

[Libreoffice-commits] core.git: basic/qa basic/source

2020-08-27 Thread Andreas Heinisch (via logerrit)
 basic/qa/basic_coverage/test_ismissing_cascade.vb |   51 ++
 basic/source/runtime/runtime.cxx  |2 
 2 files changed, 53 insertions(+)

New commits:
commit 781b6ac998370f2923c0783100da7086bfad622d
Author: Andreas Heinisch 
AuthorDate: Wed Aug 26 18:56:28 2020 +0200
Commit: Mike Kaganski 
CommitDate: Thu Aug 27 15:49:16 2020 +0200

tdf#136143 - reset SbxFlagBits::Fixed SbiRuntime::StepPARAM

In order to prevent type conversion errors, reset a variable of type
SbxERROR to not fixed. Variable will be of type SbxERROR, but can be
converted to any requested type.

Change-Id: Ic856376e3f8232577a5e894a2adb2545c8723033
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/101419
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/basic/qa/basic_coverage/test_ismissing_cascade.vb 
b/basic/qa/basic_coverage/test_ismissing_cascade.vb
new file mode 100644
index ..ad967c7bbd81
--- /dev/null
+++ b/basic/qa/basic_coverage/test_ismissing_cascade.vb
@@ -0,0 +1,51 @@
+Dim passCount As Integer
+Dim failCount As Integer
+Dim result As String
+
+Function doUnitTest() As String
+result = verify_testIsMissingCascade()
+If failCount <> 0 Or passCount = 0 Then
+doUnitTest = 0
+Else
+doUnitTest = 1
+End If
+End Function
+
+Function verify_testIsMissingCascade() As String
+
+passCount = 0
+failCount = 0
+
+result = "Test Results" & Chr$(10) & "" & Chr$(10)
+testName = "Test missing (IsMissing with cascading optionals)"
+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.
+TestLog_ASSERT TestOpt(), 2, "Cascading optionals"
+
+result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & 
"Tests failed: " & failCount & Chr$(10)
+verify_testIsMissingCascade = result
+
+Exit Function
+errorHandler:
+TestLog_ASSERT False, True, Err.Description
+End Function
+
+Function TestOpt(Optional A)
+TestOpt = TestOptCascade(A)
+End Function
+
+Function TestOptCascade(Optional A)
+If IsMissing(A) Then A = 2
+TestOptCascade = A
+End Function
+
+Sub TestLog_ASSERT(actual As Variant, expected As Integer, 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
\ No newline at end of file
diff --git a/basic/source/runtime/runtime.cxx b/basic/source/runtime/runtime.cxx
index f55d5ad86bd8..abd65aa685a8 100644
--- a/basic/source/runtime/runtime.cxx
+++ b/basic/source/runtime/runtime.cxx
@@ -4110,6 +4110,8 @@ void SbiRuntime::StepPARAM( sal_uInt32 nOp1, sal_uInt32 
nOp2 )
 const SbxParamInfo* pParam = pInfo->GetParam( nIdx );
 if( pParam && ( pParam->nFlags & SbxFlagBits::Optional ) )
 {
+// tdf#136143 - reset SbxFlagBits::Fixed in order to 
prevent type conversion errors
+pVar->ResetFlag( SbxFlagBits::Fixed );
 // Default value?
 sal_uInt16 nDefaultId = 
static_cast(pParam->nUserData & 0x0);
 if( nDefaultId > 0 )
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: basic/qa

2020-08-19 Thread Andrea Gelmini (via logerrit)
 basic/qa/vba_tests/stringplusdouble.vb |2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

New commits:
commit 21c1f1701fe11a87b4e65991aab1911185ea9d48
Author: Andrea Gelmini 
AuthorDate: Mon Aug 17 17:41:30 2020 +0200
Commit: Noel Grandin 
CommitDate: Wed Aug 19 16:31:56 2020 +0200

Fix typo in code

Change-Id: Ie8ebbfd9bdf5916d50161fdf39de963730f051a8
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100868
Tested-by: Jenkins
Reviewed-by: Julien Nabet 
Reviewed-by: Noel Grandin 

diff --git a/basic/qa/vba_tests/stringplusdouble.vb 
b/basic/qa/vba_tests/stringplusdouble.vb
index cfe4a5bc6cf3..7d416709a4c0 100644
--- a/basic/qa/vba_tests/stringplusdouble.vb
+++ b/basic/qa/vba_tests/stringplusdouble.vb
@@ -275,7 +275,7 @@ Sub test2()
 MsgBox d
 End Sub
 
-Sub testBolean()
+Sub testBoolean()
 Dim a As String
 Dim b As Boolean
 Dim c As Boolean
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: basic/qa basic/source

2020-08-07 Thread Mike Kaganski (via logerrit)
 basic/qa/basic_coverage/test_for_each.vb |   43 +++
 basic/source/runtime/runtime.cxx |5 ++-
 2 files changed, 46 insertions(+), 2 deletions(-)

New commits:
commit e67ffd5a62c8c27697da594a0fea2362317f221f
Author: Mike Kaganski 
AuthorDate: Thu Aug 6 18:50:08 2020 +0300
Commit: Mike Kaganski 
CommitDate: Fri Aug 7 09:43:44 2020 +0200

tdf#135470: Fix checks

The check should prevent error in case when the variable has
wrong type. IsObject returns false e.g. for arrays, which are
valid iterables. So proper check is using GetFullType, which
will give SbxOBJECT for any variable for which GetObject does
not set error.

"Next" should also generate an error for uninitialized loops.

Regression after 5760c94b8847164f9a7a181f031c7c86643944af

Change-Id: Ib58e1cc76ef63aa1ff8a86c9d5dc956e4780fb49
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/100258
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/basic/qa/basic_coverage/test_for_each.vb 
b/basic/qa/basic_coverage/test_for_each.vb
new file mode 100644
index ..654513e88332
--- /dev/null
+++ b/basic/qa/basic_coverage/test_for_each.vb
@@ -0,0 +1,43 @@
+'
+' This file is part of the LibreOffice project.
+'
+' This Source Code Form is subject to the terms of the Mozilla Public
+' License, v. 2.0. If a copy of the MPL was not distributed with this
+' file, You can obtain one at http://mozilla.org/MPL/2.0/.
+'
+
+Function doUnitTest as Integer
+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 = 1
+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/source/runtime/runtime.cxx b/basic/source/runtime/runtime.cxx
index 9ac23bd2fef5..62a54b87b576 100644
--- a/basic/source/runtime/runtime.cxx
+++ b/basic/source/runtime/runtime.cxx
@@ -1144,7 +1144,7 @@ void SbiRuntime::PushForEach()
 pForStk = p;
 
 SbxVariableRef xObjVar = PopVar();
-SbxBase* pObj = xObjVar.is() && xObjVar->IsObject() ? xObjVar->GetObject() 
: nullptr;
+SbxBase* pObj = xObjVar && xObjVar->GetFullType() == SbxOBJECT ? 
xObjVar->GetObject() : nullptr;
 
 if (SbxDimArray* pArray = dynamic_cast(pObj))
 {
@@ -3118,8 +3118,9 @@ void SbiRuntime::StepTESTFOR( sal_uInt32 nOp1 )
 }
 case ForType::Error:
 {
-// We are in Resume Next mode, and we already had one iteration
+// We are in Resume Next mode after failed loop initialization
 bEndLoop = true;
+Error(ERRCODE_BASIC_BAD_PARAMETER);
 break;
 }
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: basic/qa

2020-07-21 Thread Xisco Fauli (via logerrit)
 basic/qa/cppunit/test_nested_struct.cxx |   20 
 1 file changed, 20 insertions(+)

New commits:
commit 23bfaf601d78ab2a80ec5493ef7eab1410975769
Author: Xisco Fauli 
AuthorDate: Tue Jul 21 00:14:14 2020 +0200
Commit: Xisco Fauli 
CommitDate: Tue Jul 21 09:40:34 2020 +0200

tdf#134576: basic_macros: Add unittest

Change-Id: I6078e0712f7983159ea3b3f2060a1c4b69e9d5c6
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/99114
Tested-by: Jenkins
Reviewed-by: Xisco Fauli 

diff --git a/basic/qa/cppunit/test_nested_struct.cxx 
b/basic/qa/cppunit/test_nested_struct.cxx
index 009d832b1ce6..daced48ba2bf 100644
--- a/basic/qa/cppunit/test_nested_struct.cxx
+++ b/basic/qa/cppunit/test_nested_struct.cxx
@@ -28,6 +28,7 @@ namespace
 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);
@@ -42,6 +43,7 @@ namespace
 CPPUNIT_TEST(testFixedVarAssign);
 CPPUNIT_TEST(testFixedVarAssignAlt);
 CPPUNIT_TEST(testUnoAccess);
+CPPUNIT_TEST(testTdf134576);
 
 // End of test suite definition
 CPPUNIT_TEST_SUITE_END();
@@ -296,6 +298,24 @@ void Nested_Struct::testUnoAccess()
 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(1), pNew->GetInteger());
+}
+
   // Put the test suite in the registry
   CPPUNIT_TEST_SUITE_REGISTRATION(Nested_Struct);
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: basic/qa basic/source

2020-06-30 Thread Stephan Bergmann (via logerrit)
 basic/qa/cppunit/test_scanner.cxx |   12 ++--
 basic/source/basmgr/basmgr.cxx|   12 ++--
 basic/source/classes/image.cxx|2 +-
 basic/source/classes/sb.cxx   |8 
 basic/source/classes/sbunoobj.cxx |8 
 basic/source/comp/buffer.cxx  |2 +-
 basic/source/comp/exprgen.cxx |2 +-
 basic/source/comp/parser.cxx  |2 +-
 basic/source/comp/token.cxx   |2 +-
 basic/source/runtime/ddectrl.cxx  |2 +-
 basic/source/runtime/runtime.cxx  |2 +-
 basic/source/sbx/sbxscan.cxx  |2 +-
 12 files changed, 28 insertions(+), 28 deletions(-)

New commits:
commit d902e04bafcf7436c4c05140e82e677cd6bc826f
Author: Stephan Bergmann 
AuthorDate: Tue Jun 30 15:25:15 2020 +0200
Commit: Stephan Bergmann 
CommitDate: Tue Jun 30 19:05:48 2020 +0200

Upcoming improved loplugin:staticanonymous -> redundantstatic: basic

Change-Id: I1046ee1ea28e19afa51b0e20ee573105ced77535
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/97522
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann 

diff --git a/basic/qa/cppunit/test_scanner.cxx 
b/basic/qa/cppunit/test_scanner.cxx
index 6f3d9d7ecae1..9b80c32512d6 100644
--- a/basic/qa/cppunit/test_scanner.cxx
+++ b/basic/qa/cppunit/test_scanner.cxx
@@ -67,12 +67,12 @@ namespace
 CPPUNIT_TEST_SUITE_END();
   };
 
-  static const OUString cr = "\n";
-  static const OUString rem = "REM";
-  static const OUString asdf = "asdf";
-  static const OUString dot = ".";
-  static const OUString goto_ = "goto";
-  static const OUString excl = "!";
+  const OUString cr = "\n";
+  const OUString rem = "REM";
+  const OUString asdf = "asdf";
+  const OUString dot = ".";
+  const OUString goto_ = "goto";
+  const OUString excl = "!";
 
   std::vector getSymbols(const OUString& source, sal_Int32& errors, 
bool bCompatible = false)
   {
diff --git a/basic/source/basmgr/basmgr.cxx b/basic/source/basmgr/basmgr.cxx
index 753aaf04b201..c7bc2e468198 100644
--- a/basic/source/basmgr/basmgr.cxx
+++ b/basic/source/basmgr/basmgr.cxx
@@ -84,12 +84,12 @@ typedef WeakImplHelper< script::XStarBasicAccess > 
StarBasicAccessHelper;
 // Version 2
 //  + bool  bReference
 
-static const char szStdLibName[] = "Standard";
-static const char szBasicStorage[] = "StarBASIC";
-static const char szOldManagerStream[] = "BasicManager";
-static const char szManagerStream[] = "BasicManager2";
-static const char szImbedded[] = "LIBIMBEDDED";
-static const char szCryptingKey[] = "CryptedBasic";
+const char szStdLibName[] = "Standard";
+const char szBasicStorage[] = "StarBASIC";
+const char szOldManagerStream[] = "BasicManager";
+const char szManagerStream[] = "BasicManager2";
+const char szImbedded[] = "LIBIMBEDDED";
+const char szCryptingKey[] = "CryptedBasic";
 
 
 const StreamMode eStreamReadMode = StreamMode::READ | StreamMode::NOCREATE | 
StreamMode::SHARE_DENYALL;
diff --git a/basic/source/classes/image.cxx b/basic/source/classes/image.cxx
index 84878136a756..bb4d8409573f 100644
--- a/basic/source/classes/image.cxx
+++ b/basic/source/classes/image.cxx
@@ -86,7 +86,7 @@ static void SbiCloseRecord( SvStream& r, sal_uInt64 nOff )
 r.Seek( nPos );
 }
 
-static constexpr sal_uInt32 nUnicodeDataMagicNumber = 0x556E6920; // "Uni " BE
+constexpr sal_uInt32 nUnicodeDataMagicNumber = 0x556E6920; // "Uni " BE
 
 static bool GetToUnicodePoolData(SvStream& r, sal_uInt64 nLen, sal_uInt64 
nNext)
 {
diff --git a/basic/source/classes/sb.cxx b/basic/source/classes/sb.cxx
index 0377d854359c..1de6c8203426 100644
--- a/basic/source/classes/sb.cxx
+++ b/basic/source/classes/sb.cxx
@@ -1947,10 +1947,10 @@ void StarBASIC::DetachAllDocBasicItems()
 // #118116 Implementation Collection object
 
 
-static const char pCountStr[]   = "Count";
-static const char pAddStr[] = "Add";
-static const char pItemStr[]= "Item";
-static const char pRemoveStr[]  = "Remove";
+const char pCountStr[]   = "Count";
+const char pAddStr[] = "Add";
+const char pItemStr[]= "Item";
+const char pRemoveStr[]  = "Remove";
 static sal_uInt16 nCountHash = 0, nAddHash, nItemHash, nRemoveHash;
 
 SbxInfoRef BasicCollection::xAddInfo;
diff --git a/basic/source/classes/sbunoobj.cxx 
b/basic/source/classes/sbunoobj.cxx
index 3f5da99a6d5f..8ce98b6c3b48 100644
--- a/basic/source/classes/sbunoobj.cxx
+++ b/basic/source/classes/sbunoobj.cxx
@@ -98,11 +98,11 @@ using namespace cppu;
 
 
 // Identifiers for creating the strings for dbg_Properties
-static char const ID_DBG_SUPPORTEDINTERFACES[] = "Dbg_SupportedInterfaces";
-static char const ID_DBG_PROPERTIES[] = "Dbg_Properties";
-static char const ID_DBG_METHODS[] = "Dbg_Methods";
+char const ID_DBG_SUPPORTEDINTERFACES[] = "Dbg_SupportedInterfaces";
+char const ID_DBG_PROPERTIES[] = "Dbg_Properties";
+char const ID_DBG_METHODS[] = "Dbg_Methods";
 
-static char const aSeqLevelStr[] = "[]";
+char const aSeqLevelStr[] = "[]";
 
 // Gets the default property for a uno object. Note: There is some
 // redirection 

[Libreoffice-commits] core.git: basic/qa basic/source

2020-06-16 Thread Andreas Heinisch (via logerrit)
 basic/qa/basic_coverage/test_numeric_constant_parameter.vb|   34 ++
 basic/qa/basic_coverage/test_optional_paramters_basic.vb  |   20 ++---
 basic/qa/basic_coverage/test_optional_paramters_compatible.vb |   26 +++
 basic/qa/vba_tests/optional_paramters.vb  |6 -
 basic/source/runtime/runtime.cxx  |2 
 5 files changed, 60 insertions(+), 28 deletions(-)

New commits:
commit 0f6e012057bf0d1cc339154e8af6586d9615a37f
Author: Andreas Heinisch 
AuthorDate: Mon Jun 15 22:44:27 2020 +0200
Commit: Mike Kaganski 
CommitDate: Tue Jun 16 22:59:30 2020 +0200

tdf#133913 - create variable with Variant/Type in StepLOADNC

During the loading of numeric constants in StepLOADNC, create variables
of type Variant and convert them to the requested type, i.e.
Variant/Type in order to prevent type conversion errors, when they are
passed to a method with variant parameter types.

Change-Id: I2ab0111b5b53dd2de9523ba7cf12bd2519d050b0
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96402
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/basic/qa/basic_coverage/test_numeric_constant_parameter.vb 
b/basic/qa/basic_coverage/test_numeric_constant_parameter.vb
new file mode 100644
index ..96a7e8f9c4fd
--- /dev/null
+++ b/basic/qa/basic_coverage/test_numeric_constant_parameter.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/.
+'
+
+' 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 Integer
+' 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 = 1
+Else
+doUnitTest = 0
+End If
+Exit Function
+errorHandler:
+doUnitTest = 0
+End Function
\ No newline at end of file
diff --git a/basic/qa/basic_coverage/test_optional_paramters_basic.vb 
b/basic/qa/basic_coverage/test_optional_paramters_basic.vb
index 39aeb62b27a4..92a81a861d71 100644
--- a/basic/qa/basic_coverage/test_optional_paramters_basic.vb
+++ b/basic/qa/basic_coverage/test_optional_paramters_basic.vb
@@ -40,13 +40,13 @@ Function verify_testOptionalsBasic() As String
 TestLog_ASSERT TestOptDouble(), 0, "TestOptDouble()"
 TestLog_ASSERT TestOptDouble(123.4), 123.4, "TestOptDouble(123.4)"
 TestLog_ASSERT TestOptDouble(, 567.8), 567.8, "TestOptDouble(, 567.8)"
-TestLog_ASSERT Format(TestOptDouble(123.4, 567.8), "0.0"), 691.2, 
"TestOptDouble(123.4, 567.8)"
+TestLog_ASSERT CDbl(Format(TestOptDouble(123.4, 567.8), "0.0")), 691.2, 
"TestOptDouble(123.4, 567.8)"
 
 ' optionals with double datatypes (ByRef and ByVal)
 TestLog_ASSERT TestOptDoubleByRefByVal(), 0, "TestOptDouble()"
 TestLog_ASSERT TestOptDoubleByRefByVal(123.4), 123.4, 
"TestOptDouble(123.4)"
 TestLog_ASSERT TestOptDoubleByRefByVal(, 567.8), 567.8, 
"TestOptDoubleByRefByVal(, 567.8)"
-TestLog_ASSERT Format(TestOptDoubleByRefByVal(123.4, 567.8), "0.0"), 
691.2, "TestOptDoubleByRefByVal(123.4, 567.8)"
+TestLog_ASSERT CDbl(Format(TestOptDoubleByRefByVal(123.4, 567.8), "0.0")), 
691.2, "TestOptDoubleByRefByVal(123.4, 567.8)"
 
 ' optionals with integer datatypes
 TestLog_ASSERT TestOptInteger(), 0, "TestOptInteger()"
@@ -81,14 +81,14 @@ Function verify_testOptionalsBasic() As String
 cB.Add (567.8)
 TestLog_ASSERT TestOptObject(), 0, "TestOptObject()"
 TestLog_ASSERT TestOptObject(cA), 579, "TestOptObject(A)"
-TestLog_ASSERT Format(TestOptObject(, cB), "0.0"), 691.2, "TestOptObject(, 
B)"
-TestLog_ASSERT Format(TestOptObject(cA, cB), "0.0"), 1270.2, 
"TestOptObject(A, B)"
+TestLog_ASSERT CDbl(Format(TestOptObject(, cB), "0.0")), 691.2, 
"TestOptObject(, B)"
+TestLog_ASSERT CDbl(Format(TestOptObject(cA, cB), "0.0")), 1270.2, 
"TestOptObject(A, B)"
 
 ' optionals with object datatypes (ByRef and ByVal)
 TestLog_ASSERT TestOptObjectByRefByVal(), 0, "TestOptObjectByRefByVal()"
 TestLog_ASSERT TestOptObjectByRefByVal(cA), 579, 
"TestOptObjectByRefByVal(A)"
-TestLog_ASSERT Format(TestOptObjectByRefByVal(, cB), "0.0"), 691.2, 
"TestOptObjectByRefByVal(, B)"
-TestLog_ASSERT 

[Libreoffice-commits] core.git: basic/qa basic/source

2020-06-11 Thread Andreas Heinisch (via logerrit)
 basic/qa/basic_coverage/test_empty_parameter.vb |   22 ++
 basic/source/runtime/runtime.cxx|2 +-
 2 files changed, 23 insertions(+), 1 deletion(-)

New commits:
commit 345cb192f0bc2fef97ae52ade48efc2d8591a165
Author: Andreas Heinisch 
AuthorDate: Thu Jun 11 11:09:02 2020 +0200
Commit: Mike Kaganski 
CommitDate: Thu Jun 11 15:26:22 2020 +0200

tdf#132563 - Convert parameters of type SbxEMPTY

During the construction of the parameter list of a method,
convert parameters of type SbxEMPTY to their requested type,
since missing parameters are handled differently in StepEMPTY,
where separate parameter information (SbxMISSING) is added.

Change-Id: Ie1e027cfdd652404ec29bd3d05e7daf533468936
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96088
Reviewed-by: Mike Kaganski 
Tested-by: Jenkins

diff --git a/basic/qa/basic_coverage/test_empty_parameter.vb 
b/basic/qa/basic_coverage/test_empty_parameter.vb
new file mode 100644
index ..fe6e2651c094
--- /dev/null
+++ b/basic/qa/basic_coverage/test_empty_parameter.vb
@@ -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 Integer
+' 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 = 1
+Else
+doUnitTest = 0
+End If
+End Function
diff --git a/basic/source/runtime/runtime.cxx b/basic/source/runtime/runtime.cxx
index afe6c21790a1..ff5d7936247b 100644
--- a/basic/source/runtime/runtime.cxx
+++ b/basic/source/runtime/runtime.cxx
@@ -686,7 +686,7 @@ void SbiRuntime::SetParameters( SbxArray* pParams )
 {
 bByVal |= ( p->eType & SbxBYREF ) == 0;
 // tdf#79426, tdf#125180 - don't convert missing arguments to 
the requested parameter type
-if ( t != SbxEMPTY && !IsMissing( v, 1 ) )
+if ( !IsMissing( v, 1 ) )
 {
 t = static_cast( p->eType & 0x0FFF );
 }
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: basic/qa basic/source

2020-06-02 Thread Stephan Bergmann (via logerrit)
 basic/qa/cppunit/test_append.cxx|6 
 basic/qa/cppunit/test_language_conditionals.cxx |  166 -
 basic/qa/cppunit/test_scanner.cxx   |  222 +++-
 basic/source/classes/sb.cxx |3 
 4 files changed, 154 insertions(+), 243 deletions(-)

New commits:
commit 31ec2c252425f8a30b25177b4f67dde0a21771fc
Author: Stephan Bergmann 
AuthorDate: Tue Jun 2 18:46:45 2020 +0200
Commit: Stephan Bergmann 
CommitDate: Tue Jun 2 21:43:31 2020 +0200

Upcoming loplugin:elidestringvar: basic

Change-Id: Ie723d07afcc6e0d5e52bec77617fec326a739415
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/95374
Tested-by: Jenkins
Reviewed-by: Stephan Bergmann 

diff --git a/basic/qa/cppunit/test_append.cxx b/basic/qa/cppunit/test_append.cxx
index 7ff58012b28f..aa3280a4ad86 100644
--- a/basic/qa/cppunit/test_append.cxx
+++ b/basic/qa/cppunit/test_append.cxx
@@ -63,12 +63,10 @@ void EnableTest::testDimEnable()
 
 void EnableTest::testWin64()
 {
-OUString aSource1 = "   #If Win64\n"
+MacroSnippet myMacro("   #If Win64\n"
 "Declare PtrSafe Function aht_apiGetOpenFileName Lib \"comdlg32.dll\""
 "\n"
-"#End if\n";
-
-MacroSnippet myMacro(aSource1);
+"#End if\n");
 myMacro.Compile();
 CPPUNIT_ASSERT_MESSAGE("#if Win64 Declare PtrSafe causes compile error", 
!myMacro.HasError() );
 }
diff --git a/basic/qa/cppunit/test_language_conditionals.cxx 
b/basic/qa/cppunit/test_language_conditionals.cxx
index 53d6b6ec4cdd..190a34ead874 100644
--- a/basic/qa/cppunit/test_language_conditionals.cxx
+++ b/basic/qa/cppunit/test_language_conditionals.cxx
@@ -35,38 +35,36 @@ public:
 void Language_Conditionals::testIfNot()
 {
 { // need a block to ensure MacroSnippet is cleaned properly
-const OUString aSnippet("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");
-MacroSnippet myMacro(aSnippet);
+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(1), pNew->GetInteger());
 }
 { // need a block to ensure MacroSnippet is cleaned properly
-const OUString aSnippet("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");
-MacroSnippet myMacro(aSnippet);
+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();
@@ -77,42 +75,40 @@ void Language_Conditionals::testIfNot()
 void Language_Conditionals::testIfAndNot()
 {
 { // need a block to ensure MacroSnippet is cleaned properly
-const OUString aSnippet("Option VBASupport 1\n"
-"Option Explicit\n"
-  

[Libreoffice-commits] core.git: basic/qa basic/source

2020-05-21 Thread Andreas Heinisch (via logerrit)
 basic/qa/basic_coverage/test_string_replace.vb |   37 +
 basic/qa/vba_tests/replace.vb  |7 
 basic/source/runtime/methods.cxx   |   11 +--
 3 files changed, 52 insertions(+), 3 deletions(-)

New commits:
commit 3ff159d35770ac3454ee909b348cb4f4ca8b0b9b
Author: Andreas Heinisch 
AuthorDate: Wed May 20 15:49:08 2020 +0200
Commit: Noel Grandin 
CommitDate: Thu May 21 08:50:23 2020 +0200

tdf#132389 - case-insensitive operation for non-ASCII characters

Support case-insensitive operation for non-ASCII characters in the
Replace function in Basic.

Change-Id: I48069ad7be1ae0f012c52f595cc44e6b50580b94
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/94580
Tested-by: Jenkins
Reviewed-by: Noel Grandin 

diff --git a/basic/qa/basic_coverage/test_string_replace.vb 
b/basic/qa/basic_coverage/test_string_replace.vb
new file mode 100644
index ..99eafdba6b14
--- /dev/null
+++ b/basic/qa/basic_coverage/test_string_replace.vb
@@ -0,0 +1,37 @@
+Dim passCount As Integer
+Dim failCount As Integer
+Dim result As String
+
+Function doUnitTest() As String
+result = verify_stringReplace()
+If failCount <> 0 Or passCount = 0 Then
+doUnitTest = 0
+Else
+doUnitTest = 1
+End If
+End Function
+
+Function verify_stringReplace() As String
+passCount = 0
+failCount = 0
+
+result = "Test Results" & Chr$(10) & "" & Chr$(10)
+
+' tdf#132389 - case-insensitive operation for non-ASCII characters
+retStr = Replace("ABCabc", "b", "*")
+TestLog_ASSERT retStr, "A*Ca*c", "case-insensitive ASCII: " & retStr
+retStr = Replace("АБВабв", "б", "*")
+TestLog_ASSERT retStr, "А*Ва*в", "case-insensitive non-ASCII: " & retStr
+
+result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & 
"Tests failed: " & failCount & Chr$(10)
+verify_stringReplace = result
+End Function
+
+Sub TestLog_ASSERT(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
diff --git a/basic/qa/vba_tests/replace.vb b/basic/qa/vba_tests/replace.vb
index 64a3f99421f1..1349c10fae20 100644
--- a/basic/qa/vba_tests/replace.vb
+++ b/basic/qa/vba_tests/replace.vb
@@ -42,6 +42,13 @@ Function verify_testReplace() as String
 TestLog_ASSERT retStr = "aefefdBc", "count = 2: " & retStr
 retStr = Replace(srcStr, destStr, repStr, 1, 0, vbBinaryCompare)
 TestLog_ASSERT retStr = "abcbcdBc", "start = 1, count = 0, not support in 
Unix: " & retStr
+
+' tdf#132389 - case-insensitive operation for non-ASCII characters
+retStr = Replace("ABCabc", "b", "*", 1, 2, vbTextCompare)
+TestLog_ASSERT retStr = "A*Ca*c", "case-insensitive ASCII: " & retStr
+retStr = Replace("АБВабв", "б", "*", 1, 2, vbTextCompare)
+TestLog_ASSERT retStr = "А*Ва*в", "case-insensitive non-ASCII: " & retStr
+
 result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & 
"Tests failed: " & failCount & Chr$(10)
 verify_testReplace = result
 
diff --git a/basic/source/runtime/methods.cxx b/basic/source/runtime/methods.cxx
index 75b7b9177b42..106bfe806d0b 100644
--- a/basic/source/runtime/methods.cxx
+++ b/basic/source/runtime/methods.cxx
@@ -98,6 +98,9 @@ using namespace com::sun::star::uno;
 #include 
 #endif
 
+#include 
+#include 
+
 #if HAVE_FEATURE_SCRIPTING
 
 static void FilterWhiteSpace( OUString& rStr )
@@ -1278,9 +1281,11 @@ void SbRtl_Replace(StarBASIC *, SbxArray & rPar, bool)
 OUString aSrcStr(aExpStr);
 if (bCaseInsensitive)
 {
-// FIXME: case insensitivity should not be ASCII-only
-aSrcStr = aSrcStr.toAsciiUpperCase();
-aFindStr = aFindStr.toAsciiUpperCase();
+// tdf#132389 - case-insensitive operation for non-ASCII characters
+const css::lang::Locale& rLocale = 
Application::GetSettings().GetUILanguageTag().getLocale();
+css::uno::Reference < i18n::XCharacterClassification > xCharClass = 
vcl::unohelper::CreateCharacterClassification();
+aSrcStr = xCharClass->toUpper(aSrcStr, 0, aSrcStr.getLength(), 
rLocale);
+aFindStr = xCharClass->toUpper(aFindStr, 0, aSrcStr.getLength(), 
rLocale);
 }
 
 // Note: the result starts from lStartPos, removing everything to the 
left. See i#94895.
___
Libreoffice-commits mailing list
libreoffice-comm...@lists.freedesktop.org
https://lists.freedesktop.org/mailman/listinfo/libreoffice-commits


[Libreoffice-commits] core.git: basic/qa

2020-03-30 Thread Andreas Heinisch (via logerrit)
 basic/qa/cppunit/test_scanner.cxx |   59 +-
 1 file changed, 27 insertions(+), 32 deletions(-)

New commits:
commit ffbcbbc8dcc946d4d91cc08a937c2067be5a18b7
Author: Andreas Heinisch 
AuthorDate: Fri Mar 27 15:15:40 2020 +0100
Commit: Mike Kaganski 
CommitDate: Mon Mar 30 08:57:44 2020 +0200

Cleanup for tdf#130476, tdf#62323 and tdf#62326

Change-Id: I21b934415a8fd39e0dfd6a4c3cc8d589c84084f2
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/91222
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/basic/qa/cppunit/test_scanner.cxx 
b/basic/qa/cppunit/test_scanner.cxx
index bea47b7473b4..f1cae3fcd492 100644
--- a/basic/qa/cppunit/test_scanner.cxx
+++ b/basic/qa/cppunit/test_scanner.cxx
@@ -827,15 +827,6 @@ namespace
 const OUString source8("");
 const OUString source9("");
 
-// tdf#62323, tdf#62326 - conversion of Hex literals to basic signed 
Integers
-const OUString source10("");
-const OUString source11("");
-const OUString source12("");
-const OUString source13("");
-const OUString source14("");
-const OUString source15("");
-const OUString source16("");
-
 sal_Int32 errors;
 std::vector symbols;
 
@@ -919,8 +910,10 @@ namespace
 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 */
+
 //  = 0
-symbols = getSymbols(source10);
+symbols = getSymbols("");
 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);
@@ -928,7 +921,7 @@ namespace
 CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
 
 //  = -32768
-symbols = getSymbols(source11);
+symbols = getSymbols("");
 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);
@@ -936,7 +929,7 @@ namespace
 CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
 
 //  = -2147483648
-symbols = getSymbols(source12);
+symbols = getSymbols("");
 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);
@@ -944,7 +937,7 @@ namespace
 CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
 
 //  = -1
-symbols = getSymbols(source13);
+symbols = getSymbols("");
 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);
@@ -952,7 +945,7 @@ namespace
 CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
 
 //  = -1
-symbols = getSymbols(source14);
+symbols = getSymbols("");
 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);
@@ -960,7 +953,7 @@ namespace
 CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
 
 //  = 32767
-symbols = getSymbols(source15);
+symbols = getSymbols("");
 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);
@@ -968,14 +961,16 @@ namespace
 CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
 
 //  = 2147483647
-symbols = getSymbols(source16);
+symbols = getSymbols("");
 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 character % = SbxINTEGER
+/* tdf#130476 - trailing data type characters */
+
+// % = SbxINTEGER
 symbols = getSymbols("%");
 CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0, symbols[0].number, 1E-12);
@@ -983,7 +978,7 @@ namespace
 CPPUNIT_ASSERT_EQUAL(SbxINTEGER, symbols[0].type);
 CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
 
-// tdf#130476 - trailing data type character & = SbxLONG
+// & = SbxLONG
 symbols = getSymbols("&");
 CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0, symbols[0].number, 1E-12);
@@ -991,7 +986,7 @@ namespace
 CPPUNIT_ASSERT_EQUAL(SbxLONG, symbols[0].type);
 CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
 
-// tdf#130476 - trailing data type character ! = SbxSINGLE
+// ! = SbxSINGLE
 symbols = getSymbols("!");
 CPPUNIT_ASSERT_EQUAL(size_t(2), symbols.size());
 CPPUNIT_ASSERT_DOUBLES_EQUAL(0.0, symbols[0].number, 1E-12);
@@ -999,7 +994,7 @@ namespace
 

[Libreoffice-commits] core.git: basic/qa basic/source

2020-03-27 Thread Andreas Heinisch (via logerrit)
 basic/qa/cppunit/test_scanner.cxx |  191 +-
 basic/source/comp/scanner.cxx |   55 +-
 2 files changed, 235 insertions(+), 11 deletions(-)

New commits:
commit 384afeaa3df919585d9df1df5b4cf6c93536e319
Author: Andreas Heinisch 
AuthorDate: Tue Mar 24 12:16:35 2020 +0100
Commit: Mike Kaganski 
CommitDate: Fri Mar 27 14:16:03 2020 +0100

tdf#130476 - take into account trailing data type characters

For hex/octal literals take into account trailing suffix types
from GetSuffixType in basic/source/comp/scanner.cxx.

The suffix type $ (String) is not allowed for numeric values
or hex/octal literals and leads to a syntax error
(ERRCODE_BASIC_SYNTAX) during compile time.

Change-Id: Id6c4bbf1296361879f7dec461a48bbdc5c683338
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/90978
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/basic/qa/cppunit/test_scanner.cxx 
b/basic/qa/cppunit/test_scanner.cxx
index 42cd637cbd44..bea47b7473b4 100644
--- a/basic/qa/cppunit/test_scanner.cxx
+++ b/basic/qa/cppunit/test_scanner.cxx
@@ -715,6 +715,56 @@ namespace
 CPPUNIT_ASSERT_EQUAL(SbxDOUBLE, symbols[0].type);
 CPPUNIT_ASSERT_EQUAL(cr, symbols[1].text);
 CPPUNIT_ASSERT_EQUAL(1u, static_cast(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(errors));
   }
 
   void ScannerTest::testDataType()
@@ -786,6 +836,7 @@ namespace
 const OUString source15("");
 const OUString source16("");
 
+sal_Int32 errors;
 std::vector symbols;
 
 symbols = getSymbols(source1);
@@ -816,7 +867,7 @@ namespace
 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(SbxINTEGER, symbols[1].type);
+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);
@@ -832,7 +883,7 @@ namespace
 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(SbxINTEGER, symbols[0].type);
+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);
@@ -923,6 +974,142 @@ namespace
 CPPUNIT_ASSERT_EQUAL(OUString(), symbols[0].text);
 

[Libreoffice-commits] core.git: basic/qa

2020-03-24 Thread LibreOfficiant (via logerrit)
 basic/qa/cppunit/test_vba.cxx   |1 
 basic/qa/vba_tests/Err.Raise.vb |   86 
 2 files changed, 87 insertions(+)

New commits:
commit 45435e2ac007aed2aabd175ad944d6c779d99167
Author: LibreOfficiant 
AuthorDate: Thu Dec 12 09:54:34 2019 +0100
Commit: Mike Kaganski 
CommitDate: Tue Mar 24 11:16:21 2020 +0100

VBA Err object raise method TestCases

Err.Raise(#) enables 'User-Defined Exceptions'

Std Basic alternative is: Error # 'without  parentheses
which throws pre-defined error codes.

Change-Id: I76229b237066e33229d4d13e6742c660887fda2e
Reviewed-on: https://gerrit.libreoffice.org/c/core/+/85017
Tested-by: Jenkins
Reviewed-by: Mike Kaganski 

diff --git a/basic/qa/cppunit/test_vba.cxx b/basic/qa/cppunit/test_vba.cxx
index fd0bdb1c2c2c..235bcc2cf7b6 100644
--- a/basic/qa/cppunit/test_vba.cxx
+++ b/basic/qa/cppunit/test_vba.cxx
@@ -84,6 +84,7 @@ void VBATest::testMiscVBAFunctions()
 "day.vb",
 "enum.vb",
 "error.vb",
+"Err.Raise.vb",
 "exp.vb",
 "fix.vb",
 "hex.vb",
diff --git a/basic/qa/vba_tests/Err.Raise.vb b/basic/qa/vba_tests/Err.Raise.vb
new file mode 100644
index ..fa04856cc5b5
--- /dev/null
+++ b/basic/qa/vba_tests/Err.Raise.vb
@@ -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 VBASupport 1
+Option Explicit
+Dim passCount As Integer
+Dim failCount As Integer
+Dim result As String
+
+Function doUnitTest()
+''' This routine is QA/…/test_vba.cxx main entry point '''
+passCount = 0 : failCount = 0
+Const MIN_ERR =  : Const MAX_ERR = 2^31-1
+
+''' Raise one-to-many User-Defined Errors as signed Int32 '''
+result = "Test Results" & vbNewLine & "" & vbNewLine
+'  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")
+
+If failCount <> 0 Or passCount = 0 Then
+doUnitTest = result
+Else
+doUnitTest = "OK"
+End If
+End Function
+
+Sub TestErrRaise(TestName As String, CurErrNo As Long, CurErrSource As String, 
CurErrDescription As String)
+result = result & vbNewLine & TestName
+Dim origPassCount As Integer, origFailCount As Integer
+origPassCount = passCount
+origFailCount = failCount
+
+try: On Error Goto catch
+Err.Raise(CurErrNo, CurErrSource, CurErrDescription, "", "")
+
+'result = result & vbNewLine & "Testing after error handler"
+TestLog_ASSERT (passCount + failCount) > (origPassCount + origFailCount), 
TestName, "error handler did not execute!"
+TestLog_ASSERT Erl = 0, TestName, "Erl = " & Erl
+TestLog_ASSERT Err = 0, TestName, "Err = " & Err
+TestLog_ASSERT Error = "", TestName, "Error = " & Error
+TestLog_ASSERT Err.Description = "", "Err.Description  reset", 
"Err.Description = "& Err.Description
+TestLog_ASSERT Err.Number = 0, "Err.Number reset", "Err.Number = " & 
Err.Number
+TestLog_ASSERT Err.Source = "", "Err.Source reset", "Err.Source = " & 
Err.Source
+Exit Sub
+
+catch:
+'result = result & vbNewLine & "Testing in error handler"
+TestLog_ASSERT Err.Number = CurErrNo, "Err.Number failure", "Err.Number = 
" & Err.Number
+TestLog_ASSERT Err.Source = CurErrSource, "Err.Source failure", 
"Err.Source = " & Err.Source
+TestLog_ASSERT Err.Description = CurErrDescription, "Err.Description 
failure", "Err.Description = " & Err.Description
+
+TestLog_ASSERT Erl = 42, "line# failure", "Erl = " & Erl ' WATCH OUT for 
HARDCODED LINE # HERE !
+TestLog_ASSERT Err = CurErrNo, "Err# failure", "Err = " & Err
+TestLog_ASSERT Error = CurErrDescription, "Error description failure", 
"Error$ = " & Error$
+
+Resume Next ' Err object properties reset from here …
+End Sub
+
+Sub DEV_TEST : doUnitTest : MsgBox result : End Sub
+
+Sub TestLog_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 = testMsg + testId + ":"
+End If
+If Not IsMissing(testComment) And Not (testComment = "") Then
+testMsg = testMsg + " (" + testComment + ")"
+End If
+
+result = result & vbNewLine & "Failed: " & testMsg
+

  1   2   3   >