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>
diff --git a/basic/qa/basic_coverage/test_booltypename.bas b/basic/qa/basic_coverage/test_booltypename.bas
new file mode 100644
index 0000000..f8ed1f1
--- /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 87d29f6..089da74 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 8c1fd17..202c237 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 10396c3..dee531e 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;