Add failing unit test for accessing member of null object

This commit is contained in:
Jason Turner 2014-09-08 18:23:53 -06:00
parent 52179d8333
commit 4a70ffe599
2 changed files with 21 additions and 2 deletions

View File

@ -51,12 +51,17 @@ class TestMoreDerivedType : public TestDerivedType
std::shared_ptr<TestBaseType> derived_type_factory()
{
return std::shared_ptr<TestBaseType>(new TestDerivedType());
return std::make_shared<TestDerivedType>();
}
std::shared_ptr<TestBaseType> more_derived_type_factory()
{
return std::shared_ptr<TestBaseType>(new TestMoreDerivedType());
return std::make_shared<TestBaseType>();
}
std::shared_ptr<TestBaseType> null_factory()
{
return std::shared_ptr<TestBaseType>();
}
std::string hello_world()
@ -111,6 +116,7 @@ CHAISCRIPT_MODULE_EXPORT chaiscript::ModulePtr create_chaiscript_module_test_mo
m->add(chaiscript::fun(&derived_type_factory), "derived_type_factory");
m->add(chaiscript::fun(&more_derived_type_factory), "more_derived_type_factory");
m->add(chaiscript::fun(&null_factory), "null_factory");
m->add(chaiscript::fun(&TestDerivedType::func), "func");

View File

@ -0,0 +1,13 @@
load_module("test_module")
auto o = null_factory();
try {
o.func();
} catch (e) {
exit(0);
}
assert_true(false);