summaryrefslogtreecommitdiff
path: root/basic
diff options
context:
space:
mode:
authorNoel Power <noel.power@novell.com>2012-05-14 13:58:43 +0100
committerNoel Power <noel.power@novell.com>2012-05-14 13:59:09 +0100
commitd7149abc7793eafd654214ed9446b3d84d628d58 (patch)
tree93a1658448ed4576b5dd82617468b68fbe19fcb6 /basic
parente6007cf40be9a1dd9913c6c7e539f14377add77e (diff)
add simple basic runtime test
Change-Id: If8742cb174aa1d017763d3ba42807ac4cf6c7420
Diffstat (limited to 'basic')
-rw-r--r--basic/CppunitTest_basic_enable.mk3
-rw-r--r--basic/qa/cppunit/test_append.cxx34
2 files changed, 27 insertions, 10 deletions
diff --git a/basic/CppunitTest_basic_enable.mk b/basic/CppunitTest_basic_enable.mk
index e3256507ded2..487cdd4e6ff2 100644
--- a/basic/CppunitTest_basic_enable.mk
+++ b/basic/CppunitTest_basic_enable.mk
@@ -49,6 +49,3 @@ $(eval $(call gb_CppunitTest_use_components,basic_enable,\
ucb/source/core/ucb1 \
))
$(eval $(call gb_CppunitTest_use_configuration,basic_enable))
-
-$(eval $(call gb_CppunitTest_use_filter_configuration,basic_enable))
-
diff --git a/basic/qa/cppunit/test_append.cxx b/basic/qa/cppunit/test_append.cxx
index 2afd912087f4..622d1d28e7d9 100644
--- a/basic/qa/cppunit/test_append.cxx
+++ b/basic/qa/cppunit/test_append.cxx
@@ -14,6 +14,7 @@
#include "basic/sbstar.hxx"
#include "basic/sbmod.hxx"
+#include "basic/sbmeth.hxx"
#include "basic/basrdll.hxx"
namespace
{
@@ -24,11 +25,13 @@ namespace
public:
EnableTest() : mbError(false) {};
void testDimEnable();
+ void testEnableRuntime();
// Adds code needed to register the test suite
CPPUNIT_TEST_SUITE(EnableTest);
// Declares the method as a test to call
CPPUNIT_TEST(testDimEnable);
+ CPPUNIT_TEST(testEnableRuntime);
// End of test suite definition
CPPUNIT_TEST_SUITE_END();
@@ -49,18 +52,35 @@ IMPL_LINK( EnableTest, BasicErrorHdl, StarBASIC *, /*pBasic*/)
return 0;
}
-class MyBASIC : public StarBASIC
+void EnableTest::testEnableRuntime()
{
- public:
- MyBASIC(){}
- ~MyBASIC(){}
-};
+ CPPUNIT_ASSERT_MESSAGE( "No resource manager", basicDLL().GetBasResMgr() != NULL );
+ StarBASICRef pBasic = new StarBASIC();
+ StarBASIC::SetGlobalErrorHdl( LINK( this, EnableTest, BasicErrorHdl ) );
+
+ rtl::OUString sSource("Function Test as Integer\n");
+ sSource += rtl::OUString("Dim Enable as Integer\n");
+ sSource += rtl::OUString("Enable = 1\n");
+ sSource += rtl::OUString("Enable = Enable + 2\n");
+ sSource += rtl::OUString("Test = Enable\n");
+ sSource += rtl::OUString("End Function\n");
+
+ SbModule* pMod = pBasic->MakeModule( rtl::OUString( "TestModule" ), sSource );
+ pMod->Compile();
+ CPPUNIT_ASSERT_MESSAGE("testEnableRuntime fails with compile error",!mbError );
+ SbMethod* pMeth = static_cast<SbMethod*>(pMod->Find( rtl::OUString("Test"), SbxCLASS_METHOD ));
+ CPPUNIT_ASSERT_MESSAGE("testEnableRuntime no method found", pMeth );
+ SbxVariableRef refTemp = pMeth;
+ // forces a broadcast
+ SbxVariableRef pNew = new SbxMethod( *((SbxMethod*)pMeth));
+ CPPUNIT_ASSERT(pNew->GetInteger() == 3 );
+ StarBASIC::SetGlobalErrorHdl( Link() );
+}
void EnableTest::testDimEnable()
{
CPPUNIT_ASSERT_MESSAGE( "No resource manager", basicDLL().GetBasResMgr() != NULL );
- std::auto_ptr<MyBASIC> pBasic;
- pBasic.reset( new MyBASIC() );
+ StarBASICRef pBasic = new StarBASIC();
StarBASIC::SetGlobalErrorHdl( LINK( this, EnableTest, BasicErrorHdl ) );
rtl::OUString sSource("Sub Test\n");