diff options
author | Andreas Heinisch <andreas.heinisch@yahoo.de> | 2021-12-28 13:01:22 +0100 |
---|---|---|
committer | Andreas Heinisch <andreas.heinisch@yahoo.de> | 2021-12-28 19:54:58 +0100 |
commit | 565a5fdee3c00b383b4d36180be845d48fd42556 (patch) | |
tree | 914ec6e0fcbda3f44298fd488443b00bfdf8ae06 | |
parent | 144e2e6fc56d1d7d24dc19bc31670e28a1675a32 (diff) |
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 <andreas.heinisch@yahoo.de>
-rw-r--r-- | basic/qa/basic_coverage/test_booltypename.bas | 46 | ||||
-rw-r--r-- | basic/qa/cppunit/test_vba.cxx | 1 | ||||
-rw-r--r-- | basic/qa/vba_tests/booltypename.vb | 16 | ||||
-rw-r--r-- | basic/source/sbx/sbxvalue.cxx | 3 |
4 files changed, 62 insertions, 4 deletions
diff --git a/basic/qa/basic_coverage/test_booltypename.bas b/basic/qa/basic_coverage/test_booltypename.bas new file mode 100644 index 000000000000..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)") + 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) diff --git a/basic/source/sbx/sbxvalue.cxx b/basic/source/sbx/sbxvalue.cxx index 10396c3e5eb9..dee531ea28c0 100644 --- a/basic/source/sbx/sbxvalue.cxx +++ b/basic/source/sbx/sbxvalue.cxx @@ -843,7 +843,8 @@ bool SbxValue::Compute( SbxOperator eOp, const SbxValue& rOp ) if( GetType() == SbxSALUINT64 || GetType() == SbxSALINT64 || GetType() == SbxCURRENCY || GetType() == SbxULONG ) aL.eType = aR.eType = GetType(); - else if ( bVBAInterop && eOpType == SbxBOOL ) + // tdf#145960 - return type of boolean operators should be of type boolean + else if ( eOpType == SbxBOOL && eOp != SbxMOD && eOp != SbxIDIV ) aL.eType = aR.eType = SbxBOOL; else aL.eType = aR.eType = SbxLONG; |