Add explicit tests for accessing data members of const objects
This commit is contained in:
parent
101225aa68
commit
d44de49fb1
@ -11,6 +11,8 @@ class TestBaseType
|
||||
virtual ~TestBaseType() {}
|
||||
virtual int func() { return 0; }
|
||||
|
||||
const TestBaseType &constMe() const { return *this; }
|
||||
|
||||
int val;
|
||||
const int const_val;
|
||||
};
|
||||
@ -84,6 +86,7 @@ CHAISCRIPT_MODULE_EXPORT chaiscript::ModulePtr create_chaiscript_module_test_mo
|
||||
m->add(chaiscript::user_type<TestEnum>(), "TestEnum");
|
||||
|
||||
m->add(chaiscript::fun(&to_int), "to_int");
|
||||
m->add(chaiscript::fun(&TestBaseType::constMe), "constMe");
|
||||
|
||||
|
||||
return m;
|
||||
|
11
unittests/member_variable_access.chai
Normal file
11
unittests/member_variable_access.chai
Normal file
@ -0,0 +1,11 @@
|
||||
load_module("test_module")
|
||||
|
||||
var t0 = TestBaseType()
|
||||
t0.val = 13
|
||||
|
||||
assert_equal(15, t0.const_val)
|
||||
assert_equal(13, t0.val)
|
||||
assert_equal(15, t0.constMe().const_val)
|
||||
assert_equal(13, t0.constMe().val)
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user