Initial commit

This commit is contained in:
Bassem Girgis
2018-12-20 17:34:07 -06:00
parent 7a2d899662
commit 81b4b9e273
34743 changed files with 5940233 additions and 0 deletions

View File

@@ -0,0 +1,92 @@
#######################################################################
# Makefile for octave test-suite
#######################################################################
LANGUAGE = octave
OCTAVE = @OCTAVE@
SCRIPTSUFFIX = _runme.m
srcdir = @srcdir@
top_srcdir = @top_srcdir@
top_builddir = @top_builddir@
CPP_TEST_CASES += \
li_std_pair_extra \
li_std_string_extra \
octave_cell_deref\
octave_dim
CPP_TEST_BROKEN += \
implicittest \
li_implicit \
li_std_set \
li_std_stream
#C_TEST_CASES +=
#
# This test only works with modern C compilers
#
#C_TEST_CASES += \
# complextest
include $(srcdir)/../common.mk
# Overridden variables here
LIBS = -L.
CSRCS = octave_empty.c
# Custom tests - tests with additional commandline options
# none!
# Rules for the different types of tests
%.cpptest:
$(setup)
+$(swig_and_compile_cpp)
$(run_testcase)
%.ctest:
$(setup)
+$(swig_and_compile_c)
$(run_testcase)
%.multicpptest:
$(setup)
+$(swig_and_compile_multi_cpp)
$(run_testcase)
# Runs the testcase. A testcase is only run if
# a file is found which has _runme.m appended after the testcase name.
run_testcase = \
if [ -f $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH OCTAVE_PATH=$(srcdir):$$OCTAVE_PATH $(RUNTOOL) $(OCTAVE) $(SCRIPTDIR)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
fi
# Clean: remove the generated .m file
%.clean:
@rm -f hugemod.h hugemod_a.i hugemod_b.i hugemod_a.m hugemod_b.m hugemod_runme.m
@rm -f $*.m;
clean:
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile SRCDIR='$(SRCDIR)' octave_clean
cvsignore:
@echo '*wrap* *.mc *.so *.dll *.exp *.lib'
@echo Makefile
@for i in ${CPP_TEST_CASES} ${C_TEST_CASES}; do echo $$i.m; done
@for i in ${CPP_TEST_CASES} ${C_TEST_CASES}; do if grep -q $${i}_runme.m CVS/Entries ; then echo $${i}_runme.m; fi; done
@echo clientdata_prop_a.m
@echo clientdata_prop_b.m
@echo imports_a.m
@echo imports_b.m
@echo mod_a.m mod_b.m
@echo hugemod.h hugemod_a.i hugemod_b.i hugemod_a.m hugemod_b.m hugemod_runme.m
@echo template_typedef_import.m
hugemod:
perl hugemod.pl
$(MAKE) hugemod_a.cpptest
$(MAKE) hugemod_b.cpptest
time $(OCTAVE) hugemod_runme.m
time $(OCTAVE) hugemod_runme.m

View File

@@ -0,0 +1,7 @@
abstract_access
d = abstract_access.D();
if (d.do_x() != 1)
error
endif

View File

@@ -0,0 +1,13 @@
# do not dump Octave core
if exist("crash_dumps_octave_core", "builtin")
crash_dumps_octave_core(0);
endif
abstract_typedef2
a = A_UF();

View File

@@ -0,0 +1,17 @@
# do not dump Octave core
if exist("crash_dumps_octave_core", "builtin")
crash_dumps_octave_core(0);
endif
abstract_typedef
e = Engine();
a = A();
if (a.write(e) != 1)
error
endif

View File

@@ -0,0 +1,12 @@
# do not dump Octave core
if exist("crash_dumps_octave_core", "builtin")
crash_dumps_octave_core(0);
endif
abstract_virtual
d = D();
e = E();

View File

@@ -0,0 +1,29 @@
argcargvtest
largs={'hi','hola','hello'};
if (mainc(largs) != 3)
error("bad main typemap");
endif
targs={'hi','hola'};
if (mainv(targs,1) != 'hola')
error("bad main typemap");
endif
targs={'hi', 'hola'};
if (mainv(targs,1) != 'hola')
error("bad main typemap");
endif
try
error_flag = 0;
mainv('hello',1);
error_flag = 1;
catch
end_try_catch
if (error_flag)
error("bad main typemap")
endif
initializeApp(largs);

View File

@@ -0,0 +1,25 @@
array_member
f = Foo();
f.data = cvar.global_data;
for i=0:7,
if (get_value(f.data,i) != get_value(cvar.global_data,i))
error("Bad array assignment");
endif
endfor
for i=0:7,
set_value(f.data,i,-i);
endfor
cvar.global_data = f.data;
for i=0:7,
if (get_value(f.data,i) != get_value(cvar.global_data,i))
error("Bad array assignment")
endif
endfor

View File

@@ -0,0 +1,24 @@
# do not dump Octave core
if exist("crash_dumps_octave_core", "builtin")
crash_dumps_octave_core(0);
endif
arrays_global
arrays_global.cvar.array_i = arrays_global.cvar.array_const_i;
cvar.BeginString_FIX44a;
cvar.BeginString_FIX44b;
cvar.BeginString_FIX44c;
cvar.BeginString_FIX44d;
cvar.BeginString_FIX44d;
cvar.BeginString_FIX44b = strcat("12","\0","45");
cvar.BeginString_FIX44b;
cvar.BeginString_FIX44d;
cvar.BeginString_FIX44e;
cvar.BeginString_FIX44f;
test_a("hello","hi","chello","chi");
test_b("1234567","hi");

View File

@@ -0,0 +1,40 @@
_callback
callback
if (foo(2) != 2)
error
endif
if (A_bar(2) != 4)
error
endif
if (foobar(3, _callback.foo) != foo(3))
error
endif
if (foobar(3, foo) != foo(3))
error
endif
if (foobar(3, A_bar) != A_bar(3))
error
endif
if (foobar(3, foof) != foof(3))
error
endif
if (foobar_i(3, foo_i) != foo_i(3))
error
endif
if (foobar_d(3.5, foo_d) != foo_d(3.5))
error
endif
a = A();
if (foobarm(3, a, A.foom_cb_ptr) != a.foom(3))
error
endif

View File

@@ -0,0 +1,12 @@
# do not dump Octave core
if exist("crash_dumps_octave_core", "builtin")
crash_dumps_octave_core(0);
endif
class_ignore
a = class_ignore.Bar();
if (!strcmp(class_ignore.do_blah(a),"Bar::blah"))
error
endif

View File

@@ -0,0 +1,7 @@
class_scope_weird
f = class_scope_weird.Foo();
g = class_scope_weird.Foo(3);
if (f.bar(3) != 3)
error
endif

View File

@@ -0,0 +1,24 @@
compactdefaultargs
defaults1 = Defaults1(1000);
defaults1 = Defaults1();
if (defaults1.ret(10.0) != 10.0)
error
endif
if (defaults1.ret() != -1.0)
error
endif
defaults2 = Defaults2(1000);
defaults2 = Defaults2();
if (defaults2.ret(10.0) != 10.0)
error
endif
if (defaults2.ret() != -1.0)
error
endif

View File

@@ -0,0 +1,24 @@
# do not dump Octave core
if exist("crash_dumps_octave_core", "builtin")
crash_dumps_octave_core(0);
endif
complextest
a = complex(-1,2);
if (complextest.Conj(a) != a.conjugate())
error("bad complex mapping")
endif
if (complextest.Conjf(a) != a.conjugate())
error("bad complex mapping")
endif
v = (complex(1,2), complex(2,3), complex(4,3), 1);
try
complextest.Copy_h(v);
catch
end_try_catch

View File

@@ -0,0 +1,39 @@
# do not dump Octave core
if exist("crash_dumps_octave_core", "builtin")
crash_dumps_octave_core(0);
endif
constover
p = constover.test("test");
if (!strcmp(p,"test"))
error("test failed!")
endif
p = constover.test_pconst("test");
if (!strcmp(p,"test_pconst"))
error("test_pconst failed!")
endif
f = constover.Foo();
p = f.test("test");
if (!strcmp(p,"test"))
error("member-test failed!")
endif
p = f.test_pconst("test");
if (!strcmp(p,"test_pconst"))
error("member-test_pconst failed!")
endif
p = f.test_constm("test");
if (!strcmp(p,"test_constmethod"))
error("member-test_constm failed!")
endif
p = f.test_pconstm("test");
if (!strcmp(p,"test_pconstmethod"))
error("member-test_pconstm failed!")
endif

View File

@@ -0,0 +1,49 @@
# do not dump Octave core
if exist("crash_dumps_octave_core", "builtin")
crash_dumps_octave_core(0);
endif
constructor_copy
f1 = Foo1(3);
f11 = Foo1(f1);
if (f1.x != f11.x)
error
endif
f8 = Foo8();
try
f81 = Foo8(f8);
good = 0;
catch
good = 1;
end_try_catch
if (!good)
error
endif
bi = Bari(5);
bc = Bari(bi);
if (bi.x != bc.x)
error
endif
bd = Bard(5);
try
bc = Bard(bd);
good = 0;
catch
good = 1;
end_try_catch
if (!good)
error
endif

View File

@@ -0,0 +1,135 @@
contract
contract.test_preassert(1,2);
try
contract.test_preassert(-1,0)
error("Failed! Preassertions are broken")
catch
end_try_catch
contract.test_postassert(3);
try
contract.test_postassert(-3);
error("Failed! Postassertions are broken")
catch
end_try_catch
contract.test_prepost(2,3);
contract.test_prepost(5,-4);
try
contract.test_prepost(-3,4);
error("Failed! Preassertions are broken")
catch
end_try_catch
try
contract.test_prepost(4,-10);
error("Failed! Postassertions are broken")
catch
end_try_catch
f = contract.Foo();
f.test_preassert(4,5);
try
f.test_preassert(-2,3);
error("Failed! Method preassertion.")
catch
end_try_catch
f.test_postassert(4);
try
f.test_postassert(-4);
error("Failed! Method postassertion")
catch
end_try_catch
f.test_prepost(3,4);
f.test_prepost(4,-3);
try
f.test_prepost(-4,2);
error("Failed! Method preassertion.")
catch
end_try_catch
try
f.test_prepost(4,-10);
error("Failed! Method postassertion.")
catch
end_try_catch
contract.Foo_stest_prepost(4,0);
try
contract.Foo_stest_prepost(-4,2);
error("Failed! Static method preassertion")
catch
end_try_catch
try
contract.Foo_stest_prepost(4,-10);
error("Failed! Static method posteassertion")
catch
end_try_catch
b = contract.Bar();
try
b.test_prepost(2,-4);
error("Failed! Inherited preassertion.")
catch
end_try_catch
d = contract.D();
try
d.foo(-1,1,1,1,1);
error("Failed! Inherited preassertion (D).")
catch
end_try_catch
try
d.foo(1,-1,1,1,1);
error("Failed! Inherited preassertion (D).")
catch
end_try_catch
try
d.foo(1,1,-1,1,1);
error("Failed! Inherited preassertion (D).")
catch
end_try_catch
try
d.foo(1,1,1,-1,1);
error("Failed! Inherited preassertion (D).")
catch
end_try_catch
try
d.foo(1,1,1,1,-1);
error("Failed! Inherited preassertion (D).")
catch
end_try_catch
try
d.bar(-1,1,1,1,1);
error("Failed! Inherited preassertion (D).")
catch
end_try_catch
try
d.bar(1,-1,1,1,1);
error("Failed! Inherited preassertion (D).")
catch
end_try_catch
try
d.bar(1,1,-1,1,1);
error("Failed! Inherited preassertion (D).")
catch
end_try_catch
try
d.bar(1,1,1,-1,1);
error("Failed! Inherited preassertion (D).")
catch
end_try_catch
try
d.bar(1,1,1,1,-1);
error("Failed! Inherited preassertion (D).")
catch
end_try_catch

View File

@@ -0,0 +1,166 @@
cpp11_strongly_typed_enumerations
function newvalue = enumCheck(actual, expected)
if (actual != expected);
error("Enum value mismatch. Expected: %d Actual: %d", expected, actual);
endif
newvalue = expected + 1;
end
val = 0;
val = enumCheck(cpp11_strongly_typed_enumerations.Enum1_Val1, val);
val = enumCheck(cpp11_strongly_typed_enumerations.Enum1_Val2, val);
val = enumCheck(cpp11_strongly_typed_enumerations.Enum1_Val3, 13);
val = enumCheck(cpp11_strongly_typed_enumerations.Enum1_Val4, val);
val = enumCheck(cpp11_strongly_typed_enumerations.Enum1_Val5a, 13);
val = enumCheck(cpp11_strongly_typed_enumerations.Enum1_Val6a, val);
val = 0;
val = enumCheck(cpp11_strongly_typed_enumerations.Enum2_Val1, val);
val = enumCheck(cpp11_strongly_typed_enumerations.Enum2_Val2, val);
val = enumCheck(cpp11_strongly_typed_enumerations.Enum2_Val3, 23);
val = enumCheck(cpp11_strongly_typed_enumerations.Enum2_Val4, val);
val = enumCheck(cpp11_strongly_typed_enumerations.Enum2_Val5b, 23);
val = enumCheck(cpp11_strongly_typed_enumerations.Enum2_Val6b, val);
val = 0;
val = enumCheck(cpp11_strongly_typed_enumerations.Val1, val);
val = enumCheck(cpp11_strongly_typed_enumerations.Val2, val);
val = enumCheck(cpp11_strongly_typed_enumerations.Val3, 43);
val = enumCheck(cpp11_strongly_typed_enumerations.Val4, val);
val = 0;
val = enumCheck(cpp11_strongly_typed_enumerations.Enum5_Val1, val);
val = enumCheck(cpp11_strongly_typed_enumerations.Enum5_Val2, val);
val = enumCheck(cpp11_strongly_typed_enumerations.Enum5_Val3, 53);
val = enumCheck(cpp11_strongly_typed_enumerations.Enum5_Val4, val);
val = 0;
val = enumCheck(cpp11_strongly_typed_enumerations.Enum6_Val1, val);
val = enumCheck(cpp11_strongly_typed_enumerations.Enum6_Val2, val);
val = enumCheck(cpp11_strongly_typed_enumerations.Enum6_Val3, 63);
val = enumCheck(cpp11_strongly_typed_enumerations.Enum6_Val4, val);
val = 0;
val = enumCheck(cpp11_strongly_typed_enumerations.Enum7td_Val1, val);
val = enumCheck(cpp11_strongly_typed_enumerations.Enum7td_Val2, val);
val = enumCheck(cpp11_strongly_typed_enumerations.Enum7td_Val3, 73);
val = enumCheck(cpp11_strongly_typed_enumerations.Enum7td_Val4, val);
val = 0;
val = enumCheck(cpp11_strongly_typed_enumerations.Enum8_Val1, val);
val = enumCheck(cpp11_strongly_typed_enumerations.Enum8_Val2, val);
val = enumCheck(cpp11_strongly_typed_enumerations.Enum8_Val3, 83);
val = enumCheck(cpp11_strongly_typed_enumerations.Enum8_Val4, val);
val = 0;
val = enumCheck(cpp11_strongly_typed_enumerations.Enum10_Val1, val);
val = enumCheck(cpp11_strongly_typed_enumerations.Enum10_Val2, val);
val = enumCheck(cpp11_strongly_typed_enumerations.Enum10_Val3, 103);
val = enumCheck(cpp11_strongly_typed_enumerations.Enum10_Val4, val);
val = 0;
val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Enum12_Val1, 1121);
val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Enum12_Val2, 1122);
val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Enum12_Val3, val);
val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Enum12_Val4, val);
val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Enum12_Val5c, 1121);
val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Enum12_Val6c, val);
val = 0;
val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Val1, 1131);
val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Val2, 1132);
val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Val3, val);
val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Val4, val);
val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Val5d, 1131);
val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Val6d, val);
val = 0;
val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Enum14_Val1, 1141);
val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Enum14_Val2, 1142);
val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Enum14_Val3, val);
val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Enum14_Val4, val);
val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Enum14_Val5e, 1141);
val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Enum14_Val6e, val);
# Requires nested class support to work
#val = 0;
#val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Struct1.Enum12_Val1, 3121);
#val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Struct1.Enum12_Val2, 3122);
#val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Struct1.Enum12_Val3, val);
#val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Struct1.Enum12_Val4, val);
#val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Struct1.Enum12_Val5f, 3121);
#val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Struct1.Enum12_Val6f, val);
#
#val = 0;
#val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Struct1.Val1, 3131);
#val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Struct1.Val2, 3132);
#val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Struct1.Val3, val);
#val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Struct1.Val4, val);
#
#val = 0;
#val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Struct1.Enum14_Val1, 3141);
#val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Struct1.Enum14_Val2, 3142);
#val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Struct1.Enum14_Val3, val);
#val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Struct1.Enum14_Val4, val);
#val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Struct1.Enum14_Val5g, 3141);
#val = enumCheck(cpp11_strongly_typed_enumerations.Class1_Struct1.Enum14_Val6g, val);
val = 0;
val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Enum12_Val1, 2121);
val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Enum12_Val2, 2122);
val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Enum12_Val3, val);
val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Enum12_Val4, val);
val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Enum12_Val5h, 2121);
val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Enum12_Val6h, val);
val = 0;
val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Val1, 2131);
val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Val2, 2132);
val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Val3, val);
val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Val4, val);
val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Val5i, 2131);
val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Val6i, val);
val = 0;
val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Enum14_Val1, 2141);
val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Enum14_Val2, 2142);
val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Enum14_Val3, val);
val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Enum14_Val4, val);
val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Enum14_Val5j, 2141);
val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Enum14_Val6j, val);
# Requires nested class support to work
#val = 0;
#val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Struct1_Enum12_Val1, 4121);
#val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Struct1_Enum12_Val2, 4122);
#val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Struct1_Enum12_Val3, val);
#val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Struct1_Enum12_Val4, val);
#val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Struct1_Enum12_Val5k, 4121);
#val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Struct1_Enum12_Val6k, val);
#
#val = 0;
#val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Struct1_Val1, 4131);
#val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Struct1_Val2, 4132);
#val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Struct1_Val3, val);
#val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Struct1_Val4, val);
#val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Struct1_Val5l, 4131);
#val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Struct1_Val6l, val);
#
#val = 0;
#val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Struct1_Enum14_Val1, 4141);
#val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Struct1_Enum14_Val2, 4142);
#val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Struct1_Enum14_Val3, val);
#val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Struct1_Enum14_Val4, val);
#val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Struct1_Enum14_Val5m, 4141);
#val = enumCheck(cpp11_strongly_typed_enumerations.Class2_Struct1_Enum14_Val6m, val);
class1 = Class1();
enumCheck(class1.class1Test1(cpp11_strongly_typed_enumerations.Enum1_Val5a), 13);
enumCheck(class1.class1Test2(cpp11_strongly_typed_enumerations.Class1_Enum12_Val5c), 1121);
#enumCheck(class1.class1Test3(cpp11_strongly_typed_enumerations.Class1_Struct1_Enum12_Val5f), 3121);
enumCheck(cpp11_strongly_typed_enumerations.globalTest1(cpp11_strongly_typed_enumerations.Enum1_Val5a), 13);
enumCheck(cpp11_strongly_typed_enumerations.globalTest2(cpp11_strongly_typed_enumerations.Class1_Enum12_Val5c), 1121);
#enumCheck(globalTest3(cpp11_strongly_typed_enumerations.Class1_Struct1_Enum12_Val5f), 3121);

View File

@@ -0,0 +1,27 @@
cpp_enum
f = cpp_enum.Foo();
if (f.hola != cpp_enum.Foo_Hello)
error(f.hola);
error;
endif
f.hola = cpp_enum.Foo_Hi;
if (f.hola != cpp_enum.Foo_Hi)
error(f.hola);
error;
endif
f.hola = cpp_enum.Foo_Hello;
if (f.hola != cpp_enum.Foo_Hello)
error(f.hola);
error;
endif
cpp_enum.hi = cpp_enum.Hello;
if (cpp_enum.hi != cpp_enum.Hello)
error(cpp_enum.hi);
error;
endif

View File

@@ -0,0 +1,55 @@
# Note: This example assumes that namespaces are flattened
cpp_namespace
n = cpp_namespace.fact(4);
if (n != 24)
error("Bad return value!")
endif
if (cpp_namespace.cvar.Foo != 42)
error("Bad variable value!")
endif
t = cpp_namespace.Test();
if (!strcmp(t.method(),"Test::method"))
error("Bad method return value!")
endif
if (!strcmp(cpp_namespace.do_method(t),"Test::method"))
error("Bad return value!")
endif
if (!strcmp(cpp_namespace.do_method2(t),"Test::method"))
error("Bad return value!")
endif
cpp_namespace.weird("hello", 4);
clear t;
t2 = cpp_namespace.Test2();
t3 = cpp_namespace.Test3();
t4 = cpp_namespace.Test4();
t5 = cpp_namespace.Test5();
if (cpp_namespace.foo3(42) != 42)
error("Bad return value!")
endif
if (!strcmp(cpp_namespace.do_method3(t2,40),"Test2::method"))
error("Bad return value!")
endif
if (!strcmp(cpp_namespace.do_method3(t3,40),"Test3::method"))
error("Bad return value!")
endif
if (!strcmp(cpp_namespace.do_method3(t4,40),"Test4::method"))
error("Bad return value!")
endif
if (!strcmp(cpp_namespace.do_method3(t5,40),"Test5::method"))
error("Bad return value!")
endif

View File

@@ -0,0 +1,91 @@
# do not dump Octave core
if exist("crash_dumps_octave_core", "builtin")
crash_dumps_octave_core(0);
endif
default_args
if (default_args.Statics.staticmethod() != 60)
error
endif
if (default_args.cfunc1(1) != 2)
error
endif
if (default_args.cfunc2(1) != 3)
error
endif
if (default_args.cfunc3(1) != 4)
error
endif
f = default_args.Foo();
f.newname();
f.newname(1);
try
f = default_args.Foo(1);
ok = 1;
catch
ok = 0;
end_try_catch
if (ok)
error("Foo::Foo ignore is not working")
endif
try
f = default_args.Foo(1,2);
ok = 1;
catch
ok = 0;
end_try_catch
if (ok)
error("Foo::Foo ignore is not working")
endif
try
f = default_args.Foo(1,2,3);
ok = 1;
catch
ok = 0;
end_try_catch
if (ok)
error("Foo::Foo ignore is not working")
endif
try
m = f.meth(1);
ok = 1;
catch
ok = 0;
end_try_catch
if (ok)
error("Foo::meth ignore is not working")
endif
try
m = f.meth(1,2);
ok = 1;
catch
ok = 0;
end_try_catch
if (ok)
error("Foo::meth ignore is not working")
endif
try
m = f.meth(1,2,3);
ok = 1;
catch
ok = 0;
end_try_catch
if (ok)
error("Foo::meth ignore is not working")
endif

View File

@@ -0,0 +1,93 @@
# do not dump Octave core
if exist("crash_dumps_octave_core", "builtin")
crash_dumps_octave_core(0);
endif
default_constructor
dc = default_constructor;
a = dc.new_A();
dc.delete_A(a);
aa = dc.new_AA();
dc.delete_AA(aa);
try
b = dc.new_B();
error("Whoa. new_BB created.")
catch
end_try_catch
try
bb = dc.new_BB();
error("Whoa. new_BB created.")
catch
end_try_catch
try
c = dc.new_C();
error("Whoa. new_C created.")
catch
end_try_catch
cc = dc.new_CC();
dc.delete_CC(cc);
try
d = dc.new_D();
error("Whoa. new_D created")
catch
end_try_catch
try
dd = dc.new_DD();
error("Whoa. new_DD created")
catch
end_try_catch
try
ad = dc.new_AD();
error("Whoa. new_AD created")
catch
end_try_catch
e = dc.new_E();
dc.delete_E(e);
ee = dc.new_EE();
dc.delete_EE(ee);
try
eb = dc.new_EB();
error("Whoa. new_EB created")
catch
end_try_catch
f = dc.new_F();
try
del_f = dc.delete_F(f);
error("Whoa. delete_F created")
catch
end_try_catch
dc.F_destroy(f);
g = dc.new_G();
try
del_g = dc.delete_G(g);
error("Whoa. delete_G created")
catch
end_try_catch
dc.G_destroy(g);
gg = dc.new_GG();
dc.delete_GG(gg);
hh = default_constructor.HH(1,1);

View File

@@ -0,0 +1,49 @@
# do not dump Octave core
if exist("crash_dumps_octave_core", "builtin")
crash_dumps_octave_core(0);
endif
director_abstract
MyFoo=@() subclass(director_abstract.Foo(),@ping);
function out=ping(self)
out="MyFoo::ping()";
end
a = MyFoo();
if (!strcmp(a.ping(),"MyFoo::ping()"))
error(a.ping())
endif
if (!strcmp(a.pong(),"Foo::pong();MyFoo::ping()"))
error(a.pong())
endif
MyExample1=@() subclass(director_abstract.Example1(),'Color',@(self,r,g,b) r);
MyExample2=@(a,b) subclass(director_abstract.Example2(a,b),'Color',@(self,r,g,b) g);
MyExample3=@() subclass(director_abstract.Example3_i(),'Color',@(self,r,g,b) b);
me1 = MyExample1();
if (director_abstract.Example1.get_color(me1, 1,2,3) != 1)
error
endif
me2 = MyExample2(1,2);
if (me2.get_color(me2, 1,2,3) != 2)
error
endif
me3 = MyExample3();
if (me3.get_color(me3, 1,2,3) != 3)
error
endif
# don't check that we cannot construct abstract bases, since we have no
# way of disambiguating that with the normal construction case using
# subclass. furthermore, calling a pure virtual method will still generate
# an error.

View File

@@ -0,0 +1,110 @@
director_basic
function self=OctFoo()
global director_basic;
self=subclass(director_basic.Foo());
self.ping=@OctFoo_ping;
end
function string=OctFoo_ping(self)
string="OctFoo::ping()";
end
a = OctFoo();
if (!strcmp(a.ping(),"OctFoo::ping()"))
error(a.ping())
endif
if (!strcmp(a.pong(),"Foo::pong();OctFoo::ping()"))
error(a.pong())
endif
b = director_basic.Foo();
if (!strcmp(b.ping(),"Foo::ping()"))
error(b.ping())
endif
if (!strcmp(b.pong(),"Foo::pong();Foo::ping()"))
error(b.pong())
endif
a = director_basic.A1(1);
if (a.rg(2) != 2)
error
endif
function self=OctClass()
global director_basic;
self=subclass(director_basic.MyClass());
self.method=@OctClass_method;
self.vmethod=@OctClass_vmethod;
end
function OctClass_method(self,vptr)
self.cmethod = 7;
end
function out=OctClass_vmethod(self,b)
b.x = b.x + 31;
out=b;
end
b = director_basic.Bar(3);
d = director_basic.MyClass();
c = OctClass();
cc = director_basic.MyClass_get_self(c);
dd = director_basic.MyClass_get_self(d);
bc = cc.cmethod(b);
bd = dd.cmethod(b);
cc.method(b);
if (c.cmethod != 7)
error
endif
if (bc.x != 34)
error
endif
if (bd.x != 16)
error
endif
function self=OctMulti()
global director_basic;
self=subclass(director_basic.Foo(),director_basic.MyClass());
self.vmethod=@OctMulti_vmethod;
self.ping=@OctMulti_ping;
end
function out=OctMulti_vmethod(self,b)
b.x = b.x + 31;
out=b;
end
function out=OctMulti_ping(self)
out="OctFoo::ping()";
end
a = 0;
for i=0:100,
octmult = OctMulti();
octmult.pong();
clear octmult
endfor
octmult = OctMulti();
p1 = director_basic.Foo_get_self(octmult);
p2 = director_basic.MyClass_get_self(octmult);
p1.ping();
p2.vmethod(bc);

View File

@@ -0,0 +1,103 @@
# do not dump Octave core
if exist("crash_dumps_octave_core", "builtin")
crash_dumps_octave_core(0);
endif
director_classic
TargetLangPerson=@() subclass(Person(),'id',@(self) "TargetLangPerson");
TargetLangChild=@() subclass(Child(),'id',@(self) "TargetLangChild");
TargetLangGrandChild=@() subclass(GrandChild(),'id',@(self) "TargetLangGrandChild");
# Semis - don't override id() in target language
TargetLangSemiPerson=@() subclass(Person());
TargetLangSemiChild=@() subclass(Child());
TargetLangSemiGrandChild=@() subclass(GrandChild());
# Orphans - don't override id() in C++
TargetLangOrphanPerson=@() subclass(OrphanPerson(),'id',@(self) "TargetLangOrphanPerson");
TargetLangOrphanChild=@() subclass(OrphanChild(),'id',@(self) "TargetLangOrphanChild");
function check(person,expected)
global Caller;
# Normal target language polymorphic call
ret = person.id();
if (ret != expected)
raise ("Failed. Received: " + ret + " Expected: " + expected);
endif
# Polymorphic call from C++
caller = Caller();
caller.setCallback(person);
ret = caller.call();
if (ret != expected)
error ("Failed. Received: " + ret + " Expected: " + expected);
endif
# Polymorphic call of object created in target language and passed to C++ and back again
baseclass = caller.baseClass();
ret = baseclass.id();
if (ret != expected)
error ("Failed. Received: " + ret + " Expected: " + expected);
endif
caller.resetCallback();
end
person = Person();
check(person, "Person");
clear person;
person = Child();
check(person, "Child");
clear person;
person = GrandChild();
check(person, "GrandChild");
clear person;
person = TargetLangPerson();
check(person, "TargetLangPerson");
clear person;
person = TargetLangChild();
check(person, "TargetLangChild");
clear person;
person = TargetLangGrandChild();
check(person, "TargetLangGrandChild");
clear person;
# Semis - don't override id() in target language
person = TargetLangSemiPerson();
check(person, "Person");
clear person;
person = TargetLangSemiChild();
check(person, "Child");
clear person;
person = TargetLangSemiGrandChild();
check(person, "GrandChild");
clear person;
# Orphans - don't override id() in C++
person = OrphanPerson();
check(person, "Person");
clear person;
person = OrphanChild();
check(person, "Child");
clear person;
person = TargetLangOrphanPerson();
check(person, "TargetLangOrphanPerson");
clear person;
person = TargetLangOrphanChild();
check(person, "TargetLangOrphanChild");
clear person;

View File

@@ -0,0 +1,10 @@
director_default
f = Foo();
f = Foo(1);
f = Bar();
f = Bar(1);

View File

@@ -0,0 +1,36 @@
director_detect
global MyBar=@(val=2) subclass(director_detect.Bar(),'val',val,@get_value,@get_class,@just_do_it,@clone);
function val=get_value(self)
self.val = self.val + 1;
val = self.val;
end
function ptr=get_class(self)
global director_detect;
self.val = self.val + 1;
ptr=director_detect.A();
end
function just_do_it(self)
self.val = self.val + 1;
end
function ptr=clone(self)
global MyBar;
ptr=MyBar(self.val);
end
b = MyBar();
f = b.baseclass();
v = f.get_value();
a = f.get_class();
f.just_do_it();
c = b.clone();
vc = c.get_value();
if ((v != 3) || (b.val != 5) || (vc != 6))
error("Bad virtual detection")
endif

View File

@@ -0,0 +1,10 @@
director_enum
MyFoo=@() subclass(director_enum.Foo(),'say_hi',@(self,val) val);
b = director_enum.Foo();
a = MyFoo();
if (a.say_hi(director_enum.hello) != b.say_hello(director_enum.hi))
error
endif

View File

@@ -0,0 +1,17 @@
# do not dump Octave core
if exist("crash_dumps_octave_core", "builtin")
crash_dumps_octave_core(0);
endif
director_extend
MyObject=@() subclass(SpObject(),'getFoo',@(self) 123);
m = MyObject();
if (m.dummy() != 666)
error("1st call")
endif
if (m.dummy() != 666)
error("2nd call")
endif

View File

@@ -0,0 +1,9 @@
director_frob
foo = Bravo();
s = foo.abs_method();
if (!strcmp(s,"Bravo::abs_method()"))
error(s)
endif

View File

@@ -0,0 +1,39 @@
director_nested
A=@() subclass(FooBar_int(),
'do_step',@(self) "A::do_step;",
'get_value',@(self) "A::get_value");
a = A();
if (!strcmp(a.step(),"Bar::step;Foo::advance;Bar::do_advance;A::do_step;"))
error("Bad A virtual resolution")
endif
B=@() subclass(FooBar_int(),
'do_advance',@(self) strcat("B::do_advance;",self.do_step()),
'do_step',@(self) "B::do_step;",
'get_value',@(self) 1);
b = B();
if (!strcmp(b.step(),"Bar::step;Foo::advance;B::do_advance;B::do_step;"))
error("Bad B virtual resolution")
endif
C=@() subclass(FooBar_int(),
'do_advance',@(self) strcat("C::do_advance;",self.FooBar_int.do_advance()),
'do_step',@(self) "C::do_step;",
'get_value',@(self) 2,
'get_name',@(self) strcat(self.FooBar_int.get_name()," hello"));
cc = C();
c = FooBar_int_get_self(cc);
c.advance();
if (!strcmp(c.get_name(),"FooBar::get_name hello"))
error
endif
if (!strcmp(c.name(),"FooBar::get_name hello"))
error
endif

View File

@@ -0,0 +1,36 @@
# do not dump Octave core
if exist("crash_dumps_octave_core", "builtin")
crash_dumps_octave_core(0);
endif
director_stl
MyFoo=@() subclass(director_stl.Foo(),\
'ping',@(self,s) "MyFoo::ping():" + s,\
'pident',@(self,arg) arg,\
'vident',@(self,v) v,\
'vidents',@(self,v) v,\
'vsecond',@(self,v1,v2) v2,\
);
a = MyFoo();
a.tping("hello");
a.tpong("hello");
p = {1,2}
a.pident(p);
v = {3,4}
a.vident(v);
a.tpident(p);
a.tvident(v);
v1 = {3,4};
v2 = {5,6};
a.tvsecond(v1,v2);
vs=("hi", "hello");
vs;
a.tvidents(vs);

View File

@@ -0,0 +1,32 @@
# do not dump Octave core
if exist("crash_dumps_octave_core", "builtin")
crash_dumps_octave_core(0);
endif
director_string
function out=get_first(self)
out = strcat(self.A.get_first()," world!");
end
function process_text(self,string)
self.A.process_text(string);
self.smem = "hello";
end
B=@(string) subclass(A(string),'get_first',@get_first,'process_text',@process_text);
b = B("hello");
b.get(0);
if (!strcmp(b.get_first(),"hello world!"))
error(b.get_first())
endif
b.call_process_func();
if (!strcmp(b.smem,"hello"))
error(b.smem)
endif

View File

@@ -0,0 +1,16 @@
director_unroll
MyFoo=@() subclass(director_unroll.Foo(),'ping',@(self) "MyFoo::ping()");
a = MyFoo();
b = director_unroll.Bar();
b.set(a);
c = b.get();
if (swig_this(a) != swig_this(c))
a,c
error
endif

View File

@@ -0,0 +1,26 @@
# do not dump Octave core
if exist("crash_dumps_octave_core", "builtin")
crash_dumps_octave_core(0);
endif
director_wstring
B=@(string) subclass(A(string),\
'get_first',A.get_first(self) + " world!",\
'process_text',@(self) self.smem = u"hello"\
);
b = B("hello");
b.get(0);
if (!strcmp(b.get_first(),"hello world!"))
error(b.get_first())
endif
b.call_process_func();
if (!strcmp(b.smem,"hello"))
error(smem)
endif

View File

@@ -0,0 +1,19 @@
# do not dump Octave core
if exist("crash_dumps_octave_core", "builtin")
crash_dumps_octave_core(0);
endif
dynamic_cast
f = dynamic_cast.Foo();
b = dynamic_cast.Bar();
x = f.blah();
y = b.blah();
a = dynamic_cast.do_test(y);
if (!strcmp(a,"Bar::test"))
error("Failed!!")
endif

View File

@@ -0,0 +1,7 @@
# do not dump Octave core
if exist("crash_dumps_octave_core", "builtin")
crash_dumps_octave_core(0);
endif
empty_c

View File

@@ -0,0 +1,7 @@
# do not dump Octave core
if exist("crash_dumps_octave_core", "builtin")
crash_dumps_octave_core(0);
endif
empty

View File

@@ -0,0 +1,18 @@
# do not dump Octave core
if exist("crash_dumps_octave_core", "builtin")
crash_dumps_octave_core(0);
endif
enum_template
if (enum_template.MakeETest() != 1)
error
endif
enum_template.TakeETest(0);
try
a=enum_template.TakeETest(0);
error
catch
end_try_catch

View File

@@ -0,0 +1,23 @@
enums
enums.bar2(1)
enums.bar3(1)
enums.bar1(1)
if (enums.cvar.enumInstance != 2)
error
endif
if (enums.cvar.Slap != 10)
error
endif
if (enums.cvar.Mine != 11)
error
endif
if (enums.cvar.Thigh != 12)
error
endif

View File

@@ -0,0 +1,47 @@
# do not dump Octave core
if exist("crash_dumps_octave_core", "builtin")
crash_dumps_octave_core(0);
endif
exception_order
function check_lasterror(expected)
if (!strcmp(lasterror.message, expected))
# Take account of older versions prefixing with "error: " and adding a newline at the end
if (!strcmp(regexprep(lasterror.message, 'error: (.*)\n$', '$1'), expected))
error(["Bad exception order. Expected: \"", expected, "\" Got: \"", lasterror.message, "\""])
endif
endif
endfunction
a = A();
try
a.foo()
catch
check_lasterror("C++ side threw an exception of type E1")
end_try_catch
try
a.bar()
catch
check_lasterror("C++ side threw an exception of type E2")
end_try_catch
try
a.foobar()
catch
check_lasterror("postcatch unknown (SWIG_RuntimeError)")
end_try_catch
try
a.barfoo(1)
catch
check_lasterror("C++ side threw an exception of type E1")
end_try_catch
try
a.barfoo(2)
catch
check_lasterror("C++ side threw an exception of type E2 *")
end_try_catch

View File

@@ -0,0 +1,46 @@
extend_placement
foo = extend_placement.Foo();
foo = extend_placement.Foo(1);
foo = extend_placement.Foo(1,1);
foo.spam();
foo.spam("hello");
foo.spam(1);
foo.spam(1,1);
foo.spam(1,1,1);
foo.spam(extend_placement.Foo());
foo.spam(extend_placement.Foo(), 1.0);
bar = extend_placement.Bar();
bar = extend_placement.Bar(1);
bar.spam();
bar.spam("hello");
bar.spam(1);
bar.spam(1,1);
bar.spam(1,1,1);
bar.spam(extend_placement.Bar());
bar.spam(extend_placement.Bar(), 1.0);
foo = extend_placement.FooTi();
foo = extend_placement.FooTi(1);
foo = extend_placement.FooTi(1,1);
foo.spam();
foo.spam("hello");
foo.spam(1);
foo.spam(1,1);
foo.spam(1,1,1);
foo.spam(extend_placement.Foo());
foo.spam(extend_placement.Foo(), 1.0);
bar = extend_placement.BarTi();
bar = extend_placement.BarTi(1);
bar.spam();
bar.spam("hello");
bar.spam(1);
bar.spam(1,1);
bar.spam(1,1,1);
bar.spam(extend_placement.Bar());
bar.spam(extend_placement.Bar(), 1.0);

View File

@@ -0,0 +1,15 @@
# do not dump Octave core
if exist("crash_dumps_octave_core", "builtin")
crash_dumps_octave_core(0);
endif
extend_template_ns
f = Foo_One();
if (f.test1(37) != 37)
error
endif
if (f.test2(42) != 42)
error
endif

View File

@@ -0,0 +1,10 @@
extend_template
f = extend_template.Foo_0();
if (f.test1(37) != 37)
error
endif
if (f.test2(42) != 42)
error
endif

View File

@@ -0,0 +1,6 @@
extend_variable
if (Foo.Bar != 42)
error
endif

View File

@@ -0,0 +1,9 @@
file_test
file_test.nfile("stdout");
cstdout = file_test.GetStdOut();
file_test.nfile(cstdout);
file_test.nfile_name("test.dat");

View File

@@ -0,0 +1,51 @@
# do not dump Octave core
if exist("crash_dumps_octave_core", "builtin")
crash_dumps_octave_core(0);
endif
friends
a = friends.A(2);
if (friends.get_val1(a) != 2)
error
endif
if (friends.get_val2(a) != 4)
error
endif
if (friends.get_val3(a) != 6)
error
endif
# nice overload working fine
if (friends.get_val1(1,2,3) != 1)
error
endif
b = friends.B(3);
# David's case
if (friends.mix(a,b) != 5)
error
endif
di = friends.D_d(2);
dd = friends.D_d(3.3);
# incredible template overloading working just fine
if (friends.get_val1(di) != 2)
error
endif
if (friends.get_val1(dd) != 3.3)
error
endif
friends.set(di, 4);
friends.set(dd, 1.3);
if (friends.get_val1(di) != 4)
error
endif
if (friends.get_val1(dd) != 1.3)
error
endif

View File

@@ -0,0 +1,10 @@
fvirtual
sw = NodeSwitch();
n = Node();
i = sw.addChild(n);
if (i != 2)
error("addChild")
endif

View File

@@ -0,0 +1,10 @@
# do not dump Octave core
if exist("crash_dumps_octave_core", "builtin")
crash_dumps_octave_core(0);
endif
global_ns_arg
a = foo(1);
b = bar_fn();

View File

@@ -0,0 +1,20 @@
# do not dump Octave core
if exist("crash_dumps_octave_core", "builtin")
crash_dumps_octave_core(0);
endif
grouping
x = grouping.test1(42);
if (x != 42)
error
endif
grouping.test2(42);
x = (grouping.do_unary(37, grouping.NEGATE));
if (x != -37)
error
endif
grouping.cvar.test3 = 42;

View File

@@ -0,0 +1,10 @@
iadd
f = iadd.Foo();
f.AsA.x = 3;
f.AsA += f.AsA;
if (f.AsA.x != 6)
error
endif

View File

@@ -0,0 +1,8 @@
import_nomodule
f = create_Foo();
test1(f,42);
delete_Foo(f);
b = Bar();
test1(b,37);

View File

@@ -0,0 +1,22 @@
# This is the import runtime testcase.
# Workaround seg fault occurring during interpreter cleanup/exit in version 3.1 and 3.2, seems okay in 3.6
if (compare_versions(version(), "3.3", ">="))
imports_b;
imports_a;
x = imports_b.B();
x.hello();
a = imports_a.A();
c = imports_b.C();
a1 = c.get_a(c);
a2 = c.get_a_type(c);
a1.hello();
a2.hello();
assert(swig_this(a1)==swig_this(a2));
assert(strcmp(swig_type(a1),swig_type(a2)));
endif

View File

@@ -0,0 +1,24 @@
inctest
try
a = inctest.A();
catch
error("didn't find A\ntherefore, I didn't include \
'testdir/subdir1/hello.i'")
end_try_catch
try
b = inctest.B();
catch
error("didn't find B\ntherefore, I didn't include 'testdir/subdir2/hello.i'")
end_try_catch
# Check the import in subdirectory worked
if (inctest.importtest1(5) != 15)
error("import test 1 failed")
endif
if (!strcmp(inctest.importtest2("black"),"white"))
error("import test 2 failed")
endif

View File

@@ -0,0 +1,22 @@
inherit_missing
a = inherit_missing.new_Foo();
b = inherit_missing.Bar();
c = inherit_missing.Spam();
x = inherit_missing.do_blah(a);
if (!strcmp(x, "Foo::blah"))
error("Whoa! Bad return %s", x)
endif
x = inherit_missing.do_blah(b);
if (!strcmp(x, "Bar::blah"))
error("Whoa! Bad return %s", x)
endif
x = inherit_missing.do_blah(c);
if (!strcmp(x, "Spam::blah"))
error("Whoa! Bad return %s", x)
endif
inherit_missing.delete_Foo(a);

View File

@@ -0,0 +1,27 @@
inout
a = inout.AddOne1(1);
if (a != 2)
error
endif
a = inout.AddOne3(1,1,1);
if (a != [2,2,2])
error
endif
a = inout.AddOne1p((1,1));
if (a != (2,2))
error
endif
a = inout.AddOne2p((1,1),1);
if (a != [(2,2),2])
error
endif
a = inout.AddOne3p(1,(1,1),1);
if (a != [2,(2,2),2])
error
endif

View File

@@ -0,0 +1,24 @@
inplaceadd
a = inplaceadd.A(7);
a += 5;
if (a.val != 12)
error
endif
a -= 5;
if a.val != 7:
error
endif
a *= 2;
if (a.val != 14)
error
endif
a += a;
if (a.val != 28)
error
endif

View File

@@ -0,0 +1,27 @@
# do not dump Octave core
if exist("crash_dumps_octave_core", "builtin")
crash_dumps_octave_core(0);
endif
input
f = Foo();
if (f.foo(2) != 4)
error
endif
try
a=f.foo();
error
catch
end_try_catch
if (!strcmp(sfoo("Hello"),"Hello world"))
error
endif
try
a=sfoo();
error
catch
end_try_catch

View File

@@ -0,0 +1,90 @@
# do not dump Octave core
if exist("crash_dumps_octave_core", "builtin")
crash_dumps_octave_core(0);
endif
li_attribute
aa = li_attribute.A(1,2,3);
if (aa.a != 1)
error
endif
aa.a = 3;
if (aa.a != 3)
error("aa.a = %i",aa.a)
endif
if (aa.b != 2)
error(aa.b)
endif
aa.b = 5;
if (aa.b != 5)
error
endif
if (aa.d != aa.b)
error
endif
if (aa.c != 3)
error
endif
pi = li_attribute.Param_i(7);
if (pi.value != 7)
error
endif
pi.value=3;
if (pi.value != 3)
error
endif
b = li_attribute.B(aa);
if (b.a.c != 3)
error
endif
# class/struct attribute with get/set methods using return/pass by reference
myFoo = li_attribute.MyFoo();
myFoo.x = 8;
myClass = li_attribute.MyClass();
myClass.Foo = myFoo;
if (myClass.Foo.x != 8)
error
endif
# class/struct attribute with get/set methods using return/pass by value
myClassVal = li_attribute.MyClassVal();
if (myClassVal.ReadWriteFoo.x != -1)
error
endif
if (myClassVal.ReadOnlyFoo.x != -1)
error
endif
myClassVal.ReadWriteFoo = myFoo;
if (myClassVal.ReadWriteFoo.x != 8)
error
endif
if (myClassVal.ReadOnlyFoo.x != 8)
error
endif
# string attribute with get/set methods using return/pass by value
myStringyClass = li_attribute.MyStringyClass("initial string");
if (myStringyClass.ReadWriteString != "initial string")
error
endif
if (myStringyClass.ReadOnlyString != "initial string")
error
endif
myStringyClass.ReadWriteString = "changed string";
if (myStringyClass.ReadWriteString != "changed string")
error
endif
if (myStringyClass.ReadOnlyString != "changed string")
error
endif

View File

@@ -0,0 +1,570 @@
# do not dump Octave core
if exist("crash_dumps_octave_core", "builtin")
crash_dumps_octave_core(0);
endif
1;
li_boost_shared_ptr;
function verifyValue(expected, got)
if (expected ~= got)
error("verify value failed.");% Expected: ", expected, " Got: ", got)
end
endfunction
function verifyCount(expected, k)
got = use_count(k);
if (expected ~= got)
error("verify use_count failed. Expected: %d Got: %d ", expected, got);
end
endfunction
function runtest()
li_boost_shared_ptr; # KTTODO this needs to be here at present. Global module failure?
# simple shared_ptr usage - created in C++
k = Klass("me oh my");
val = k.getValue();
verifyValue("me oh my", val)
verifyCount(1, k)
# simple shared_ptr usage - not created in C++
k = factorycreate();
val = k.getValue();
verifyValue("factorycreate", val)
verifyCount(1, k)
# pass by shared_ptr
k = Klass("me oh my");
kret = smartpointertest(k);
val = kret.getValue();
verifyValue("me oh my smartpointertest", val)
verifyCount(2, k)
verifyCount(2, kret)
# pass by shared_ptr pointer
k = Klass("me oh my");
kret = smartpointerpointertest(k);
val = kret.getValue();
verifyValue("me oh my smartpointerpointertest", val)
verifyCount(2, k)
verifyCount(2, kret)
# pass by shared_ptr reference
k = Klass("me oh my");
kret = smartpointerreftest(k);
val = kret.getValue();
verifyValue("me oh my smartpointerreftest", val)
verifyCount(2, k)
verifyCount(2, kret)
# pass by shared_ptr pointer reference
k = Klass("me oh my");
kret = smartpointerpointerreftest(k);
val = kret.getValue();
verifyValue("me oh my smartpointerpointerreftest", val)
verifyCount(2, k)
verifyCount(2, kret)
# const pass by shared_ptr
k = Klass("me oh my");
kret = constsmartpointertest(k);
val = kret.getValue();
verifyValue("me oh my", val)
verifyCount(2, k)
verifyCount(2, kret)
# const pass by shared_ptr pointer
k = Klass("me oh my");
kret = constsmartpointerpointertest(k);
val = kret.getValue();
verifyValue("me oh my", val)
verifyCount(2, k)
verifyCount(2, kret)
# const pass by shared_ptr reference
k = Klass("me oh my");
kret = constsmartpointerreftest(k);
val = kret.getValue();
verifyValue("me oh my", val)
verifyCount(2, k)
verifyCount(2, kret)
# pass by value
k = Klass("me oh my");
kret = valuetest(k);
val = kret.getValue();
verifyValue("me oh my valuetest", val)
verifyCount(1, k)
verifyCount(1, kret)
# pass by pointer
k = Klass("me oh my");
kret = pointertest(k);
val = kret.getValue();
verifyValue("me oh my pointertest", val)
verifyCount(1, k)
verifyCount(1, kret)
# pass by reference
k = Klass("me oh my");
kret = reftest(k);
val = kret.getValue();
verifyValue("me oh my reftest", val)
verifyCount(1, k)
verifyCount(1, kret)
# pass by pointer reference
k = Klass("me oh my");
kret = pointerreftest(k);
val = kret.getValue();
verifyValue("me oh my pointerreftest", val)
verifyCount(1, k)
verifyCount(1, kret)
# null tests
#KTODO None not defined
# k = None;
# if (smartpointertest(k) ~= None)
# error("return was not null")
# end
# if (smartpointerpointertest(k) ~= None)
# error("return was not null")
# end
# if (smartpointerreftest(k) ~= None)
# error("return was not null")
# end
# if (smartpointerpointerreftest(k) ~= None)
# error("return was not null")
# end
# if (nullsmartpointerpointertest(None) ~= "null pointer")
# error("not null smartpointer pointer")
# end
# # try:
# # valuetest(k)
# # error("Failed to catch null pointer")
# # except ValueError:
# # pass
# if (pointertest(k) ~= None)
# error("return was not null")
# end
# # try:
# # reftest(k)
# # error("Failed to catch null pointer")
# # except ValueError:
# # pass
# $owner
k = pointerownertest();
val = k.getValue();
verifyValue("pointerownertest", val)
verifyCount(1, k)
k = smartpointerpointerownertest();
val = k.getValue();
verifyValue("smartpointerpointerownertest", val)
verifyCount(1, k)
# //////////////////////////////// Derived class ////////////////////////////////////////
# derived pass by shared_ptr
k = KlassDerived("me oh my");
kret = derivedsmartptrtest(k);
val = kret.getValue();
verifyValue("me oh my derivedsmartptrtest-Derived", val)
verifyCount(2, k)
verifyCount(2, kret)
# derived pass by shared_ptr pointer
k = KlassDerived("me oh my");
kret = derivedsmartptrpointertest(k);
val = kret.getValue();
verifyValue("me oh my derivedsmartptrpointertest-Derived", val)
verifyCount(2, k)
verifyCount(2, kret)
# derived pass by shared_ptr ref
k = KlassDerived("me oh my");
kret = derivedsmartptrreftest(k);
val = kret.getValue();
verifyValue("me oh my derivedsmartptrreftest-Derived", val)
verifyCount(2, k)
verifyCount(2, kret)
# derived pass by shared_ptr pointer ref
k = KlassDerived("me oh my");
kret = derivedsmartptrpointerreftest(k);
val = kret.getValue();
verifyValue("me oh my derivedsmartptrpointerreftest-Derived", val)
verifyCount(2, k)
verifyCount(2, kret)
# derived pass by pointer
k = KlassDerived("me oh my");
kret = derivedpointertest(k);
val = kret.getValue();
verifyValue("me oh my derivedpointertest-Derived", val)
verifyCount(1, k)
verifyCount(1, kret)
# derived pass by ref
k = KlassDerived("me oh my");
kret = derivedreftest(k);
val = kret.getValue();
verifyValue("me oh my derivedreftest-Derived", val)
verifyCount(1, k)
verifyCount(1, kret)
# //////////////////////////////// Derived and base class mixed ////////////////////////////////////////
# pass by shared_ptr (mixed)
k = KlassDerived("me oh my");
kret = smartpointertest(k);
val = kret.getValue();
verifyValue("me oh my smartpointertest-Derived", val)
verifyCount(2, k)
verifyCount(2, kret)
# pass by shared_ptr pointer (mixed)
k = KlassDerived("me oh my");
kret = smartpointerpointertest(k);
val = kret.getValue();
verifyValue("me oh my smartpointerpointertest-Derived", val)
verifyCount(2, k)
verifyCount(2, kret)
# pass by shared_ptr reference (mixed)
k = KlassDerived("me oh my");
kret = smartpointerreftest(k);
val = kret.getValue();
verifyValue("me oh my smartpointerreftest-Derived", val)
verifyCount(2, k)
verifyCount(2, kret)
# pass by shared_ptr pointer reference (mixed)
k = KlassDerived("me oh my");
kret = smartpointerpointerreftest(k);
val = kret.getValue();
verifyValue("me oh my smartpointerpointerreftest-Derived", val)
verifyCount(2, k)
verifyCount(2, kret)
# pass by value (mixed)
k = KlassDerived("me oh my");
kret = valuetest(k);
val = kret.getValue();
verifyValue("me oh my valuetest", val) # note slicing
verifyCount(1, k)
verifyCount(1, kret)
# pass by pointer (mixed)
k = KlassDerived("me oh my");
kret = pointertest(k);
val = kret.getValue();
verifyValue("me oh my pointertest-Derived", val)
verifyCount(1, k)
verifyCount(1, kret)
# pass by ref (mixed)
k = KlassDerived("me oh my");
kret = reftest(k);
val = kret.getValue();
verifyValue("me oh my reftest-Derived", val)
verifyCount(1, k)
verifyCount(1, kret)
# //////////////////////////////// Overloading tests ////////////////////////////////////////
# Base class
k = Klass("me oh my");
verifyValue(overload_rawbyval(k), "rawbyval")
verifyValue(overload_rawbyref(k), "rawbyref")
verifyValue(overload_rawbyptr(k), "rawbyptr")
verifyValue(overload_rawbyptrref(k), "rawbyptrref")
verifyValue(overload_smartbyval(k), "smartbyval")
verifyValue(overload_smartbyref(k), "smartbyref")
verifyValue(overload_smartbyptr(k), "smartbyptr")
verifyValue(overload_smartbyptrref(k), "smartbyptrref")
# Derived class
k = KlassDerived("me oh my");
verifyValue(overload_rawbyval(k), "rawbyval")
verifyValue(overload_rawbyref(k), "rawbyref")
verifyValue(overload_rawbyptr(k), "rawbyptr")
verifyValue(overload_rawbyptrref(k), "rawbyptrref")
verifyValue(overload_smartbyval(k), "smartbyval")
verifyValue(overload_smartbyref(k), "smartbyref")
verifyValue(overload_smartbyptr(k), "smartbyptr")
verifyValue(overload_smartbyptrref(k), "smartbyptrref")
# 3rd derived class
k = Klass3rdDerived("me oh my");
val = k.getValue();
verifyValue("me oh my-3rdDerived", val)
verifyCount(1, k)
val = test3rdupcast(k);
verifyValue("me oh my-3rdDerived", val)
verifyCount(1, k)
# //////////////////////////////// Member variables ////////////////////////////////////////
# smart pointer by value
m = MemberVariables();
k = Klass("smart member value");
m.SmartMemberValue = k;
val = k.getValue();
verifyValue("smart member value", val)
verifyCount(2, k)
kmember = m.SmartMemberValue;
val = kmember.getValue();
verifyValue("smart member value", val)
verifyCount(3, kmember)
verifyCount(3, k)
clear m
verifyCount(2, kmember)
verifyCount(2, k)
# smart pointer by pointer
m = MemberVariables();
k = Klass("smart member pointer");
m.SmartMemberPointer = k;
val = k.getValue();
verifyValue("smart member pointer", val)
verifyCount(1, k)
kmember = m.SmartMemberPointer;
val = kmember.getValue();
verifyValue("smart member pointer", val)
verifyCount(2, kmember)
verifyCount(2, k)
clear m
verifyCount(2, kmember)
verifyCount(2, k)
# smart pointer by reference
m = MemberVariables();
k = Klass("smart member reference");
m.SmartMemberReference = k;
val = k.getValue();
verifyValue("smart member reference", val)
verifyCount(2, k)
kmember = m.SmartMemberReference;
val = kmember.getValue();
verifyValue("smart member reference", val)
verifyCount(3, kmember)
verifyCount(3, k)
# The C++ reference refers to SmartMemberValue...
kmemberVal = m.SmartMemberValue;
val = kmember.getValue();
verifyValue("smart member reference", val)
verifyCount(4, kmemberVal)
verifyCount(4, kmember)
verifyCount(4, k)
clear m
verifyCount(3, kmemberVal)
verifyCount(3, kmember)
verifyCount(3, k)
# plain by value
m = MemberVariables();
k = Klass("plain member value");
m.MemberValue = k;
val = k.getValue();
verifyValue("plain member value", val)
verifyCount(1, k)
kmember = m.MemberValue;
val = kmember.getValue();
verifyValue("plain member value", val)
verifyCount(1, kmember)
verifyCount(1, k)
clear m
verifyCount(1, kmember)
verifyCount(1, k)
# plain by pointer
m = MemberVariables();
k = Klass("plain member pointer");
m.MemberPointer = k;
val = k.getValue();
verifyValue("plain member pointer", val)
verifyCount(1, k)
kmember = m.MemberPointer;
val = kmember.getValue();
verifyValue("plain member pointer", val)
verifyCount(1, kmember)
verifyCount(1, k)
clear m
verifyCount(1, kmember)
verifyCount(1, k)
# plain by reference
m = MemberVariables();
k = Klass("plain member reference");
m.MemberReference = k;
val = k.getValue();
verifyValue("plain member reference", val)
verifyCount(1, k)
kmember = m.MemberReference;
val = kmember.getValue();
verifyValue("plain member reference", val)
verifyCount(1, kmember)
verifyCount(1, k)
clear m
verifyCount(1, kmember)
verifyCount(1, k)
# null member variables
m = MemberVariables();
# shared_ptr by value
k = m.SmartMemberValue;
#KTODO None not defined
# if (k ~= None)
# error("expected null")
# end
# m.SmartMemberValue = None
# k = m.SmartMemberValue
# if (k ~= None)
# error("expected null")
# end
# verifyCount(0, k)
# # plain by value
# # try:
# # m.MemberValue = None
# # error("Failed to catch null pointer")
# # except ValueError:
# # pass
# # ////////////////////////////////// Global variables ////////////////////////////////////////
# # smart pointer
# kglobal = cvar.GlobalSmartValue
# if (kglobal ~= None)
# error("expected null")
# end
k = Klass("smart global value");
cvar.GlobalSmartValue = k;
verifyCount(2, k)
kglobal = cvar.GlobalSmartValue;
val = kglobal.getValue();
verifyValue("smart global value", val)
verifyCount(3, kglobal)
verifyCount(3, k)
verifyValue("smart global value", cvar.GlobalSmartValue.getValue())
#KTTODO cvar.GlobalSmartValue = None
# plain value
k = Klass("global value");
cvar.GlobalValue = k;
verifyCount(1, k)
kglobal = cvar.GlobalValue;
val = kglobal.getValue();
verifyValue("global value", val)
verifyCount(1, kglobal)
verifyCount(1, k)
verifyValue("global value", cvar.GlobalValue.getValue())
# try:
# cvar.GlobalValue = None
# error("Failed to catch null pointer")
# except ValueError:
# pass
# plain pointer
kglobal = cvar.GlobalPointer;
#KTODO if (kglobal ~= None)
#KTODO error("expected null")
#KTODO end
k = Klass("global pointer");
cvar.GlobalPointer = k;
verifyCount(1, k)
kglobal = cvar.GlobalPointer;
val = kglobal.getValue();
verifyValue("global pointer", val)
verifyCount(1, kglobal)
verifyCount(1, k)
#KTODO cvar.GlobalPointer = None
# plain reference
k = Klass("global reference");
cvar.GlobalReference = k;
verifyCount(1, k)
kglobal = cvar.GlobalReference;
val = kglobal.getValue();
verifyValue("global reference", val)
verifyCount(1, kglobal)
verifyCount(1, k)
# try:
# cvar.GlobalReference = None
# error("Failed to catch null pointer")
# except ValueError:
# pass
# ////////////////////////////////// Templates ////////////////////////////////////////
pid = PairIntDouble(10, 20.2);
if (pid.baseVal1 ~= 20 || pid.baseVal2 ~= 40.4)
error("Base values wrong")
end
if (pid.val1 ~= 10 || pid.val2 ~= 20.2)
error("Derived Values wrong")
end
endfunction
debug = false;%true;
if (debug)
fprintf( "Started\n" )
end
cvar.debug_shared = debug;
# Change loop count to run for a long time to monitor memory
loopCount = 1; #5000
for i=0:loopCount
runtest()
end
# Expect 1 instance - the one global variable (GlobalValue)
#KTTODO next fails, possibly because we commented GlobalSmartValue=None
#if (Klass.getTotal_count() ~= 1)
# error("Klass.total_count=%d", Klass.getTotal_count())
#end
wrapper_count = shared_ptr_wrapper_count() ;
#KTTODO next fails as NOT_COUNTING not in octave name space, so we hard-wire it here
#if (wrapper_count ~= NOT_COUNTING)
if (wrapper_count ~= -123456)
# Expect 1 instance - the one global variable (GlobalSmartValue)
if (wrapper_count ~= 1)
error("shared_ptr wrapper count=%s", wrapper_count)
end
end
if (debug)
fprintf( "Finished\n" )
end

View File

@@ -0,0 +1,15 @@
# do not dump Octave core
if exist("crash_dumps_octave_core", "builtin")
crash_dumps_octave_core(0);
endif
li_carrays_cpp
d = doubleArray(10);
d(0) = 7;
d(5) = d(0) + 3;
if (d(5) + d(0) != 17)
error
endif

View File

@@ -0,0 +1,15 @@
# do not dump Octave core
if exist("crash_dumps_octave_core", "builtin")
crash_dumps_octave_core(0);
endif
li_carrays
d = doubleArray(10);
d(0) = 7;
d(5) = d(0) + 3;
if (d(5) + d(0) != 17)
error
endif

View File

@@ -0,0 +1,22 @@
# do not dump Octave core
if exist("crash_dumps_octave_core", "builtin")
crash_dumps_octave_core(0);
endif
li_cmalloc
p = malloc_int();
free_int(p);
ok = 0;
try
p = calloc_int(-1);
free_int(p);
catch
ok = 1;
end_try_catch
if (ok != 1)
error
endif

View File

@@ -0,0 +1,12 @@
li_cpointer_cpp
p = new_intp();
intp_assign(p,3);
if (intp_value(p) != 3)
error
endif
delete_intp(p);

View File

@@ -0,0 +1,17 @@
# do not dump Octave core
if exist("crash_dumps_octave_core", "builtin")
crash_dumps_octave_core(0);
endif
li_cpointer
p = new_intp();
intp_assign(p,3);
if (intp_value(p) != 3)
error
endif
delete_intp(p);

View File

@@ -0,0 +1,44 @@
# do not dump Octave core
if exist("crash_dumps_octave_core", "builtin")
crash_dumps_octave_core(0);
endif
li_cstring
if (count("ab\0ab\0ab\0", 0) != 3)
error
endif
if (!strcmp(test1(),"Hello World"))
error
endif
if (!strcmp(test2()," !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_"))
error
endif
if (!strcmp(test3("hello"),"hello-suffix"))
error(test3("hello"))
endif
if (!strcmp(test4("hello"),"hello-suffix"))
error(test4("hello"))
endif
if (!strcmp(test5(4),'xxxx'))
error
endif
if (!strcmp(test6(10),'xxxxx'))
error
endif
if (!strcmp(test7(),"Hello world!"))
error
endif
if (!strcmp(test8()," !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_"))
error
endif

View File

@@ -0,0 +1,43 @@
# do not dump Octave core
if exist("crash_dumps_octave_core", "builtin")
crash_dumps_octave_core(0);
endif
li_cwstring
if (count("ab\0ab\0ab\0", 0) != 3)
error
endif
if (!strcmp(test1(),"Hello World"))
error
endif
if (!strcmp(test2()," !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_"))
error
endif
if (!strcmp(test3("hello"),"hello-suffix"))
error
endif
if (!strcmp(test4("hello"),"hello-suffix"))
error
endif
if (!strcmp(test5(4),'xxxx'))
error
endif
if (!strcmp(test6(10),'xxxxx'))
error
endif
if (!strcmp(test7(),"Hello world!"))
error
endif
if (!strcmp(test8()," !\"#$%&'()*+,-./0123456789:;<=>?@ABCDEFGHIJKLMNOPQRSTUVWXYZ[\]^_"))
error
endif

View File

@@ -0,0 +1,18 @@
# do not dump Octave core
if exist("crash_dumps_octave_core", "builtin")
crash_dumps_octave_core(0);
endif
li_factory
circle = Geometry_create(Geometry.CIRCLE);
r = circle.radius();
if (r != 1.5)
error
endif
point = Geometry_create(Geometry.POINT);
w = point.width();
if (w != 1.0)
error
endif

View File

@@ -0,0 +1,25 @@
# do not dump Octave core
if exist("crash_dumps_octave_core", "builtin")
crash_dumps_octave_core(0);
endif
li_implicit
b = B();
ai = A(1);
ad = A(2.0);
ab = A(b);
ai, get(ai);
ad, get(ad);
ab, get(ab);
if (get(ai) != get(1))
error("bad implicit type")
endif
if (get(ad) != get(2.0))
error("bad implicit type")
endif
if (get(ab) != get(b))
error("bad implicit type")
endif

View File

@@ -0,0 +1,52 @@
li_std_carray
v3 = Vector3();
for i=0:len(v3),
v3(i) = i;
endfor
i = 0;
for d in v3,
if (d != i)
error
endif
i = i + 1;
endfor
m3 = Matrix3();
for i=0:len(m3),
v3 = m3(i);
for j=0:len(v3),
v3(j) = i + j;
endfor
endfor
i = 0;
for v3 in m3,
j = 0;
for d in v3,
if (d != i + j)
error
endif
j = j + 1;
endfor
i = i + 1
endfor
for i=0:len(m3),
for j=0:len(m3),
if (m3(i,j) != i + j)
error
endif
endfor
endfor
da = Vector3([1,2,3]);
ma = Matrix3({[1,2,3],[4,5,6],[7,8,9]});

View File

@@ -0,0 +1,74 @@
# do not dump Octave core
if exist("crash_dumps_octave_core", "builtin")
crash_dumps_octave_core(0);
endif
li_std_pair_extra
p = {1,2};
p1 = li_std_pair_extra.p_inout(p);
assert(all(cell2mat(p1)==[2,1]));
p2 = li_std_pair_extra.p_inoutd(p1);
assert(all(cell2mat(p2)==[1,2]));
d1 = li_std_pair_extra.d_inout(2);
assert(d1==4);
[i,d2] = li_std_pair_extra.d_inout2(2);
assert(all([i,d2]==[1,4]));
[i,p] = li_std_pair_extra.p_inout2(p);
assert(i==1&&all([cell2mat(p)]==[2,1]));
[p3,p4] = li_std_pair_extra.p_inout3(p1,p1);
assert(all(cell2mat(p3)==[2,1]));
assert(all(cell2mat(p4)==[2,1]));
psi = li_std_pair_extra.SIPair("hello",1);
assert(psi=={"hello",1});
pci = li_std_pair_extra.CIPair(complex(1,2),1);
assert(pci.first==complex(1,2)&&pci.second==1);
psi = li_std_pair_extra.SIPair("hi",1);
assert(psi.first=="hi"&&psi.second==1);
psii = li_std_pair_extra.SIIPair(psi,1);
assert(psii.first.first=="hi");
assert(psii.first.second==1);
assert(psii.second==1);
a = li_std_pair_extra.A();
b = li_std_pair_extra.B();
pab = li_std_pair_extra.ABPair(a,b);
pab.first = a;
pab.first.val = 2;
assert(pab.first.val == 2);
pci = li_std_pair_extra.CIntPair(1,0);
assert(pci.first==1&&pci.second==0);
a = li_std_pair_extra.A(5);
p1 = li_std_pair_extra.pairP1(1,a);
p2 = li_std_pair_extra.pairP2(a,1);
p3 = li_std_pair_extra.pairP3(a,a);
assert(a.val == li_std_pair_extra.p_identa(p1){2}.val);
p = li_std_pair_extra.IntPair(1,10);
assert(p.first==1&&p.second==10);
p.first = 1;
assert(p.first==1);
p = li_std_pair_extra.paircA1(1,a);
assert(p.first==1);
assert(swig_this(p.second)==swig_this(a));
p = li_std_pair_extra.paircA2(1,a);
assert(p.first==1);
assert(swig_this(p.second)==swig_this(a));
#pp = li_std_pair_extra.pairiiA(1,p); # conversion pb re const of pairA1/A2
pp = li_std_pair_extra.pairiiA(1,{1,A()});

View File

@@ -0,0 +1,96 @@
li_std_set
s = set_string()
s.append("a")
s.append("b")
s.append("c")
sum = ""
for i in s:
sum = sum + i
if (sum != "abc")
error
i = s.__iter__()
if i.next() != "a":
error
if i.next() != "b":
error
if i.next() != "c":
error
b = s.begin()
e = s.end()
sum = ""
while (b != e):
sum = sum + b.next()
if sum != "abc":
error
b = s.rbegin()
e = s.rend()
sum = ""
while (b != e):
sum = sum + b.next()
if sum != "cba":
error
si = set_int()
si.append(1)
si.append(2)
si.append(3)
i = si.__iter__()
if i.next() != 1:
error
if i.next() != 2:
error
if i.next() != 3:
error
i = s.begin()
i.next()
s.erase(i)
b = s.begin()
e = s.end()
sum = ""
while (b != e):
sum = sum + b.next()
if sum != "ac":
error
b = s.begin()
e = s.end()
if e - b != 2:
error
m = b + 1
if m.value() != "c":
error
s = pyset()
s.insert((1,2))
s.insert(1)
s.insert("hello")
sum = ()
for i in s:
sum = sum + (i,)
if sum != (1, 'hello', (1, 2)):
error

View File

@@ -0,0 +1,13 @@
li_std_stream
a = A();
o = ostringstream();
o << a << " " << 2345 << " " << 1.435;
if (o.str() != "A class 2345 1.435")
error
endif

View File

@@ -0,0 +1,162 @@
li_std_string_extra
x="hello";
if (li_std_string_extra.test_ccvalue(x) != x)
error("bad string mapping")
endif
if (li_std_string_extra.test_cvalue(x) != x)
error("bad string mapping")
endif
if (li_std_string_extra.test_value(x) != x)
error("bad string mapping: %s, %s", x, li_std_string_extra.test_value(x))
endif
if (li_std_string_extra.test_const_reference(x) != x)
error("bad string mapping")
endif
s = li_std_string_extra.string("he");
#s += "ll"
#s.append("ll")
s = s + "llo";
if (s != x)
error("bad string mapping: %s, %s", s, x);
endif
#if (s(1:4) != x(1:4))
# error("bad string mapping")
#endif
if (li_std_string_extra.test_value(s) != x)
error("bad string mapping")
endif
if (li_std_string_extra.test_const_reference(s) != x)
error("bad string mapping")
endif
a = li_std_string_extra.A(s);
if (li_std_string_extra.test_value(a) != x)
error("bad string mapping")
endif
if (li_std_string_extra.test_const_reference(a) != x)
error("bad string mapping")
endif
b = li_std_string_extra.string(" world");
s = a + b;
if (a + b != "hello world")
error("bad string mapping: %s", a + b)
endif
if (a + " world" != "hello world")
error("bad string mapping")
endif
#if ("hello" + b != "hello world")
# error("bad string mapping")
#endif
c = (li_std_string_extra.string("hello") + b);
if (c.find_last_of("l") != 9)
error("bad string mapping")
endif
s = "hello world";
b = li_std_string_extra.B("hi");
b.name = li_std_string_extra.string("hello");
if (b.name != "hello")
error("bad string mapping")
endif
b.a = li_std_string_extra.A("hello");
if (b.a != "hello")
error("bad string mapping")
endif
if (li_std_string_extra.test_value_basic1(x) != x)
error("bad string mapping")
endif
if (li_std_string_extra.test_value_basic2(x) != x)
error("bad string mapping")
endif
if (li_std_string_extra.test_value_basic3(x) != x)
error("bad string mapping")
endif
# Global variables
s = "initial string";
if (li_std_string_extra.cvar.GlobalString2 != "global string 2")
error("GlobalString2 test 1")
endif
li_std_string_extra.cvar.GlobalString2 = s;
if (li_std_string_extra.cvar.GlobalString2 != s)
error("GlobalString2 test 2")
endif
if (li_std_string_extra.cvar.ConstGlobalString != "const global string")
error("ConstGlobalString test")
endif
# Member variables
myStructure = li_std_string_extra.Structure();
if (myStructure.MemberString2 != "member string 2")
error("MemberString2 test 1")
endif
myStructure.MemberString2 = s;
if (myStructure.MemberString2 != s)
error("MemberString2 test 2")
endif
if (myStructure.ConstMemberString != "const member string")
error("ConstMemberString test")
endif
if (li_std_string_extra.cvar.Structure_StaticMemberString2 != "static member string 2")
error("StaticMemberString2 test 1")
endif
li_std_string_extra.cvar.Structure_StaticMemberString2 = s;
if (li_std_string_extra.cvar.Structure_StaticMemberString2 != s)
error("StaticMemberString2 test 2")
endif
if (li_std_string_extra.cvar.Structure_ConstStaticMemberString != "const static member string")
error("ConstStaticMemberString test")
endif
if (li_std_string_extra.test_reference_input("hello") != "hello")
error
endif
s = li_std_string_extra.test_reference_inout("hello");
if (s != "hellohello")
error
endif
if (li_std_string_extra.stdstring_empty() != "")
error
endif
if (li_std_string_extra.c_empty() != "")
error
endif
#if (li_std_string_extra.c_null() != None)
# error
#endif

View File

@@ -0,0 +1,32 @@
# do not dump Octave core
if exist("crash_dumps_octave_core", "builtin")
crash_dumps_octave_core(0);
endif
li_std_vector_enum
function check(a, b)
if (a != b)
error("incorrect match");
endif
end
ev = EnumVector();
check(ev.nums(0), 10);
check(ev.nums(1), 20);
check(ev.nums(2), 30);
it = ev.nums.begin();
v = it.value();
check(v, 10);
it.next();
v = it.value();
check(v, 20);
#expected = 10
#ev.nums.each do|val|
# swig_assert(val == expected)
# expected += 10
#end

View File

@@ -0,0 +1,11 @@
li_std_vector
iv = IntVector(4);
for i=0:3,
iv(i) = i;
endfor
x = average(iv);
if (x != 1.5)
error("average failed");
endif

View File

@@ -0,0 +1,14 @@
li_std_wstream
a = A();
o = wostringstream();
o << a << u" " << 2345 << u" " << 1.435 << wends;
if (o.str() != "A class 2345 1.435\0")
error
endif

View File

@@ -0,0 +1,95 @@
# do not dump Octave core
if exist("crash_dumps_octave_core", "builtin")
crash_dumps_octave_core(0);
endif
li_std_wstring
x="h";
if (li_std_wstring.test_wcvalue(x) != x)
error("bad string mapping")
endif
x="hello";
if (li_std_wstring.test_ccvalue(x) != x)
error("bad string mapping")
endif
if (li_std_wstring.test_cvalue(x) != x)
error("bad string mapping")
endif
if (li_std_wstring.test_value(x) != x)
error("bad string mapping")
endif
if (li_std_wstring.test_const_reference(x) != x)
error("bad string mapping")
endif
s = li_std_wstring.wstring("he");
s = s + "llo";
if (s != x)
error("bad string mapping")
endif
if (s(1:4) != x(1:4))
error("bad string mapping")
endif
if (li_std_wstring.test_value(s) != x)
error("bad string mapping")
endif
if (li_std_wstring.test_const_reference(s) != x)
error("bad string mapping")
endif
a = li_std_wstring.A(s);
if (li_std_wstring.test_value(a) != x)
error("bad string mapping")
endif
if (li_std_wstring.test_const_reference(a) != x)
error("bad string mapping")
endif
b = li_std_wstring.wstring(" world");
if (a + b != "hello world")
error("bad string mapping")
endif
if (a + " world" != "hello world")
error("bad string mapping")
endif
if ("hello" + b != "hello world")
error("bad string mapping")
endif
c = "hello" + b;
if (c.find_last_of("l") != 9)
error("bad string mapping")
endif
s = "hello world";
b = li_std_wstring.B("hi");
b.name = li_std_wstring.wstring("hello");
if (b.name != "hello")
error("bad string mapping")
endif
b.a = li_std_wstring.A("hello");
if (b.a != "hello")
error("bad string mapping")
endif

View File

@@ -0,0 +1,45 @@
# Example using pointers to member functions
member_pointer
function check(what,expected,actual)
if (expected != actual)
error ("Failed: %s, Expected: %f, Actual: %f",what,expected,actual);
endif
end
# Get the pointers
area_pt = areapt;
perim_pt = perimeterpt;
# Create some objects
s = Square(10);
# Do some calculations
check ("Square area ", 100.0, do_op(s,area_pt));
check ("Square perim", 40.0, do_op(s,perim_pt));
memberPtr = cvar.areavar;
memberPtr = cvar.perimetervar;
# Try the variables
check ("Square area ", 100.0, do_op(s,cvar.areavar));
check ("Square perim", 40.0, do_op(s,cvar.perimetervar));
# Modify one of the variables
cvar.areavar = perim_pt;
check ("Square perimeter", 40.0, do_op(s,cvar.areavar));
# Try the constants
memberPtr = AREAPT;
memberPtr = PERIMPT;
memberPtr = NULLPT;
check ("Square area ", 100.0, do_op(s,AREAPT));
check ("Square perim", 40.0, do_op(s,PERIMPT));

View File

@@ -0,0 +1,91 @@
# do not dump Octave core
if exist("crash_dumps_octave_core", "builtin")
crash_dumps_octave_core(0);
endif
minherit
a = minherit.Foo();
b = minherit.Bar();
c = minherit.FooBar();
d = minherit.Spam();
if (a.xget() != 1)
error("Bad attribute value")
endif
if (b.yget() != 2)
error("Bad attribute value")
endif
if (c.xget() != 1 || c.yget() != 2 || c.zget() != 3)
error("Bad attribute value")
endif
if (d.xget() != 1 || d.yget() != 2 || d.zget() != 3 || d.wget() != 4)
error("Bad attribute value")
endif
if (minherit.xget(a) != 1)
error("Bad attribute value %d",minherit.xget(a))
endif
if (minherit.yget(b) != 2)
error("Bad attribute value %d",minherit.yget(b))
endif
if (minherit.xget(c) != 1 || minherit.yget(c) != 2 || minherit.zget(c) != 3)
error("Bad attribute value %d %d %d",minherit.xget(c),minherit.yget(c),minherit.zget(c))
endif
if (minherit.xget(d) != 1 || minherit.yget(d) != 2 || minherit.zget(d) != 3 || minherit.wget(d) != 4)
error("Bad attribute value %d %d %d %d",minherit.xget(d),minherit.yget(d),minherit.zget(d),minherit.wget(d))
endif
# Cleanse all of the pointers and see what happens
aa = minherit.toFooPtr(a);
bb = minherit.toBarPtr(b);
cc = minherit.toFooBarPtr(c);
dd = minherit.toSpamPtr(d);
if (aa.xget() != 1)
error("Bad attribute value");
endif
if (bb.yget() != 2)
error("Bad attribute value");
endif
if (cc.xget() != 1 || cc.yget() != 2 || cc.zget() != 3)
error("Bad attribute value")
endif
if (dd.xget() != 1 || dd.yget() != 2 || dd.zget() != 3 || dd.wget() != 4)
error("Bad attribute value")
endif
if (minherit.xget(aa) != 1)
error("Bad attribute value %d",minherit.xget(aa));
endif
if (minherit.yget(bb) != 2)
error("Bad attribute value %d",minherit.yget(bb));
endif
if (minherit.xget(cc) != 1 || minherit.yget(cc) != 2 || minherit.zget(cc) != 3)
error("Bad attribute value %d %d %d",minherit.xget(cc),minherit.yget(cc),minherit.zget(cc));
endif
if (minherit.xget(dd) != 1 || minherit.yget(dd) != 2 || minherit.zget(dd) != 3 || minherit.wget(dd) != 4)
error("Bad attribute value %d %d %d %d",minherit.xget(dd),minherit.yget(dd),minherit.zget(dd),minherit.wget(dd))
endif

View File

@@ -0,0 +1,12 @@
# do not dump Octave core
if exist("crash_dumps_octave_core", "builtin")
crash_dumps_octave_core(0);
endif
mod_a
mod_b
c = mod_b.C();
d = mod_b.D();
d.DoSomething(c);

View File

@@ -0,0 +1,29 @@
# do not dump Octave core
if exist("crash_dumps_octave_core", "builtin")
crash_dumps_octave_core(0);
endif
multi_import_a;
multi_import_b;
x = multi_import_b.XXX();
if (x.testx() != 0)
error
endif
y = multi_import_b.YYY();
if (y.testx() != 0)
error
endif
if (y.testy() != 1)
error
endif
z = multi_import_a.ZZZ();
if (z.testx() != 0)
error
endif
if (z.testz() != 2)
error
endif

View File

@@ -0,0 +1,39 @@
namespace_class
try
p = Private1();
ok = 1;
catch
ok = 0;
end_try_catch
if (ok)
error("Private1 is private")
endif
try
p = Private2();
ok = 1;
catch
ok = 0;
end_try_catch
if (ok)
error("Private2 is private")
endif
EulerT3D.toFrame(1,1,1);
b = BooT_i();
b = BooT_H();
f = FooT_i();
f.quack(1);
f = FooT_d();
f.moo(1);
f = FooT_H();
f.foo(Hi);

View File

@@ -0,0 +1,106 @@
namespace_typemap
if (!strcmp(stest1("hello"),"hello"))
error
endif
if (!strcmp(stest2("hello"),"hello"))
error
endif
if (!strcmp(stest3("hello"),"hello"))
error
endif
if (!strcmp(stest4("hello"),"hello"))
error
endif
if (!strcmp(stest5("hello"),"hello"))
error
endif
if (!strcmp(stest6("hello"),"hello"))
error
endif
if (!strcmp(stest7("hello"),"hello"))
error
endif
if (!strcmp(stest8("hello"),"hello"))
error
endif
if (!strcmp(stest9("hello"),"hello"))
error
endif
if (!strcmp(stest10("hello"),"hello"))
error
endif
if (!strcmp(stest11("hello"),"hello"))
error
endif
if (!strcmp(stest12("hello"),"hello"))
error
endif
c = complex(2,3);
r = real(c);
if (ctest1(c) != r)
error
endif
if (ctest2(c) != r)
error
endif
if (ctest3(c) != r)
error
endif
if (ctest4(c) != r)
error
endif
if (ctest5(c) != r)
error
endif
if (ctest6(c) != r)
error
endif
if (ctest7(c) != r)
error
endif
if (ctest8(c) != r)
error
endif
if (ctest9(c) != r)
error
endif
if (ctest10(c) != r)
error
endif
if (ctest11(c) != r)
error
endif
if (ctest12(c) != r)
error
endif
try
ttest1(-14)
error
catch
end_try_catch

View File

@@ -0,0 +1,4 @@
namespace_virtual_method
x = namespace_virtual_method.Spam();

View File

@@ -0,0 +1,19 @@
# do not dump Octave core
if exist("crash_dumps_octave_core", "builtin")
crash_dumps_octave_core(0);
endif
naturalvar
f = Foo();
b = Bar();
b.f = f;
cvar.s = "hello";
b.s = "hello";
if (b.s != cvar.s)
error
endif

View File

@@ -0,0 +1,14 @@
nested_structs
named = nested_structs.Named();
named.val = 999;
assert(nested_structs.nestedByVal(named), 999);
assert(nested_structs.nestedByPtr(named), 999);
outer = nested_structs.Outer();
outer.inside1.val = 456;
assert(nested_structs.getInside1Val(outer), 456);
outer.inside1 = named;
assert(nested_structs.getInside1Val(outer), 999);

View File

@@ -0,0 +1,36 @@
nondynamic
aa = nondynamic.A();
aa.a = 1;
aa.b = 2;
try
aa.c = 2;
err = 0;
catch
err = 1;
end_try_catch
if (!err)
error("A is not static")
endif
B=@() subclass(nondynamic.A(),'c',4);
bb = B();
bb.c = 3;
try
bb.d = 2
err = 0
catch
err = 1
end_try_catch
if (!err)
error("B is not static")
endif
cc = nondynamic.C();
cc.d = 3;

View File

@@ -0,0 +1,8 @@
# do not dump Octave core
if exist("crash_dumps_octave_core", "builtin")
crash_dumps_octave_core(0);
endif
null_pointer;
assert(func([]));

View File

@@ -0,0 +1,13 @@
# do not dump Octave core
if exist("crash_dumps_octave_core", "builtin")
crash_dumps_octave_core(0);
endif
octave_cell_deref;
assert(func("hello"));
assert(func({"hello"}));
c = func2();
assert(strcmp(c{1}, "hello"));
assert(c{2} == 4);

View File

@@ -0,0 +1,18 @@
octave_dim
assert(all(size(Foo45a())==[4 5]));
assert(all(size(Foo456a())==[4 5 6]));
assert(all(size(Foo4a())==[4 1]));
assert(all(size(Foo4b())==[4 1]));
assert(all(size(Foo())==[1 1]));
assert(all(size(Bar1())==[1 1]));
assert(all(size(Bar2())==[1 1]));
assert(all(size(Baz1())==[3 4]));
assert(all(size(Baz2())==[3 4]));
assert(all(size(Baz3())==[3 4]));
assert(all(size(Baz4())==[3 4]));
% Assertions will not work, but kept for future reference.
%assert(all(size(Baz5())==[3 4]));
%assert(all(size(Baz6())==[3 4]));
%assert(all(size(Baz7())==[3 4]));

View File

@@ -0,0 +1 @@
/* empty C file for the Octave test-suite C tests is needed - build system workaround as the generated files for Octave are C++ files */

View File

@@ -0,0 +1,63 @@
# do not dump Octave core
if exist("crash_dumps_octave_core", "builtin")
crash_dumps_octave_core(0);
endif
overload_complicated
pInt = None;
# Check the correct constructors are available
p = Pop(pInt);
p = Pop(pInt, 0);
# Check overloaded in const only and pointers/references which target languages cannot disambiguate
if (p.hip(0) != 701)
error("Test 1 failed")
endif
if (p.hip(pInt) != 702)
error("Test 2 failed")
endif
# Reverse the order for the above
if (p.hop(pInt) != 805)
error("Test 3 failed")
endif
if (p.hop(0) != 801)
error("Test 4 failed")
endif
# Few more variations and order shuffled
if (p.pop(0) != 901)
error("Test 5 failed")
endif
if (p.pop(pInt) != 902)
error("Test 6 failed")
endif
if (p.pop() != 905)
error("Test 7 failed")
endif
# Overload on const only
if (p.bop(pInt) != 1001)
error("Test 8 failed")
endif
if (p.bip(pInt) != 2001)
error("Test 9 failed")
endif
# Globals
if (muzak(0) != 3001)
error("Test 10 failed")
endif
if (muzak(pInt) != 3002)
error("Test 11 failed")
endif

View File

@@ -0,0 +1,3 @@
overload_copy
f = Foo();
g = Foo(f);

View File

@@ -0,0 +1,30 @@
overload_extend2
f = overload_extend2.Foo();
if (f.test(3) != 1)
error
endif
if (f.test("hello") != 2)
error
endif
if (f.test(3.5,2.5) != 3)
error
endif
if (f.test("hello",20) != 1020)
error
endif
if (f.test("hello",20,100) != 120)
error
endif
# C default args
if (f.test(f) != 30)
error
endif
if (f.test(f,100) != 120)
error
endif
if (f.test(f,100,200) != 300)
error
endif

View File

@@ -0,0 +1,24 @@
# do not dump Octave core
if exist("crash_dumps_octave_core", "builtin")
crash_dumps_octave_core(0);
endif
overload_extend_c
f = overload_extend_c.Foo();
if (f.test() != 0)
error
endif
if (f.test(3) != 1)
error
endif
if (f.test("hello") != 2)
error
endif
if (f.test(3,2) != 5)
error
endif
if (f.test(3.1)-.1 != 1003) # :)
error
endif

View File

@@ -0,0 +1,24 @@
# do not dump Octave core
if exist("crash_dumps_octave_core", "builtin")
crash_dumps_octave_core(0);
endif
overload_extend
f = overload_extend.Foo();
if (f.test() != 0)
error
endif
if (f.test(3) != 1)
error
endif
if (f.test("hello") != 2)
error
endif
if (f.test(3,2) != 5)
error
endif
if (f.test(3.1)-.1 != 1003) # :)
error
endif

View File

@@ -0,0 +1,8 @@
overload_rename
f = overload_rename.Foo(1);
f = overload_rename.Foo(1,1);
f = overload_rename.new_Foo_int(1,1);
f = overload_rename.new_Foo_int(1,1,1);

View File

@@ -0,0 +1,234 @@
# do not dump Octave core
if exist("crash_dumps_octave_core", "builtin")
crash_dumps_octave_core(0);
endif
overload_simple_cast
Ai=@(x) subclass('x',x,'__int',@(self) self.x);
Ad=@(x) subclass('x',x,'__float',@(self) self.x);
ai = Ai(4);
ad = Ad(5.0);
add = Ad(5.5);
try
fint(add);
good = 0;
catch
good = 1;
end_try_catch
if (!good)
error("fint(int)")
endif
if (!strcmp(fint(ad),"fint:int"))
error("fint(int)")
endif
if (!strcmp(fdouble(ad),"fdouble:double"))
error("fdouble(double)")
endif
if (!strcmp(fint(ai),"fint:int"))
error("fint(int)")
endif
if (!strcmp(fint(5.0),"fint:int"))
error("fint(int)")
endif
if (!strcmp(fint(3),"fint:int"))
error("fint(int)")
endif
if (!strcmp(fint(3.0),"fint:int"))
error("fint(int)")
endif
if (!strcmp(fdouble(ad),"fdouble:double"))
error("fdouble(double)")
endif
if (!strcmp(fdouble(3),f"fdouble:double"))
error("fdouble(double)")
endif
if (!strcmp(fdouble(3.0),"fdouble:double"))
error("fdouble(double)")
endif
if (!strcmp(fid(3,3.0),"fid:intdouble"))
error("fid:intdouble")
endif
if (!strcmp(fid(3.0,3),"fid:doubleint"))
error("fid:doubleint")
endif
if (!strcmp(fid(ad,ai),"fid:doubleint"))
error("fid:doubleint")
endif
if (!strcmp(fid(ai,ad),"fid:intdouble"))
error("fid:intdouble")
endif
if (!strcmp(foo(3),"foo:int"))
error("foo(int)")
endif
if (!strcmp(foo(3.0),"foo:double"))
error("foo(double)")
endif
if (!strcmp(foo("hello"),"foo:char *"))
error("foo(char *)")
endif
f = Foo();
b = Bar();
if (!strcmp(foo(f),"foo:Foo *"))
error("foo(Foo *)")
endif
if (!strcmp(foo(b),"foo:Bar *"))
error("foo(Bar *)")
endif
v = malloc_void(32);
if (!strcmp(foo(v),"foo:void *"))
error("foo(void *)")
endif
s = Spam();
if (!strcmp(s.foo(3),"foo:int"))
error("Spam::foo(int)")
endif
if (!strcmp(s.foo(3.0),"foo:double"))
error("Spam::foo(double)")
endif
if (!strcmp(s.foo("hello"),"foo:char *"))
error("Spam::foo(char *)")
endif
if (!strcmp(s.foo(f),"foo:Foo *"))
error("Spam::foo(Foo *)")
endif
if (!strcmp(s.foo(b),"foo:Bar *"))
error("Spam::foo(Bar *)")
endif
if (!strcmp(s.foo(v),"foo:void *"))
error("Spam::foo(void *)")
endif
if (!strcmp(Spam_bar(3),"bar:int"))
error("Spam::bar(int)")
endif
if (!strcmp(Spam_bar(3.0),"bar:double"))
error("Spam::bar(double)")
endif
if (!strcmp(Spam_bar("hello"),"bar:char *"))
error("Spam::bar(char *)")
endif
if (!strcmp(Spam_bar(f),"bar:Foo *"))
error("Spam::bar(Foo *)")
endif
if (!strcmp(Spam_bar(b),"bar:Bar *"))
error("Spam::bar(Bar *)")
endif
if (!strcmp(Spam_bar(v),"bar:void *"))
error("Spam::bar(void *)")
endif
# Test constructors
s = Spam();
if (!strcmp(s.type,"none"))
error("Spam()")
endif
s = Spam(3);
if (!strcmp(s.type,"int"))
error("Spam(int)")
endif
s = Spam(3.4);
if (!strcmp(s.type,"double"))
error("Spam(double)")
endif
s = Spam("hello");
if (!strcmp(s.type,"char *"))
error("Spam(char *)")
endif
s = Spam(f);
if (!strcmp(s.type,"Foo *"))
error("Spam(Foo *)")
endif
s = Spam(b);
if (!strcmp(s.type,"Bar *"))
error("Spam(Bar *)")
endif
s = Spam(v);
if (!strcmp(s.type,"void *"))
error("Spam(void *)")
endif
# unsigned long long
ullmax = 9223372036854775807; #0xffffffffffffffff
ullmaxd = 9007199254740992.0;
ullmin = 0;
ullmind = 0.0;
if (ull(ullmin) != ullmin)
error("ull(ullmin)")
endif
if (ull(ullmax) != ullmax)
error("ull(ullmax)")
endif
if (ull(ullmind) != ullmind)
error("ull(ullmind)")
endif
if (ull(ullmaxd) != ullmaxd)
error("ull(ullmaxd)")
endif
# long long
llmax = 9223372036854775807; #0x7fffffffffffffff
llmin = -9223372036854775808;
# these are near the largest floats we can still convert into long long
llmaxd = 9007199254740992.0;
llmind = -9007199254740992.0;
if (ll(llmin) != llmin)
error("ll(llmin)")
endif
if (ll(llmax) != llmax)
error("ll(llmax)")
endif
if (ll(llmind) != llmind)
error("ll(llmind)")
endif
if (ll(llmaxd) != llmaxd)
error("ll(llmaxd)")
endif
free_void(v);

View File

@@ -0,0 +1,125 @@
overload_simple
# unless explicitly casted via {{u}int{8,16,32,64},double,single},
# octave will take numeric literals as doubles.
if (!strcmp(foo(3),"foo:int"))
error("foo(int)")
endif
if (!strcmp(foo(3.1),"foo:double"))
error("foo(double)")
endif
if (!strcmp(foo("hello"),"foo:char *"))
error("foo(char *)")
endif
f = Foo();
b = Bar();
if (!strcmp(foo(f),"foo:Foo *"))
error("foo(Foo *)")
endif
if (!strcmp(foo(b),"foo:Bar *"))
error("foo(Bar *)")
endif
v = malloc_void(32);
if (!strcmp(foo(v),"foo:void *"))
error("foo(void *)")
endif
s = Spam();
if (!strcmp(s.foo(3),"foo:int"))
error("Spam::foo(int)")
endif
if (!strcmp(s.foo(3.1),"foo:double"))
error("Spam::foo(double)")
endif
if (!strcmp(s.foo("hello"),"foo:char *"))
error("Spam::foo(char *)")
endif
if (!strcmp(s.foo(f),"foo:Foo *"))
error("Spam::foo(Foo *)")
endif
if (!strcmp(s.foo(b),"foo:Bar *"))
error("Spam::foo(Bar *)")
endif
if (!strcmp(s.foo(v),"foo:void *"))
error("Spam::foo(void *)")
endif
if (!strcmp(Spam_bar(3),"bar:int"))
error("Spam::bar(int)")
endif
if (!strcmp(Spam_bar(3.1),"bar:double"))
error("Spam::bar(double)")
endif
if (!strcmp(Spam_bar("hello"),"bar:char *"))
error("Spam::bar(char *)")
endif
if (!strcmp(Spam_bar(f),"bar:Foo *"))
error("Spam::bar(Foo *)")
endif
if (!strcmp(Spam_bar(b),"bar:Bar *"))
error("Spam::bar(Bar *)")
endif
if (!strcmp(Spam_bar(v),"bar:void *"))
error("Spam::bar(void *)")
endif
# Test constructors
s = Spam();
if (!strcmp(s.type,"none"))
error("Spam()")
endif
s = Spam(3);
if (!strcmp(s.type,"int"))
error("Spam(int)")
endif
s = Spam(3.4);
if (!strcmp(s.type,"double"))
error("Spam(double)")
endif
s = Spam("hello");
if (!strcmp(s.type,"char *"))
error("Spam(char *)")
endif
s = Spam(f);
if (!strcmp(s.type,"Foo *"))
error("Spam(Foo *)")
endif
s = Spam(b);
if (!strcmp(s.type,"Bar *"))
error("Spam(Bar *)")
endif
s = Spam(v);
if (!strcmp(s.type,"void *"))
error("Spam(void *)")
endif
free_void(v);
a = ClassA();
b = a.method1(1);

View File

@@ -0,0 +1,18 @@
# do not dump Octave core
if exist("crash_dumps_octave_core", "builtin")
crash_dumps_octave_core(0);
endif
overload_subtype
f = Foo();
b = Bar();
if (spam(f) != 1)
error("foo")
endif
if (spam(b) != 2)
error("bar")
endif

Some files were not shown because too many files have changed in this diff Show More