summaryrefslogtreecommitdiff
path: root/basic/qa
diff options
context:
space:
mode:
authorTor Lillqvist <tml@iki.fi>2021-12-02 12:37:07 +0200
committerMike Kaganski <mike.kaganski@collabora.com>2021-12-09 12:06:49 +0100
commit47aabde053a1472dc32770da29d68c8de5bd7919 (patch)
tree88526deaaa76a5583cd06abe48c6a44e0a65c41e /basic/qa
parentc1916d3ab8f764e465f889334050ce7c863576b3 (diff)
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 <mike.kaganski@collabora.com>
Diffstat (limited to 'basic/qa')
-rw-r--r--basic/qa/basic_coverage/test_types_conversion.bas30
1 files changed, 26 insertions, 4 deletions
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"