
Conflicts: .travis.yml CMakeLists.txt include/chaiscript/dispatchkit/bootstrap.hpp include/chaiscript/dispatchkit/boxed_cast.hpp include/chaiscript/dispatchkit/dynamic_cast_conversion.hpp include/chaiscript/dispatchkit/function_call_detail.hpp include/chaiscript/dispatchkit/proxy_functions.hpp include/chaiscript/language/chaiscript_common.hpp
36 lines
849 B
ChaiScript
36 lines
849 B
ChaiScript
load_module("test_module")
|
|
|
|
auto t0 = TestBaseType()
|
|
auto t = TestDerivedType();
|
|
|
|
assert_equal(t0.func(), 0);
|
|
assert_equal(t.func(), 1);
|
|
|
|
assert_equal(10, t0.val);
|
|
assert_equal(15, t0.const_val);
|
|
|
|
assert_equal(10, t.val);
|
|
assert_equal(15, t.const_val);
|
|
|
|
t.val = 23;
|
|
assert_equal(23, t.val)
|
|
|
|
// test_derived_factory returns a TestDerivedType contained
|
|
// in a shared_ptr<TestBaseType>. This is testing our ability
|
|
// to detect that and do the down casting for the user automatically
|
|
// at runtime
|
|
|
|
assert_equal(t.derived_only_func(), 19);
|
|
|
|
var d := derived_type_factory();
|
|
assert_equal(d.derived_only_func(), 19);
|
|
|
|
var t2 = TestMoreDerivedType();
|
|
assert_equal(t2.derived_only_func(), 19);
|
|
assert_equal(t2.base_only_func(), -9);
|
|
|
|
var md := more_derived_type_factory();
|
|
assert_equal(md.derived_only_func(), 19);
|
|
assert_equal(md.base_only_func(), -9);
|
|
|