summaryrefslogtreecommitdiffstats
path: root/basic
diff options
context:
space:
mode:
authorAndreas Heinisch <andreas.heinisch@yahoo.de>2020-06-15 22:44:27 +0200
committerXisco Fauli <xiscofauli@libreoffice.org>2020-06-17 12:15:07 +0200
commitb62d73ccb04da2c4cf7f68a23742d0670ef7eb90 (patch)
treee566af0e783c1f3efcc1e0d167311b0302943782 /basic
parenttdf#130449 allow gdk_window_move_to_rect to try GDK_ANCHOR_SLIDE (diff)
downloadcore-b62d73ccb04da2c4cf7f68a23742d0670ef7eb90.tar.gz
core-b62d73ccb04da2c4cf7f68a23742d0670ef7eb90.zip
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 <mike.kaganski@collabora.com> (cherry picked from commit 0f6e012057bf0d1cc339154e8af6586d9615a37f) Reviewed-on: https://gerrit.libreoffice.org/c/core/+/96498 Reviewed-by: Xisco Fauli <xiscofauli@libreoffice.org>
Diffstat (limited to 'basic')
-rw-r--r--basic/qa/basic_coverage/test_numeric_constant_parameter.vb34
-rw-r--r--basic/qa/basic_coverage/test_optional_paramters_basic.vb20
-rw-r--r--basic/qa/basic_coverage/test_optional_paramters_compatible.vb26
-rw-r--r--basic/qa/vba_tests/optional_paramters.vb6
-rw-r--r--basic/source/runtime/runtime.cxx2
5 files changed, 60 insertions, 28 deletions
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 000000000000..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 Format(TestOptObjectByRefByVal(cA, cB), "0.0"), 1270.2, "TestOptObjectByRefByVal(A, B)"
+ TestLog_ASSERT CDbl(Format(TestOptObjectByRefByVal(, cB), "0.0")), 691.2, "TestOptObjectByRefByVal(, B)"
+ TestLog_ASSERT CDbl(Format(TestOptObjectByRefByVal(cA, cB), "0.0")), 1270.2, "TestOptObjectByRefByVal(A, B)"
' optionals with array datatypes
Dim aA(0 To 1) As Integer
@@ -99,14 +99,14 @@ Function verify_testOptionalsBasic() As String
aB(1) = 567.8
TestLog_ASSERT TestOptArray(), 0, "TestOptArray()"
TestLog_ASSERT TestOptArray(aA), 579, "TestOptArray(A)"
- TestLog_ASSERT Format(TestOptArray(, aB), "0.0"), 691.2, "TestOptArray(, B)"
- TestLog_ASSERT Format(TestOptArray(aA, aB), "0.0"), 1270.2, "TestOptArray(A, B)"
+ TestLog_ASSERT CDbl(Format(TestOptArray(, aB), "0.0")), 691.2, "TestOptArray(, B)"
+ TestLog_ASSERT CDbl(Format(TestOptArray(aA, aB), "0.0")), 1270.2, "TestOptArray(A, B)"
' optionals with array datatypes (ByRef and ByVal)
TestLog_ASSERT TestOptArrayByRefByVal(), 0, "TestOptArrayByRefByVal()"
TestLog_ASSERT TestOptArrayByRefByVal(aA), 579, "TestOptArrayByRefByVal(A)"
- TestLog_ASSERT Format(TestOptArrayByRefByVal(, aB), "0.0"), 691.2, "TestOptArrayByRefByVal(, B)"
- TestLog_ASSERT Format(TestOptArrayByRefByVal(aA, aB), "0.0"), 1270.2, "TestOptArrayByRefByVal(A, B)"
+ TestLog_ASSERT CDbl(Format(TestOptArrayByRefByVal(, aB), "0.0")), 691.2, "TestOptArrayByRefByVal(, B)"
+ TestLog_ASSERT CDbl(Format(TestOptArrayByRefByVal(aA, aB), "0.0")), 1270.2, "TestOptArrayByRefByVal(A, B)"
result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
verify_testOptionalsBasic = result
diff --git a/basic/qa/basic_coverage/test_optional_paramters_compatible.vb b/basic/qa/basic_coverage/test_optional_paramters_compatible.vb
index 15bfe77b827a..9ea47550820d 100644
--- a/basic/qa/basic_coverage/test_optional_paramters_compatible.vb
+++ b/basic/qa/basic_coverage/test_optional_paramters_compatible.vb
@@ -27,15 +27,13 @@ Function verify_testOptionalsCompatible() As String
On Error GoTo errorHandler
' optionals with variant datatypes
- ' TODO - New bug report? Scanner initializes variable as String. Function returns "123"
- ' TestLog_ASSERT TestOptVariant(), 123, "TestOptVariant()"
+ TestLog_ASSERT TestOptVariant(), 123, "TestOptVariant()"
TestLog_ASSERT TestOptVariant(123), 246, "TestOptVariant(123)"
TestLog_ASSERT TestOptVariant(, 456), 456, "TestOptVariant(, 456)"
TestLog_ASSERT TestOptVariant(123, 456), 579, "TestOptVariant(123, 456)"
' optionals with variant datatypes (ByRef and ByVal)
- ' TODO - New bug report? Scanner initializes variable as String. Function returns "123"
- ' TestLog_ASSERT TestOptVariantByRefByVal(), 123, "TestOptVariantByRefByVal()"
+ TestLog_ASSERT TestOptVariantByRefByVal(), 123, "TestOptVariantByRefByVal()"
TestLog_ASSERT TestOptVariantByRefByVal(123), 246, "TestOptVariantByRefByVal(123)"
TestLog_ASSERT TestOptVariantByRefByVal(, 456), 456, "TestOptVariantByRefByVal(, 456)"
TestLog_ASSERT TestOptVariantByRefByVal(123, 456), 579, "TestOptVariantByRefByVal(123, 456)"
@@ -44,13 +42,13 @@ Function verify_testOptionalsCompatible() As String
TestLog_ASSERT TestOptDouble(), 123.4, "TestOptDouble()"
TestLog_ASSERT TestOptDouble(123.4), 246.8, "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(), 123.4, "TestOptDouble()"
TestLog_ASSERT TestOptDoubleByRefByVal(123.4), 246.8, "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(), 123, "TestOptInteger()"
@@ -85,14 +83,14 @@ Function verify_testOptionalsCompatible() 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 Format(TestOptObjectByRefByVal(cA, cB), "0.0"), 1270.2, "TestOptObjectByRefByVal(A, B)"
+ TestLog_ASSERT CDbl(Format(TestOptObjectByRefByVal(, cB), "0.0")), 691.2, "TestOptObjectByRefByVal(, B)"
+ TestLog_ASSERT CDbl(Format(TestOptObjectByRefByVal(cA, cB), "0.0")), 1270.2, "TestOptObjectByRefByVal(A, B)"
' optionals with array datatypes
Dim aA(0 To 1) As Integer
@@ -103,14 +101,14 @@ Function verify_testOptionalsCompatible() As String
aB(1) = 567.8
TestLog_ASSERT TestOptArray(), 0, "TestOptArray()"
TestLog_ASSERT TestOptArray(aA), 579, "TestOptArray(A)"
- TestLog_ASSERT Format(TestOptArray(, aB), "0.0"), 691.2, "TestOptArray(, B)"
- TestLog_ASSERT Format(TestOptArray(aA, aB), "0.0"), 1270.2, "TestOptArray(A, B)"
+ TestLog_ASSERT CDbl(Format(TestOptArray(, aB), "0.0")), 691.2, "TestOptArray(, B)"
+ TestLog_ASSERT CDbl(Format(TestOptArray(aA, aB), "0.0")), 1270.2, "TestOptArray(A, B)"
' optionals with array datatypes (ByRef and ByVal)
TestLog_ASSERT TestOptArrayByRefByVal(), 0, "TestOptArrayByRefByVal()"
TestLog_ASSERT TestOptArrayByRefByVal(aA), 579, "TestOptArrayByRefByVal(A)"
- TestLog_ASSERT Format(TestOptArrayByRefByVal(, aB), "0.0"), 691.2, "TestOptArrayByRefByVal(, B)"
- TestLog_ASSERT Format(TestOptArrayByRefByVal(aA, aB), "0.0"), 1270.2, "TestOptArrayByRefByVal(A, B)"
+ TestLog_ASSERT CDbl(Format(TestOptArrayByRefByVal(, aB), "0.0")), 691.2, "TestOptArrayByRefByVal(, B)"
+ TestLog_ASSERT CDbl(Format(TestOptArrayByRefByVal(aA, aB), "0.0")), 1270.2, "TestOptArrayByRefByVal(A, B)"
result = result & Chr$(10) & "Tests passed: " & passCount & Chr$(10) & "Tests failed: " & failCount & Chr$(10)
verify_testOptionalsCompatible = result
diff --git a/basic/qa/vba_tests/optional_paramters.vb b/basic/qa/vba_tests/optional_paramters.vb
index a8716c16c95e..2f527e5d72a7 100644
--- a/basic/qa/vba_tests/optional_paramters.vb
+++ b/basic/qa/vba_tests/optional_paramters.vb
@@ -28,15 +28,13 @@ Function verify_testOptionalsVba() As String
On Error GoTo errorHandler
' optionals with variant datatypes
- ' TODO - New bug report? Scanner initializes variable as String. Function returns "123"
- ' TestLog_ASSERT TestOptVariant(), 123, "TestOptVariant()"
+ TestLog_ASSERT TestOptVariant(), 123, "TestOptVariant()"
TestLog_ASSERT TestOptVariant(123), 246, "TestOptVariant(123)"
TestLog_ASSERT TestOptVariant(, 456), 456, "TestOptVariant(, 456)"
TestLog_ASSERT TestOptVariant(123, 456), 579, "TestOptVariant(123, 456)"
' optionals with variant datatypes (ByRef and ByVal)
- ' TODO - New bug report? Scanner initializes variable as String. Function returns "123"
- ' TestLog_ASSERT TestOptVariantByRefByVal(), 123, "TestOptVariantByRefByVal()"
+ TestLog_ASSERT TestOptVariantByRefByVal(), 123, "TestOptVariantByRefByVal()"
TestLog_ASSERT TestOptVariantByRefByVal(123), 246, "TestOptVariantByRefByVal(123)"
TestLog_ASSERT TestOptVariantByRefByVal(, 456), 456, "TestOptVariantByRefByVal(, 456)"
TestLog_ASSERT TestOptVariantByRefByVal(123, 456), 579, "TestOptVariantByRefByVal(123, 456)"
diff --git a/basic/source/runtime/runtime.cxx b/basic/source/runtime/runtime.cxx
index ff5d7936247b..c2182e26b77a 100644
--- a/basic/source/runtime/runtime.cxx
+++ b/basic/source/runtime/runtime.cxx
@@ -2827,6 +2827,8 @@ void SbiRuntime::StepLOADNC( sal_uInt32 nOp1 )
}
SbxVariable* p = new SbxVariable( eType );
p->PutDouble( n );
+ // tdf#133913 - create variable with Variant/Type in order to prevent type conversion errors
+ p->ResetFlag( SbxFlagBits::Fixed );
PushVar( p );
}