diff options
author | Mike Kaganski <mike.kaganski@collabora.com> | 2019-12-07 15:27:08 +0100 |
---|---|---|
committer | Mike Kaganski <mike.kaganski@collabora.com> | 2019-12-07 17:30:27 +0100 |
commit | 840c3a662012c77b5972c869587acd15ee5a3f03 (patch) | |
tree | 64fb4772a6477f98f365c7dcbc3acacac08fbdc7 /basic/qa | |
parent | 08016d2b0950e8706dc6c36f9804842156627c9e (diff) |
tdf#59327: DIM should fail in procedures when same-name argument is present
Change-Id: I0a6828bd0b0c27018dc02c36ee207b8666f88ec0
Reviewed-on: https://gerrit.libreoffice.org/84682
Tested-by: Jenkins
Reviewed-by: Mike Kaganski <mike.kaganski@collabora.com>
Diffstat (limited to 'basic/qa')
-rw-r--r-- | basic/qa/cppunit/basictest.cxx | 3 | ||||
-rw-r--r-- | basic/qa/cppunit/basictest.hxx | 2 | ||||
-rw-r--r-- | basic/qa/cppunit/test_complier_checks.cxx | 27 |
3 files changed, 32 insertions, 0 deletions
diff --git a/basic/qa/cppunit/basictest.cxx b/basic/qa/cppunit/basictest.cxx index 9a414b7f5e1a..3a22c84e9007 100644 --- a/basic/qa/cppunit/basictest.cxx +++ b/basic/qa/cppunit/basictest.cxx @@ -108,12 +108,15 @@ bool MacroSnippet::Compile() bool MacroSnippet::HasError() const { return mbError; } +const ErrCode& MacroSnippet::getError() const { return maErrCode; } + IMPL_LINK( MacroSnippet, BasicErrorHdl, StarBASIC *, /*pBasic*/, bool) { fprintf(stderr,"(%d:%d)\n", StarBASIC::GetLine(), StarBASIC::GetCol1()); fprintf(stderr,"Basic error: %s\n", OUStringToOString( StarBASIC::GetErrorText(), RTL_TEXTENCODING_UTF8 ).getStr() ); mbError = true; + maErrCode = StarBASIC::GetErrorCode(); return false; } diff --git a/basic/qa/cppunit/basictest.hxx b/basic/qa/cppunit/basictest.hxx index 8b92acf93d69..c8d262ee6def 100644 --- a/basic/qa/cppunit/basictest.hxx +++ b/basic/qa/cppunit/basictest.hxx @@ -24,6 +24,7 @@ class MacroSnippet { private: bool mbError; + ErrCode maErrCode; BasicDLL maDll; // we need a dll instance for resource manager etc. SbModuleRef mpMod; StarBASICRef mpBasic; @@ -46,6 +47,7 @@ public: DECL_LINK( BasicErrorHdl, StarBASIC *, bool ); bool HasError() const; + const ErrCode& getError() const; }; #endif diff --git a/basic/qa/cppunit/test_complier_checks.cxx b/basic/qa/cppunit/test_complier_checks.cxx new file mode 100644 index 000000000000..aad058040c31 --- /dev/null +++ b/basic/qa/cppunit/test_complier_checks.cxx @@ -0,0 +1,27 @@ +/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4; fill-column: 100 -*- */ +/* + * 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/. + */ + +#include <sal/config.h> +#include "basictest.hxx" +#include <basic/sberrors.hxx> +#include <unotest/bootstrapfixturebase.hxx> + +CPPUNIT_TEST_FIXTURE(CppUnit::TestFixture, testRedefineArgument) +{ + MacroSnippet aMacro("Sub doUnitTest(argName)\n" + " If False Then\n" + " Dim argName\n" + " End If\n" + "End Sub\n"); + aMacro.Compile(); + CPPUNIT_ASSERT(aMacro.HasError()); + CPPUNIT_ASSERT_EQUAL(ERRCODE_BASIC_VAR_DEFINED, aMacro.getError().StripDynamic()); +} + +/* vim:set shiftwidth=4 softtabstop=4 expandtab cinoptions=b1,g0,N-s cinkeys+=0=break: */ |