tdf#143706 - Mark skipped named optional parameters as missing/empty
When calling a Basic procedure using a named argument (for example, foo(y:=10)), optional skipped parameters were not correctly marked as missing, causing the function IsMissing() to return incorrect results. Change-Id: I90a9910165ec00a24deba86f7b3397dbc0720c93 Reviewed-on: https://gerrit.libreoffice.org/c/core/+/205034 Tested-by: Jenkins Reviewed-by: Andreas Heinisch <andreas.heinisch@yahoo.de>
This commit is contained in:
@@ -109,6 +109,15 @@ Sub verify_testIsMissingBasic()
|
||||
TestUtil.AssertEqual(TestOptArrayByRefByVal(, aB), IsMissingA, "TestOptArrayByRefByVal(, B)")
|
||||
TestUtil.AssertEqual(TestOptArrayByRefByVal(aA, aB), IsMissingNone, "TestOptArrayByRefByVal(A, B)")
|
||||
|
||||
' tdf#143706 - optionals with named arguments (:= syntax)
|
||||
' Without the fix in place, this test would have failed with:
|
||||
' - Expected: 0 (IsMissingA)
|
||||
' - Actual : -1 (IsMissingNone)
|
||||
TestUtil.AssertEqual(TestOptVariant(B := 456), IsMissingA, "TestOptVariant(B := 456)")
|
||||
TestUtil.AssertEqual(TestOptVariant(A := 123), IsMissingB, "TestOptVariant(A := 123)")
|
||||
TestUtil.AssertEqual(TestOptVariant(A := 123, B := 456), IsMissingNone, "TestOptVariant(A := 123, B := 456)")
|
||||
TestUtil.AssertEqual(TestOptVariant(B := 456, A := 123), IsMissingNone, "TestOptVariant(B := 456, A := 123)")
|
||||
|
||||
Exit Sub
|
||||
errorHandler:
|
||||
TestUtil.ReportErrorHandler("verify_testIsMissingBasic", Err, Error$, Erl)
|
||||
|
||||
@@ -109,6 +109,15 @@ Sub verify_testIsMissingCompatible()
|
||||
TestUtil.AssertEqual(TestOptArrayByRefByVal(, aB), IsMissingA, "TestOptArrayByRefByVal(, B)")
|
||||
TestUtil.AssertEqual(TestOptArrayByRefByVal(aA, aB), IsMissingNone, "TestOptArrayByRefByVal(A, B)")
|
||||
|
||||
' tdf#143706 - optionals with named arguments (:= syntax)
|
||||
' Without the fix in place, this test would have failed with:
|
||||
' - Expected: 0 (IsMissingA)
|
||||
' - Actual : -1 (IsMissingNone)
|
||||
TestUtil.AssertEqual(TestOptVariant(B := 456), IsMissingA, "TestOptVariant(B := 456)")
|
||||
TestUtil.AssertEqual(TestOptVariant(A := 123), IsMissingNone, "TestOptVariant(A := 123)")
|
||||
TestUtil.AssertEqual(TestOptVariant(A := 123, B := 456), IsMissingNone, "TestOptVariant(A := 123, B := 456)")
|
||||
TestUtil.AssertEqual(TestOptVariant(B := 456, A := 123), IsMissingNone, "TestOptVariant(B := 456, A := 123)")
|
||||
|
||||
Exit Sub
|
||||
errorHandler:
|
||||
TestUtil.ReportErrorHandler("verify_testIsMissingCompatible", Err, Error$, Erl)
|
||||
|
||||
@@ -115,6 +115,15 @@ Sub verify_testIsMissingVba()
|
||||
' TestUtil.AssertEqual(TestOptArrayByRefByVal(, aB), IsMissingA, "TestOptArrayByRefByVal(, B)")
|
||||
TestUtil.AssertEqual(TestOptArrayByRefByVal(aA, aB), IsMissingNone, "TestOptArrayByRefByVal(A, B)")
|
||||
|
||||
' tdf#143706 - optionals with named arguments (:= syntax)
|
||||
' Without the fix in place, this test would have failed with:
|
||||
' - Expected: 0 (IsMissingA)
|
||||
' - Actual : -1 (IsMissingNone)
|
||||
TestUtil.AssertEqual(TestOptVariant(B := 456), IsMissingA, "TestOptVariant(B := 456)")
|
||||
TestUtil.AssertEqual(TestOptVariant(A := 123), IsMissingNone, "TestOptVariant(A := 123)")
|
||||
TestUtil.AssertEqual(TestOptVariant(A := 123, B := 456), IsMissingNone, "TestOptVariant(A := 123, B := 456)")
|
||||
TestUtil.AssertEqual(TestOptVariant(B := 456, A := 123), IsMissingNone, "TestOptVariant(B := 456, A := 123)")
|
||||
|
||||
Exit Sub
|
||||
errorHandler:
|
||||
TestUtil.ReportErrorHandler("verify_testIsMissingVba", Err, Error$, Erl)
|
||||
|
||||
@@ -3923,6 +3923,27 @@ void SbiRuntime::SetupArgs( SbxVariable* p, sal_uInt32 nOp1 )
|
||||
}
|
||||
pArg->Put(pVar, nCurPar++);
|
||||
}
|
||||
// tdf#143706 - mark skipped named optional parameters as missing/empty
|
||||
SbxMethod* pSbxMeth = dynamic_cast<SbxMethod*>(p);
|
||||
const bool bIsRuntimeFunction = pSbxMeth && pSbxMeth->IsRuntimeFunction();
|
||||
for (sal_uInt32 j = 1; j < pArg->Count(); j++)
|
||||
{
|
||||
if (!pArg->GetRef(j))
|
||||
{
|
||||
SbxVariableRef xVar;
|
||||
if (bIsRuntimeFunction)
|
||||
xVar = new SbxVariable(SbxEMPTY);
|
||||
else
|
||||
{
|
||||
// Same as in SbiRuntime::StepEMPTY(), because the compiler does not
|
||||
// generate a StepEMPTY for StepPARAM when there is no COMMA token
|
||||
xVar = new SbxVariable(SbxVARIANT);
|
||||
xVar->PutErr(448);
|
||||
SetIsMissing(xVar.get());
|
||||
}
|
||||
pArg->Put(xVar.get(), j);
|
||||
}
|
||||
}
|
||||
refArgv = pArg;
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user