Add test for constructing from a pointer return value and fix test so it works. Task #13

This commit is contained in:
Jason Turner
2011-09-09 14:38:55 -06:00
parent 2b64c90a0e
commit e326fe6f2d
2 changed files with 18 additions and 0 deletions

View File

@@ -7,6 +7,7 @@ class TestBaseType
public:
TestBaseType() {}
TestBaseType(int) {}
TestBaseType(int *) {}
virtual ~TestBaseType() {}
virtual int func() { return 0; }
@@ -24,6 +25,11 @@ std::string hello_world()
return "Hello World";
}
int *get_new_int()
{
return new int(1);
}
// MSVC doesn't like that we are using C++ return types from our C declared module
// but this is the best way to do it for cross platform compatibility
#ifdef BOOST_MSVC
@@ -44,6 +50,7 @@ CHAISCRIPT_MODULE_EXPORT chaiscript::ModulePtr create_chaiscript_module_test_mo
m->add(chaiscript::constructor<TestBaseType ()>(), "TestBaseType");
// m->add(chaiscript::constructor<TestBaseType (int)>(), "TestBaseType");
m->add(chaiscript::constructor<TestBaseType (const TestBaseType &)>(), "TestBaseType");
m->add(chaiscript::constructor<TestBaseType (int *)>(), "TestBaseType");
m->add(chaiscript::constructor<TestDerivedType ()>(), "TestDerivedType");
m->add(chaiscript::constructor<TestDerivedType (const TestDerivedType &)>(), "TestDerivedType");
@@ -52,6 +59,8 @@ CHAISCRIPT_MODULE_EXPORT chaiscript::ModulePtr create_chaiscript_module_test_mo
m->add(chaiscript::fun(&TestBaseType::func), "func");
m->add(chaiscript::fun(&get_new_int), "get_new_int");
return m;
}