merge revisions 11877-12162 from trunk to gsoc2009-matevz
git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/gsoc2009-matevz@12164 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
commit
25ff4e4927
563 changed files with 22912 additions and 17189 deletions
|
|
@ -21,7 +21,7 @@ below.
|
|||
static char *global_str = NULL;
|
||||
const int UINT_DIGITS = 10; // max unsigned int is 4294967295
|
||||
|
||||
bool check(const char *str, unsigned int number) {
|
||||
bool check(const char *const str, unsigned int number) {
|
||||
static char expected[256];
|
||||
sprintf(expected, "%s%d", OTHERLAND_MSG, number);
|
||||
bool matches = (strcmp(str, expected) == 0);
|
||||
|
|
@ -105,10 +105,28 @@ bool SetConstCharArrayStaticString(const char str[], unsigned int number) {
|
|||
return check(static_str, number);
|
||||
}
|
||||
|
||||
bool SetCharConstStaticString(char *const str, unsigned int number) {
|
||||
static char static_str[] = CPLUSPLUS_MSG;
|
||||
strcpy(static_str, str);
|
||||
return check(static_str, number);
|
||||
}
|
||||
|
||||
bool SetConstCharConstStaticString(const char *const str, unsigned int number) {
|
||||
static char static_str[] = CPLUSPLUS_MSG;
|
||||
strcpy(static_str, str);
|
||||
return check(static_str, number);
|
||||
}
|
||||
|
||||
// get set function
|
||||
char *CharPingPong(char *str) {
|
||||
return str;
|
||||
}
|
||||
char *CharArrayPingPong(char abcstr[]) {
|
||||
return abcstr;
|
||||
}
|
||||
char *CharArrayDimsPingPong(char abcstr[16]) {
|
||||
return abcstr;
|
||||
}
|
||||
|
||||
// variables
|
||||
char *global_char = NULL;
|
||||
|
|
|
|||
|
|
@ -29,14 +29,17 @@
|
|||
#
|
||||
# Note that the RUNTOOL, COMPILETOOL and SWIGTOOL variables can be used
|
||||
# for invoking tools for the runtime tests and target language
|
||||
# compiler (eg javac) respectively. For example, valgrind can be used
|
||||
# for memory checking of the runtime tests using:
|
||||
# compiler (eg javac), and on SWIG respectively. For example, valgrind
|
||||
# can be used for memory checking of the runtime tests using:
|
||||
# make RUNTOOL="valgrind --leak-check=full"
|
||||
# and valgrind can be used when invoking SWIG using:
|
||||
# make SWIGTOOL="valgrind --tool=memcheck --trace-children=yes"
|
||||
# Note: trace-children needed because of preinst-swig shell wrapper
|
||||
# to the swig executable.
|
||||
#
|
||||
# An individual test run can be debugged easily:
|
||||
# make director_string.cpptest RUNTOOL="gdb --args"
|
||||
#
|
||||
# The variables below can be overridden after including this makefile
|
||||
#######################################################################
|
||||
|
||||
|
|
@ -66,7 +69,7 @@ INCLUDES = -I$(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)
|
|||
LIBS = -L.
|
||||
LIBPREFIX = lib
|
||||
ACTION = check
|
||||
INTERFACEDIR = ../
|
||||
INTERFACEDIR = $(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/
|
||||
|
||||
#
|
||||
# Please keep test cases in alphabetical order.
|
||||
|
|
@ -133,6 +136,7 @@ CPP_TEST_CASES += \
|
|||
constructor_exception \
|
||||
constructor_explicit \
|
||||
constructor_ignore \
|
||||
constructor_rename \
|
||||
constructor_value \
|
||||
contract \
|
||||
conversion \
|
||||
|
|
@ -178,6 +182,7 @@ CPP_TEST_CASES += \
|
|||
disown \
|
||||
dynamic_cast \
|
||||
empty \
|
||||
enum_rename \
|
||||
enum_scope_template \
|
||||
enum_template \
|
||||
enum_thorough \
|
||||
|
|
@ -194,9 +199,11 @@ CPP_TEST_CASES += \
|
|||
extern_c \
|
||||
extern_namespace \
|
||||
extern_throws \
|
||||
expressions \
|
||||
features \
|
||||
fragments \
|
||||
friends \
|
||||
funcptr_cpp \
|
||||
fvirtual \
|
||||
global_namespace \
|
||||
global_ns_arg \
|
||||
|
|
@ -244,6 +251,8 @@ CPP_TEST_CASES += \
|
|||
namespace_typemap \
|
||||
namespace_union \
|
||||
namespace_virtual_method \
|
||||
nspace \
|
||||
nspace_extend \
|
||||
naturalvar \
|
||||
nested_class \
|
||||
nested_comment \
|
||||
|
|
@ -375,6 +384,7 @@ CPP_TEST_CASES += \
|
|||
template_virtual \
|
||||
template_whitespace \
|
||||
threads \
|
||||
threads_exception \
|
||||
throw_exception \
|
||||
typedef_array_member \
|
||||
typedef_class \
|
||||
|
|
@ -385,12 +395,14 @@ CPP_TEST_CASES += \
|
|||
typedef_scope \
|
||||
typedef_sizet \
|
||||
typedef_struct \
|
||||
typemap_delete \
|
||||
typemap_global_scope \
|
||||
typemap_namespace \
|
||||
typemap_ns_using \
|
||||
typemap_numinputs \
|
||||
typemap_template \
|
||||
typemap_out_optimal \
|
||||
typemap_qualifier_strip \
|
||||
typemap_variables \
|
||||
typemap_various \
|
||||
typename \
|
||||
|
|
|
|||
|
|
@ -5,7 +5,7 @@
|
|||
|
||||
/* % didn't work in SWIG 1.3.40 and earlier. */
|
||||
const int X = 123%7;
|
||||
#define FOO 12 % 6
|
||||
double d_array[12 % 6];
|
||||
#define FOO 12 % 9
|
||||
double d_array[12 % 9];
|
||||
|
||||
%}
|
||||
|
|
|
|||
|
|
@ -5,6 +5,7 @@ This testcase primarily test constant pointers, eg int* const. Only a getter is
|
|||
%module constant_pointers
|
||||
|
||||
%warnfilter(SWIGWARN_TYPEMAP_SWIGTYPELEAK); /* memory leak when setting a ptr/ref variable */
|
||||
%warnfilter(SWIGWARN_GO_NAME_CONFLICT); /* Ignoring 'Foo' due to Go name ('Foo') conflict with 'foo' */
|
||||
|
||||
%inline %{
|
||||
|
||||
|
|
@ -70,6 +71,8 @@ public:
|
|||
|
||||
void ret6(int*& a) {}
|
||||
int*& ret7() {return GlobalIntPtr;}
|
||||
void ret8(int*const& a) {}
|
||||
int*const& ret9() {return GlobalIntPtr;}
|
||||
ReturnValuesTest() : int3(NULL) {}
|
||||
private:
|
||||
ReturnValuesTest& operator=(const ReturnValuesTest&);
|
||||
|
|
@ -112,7 +115,7 @@ int* const globalRet2() {return &GlobalInt;}
|
|||
return b;
|
||||
}
|
||||
|
||||
B const*& cbar(B const*& b) {
|
||||
B *const& cbar(B *const& b) {
|
||||
return b;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
12
Examples/test-suite/constructor_rename.i
Normal file
12
Examples/test-suite/constructor_rename.i
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
%module constructor_rename
|
||||
|
||||
%{
|
||||
struct Foo {
|
||||
Foo() {}
|
||||
};
|
||||
%}
|
||||
|
||||
struct Foo {
|
||||
%rename(RenamedConstructor) Foo();
|
||||
Foo() {}
|
||||
};
|
||||
|
|
@ -24,7 +24,6 @@ struct StructWithEnums {
|
|||
enum SOME_ENUM& enum_test8() { return some_enum; };
|
||||
};
|
||||
|
||||
|
||||
struct Foo
|
||||
{
|
||||
enum {Hi, Hello } hola;
|
||||
|
|
@ -41,3 +40,15 @@ extern "C"
|
|||
}
|
||||
|
||||
%}
|
||||
|
||||
// Using true and false in enums is legal in C++. Quoting the standard:
|
||||
// [dcl.enum]
|
||||
// ... The constant-expression shall be of integral or enumeration type.
|
||||
// [basic.fundamental]
|
||||
// ... Types bool, char, wchar_t, and the signed and unsigned integer
|
||||
// types are collectively called integral types.
|
||||
// So this shouldn't lead to a warning, at least in C++ mode.
|
||||
%inline %{
|
||||
typedef enum { PLAY = true, STOP = false } play_state;
|
||||
%}
|
||||
|
||||
|
|
|
|||
|
|
@ -27,7 +27,6 @@ include $(srcdir)/../common.mk
|
|||
|
||||
# Overridden variables here
|
||||
SWIGOPT += -namespace $*Namespace
|
||||
INTERFACEDIR = ../../
|
||||
|
||||
CSHARPFLAGSSPECIAL =
|
||||
|
||||
|
|
@ -69,14 +68,13 @@ run_testcase = \
|
|||
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
|
||||
$(MAKE) -f $*/$(top_builddir)/$(EXAMPLES)/Makefile \
|
||||
CSHARPFLAGS='-nologo $(CSHARPFLAGSSPECIAL) -out:$*_runme.exe' \
|
||||
CSHARPSRCS='`$(CSHARPCYGPATH_W) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX)` \
|
||||
$*$(CSHARPPATHSEPARATOR)*.cs' csharp_compile && \
|
||||
CSHARPSRCS='`$(CSHARPCYGPATH_W) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX)` `find $* -name "*.cs" -exec $(CSHARPCYGPATH_W) "{}" \+`' csharp_compile && \
|
||||
env LD_LIBRARY_PATH="$*:$$LD_LIBRARY_PATH" PATH="$*:$$PATH" SHLIB_PATH="$*:$$SHLIB_PATH" $(RUNTOOL) $(INTERPRETER) $*_runme.exe; \
|
||||
else \
|
||||
cd $* && \
|
||||
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile \
|
||||
CSHARPFLAGS='-nologo $(CSHARPFLAGSSPECIAL) -t:module -out:$*.netmodule' \
|
||||
CSHARPSRCS='*.cs' csharp_compile && cd .. ; \
|
||||
CSHARPSRCS='`find . -name "*.cs" -exec $(CSHARPCYGPATH_W) "{}" \+`' csharp_compile; \
|
||||
fi
|
||||
|
||||
# Clean: remove testcase directories
|
||||
|
|
|
|||
|
|
@ -76,6 +76,16 @@ public class char_strings_runme {
|
|||
throw new Exception("Test char set 6 failed, iteration " + i);
|
||||
}
|
||||
|
||||
for (i=0; i<count; i++) {
|
||||
if (!char_strings.SetCharConstStaticString(OTHERLAND_MSG + i, i))
|
||||
throw new Exception("Test char set 7 failed, iteration " + i);
|
||||
}
|
||||
|
||||
for (i=0; i<count; i++) {
|
||||
if (!char_strings.SetConstCharConstStaticString(OTHERLAND_MSG + i, i))
|
||||
throw new Exception("Test char set 8 failed, iteration " + i);
|
||||
}
|
||||
|
||||
// get set function
|
||||
for (i=0; i<count*10; i++) {
|
||||
string ping = OTHERLAND_MSG + i;
|
||||
|
|
|
|||
20
Examples/test-suite/csharp/li_boost_shared_ptr_bits_runme.cs
Normal file
20
Examples/test-suite/csharp/li_boost_shared_ptr_bits_runme.cs
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
using System;
|
||||
using li_boost_shared_ptr_bitsNamespace;
|
||||
|
||||
public class runme
|
||||
{
|
||||
static void Main()
|
||||
{
|
||||
VectorIntHolder v = new VectorIntHolder();
|
||||
v.Add(new IntHolder(11));
|
||||
v.Add(new IntHolder(22));
|
||||
v.Add(new IntHolder(33));
|
||||
|
||||
int sum = li_boost_shared_ptr_bits.sum(v);
|
||||
if (sum != 66)
|
||||
throw new ApplicationException("sum is wrong");
|
||||
|
||||
HiddenDestructor hidden = HiddenDestructor.create();
|
||||
hidden.Dispose();
|
||||
}
|
||||
}
|
||||
31
Examples/test-suite/csharp/li_std_combinations_runme.cs
Normal file
31
Examples/test-suite/csharp/li_std_combinations_runme.cs
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
using System;
|
||||
using li_std_combinationsNamespace;
|
||||
|
||||
public class li_std_combinations_runme {
|
||||
public static void Main() {
|
||||
VectorPairIntString vpis = new VectorPairIntString();
|
||||
vpis.Add(new PairIntString(123, "one hundred and twenty three"));
|
||||
|
||||
VectorString vs = new VectorString();
|
||||
vs.Add("hi");
|
||||
PairIntVectorString pivs = new PairIntVectorString(456, vs);
|
||||
if (pivs.second[0] != "hi")
|
||||
throw new ApplicationException("PairIntVectorString");
|
||||
|
||||
VectorVectorString vvs = new VectorVectorString();
|
||||
vvs.Add(vs);
|
||||
|
||||
PairIntPairIntString pipis = new PairIntPairIntString(12, new PairIntString(3, "4"));
|
||||
if (pipis.first != 12)
|
||||
throw new ApplicationException("PairIntPairIntString");
|
||||
|
||||
PairDoubleString pds = new PairDoubleString(12.34, "okay");
|
||||
VectorPairDoubleString vpds = new VectorPairDoubleString();
|
||||
vpds.Add(pds);
|
||||
|
||||
// Check SWIG_STD_VECTOR_ENHANCED macro - it provides the Contains method
|
||||
if (!vpds.Contains(pds))
|
||||
throw new ApplicationException("VectorPairDoubleString");
|
||||
}
|
||||
}
|
||||
|
||||
39
Examples/test-suite/csharp/nspace_extend_runme.cs
Normal file
39
Examples/test-suite/csharp/nspace_extend_runme.cs
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
using System;
|
||||
|
||||
public class runme
|
||||
{
|
||||
static void Main()
|
||||
{
|
||||
{
|
||||
// constructors and destructors
|
||||
nspace_extendNamespace.Outer.Inner1.Color color1 = new nspace_extendNamespace.Outer.Inner1.Color();
|
||||
nspace_extendNamespace.Outer.Inner1.Color color = new nspace_extendNamespace.Outer.Inner1.Color(color1);
|
||||
color1.Dispose();
|
||||
color1 = null;
|
||||
|
||||
// class methods
|
||||
color.colorInstanceMethod(20.0);
|
||||
nspace_extendNamespace.Outer.Inner1.Color.colorStaticMethod(20.0);
|
||||
nspace_extendNamespace.Outer.Inner1.Color created = nspace_extendNamespace.Outer.Inner1.Color.create();
|
||||
created.Dispose();
|
||||
}
|
||||
{
|
||||
// constructors and destructors
|
||||
nspace_extendNamespace.Outer.Inner2.Color color2 = new nspace_extendNamespace.Outer.Inner2.Color();
|
||||
nspace_extendNamespace.Outer.Inner2.Color color = new nspace_extendNamespace.Outer.Inner2.Color(color2);
|
||||
color2.Dispose();
|
||||
color2 = null;
|
||||
|
||||
// class methods
|
||||
color.colorInstanceMethod(20.0);
|
||||
nspace_extendNamespace.Outer.Inner2.Color.colorStaticMethod(20.0);
|
||||
nspace_extendNamespace.Outer.Inner2.Color created = nspace_extendNamespace.Outer.Inner2.Color.create();
|
||||
created.Dispose();
|
||||
|
||||
// Same class different namespaces
|
||||
nspace_extendNamespace.Outer.Inner1.Color col1 = new nspace_extendNamespace.Outer.Inner1.Color();
|
||||
nspace_extendNamespace.Outer.Inner2.Color col2 = nspace_extendNamespace.Outer.Inner2.Color.create();
|
||||
col2.colors(col1, col1, col2, col2, col2);
|
||||
}
|
||||
}
|
||||
}
|
||||
76
Examples/test-suite/csharp/nspace_runme.cs
Normal file
76
Examples/test-suite/csharp/nspace_runme.cs
Normal file
|
|
@ -0,0 +1,76 @@
|
|||
using System;
|
||||
|
||||
public class runme
|
||||
{
|
||||
static void Main()
|
||||
{
|
||||
// constructors and destructors
|
||||
nspaceNamespace.Outer.Inner1.Color color1 = new nspaceNamespace.Outer.Inner1.Color();
|
||||
nspaceNamespace.Outer.Inner1.Color color = new nspaceNamespace.Outer.Inner1.Color(color1);
|
||||
color1.Dispose();
|
||||
color1 = null;
|
||||
|
||||
// class methods
|
||||
color.colorInstanceMethod(20.0);
|
||||
nspaceNamespace.Outer.Inner1.Color.colorStaticMethod(20.0);
|
||||
nspaceNamespace.Outer.Inner1.Color created = nspaceNamespace.Outer.Inner1.Color.create();
|
||||
created.Dispose();
|
||||
|
||||
// class enums
|
||||
nspaceNamespace.Outer.SomeClass someClass = new nspaceNamespace.Outer.SomeClass();
|
||||
nspaceNamespace.Outer.Inner1.Color.Channel channel = someClass.GetInner1ColorChannel();
|
||||
if (channel != nspaceNamespace.Outer.Inner1.Color.Channel.Transmission)
|
||||
throw new ApplicationException("Transmission wrong");
|
||||
|
||||
// class anonymous enums
|
||||
int val1 = nspaceNamespace.Outer.Inner1.Color.ColorEnumVal1;
|
||||
int val2 = nspaceNamespace.Outer.Inner1.Color.ColorEnumVal2;
|
||||
if (val1 != 0 || val2 != 0x22)
|
||||
throw new ApplicationException("ColorEnumVal wrong");
|
||||
|
||||
// instance member variables
|
||||
color.instanceMemberVariable = 123;
|
||||
if (color.instanceMemberVariable != 123)
|
||||
throw new ApplicationException("instance member variable failed");
|
||||
|
||||
// static member variables
|
||||
nspaceNamespace.Outer.Inner1.Color.staticMemberVariable = 789;
|
||||
if (nspaceNamespace.Outer.Inner1.Color.staticMemberVariable != 789)
|
||||
throw new ApplicationException("static member variable failed");
|
||||
if (nspaceNamespace.Outer.Inner1.Color.staticConstMemberVariable != 222)
|
||||
throw new ApplicationException("static const member variable failed");
|
||||
if (nspaceNamespace.Outer.Inner1.Color.staticConstEnumMemberVariable != nspaceNamespace.Outer.Inner1.Color.Channel.Transmission)
|
||||
throw new ApplicationException("static const enum member variable failed");
|
||||
|
||||
// check globals in a namespace don't get mangled with the nspaceNamespace option
|
||||
nspaceNamespace.nspace.namespaceFunction(color);
|
||||
nspaceNamespace.nspace.namespaceVar = 111;
|
||||
if (nspaceNamespace.nspace.namespaceVar != 111)
|
||||
throw new ApplicationException("global var failed");
|
||||
|
||||
// Same class different namespaces
|
||||
nspaceNamespace.Outer.Inner1.Color col1 = new nspaceNamespace.Outer.Inner1.Color();
|
||||
nspaceNamespace.Outer.Inner2.Color col2 = nspaceNamespace.Outer.Inner2.Color.create();
|
||||
col2.colors(col1, col1, col2, col2, col2);
|
||||
|
||||
// global enums
|
||||
nspaceNamespace.Outer.Inner1.Channel outerChannel1 = someClass.GetInner1Channel();
|
||||
if (outerChannel1 != nspaceNamespace.Outer.Inner1.Channel.Transmission1)
|
||||
throw new ApplicationException("Transmission1 wrong");
|
||||
nspaceNamespace.Outer.Inner2.Channel outerChannel2 = someClass.GetInner2Channel();
|
||||
if (outerChannel2 != nspaceNamespace.Outer.Inner2.Channel.Transmission2)
|
||||
throw new ApplicationException("Transmission2 wrong");
|
||||
|
||||
// turn feature off / ignoring
|
||||
nspaceNamespace.Outer.nspace ns = new nspaceNamespace.Outer.nspace();
|
||||
ns.Dispose();
|
||||
nspaceNamespace.NoNSpacePlease nons = new nspaceNamespace.NoNSpacePlease();
|
||||
nons.Dispose();
|
||||
|
||||
// Derived class
|
||||
nspaceNamespace.Outer.Inner3.Blue blue3 = new nspaceNamespace.Outer.Inner3.Blue();
|
||||
blue3.blueInstanceMethod();
|
||||
nspaceNamespace.Outer.Inner4.Blue blue4 = new nspaceNamespace.Outer.Inner4.Blue();
|
||||
blue4.blueInstanceMethod();
|
||||
}
|
||||
}
|
||||
|
|
@ -101,3 +101,19 @@ Number times12(const Number* num) {
|
|||
%inline %{
|
||||
int myInt = 0;
|
||||
%}
|
||||
|
||||
|
||||
// Illegal special variable crash
|
||||
%typemap(cstype) WasCrashing "$csclassname /*cstype $*csclassname*/" // $*csclassname was causing crash
|
||||
%inline %{
|
||||
struct WasCrashing {};
|
||||
void hoop(WasCrashing was) {}
|
||||
%}
|
||||
|
||||
|
||||
// Enum underlying type
|
||||
%typemap(csbase) BigNumbers "uint"
|
||||
%inline %{
|
||||
enum BigNumbers { big=0x80000000, bigger };
|
||||
%}
|
||||
|
||||
|
|
|
|||
|
|
@ -48,7 +48,7 @@ namespace EnumDirector {
|
|||
|
||||
%inline %{
|
||||
namespace EnumDirector {
|
||||
enum FType{ SA = -1, NA=0, EA=1};
|
||||
enum FType{ SA = -1, NA_=0, EA=1};
|
||||
|
||||
struct A{
|
||||
A(const double a, const double b, const FType c)
|
||||
|
|
@ -71,7 +71,7 @@ struct B : public A{
|
|||
%inline %{
|
||||
namespace EnumDirector {
|
||||
struct A2{
|
||||
A2(const FType c = NA) {}
|
||||
A2(const FType c = NA_) {}
|
||||
|
||||
virtual ~A2() {}
|
||||
|
||||
|
|
|
|||
|
|
@ -18,6 +18,8 @@ namespace Swig {
|
|||
#endif
|
||||
%}
|
||||
|
||||
// Some director implementations do not have Swig::director
|
||||
#if !defined(SWIGGO)
|
||||
%extend SpObject
|
||||
{
|
||||
size_t ExceptionMethod()
|
||||
|
|
@ -29,7 +31,8 @@ namespace Swig {
|
|||
size_t size = sizeof(Swig::Director);
|
||||
return size;
|
||||
}
|
||||
};
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
%inline %{
|
||||
|
|
|
|||
|
|
@ -1,4 +1,7 @@
|
|||
%module(directors="1") director_finalizer
|
||||
|
||||
%warnfilter(SWIGWARN_GO_NAME_CONFLICT); /* Ignoring 'deleteFoo' due to Go name ('DeleteFoo') conflict with '~Foo' */
|
||||
|
||||
%{
|
||||
|
||||
int status = 0;
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
/* File : example.i */
|
||||
%module dynamic_cast
|
||||
|
||||
#if !defined(SWIGJAVA) && !defined(SWIGCSHARP)
|
||||
#if !defined(SWIGJAVA) && !defined(SWIGCSHARP) && !defined(SWIGGO)
|
||||
%apply SWIGTYPE *DYNAMIC { Foo * };
|
||||
#endif
|
||||
|
||||
|
|
@ -17,7 +17,7 @@ public:
|
|||
};
|
||||
%}
|
||||
|
||||
#if defined(SWIGJAVA) || defined(SWIGCSHARP)
|
||||
#if defined(SWIGJAVA) || defined(SWIGCSHARP) || defined(SWIGGO)
|
||||
%typemap(out) Foo *blah {
|
||||
Bar *downcast = dynamic_cast<Bar *>($1);
|
||||
*(Bar **)&$result = downcast;
|
||||
|
|
@ -37,6 +37,14 @@ public:
|
|||
}
|
||||
#endif
|
||||
|
||||
#if defined(SWIGGO)
|
||||
%insert(go_runtime) %{
|
||||
func FooToBar(f Foo) Bar {
|
||||
return SwigcptrBar(f.Swigcptr())
|
||||
}
|
||||
%}
|
||||
#endif
|
||||
|
||||
%inline %{
|
||||
|
||||
class Bar : public Foo {
|
||||
|
|
@ -54,7 +62,7 @@ char *do_test(Bar *b) {
|
|||
}
|
||||
%}
|
||||
|
||||
#if !defined(SWIGJAVA) && !defined(SWIGCSHARP)
|
||||
#if !defined(SWIGJAVA) && !defined(SWIGCSHARP) && !defined(SWIGGO)
|
||||
// A general purpose function for dynamic casting of a Foo *
|
||||
%{
|
||||
static swig_type_info *
|
||||
|
|
|
|||
12
Examples/test-suite/enum_rename.i
Normal file
12
Examples/test-suite/enum_rename.i
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
%module enum_rename
|
||||
|
||||
%warnfilter(SWIGWARN_PARSE_REDEFINED) S_May;
|
||||
|
||||
// %rename with rxspencer can do the equivalent of these two renames, which was resulting in uncompileable code
|
||||
%rename(May) M_May;
|
||||
%rename(May) S_May;
|
||||
|
||||
%inline %{
|
||||
enum Month { M_Jan, M_May, M_Dec };
|
||||
enum Severity { S_May, S_Can, S_Must };
|
||||
%}
|
||||
|
|
@ -43,6 +43,8 @@
|
|||
%warnfilter(SWIGWARN_RUBY_WRONG_NAME) Instances::memberinstance2;
|
||||
%warnfilter(SWIGWARN_RUBY_WRONG_NAME) Instances::memberinstance3;
|
||||
|
||||
%warnfilter(SWIGWARN_GO_NAME_CONFLICT); /* Ignoring 'one' due to Go name ('ObscureOne') conflict with 'Obscure::One' */
|
||||
|
||||
%inline %{
|
||||
|
||||
enum { AnonEnum1, AnonEnum2 = 100 };
|
||||
|
|
|
|||
|
|
@ -90,8 +90,8 @@ enum Exclamation {
|
|||
|
||||
enum ContainYourself {
|
||||
slap = 10,
|
||||
my,
|
||||
mine,
|
||||
thigh
|
||||
} Slap = slap, My = my, Thigh = thigh, *pThigh = &Thigh, arrayContainYourself[3] = {slap, my, thigh};
|
||||
} Slap = slap, Mine = mine, Thigh = thigh, *pThigh = &Thigh, arrayContainYourself[3] = {slap, mine, thigh};
|
||||
%}
|
||||
|
||||
|
|
|
|||
10
Examples/test-suite/expressions.i
Normal file
10
Examples/test-suite/expressions.i
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
%module expressions
|
||||
|
||||
%inline %{
|
||||
struct A
|
||||
{
|
||||
A() : k( 20/(5-1) ) {}
|
||||
A(int i) : k( 20/(5-1)*i /* comment */ ) {}
|
||||
int k;
|
||||
};
|
||||
%}
|
||||
|
|
@ -1,5 +1,5 @@
|
|||
%module extend_template
|
||||
%module xxx
|
||||
%module xxx // should be ignored
|
||||
namespace oss { // this doesn't
|
||||
%extend Foo<0> {
|
||||
int test1(int x) { return x; }
|
||||
|
|
|
|||
16
Examples/test-suite/funcptr_cpp.i
Normal file
16
Examples/test-suite/funcptr_cpp.i
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
%module funcptr_cpp
|
||||
|
||||
%inline %{
|
||||
|
||||
int addByValue(const int &a, int b) { return a+b; }
|
||||
int * addByPointer(const int &a, int b) { static int val; val = a+b; return &val; }
|
||||
int & addByReference(const int &a, int b) { static int val; val = a+b; return val; }
|
||||
|
||||
int call1(int (*d)(const int &, int), int a, int b) { return d(a, b); }
|
||||
int call2(int * (*d)(const int &, int), int a, int b) { return *d(a, b); }
|
||||
int call3(int & (*d)(const int &, int), int a, int b) { return d(a, b); }
|
||||
%}
|
||||
|
||||
%constant int (*ADD_BY_VALUE)(const int &, int) = addByValue;
|
||||
%constant int * (*ADD_BY_POINTER)(const int &, int) = addByPointer;
|
||||
%constant int & (*ADD_BY_REFERENCE)(const int &, int) = addByReference;
|
||||
|
|
@ -11,8 +11,8 @@ class Klass6 {};
|
|||
class Klass7 {};
|
||||
|
||||
struct KlassMethods {
|
||||
static void methodA(::Klass1 v, const ::Klass2 cv, const ::Klass3 *cp, ::Klass4 *p, const ::Klass5 &cr, ::Klass6 &r, ::Klass7*& pr) {}
|
||||
static void methodB( Klass1 v, const Klass2 cv, const Klass3 *cp, Klass4 *p, const Klass5 &cr, Klass6 &r, Klass7*& pr) {}
|
||||
static void methodA(::Klass1 v, const ::Klass2 cv, const ::Klass3 *cp, ::Klass4 *p, const ::Klass5 &cr, ::Klass6 &r, ::Klass7*const& pr) {}
|
||||
static void methodB( Klass1 v, const Klass2 cv, const Klass3 *cp, Klass4 *p, const Klass5 &cr, Klass6 &r, Klass7*const& pr) {}
|
||||
};
|
||||
%}
|
||||
|
||||
|
|
@ -28,8 +28,8 @@ class XYZ7 {};
|
|||
}
|
||||
|
||||
struct XYZMethods {
|
||||
static void methodA(::Space::XYZ1 v, const ::Space::XYZ2 cv, const ::Space::XYZ3 *cp, ::Space::XYZ4 *p, const ::Space::XYZ5 &cr, ::Space::XYZ6 &r, ::Space::XYZ7*& pr) {}
|
||||
static void methodB( Space::XYZ1 v, const Space::XYZ2 cv, const Space::XYZ3 *cp, Space::XYZ4 *p, const Space::XYZ5 &cr, Space::XYZ6 &r, Space::XYZ7*& pr) {}
|
||||
static void methodA(::Space::XYZ1 v, const ::Space::XYZ2 cv, const ::Space::XYZ3 *cp, ::Space::XYZ4 *p, const ::Space::XYZ5 &cr, ::Space::XYZ6 &r, ::Space::XYZ7*const& pr) {}
|
||||
static void methodB( Space::XYZ1 v, const Space::XYZ2 cv, const Space::XYZ3 *cp, Space::XYZ4 *p, const Space::XYZ5 &cr, Space::XYZ6 &r, Space::XYZ7*const& pr) {}
|
||||
};
|
||||
%}
|
||||
|
||||
|
|
|
|||
|
|
@ -39,6 +39,6 @@ namespace Spac {
|
|||
|
||||
}
|
||||
|
||||
void funcptrtest( void (*)(::Dingaling) ) {}
|
||||
extern "C" void funcptrtest( void (*)(::Dingaling) ) {}
|
||||
%}
|
||||
|
||||
|
|
|
|||
94
Examples/test-suite/go/Makefile.in
Normal file
94
Examples/test-suite/go/Makefile.in
Normal file
|
|
@ -0,0 +1,94 @@
|
|||
#######################################################################
|
||||
# Makefile for Go test-suite
|
||||
#######################################################################
|
||||
|
||||
LANGUAGE = go
|
||||
GO = @GO@
|
||||
GOGCC = false
|
||||
SCRIPTSUFFIX = _runme.go
|
||||
|
||||
GOCOMPILEARG = `if $(GOGCC) ; then echo -c -g; fi`
|
||||
GOC = $(GO:g=c)
|
||||
GOLD = $(GO:g=l)
|
||||
|
||||
GOOBJEXT = $(GO:g=)
|
||||
|
||||
SO = @SO@
|
||||
|
||||
srcdir = @srcdir@
|
||||
top_srcdir = @top_srcdir@
|
||||
top_builddir = @top_builddir@
|
||||
|
||||
include $(srcdir)/../common.mk
|
||||
|
||||
.SUFFIXES: .cpptest .ctest .multicpptest
|
||||
|
||||
# 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_multi_testcase)
|
||||
|
||||
multi_import.multicpptest:
|
||||
$(setup)
|
||||
for f in multi_import_b multi_import_a; do \
|
||||
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile CXXSRCS="$(CXXSRCS)" \
|
||||
SWIG_LIB="$(SWIG_LIB)" SWIG="$(SWIG)" LIBS='$(LIBS)' \
|
||||
INCLUDES="$(INCLUDES)" SWIGOPT="$(SWIGOPT)" NOLINK=true \
|
||||
TARGET="$(TARGETPREFIX)$${f}$(TARGETSUFFIX)" INTERFACEDIR="$(INTERFACEDIR)" INTERFACE="$$f.i" \
|
||||
$(LANGUAGE)$(VARIANT)_cpp; \
|
||||
done
|
||||
$(run_multi_testcase)
|
||||
|
||||
# Runs the testcase.
|
||||
run_testcase = \
|
||||
if test -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); then \
|
||||
$(COMPILETOOL) $(GO) -I . $(GOCOMPILEARG) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \
|
||||
if $(GOGCC) ; then \
|
||||
$(COMPILETOOL) $(GO) -o $*_runme $(SCRIPTPREFIX)$*_runme.@OBJEXT@ $*.@OBJEXT@ $*$(SO); \
|
||||
else \
|
||||
$(COMPILETOOL) $(GOLD) -L . -r $${GOROOT}/pkg/$${GOOS}_$${GOARCH}:. -o $*_runme $(SCRIPTPREFIX)$*_runme.$(GOOBJEXT); \
|
||||
fi && \
|
||||
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) ./$*_runme; \
|
||||
fi
|
||||
|
||||
run_multi_testcase = \
|
||||
if test -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); then \
|
||||
$(COMPILETOOL) $(GO) -I . $(GOCOMPILEARG) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) && \
|
||||
if $(GOGCC) ; then \
|
||||
files=`cat $(top_srcdir)/$(EXAMPLES)/$(TEST_SUITE)/$*.list`; \
|
||||
$(COMPILETOOL) $(GO) -o $*_runme $(SCRIPTPREFIX)$*_runme.@OBJEXT@ `for f in $$files; do echo $$f.@OBJEXT@ $$f$(SO); done`; \
|
||||
else \
|
||||
$(COMPILETOOL) $(GOLD) -L . -r $${GOROOT}/pkg/$${GOOS}_$${GOARCH}:. -o $*_runme $(SCRIPTPREFIX)$*_runme.$(GOOBJEXT); \
|
||||
fi && \
|
||||
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) ./$*_runme; \
|
||||
fi
|
||||
|
||||
%.clean:
|
||||
@rm -f $*.go $*_gc.c $*_wrap.* $*_runme
|
||||
|
||||
clean:
|
||||
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile go_clean
|
||||
rm -f mod_a.go mod_b.go imports_a.go imports_b.go
|
||||
rm -f clientdata_prop_a.go clientdata_prop_b.go
|
||||
rm -f multi_import_a.go multi_import_b.go
|
||||
rm -f packageoption_a.go packageoption_b.go packageoption_c.go
|
||||
|
||||
cvsignore:
|
||||
@echo '*_gc.c *_wrap.* *.so *.dll *.exp *.lib'
|
||||
@echo Makefile
|
||||
@echo mod_a.go mod_b.go imports_a.go imports_b.go
|
||||
@echo clientdata_prop_a.go clientdata_prop_b.go
|
||||
@echo multi_import_a.go multi_import_b.go
|
||||
@echo packageoption_a.go packageoption_b.go packageoption_c.go
|
||||
@for i in ${CPP_TEST_CASES} ${C_TEST_CASES}; do echo $$i.go; done
|
||||
10
Examples/test-suite/go/abstract_access_runme.go
Normal file
10
Examples/test-suite/go/abstract_access_runme.go
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
package main
|
||||
|
||||
import "./abstract_access"
|
||||
|
||||
func main() {
|
||||
d := abstract_access.NewD()
|
||||
if d.Do_x() != 1 {
|
||||
panic(d.Do_x())
|
||||
}
|
||||
}
|
||||
7
Examples/test-suite/go/abstract_typedef2_runme.go
Normal file
7
Examples/test-suite/go/abstract_typedef2_runme.go
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
package main
|
||||
|
||||
import "./abstract_typedef2"
|
||||
|
||||
func main() {
|
||||
abstract_typedef2.NewA_UF()
|
||||
}
|
||||
11
Examples/test-suite/go/abstract_typedef_runme.go
Normal file
11
Examples/test-suite/go/abstract_typedef_runme.go
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
package main
|
||||
|
||||
import "./abstract_typedef"
|
||||
|
||||
func main() {
|
||||
e := abstract_typedef.NewEngine()
|
||||
a := abstract_typedef.NewA()
|
||||
if !a.Write(e) {
|
||||
panic("failed")
|
||||
}
|
||||
}
|
||||
8
Examples/test-suite/go/abstract_virtual_runme.go
Normal file
8
Examples/test-suite/go/abstract_virtual_runme.go
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
package main
|
||||
|
||||
import "./abstract_virtual"
|
||||
|
||||
func main() {
|
||||
abstract_virtual.NewD()
|
||||
abstract_virtual.NewE()
|
||||
}
|
||||
26
Examples/test-suite/go/array_member_runme.go
Normal file
26
Examples/test-suite/go/array_member_runme.go
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
package main
|
||||
|
||||
import . "./array_member"
|
||||
|
||||
func main() {
|
||||
f := NewFoo()
|
||||
f.SetData(GetGlobal_data())
|
||||
|
||||
for i := 0; i < 8; i++ {
|
||||
if Get_value(f.GetData(), i) != Get_value(GetGlobal_data(), i) {
|
||||
panic("Bad array assignment")
|
||||
}
|
||||
}
|
||||
|
||||
for i := 0; i < 8; i++ {
|
||||
Set_value(f.GetData(), i, -i)
|
||||
}
|
||||
|
||||
SetGlobal_data(f.GetData())
|
||||
|
||||
for i := 0; i < 8; i++ {
|
||||
if Get_value(f.GetData(), i) != Get_value(GetGlobal_data(), i) {
|
||||
panic("Bad array assignment")
|
||||
}
|
||||
}
|
||||
}
|
||||
22
Examples/test-suite/go/arrays_global_runme.go
Normal file
22
Examples/test-suite/go/arrays_global_runme.go
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
package main
|
||||
|
||||
import . "./arrays_global"
|
||||
|
||||
func main() {
|
||||
SetArray_i(GetArray_const_i())
|
||||
|
||||
GetBeginString_FIX44a()
|
||||
GetBeginString_FIX44b()
|
||||
GetBeginString_FIX44c()
|
||||
GetBeginString_FIX44d()
|
||||
GetBeginString_FIX44d()
|
||||
SetBeginString_FIX44b("12\00045")
|
||||
GetBeginString_FIX44b()
|
||||
GetBeginString_FIX44d()
|
||||
GetBeginString_FIX44e()
|
||||
GetBeginString_FIX44f()
|
||||
|
||||
Test_a("hello", "hi", "chello", "chi")
|
||||
|
||||
Test_b("1234567", "hi")
|
||||
}
|
||||
10
Examples/test-suite/go/class_ignore_runme.go
Normal file
10
Examples/test-suite/go/class_ignore_runme.go
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
package main
|
||||
|
||||
import "./class_ignore"
|
||||
|
||||
func main() {
|
||||
a := class_ignore.NewBar()
|
||||
if class_ignore.Do_blah(a) != "Bar::blah" {
|
||||
panic(class_ignore.Do_blah(a))
|
||||
}
|
||||
}
|
||||
11
Examples/test-suite/go/class_scope_weird_runme.go
Normal file
11
Examples/test-suite/go/class_scope_weird_runme.go
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
package main
|
||||
|
||||
import "./class_scope_weird"
|
||||
|
||||
func main() {
|
||||
f := class_scope_weird.NewFoo()
|
||||
class_scope_weird.NewFoo(3)
|
||||
if f.Bar(3) != 3 {
|
||||
panic(f.Bar(3))
|
||||
}
|
||||
}
|
||||
29
Examples/test-suite/go/compactdefaultargs_runme.go
Normal file
29
Examples/test-suite/go/compactdefaultargs_runme.go
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
package main
|
||||
|
||||
import . "./compactdefaultargs"
|
||||
|
||||
func main() {
|
||||
defaults1 := NewDefaults1(1000)
|
||||
defaults1 = NewDefaults1()
|
||||
|
||||
if defaults1.Ret(float64(10.0)) != 10.0 {
|
||||
println(1, defaults1.Ret(float64(10.0)))
|
||||
panic(defaults1.Ret(float64(10.0)))
|
||||
}
|
||||
|
||||
if defaults1.Ret() != -1.0 {
|
||||
println(2, defaults1.Ret())
|
||||
panic(defaults1.Ret())
|
||||
}
|
||||
|
||||
defaults2 := NewDefaults2(1000)
|
||||
defaults2 = NewDefaults2()
|
||||
|
||||
if defaults2.Ret(float64(10.0)) != 10.0 {
|
||||
panic(defaults2.Ret(float64(10.0)))
|
||||
}
|
||||
|
||||
if defaults2.Ret() != -1.0 {
|
||||
panic(defaults2.Ret())
|
||||
}
|
||||
}
|
||||
50
Examples/test-suite/go/constover_runme.go
Normal file
50
Examples/test-suite/go/constover_runme.go
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"os"
|
||||
"./constover"
|
||||
)
|
||||
|
||||
func main() {
|
||||
error := 0
|
||||
|
||||
p := constover.Test("test")
|
||||
if p != "test" {
|
||||
fmt.Println("test failed!")
|
||||
error = 1
|
||||
}
|
||||
|
||||
p = constover.Test_pconst("test")
|
||||
if p != "test_pconst" {
|
||||
fmt.Println("test_pconst failed!")
|
||||
error = 1
|
||||
}
|
||||
|
||||
f := constover.NewFoo()
|
||||
p = f.Test("test")
|
||||
if p != "test" {
|
||||
fmt.Println("member-test failed!")
|
||||
error = 1
|
||||
}
|
||||
|
||||
p = f.Test_pconst("test")
|
||||
if p != "test_pconst" {
|
||||
fmt.Println("member-test_pconst failed!")
|
||||
error = 1
|
||||
}
|
||||
|
||||
p = f.Test_constm("test")
|
||||
if p != "test_constmethod" {
|
||||
fmt.Println("member-test_constm failed!")
|
||||
error = 1
|
||||
}
|
||||
|
||||
p = f.Test_pconstm("test")
|
||||
if p != "test_pconstmethod" {
|
||||
fmt.Println("member-test_pconstm failed!")
|
||||
error = 1
|
||||
}
|
||||
|
||||
os.Exit(error)
|
||||
}
|
||||
34
Examples/test-suite/go/constructor_copy_runme.go
Normal file
34
Examples/test-suite/go/constructor_copy_runme.go
Normal file
|
|
@ -0,0 +1,34 @@
|
|||
package main
|
||||
|
||||
import . "./constructor_copy"
|
||||
|
||||
func main() {
|
||||
f1 := NewFoo1(3)
|
||||
f11 := NewFoo1(f1)
|
||||
|
||||
if f1.GetX() != f11.GetX() {
|
||||
panic("f1/f11 x mismatch")
|
||||
}
|
||||
|
||||
bi := NewBari(5)
|
||||
bc := NewBari(bi)
|
||||
|
||||
if bi.GetX() != bc.GetX() {
|
||||
panic("bi/bc x mismatch")
|
||||
}
|
||||
|
||||
bd := NewBard(5)
|
||||
good := false
|
||||
func() {
|
||||
defer func() {
|
||||
if recover() != nil {
|
||||
good = true
|
||||
}
|
||||
}()
|
||||
NewBard(bd)
|
||||
}()
|
||||
|
||||
if !good {
|
||||
panic("bd !good")
|
||||
}
|
||||
}
|
||||
208
Examples/test-suite/go/contract_runme.go
Normal file
208
Examples/test-suite/go/contract_runme.go
Normal file
|
|
@ -0,0 +1,208 @@
|
|||
package main
|
||||
|
||||
import "./contract"
|
||||
|
||||
func main() {
|
||||
contract.Test_preassert(1, 2)
|
||||
contract.Test_postassert(3)
|
||||
func() {
|
||||
defer func() {
|
||||
if recover() == nil {
|
||||
panic("Failed! Postassertions are broken")
|
||||
}
|
||||
}()
|
||||
contract.Test_postassert(-3)
|
||||
}()
|
||||
|
||||
contract.Test_prepost(2, 3)
|
||||
contract.Test_prepost(5, -4)
|
||||
func() {
|
||||
defer func() {
|
||||
if recover() == nil {
|
||||
panic("Failed! Preassertions are broken")
|
||||
}
|
||||
}()
|
||||
contract.Test_prepost(-3, 4)
|
||||
}()
|
||||
|
||||
func() {
|
||||
defer func() {
|
||||
if recover() == nil {
|
||||
panic("Failed! Postassertions are broken")
|
||||
}
|
||||
}()
|
||||
contract.Test_prepost(4, -10)
|
||||
}()
|
||||
|
||||
f := contract.NewFoo()
|
||||
f.Test_preassert(4, 5)
|
||||
func() {
|
||||
defer func() {
|
||||
if recover() == nil {
|
||||
panic("Failed! Method preassertion.")
|
||||
}
|
||||
}()
|
||||
f.Test_preassert(-2, 3)
|
||||
}()
|
||||
|
||||
f.Test_postassert(4)
|
||||
func() {
|
||||
defer func() {
|
||||
if recover() == nil {
|
||||
panic("Failed! Method postassertion")
|
||||
}
|
||||
}()
|
||||
f.Test_postassert(-4)
|
||||
}()
|
||||
|
||||
f.Test_prepost(3, 4)
|
||||
f.Test_prepost(4, -3)
|
||||
func() {
|
||||
defer func() {
|
||||
if recover() == nil {
|
||||
panic("Failed! Method preassertion.")
|
||||
}
|
||||
}()
|
||||
f.Test_prepost(-4, 2)
|
||||
}()
|
||||
|
||||
func() {
|
||||
defer func() {
|
||||
if recover() == nil {
|
||||
panic("Failed! Method postassertion.")
|
||||
}
|
||||
}()
|
||||
f.Test_prepost(4, -10)
|
||||
}()
|
||||
|
||||
contract.FooStest_prepost(4, 0)
|
||||
func() {
|
||||
defer func() {
|
||||
if recover() == nil {
|
||||
panic("Failed! Static method preassertion")
|
||||
}
|
||||
}()
|
||||
contract.FooStest_prepost(-4, 2)
|
||||
}()
|
||||
|
||||
func() {
|
||||
defer func() {
|
||||
if recover() == nil {
|
||||
panic("Failed! Static method posteassertion")
|
||||
}
|
||||
}()
|
||||
contract.FooStest_prepost(4, -10)
|
||||
}()
|
||||
|
||||
b := contract.NewBar()
|
||||
func() {
|
||||
defer func() {
|
||||
if recover() == nil {
|
||||
panic("Failed! Inherited preassertion.")
|
||||
}
|
||||
}()
|
||||
b.Test_prepost(2, -4)
|
||||
}()
|
||||
|
||||
d := contract.NewD()
|
||||
func() {
|
||||
defer func() {
|
||||
if recover() == nil {
|
||||
panic("Failed! Inherited preassertion (D).")
|
||||
}
|
||||
}()
|
||||
d.Foo(-1, 1, 1, 1, 1)
|
||||
}()
|
||||
|
||||
func() {
|
||||
defer func() {
|
||||
if recover() == nil {
|
||||
panic("Failed! Inherited preassertion (D).")
|
||||
}
|
||||
}()
|
||||
d.Foo(1, -1, 1, 1, 1)
|
||||
}()
|
||||
|
||||
func() {
|
||||
defer func() {
|
||||
if recover() == nil {
|
||||
panic("Failed! Inherited preassertion (D).")
|
||||
}
|
||||
}()
|
||||
d.Foo(1, 1, -1, 1, 1)
|
||||
}()
|
||||
|
||||
func() {
|
||||
defer func() {
|
||||
if recover() == nil {
|
||||
panic("Failed! Inherited preassertion (D).")
|
||||
}
|
||||
}()
|
||||
d.Foo(1, 1, 1, -1, 1)
|
||||
}()
|
||||
|
||||
func() {
|
||||
defer func() {
|
||||
if recover() == nil {
|
||||
panic("Failed! Inherited preassertion (D).")
|
||||
}
|
||||
}()
|
||||
d.Foo(1, 1, 1, 1, -1)
|
||||
}()
|
||||
|
||||
func() {
|
||||
defer func() {
|
||||
if recover() == nil {
|
||||
panic("Failed! Inherited preassertion (D).")
|
||||
}
|
||||
}()
|
||||
d.Bar(-1, 1, 1, 1, 1)
|
||||
}()
|
||||
|
||||
func() {
|
||||
defer func() {
|
||||
if recover() == nil {
|
||||
panic("Failed! Inherited preassertion (D).")
|
||||
}
|
||||
}()
|
||||
d.Bar(1, -1, 1, 1, 1)
|
||||
}()
|
||||
|
||||
func() {
|
||||
defer func() {
|
||||
if recover() == nil {
|
||||
panic("Failed! Inherited preassertion (D).")
|
||||
}
|
||||
}()
|
||||
d.Bar(1, 1, -1, 1, 1)
|
||||
}()
|
||||
|
||||
func() {
|
||||
defer func() {
|
||||
if recover() == nil {
|
||||
panic("Failed! Inherited preassertion (D).")
|
||||
}
|
||||
}()
|
||||
d.Bar(1, 1, 1, -1, 1)
|
||||
}()
|
||||
|
||||
func() {
|
||||
defer func() {
|
||||
if recover() == nil {
|
||||
panic("Failed! Inherited preassertion (D).")
|
||||
}
|
||||
}()
|
||||
d.Bar(1, 1, 1, 1, -1)
|
||||
}()
|
||||
|
||||
//Namespace
|
||||
my := contract.NewMyClass(1)
|
||||
func() {
|
||||
defer func() {
|
||||
if recover() == nil {
|
||||
panic("Failed! constructor preassertion")
|
||||
}
|
||||
}()
|
||||
my = contract.NewMyClass(0)
|
||||
}()
|
||||
}
|
||||
27
Examples/test-suite/go/cpp_enum_runme.go
Normal file
27
Examples/test-suite/go/cpp_enum_runme.go
Normal file
|
|
@ -0,0 +1,27 @@
|
|||
package main
|
||||
|
||||
import "./cpp_enum"
|
||||
|
||||
func main() {
|
||||
f := cpp_enum.NewFoo()
|
||||
|
||||
if f.GetHola() != cpp_enum.FooHello {
|
||||
panic(f.GetHola())
|
||||
}
|
||||
|
||||
f.SetHola(cpp_enum.FooHi)
|
||||
if f.GetHola() != cpp_enum.FooHi {
|
||||
panic(f.GetHola())
|
||||
}
|
||||
|
||||
f.SetHola(cpp_enum.FooHello)
|
||||
|
||||
if f.GetHola() != cpp_enum.FooHello {
|
||||
panic(f.GetHola())
|
||||
}
|
||||
|
||||
cpp_enum.SetHi(cpp_enum.Hello)
|
||||
if cpp_enum.GetHi() != cpp_enum.Hello {
|
||||
panic(cpp_enum.Hi)
|
||||
}
|
||||
}
|
||||
57
Examples/test-suite/go/cpp_namespace_runme.go
Normal file
57
Examples/test-suite/go/cpp_namespace_runme.go
Normal file
|
|
@ -0,0 +1,57 @@
|
|||
// Note: This example assumes that namespaces are flattened
|
||||
package main
|
||||
|
||||
import "./cpp_namespace"
|
||||
|
||||
func main() {
|
||||
n := cpp_namespace.Fact(4)
|
||||
if n != 24 {
|
||||
panic("Bad return value!")
|
||||
}
|
||||
|
||||
if cpp_namespace.GetFoo() != 42 {
|
||||
panic("Bad variable value!")
|
||||
}
|
||||
|
||||
t := cpp_namespace.NewTest()
|
||||
if t.Method() != "Test::method" {
|
||||
panic("Bad method return value!")
|
||||
}
|
||||
|
||||
if cpp_namespace.Do_method(t) != "Test::method" {
|
||||
panic("Bad return value!")
|
||||
}
|
||||
|
||||
if cpp_namespace.Do_method2(t) != "Test::method" {
|
||||
panic("Bad return value!")
|
||||
}
|
||||
|
||||
cpp_namespace.Weird("hello", 4)
|
||||
|
||||
cpp_namespace.DeleteTest(t)
|
||||
|
||||
t2 := cpp_namespace.NewTest2()
|
||||
t3 := cpp_namespace.NewTest3()
|
||||
t4 := cpp_namespace.NewTest4()
|
||||
t5 := cpp_namespace.NewTest5()
|
||||
|
||||
if cpp_namespace.Foo3(42) != 42 {
|
||||
panic("Bad return value!")
|
||||
}
|
||||
|
||||
if cpp_namespace.Do_method3(t2, 40) != "Test2::method" {
|
||||
panic("Bad return value!")
|
||||
}
|
||||
|
||||
if cpp_namespace.Do_method3(t3, 40) != "Test3::method" {
|
||||
panic("Bad return value!")
|
||||
}
|
||||
|
||||
if cpp_namespace.Do_method3(t4, 40) != "Test4::method" {
|
||||
panic("Bad return value!")
|
||||
}
|
||||
|
||||
if cpp_namespace.Do_method3(t5, 40) != "Test5::method" {
|
||||
panic("Bad return value!")
|
||||
}
|
||||
}
|
||||
13
Examples/test-suite/go/cpp_static_runme.go
Normal file
13
Examples/test-suite/go/cpp_static_runme.go
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
package main
|
||||
|
||||
import . "./cpp_static"
|
||||
|
||||
func main() {
|
||||
StaticFunctionTestStatic_func()
|
||||
StaticFunctionTestStatic_func_2(1)
|
||||
StaticFunctionTestStatic_func_3(1, 2)
|
||||
SetStaticMemberTestStatic_int(10)
|
||||
if GetStaticMemberTestStatic_int() != 10 {
|
||||
panic(GetStaticMemberTestStatic_int())
|
||||
}
|
||||
}
|
||||
26
Examples/test-suite/go/default_args_runme.go
Normal file
26
Examples/test-suite/go/default_args_runme.go
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
package main
|
||||
|
||||
import "./default_args"
|
||||
|
||||
func main() {
|
||||
if default_args.StaticsStaticmethod() != 60 {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
if default_args.Cfunc1(1) != 2 {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
if default_args.Cfunc2(1) != 3 {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
if default_args.Cfunc3(1) != 4 {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
f := default_args.NewFoo()
|
||||
|
||||
f.Newname()
|
||||
f.Newname(1)
|
||||
}
|
||||
35
Examples/test-suite/go/default_constructor_runme.go
Normal file
35
Examples/test-suite/go/default_constructor_runme.go
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
package main
|
||||
|
||||
import dc "./default_constructor"
|
||||
|
||||
func main() {
|
||||
a := dc.NewA()
|
||||
dc.DeleteA(a)
|
||||
|
||||
aa := dc.NewAA()
|
||||
dc.DeleteAA(aa)
|
||||
|
||||
cc := dc.NewCC()
|
||||
dc.DeleteCC(cc)
|
||||
|
||||
e := dc.NewE()
|
||||
dc.DeleteE(e)
|
||||
|
||||
ee := dc.NewEE()
|
||||
dc.DeleteEE(ee)
|
||||
|
||||
f := dc.NewF()
|
||||
f.Destroy()
|
||||
|
||||
ff := dc.NewFFF()
|
||||
ff.Destroy()
|
||||
|
||||
g := dc.NewG()
|
||||
|
||||
dc.GDestroy(g)
|
||||
|
||||
gg := dc.NewGG()
|
||||
dc.DeleteGG(gg)
|
||||
|
||||
dc.NewHH(1, 1)
|
||||
}
|
||||
62
Examples/test-suite/go/director_abstract_runme.go
Normal file
62
Examples/test-suite/go/director_abstract_runme.go
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
package main
|
||||
|
||||
import "./director_abstract"
|
||||
|
||||
type MyFoo struct{}
|
||||
|
||||
func (p *MyFoo) Ping() string {
|
||||
return "MyFoo::ping()"
|
||||
}
|
||||
|
||||
func f1() {
|
||||
a := director_abstract.NewDirectorFoo(&MyFoo{})
|
||||
|
||||
if a.Ping() != "MyFoo::ping()" {
|
||||
panic(a.Ping())
|
||||
}
|
||||
|
||||
if a.Pong() != "Foo::pong();MyFoo::ping()" {
|
||||
panic(a.Pong())
|
||||
}
|
||||
}
|
||||
|
||||
type MyExample1 struct{}
|
||||
|
||||
func (p *MyExample1) Color(r, g, b byte) int {
|
||||
return int(r)
|
||||
}
|
||||
|
||||
type MyExample2 struct{}
|
||||
|
||||
func (p *MyExample2) Color(r, g, b byte) int {
|
||||
return int(g)
|
||||
}
|
||||
|
||||
type MyExample3 struct{}
|
||||
|
||||
func (p *MyExample3) Color(r, g, b byte) int {
|
||||
return int(b)
|
||||
}
|
||||
|
||||
func f2() {
|
||||
me1 := director_abstract.NewDirectorExample1(&MyExample1{})
|
||||
if director_abstract.Example1Get_color(me1, 1, 2, 3) != 1 {
|
||||
println(director_abstract.Example1Get_color(me1, 1, 2, 3))
|
||||
panic(0)
|
||||
}
|
||||
|
||||
me2 := director_abstract.NewDirectorExample2(&MyExample2{}, 1, 2)
|
||||
if director_abstract.Example2Get_color(me2, 1, 2, 3) != 2 {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
me3 := director_abstract.NewDirectorExample3_i(&MyExample3{})
|
||||
if director_abstract.Example3_iGet_color(me3, 1, 2, 3) != 3 {
|
||||
panic(0)
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
f1()
|
||||
f2()
|
||||
}
|
||||
115
Examples/test-suite/go/director_basic_runme.go
Normal file
115
Examples/test-suite/go/director_basic_runme.go
Normal file
|
|
@ -0,0 +1,115 @@
|
|||
package main
|
||||
|
||||
import "./director_basic"
|
||||
|
||||
type GoFoo struct{}
|
||||
|
||||
func (p *GoFoo) Ping() string {
|
||||
return "GoFoo::ping()"
|
||||
}
|
||||
|
||||
func f1() {
|
||||
a := director_basic.NewDirectorFoo(&GoFoo{})
|
||||
|
||||
if a.Ping() != "GoFoo::ping()" {
|
||||
panic(a.Ping())
|
||||
}
|
||||
|
||||
if a.Pong() != "Foo::pong();GoFoo::ping()" {
|
||||
panic(a.Pong())
|
||||
}
|
||||
|
||||
b := director_basic.NewFoo()
|
||||
|
||||
if b.Ping() != "Foo::ping()" {
|
||||
panic(b.Ping())
|
||||
}
|
||||
|
||||
if b.Pong() != "Foo::pong();Foo::ping()" {
|
||||
panic(b.Pong())
|
||||
}
|
||||
|
||||
a1 := director_basic.NewA1(1)
|
||||
|
||||
if a1.Rg(2) != 2 {
|
||||
panic(0)
|
||||
}
|
||||
}
|
||||
|
||||
type GoClass struct {
|
||||
cmethod int
|
||||
}
|
||||
|
||||
func (p *GoClass) Method(uintptr) {
|
||||
p.cmethod = 7
|
||||
}
|
||||
func (p *GoClass) Vmethod(b director_basic.Bar) director_basic.Bar {
|
||||
b.SetX(b.GetX() + 31)
|
||||
return b
|
||||
}
|
||||
|
||||
var bc director_basic.Bar
|
||||
|
||||
func f2() {
|
||||
b := director_basic.NewBar(3)
|
||||
d := director_basic.NewMyClass()
|
||||
pc := &GoClass{0}
|
||||
c := director_basic.NewDirectorMyClass(pc)
|
||||
|
||||
cc := director_basic.MyClassGet_self(c)
|
||||
dd := director_basic.MyClassGet_self(d)
|
||||
|
||||
bc = cc.Cmethod(b)
|
||||
bd := dd.Cmethod(b)
|
||||
|
||||
cc.Method(b.Swigcptr())
|
||||
if pc.cmethod != 7 {
|
||||
panic(pc.cmethod)
|
||||
}
|
||||
|
||||
if bc.GetX() != 34 {
|
||||
panic(bc.GetX())
|
||||
}
|
||||
|
||||
if bd.GetX() != 16 {
|
||||
panic(bd.GetX())
|
||||
}
|
||||
}
|
||||
|
||||
type GoMulti struct {
|
||||
GoClass
|
||||
}
|
||||
|
||||
func (p *GoMulti) Vmethod(b director_basic.Bar) director_basic.Bar {
|
||||
b.SetX(b.GetX() + 31)
|
||||
return b
|
||||
}
|
||||
func (p *GoMulti) Ping() string {
|
||||
return "GoFoo::ping()"
|
||||
}
|
||||
|
||||
func f3() {
|
||||
for i := 0; i < 100; i++ {
|
||||
p := &GoMulti{GoClass{0}}
|
||||
gomult := director_basic.NewDirectorFoo(p)
|
||||
gomult.Pong()
|
||||
director_basic.DeleteDirectorFoo(gomult)
|
||||
}
|
||||
|
||||
p := &GoMulti{GoClass{0}}
|
||||
gomult := director_basic.NewDirectorMyClass(p)
|
||||
fgomult := director_basic.NewDirectorFoo(gomult)
|
||||
|
||||
p1 := director_basic.FooGet_self(fgomult.(director_basic.Foo))
|
||||
p2 := director_basic.MyClassGet_self(gomult.(director_basic.MyClass))
|
||||
|
||||
p1.Ping()
|
||||
p2.Vmethod(bc)
|
||||
}
|
||||
|
||||
|
||||
func main() {
|
||||
f1()
|
||||
f2()
|
||||
f3()
|
||||
}
|
||||
135
Examples/test-suite/go/director_classic_runme.go
Normal file
135
Examples/test-suite/go/director_classic_runme.go
Normal file
|
|
@ -0,0 +1,135 @@
|
|||
package main
|
||||
|
||||
import "fmt"
|
||||
import . "./director_classic"
|
||||
|
||||
type TargetLangPerson struct{} // From Person
|
||||
func (p *TargetLangPerson) Id() string {
|
||||
return "TargetLangPerson"
|
||||
}
|
||||
|
||||
type TargetLangChild struct{} // Form Child
|
||||
func (p *TargetLangChild) Id() string {
|
||||
return "TargetLangChild"
|
||||
}
|
||||
|
||||
type TargetLangGrandChild struct{} // From Grandchild
|
||||
func (p *TargetLangGrandChild) Id() string {
|
||||
return "TargetLangGrandChild"
|
||||
}
|
||||
|
||||
// Semis - don't override id() in target language
|
||||
|
||||
type TargetLangSemiPerson struct{} // From Person
|
||||
|
||||
type TargetLangSemiChild struct{} // From Child
|
||||
|
||||
type TargetLangSemiGrandChild struct{} // From GrandChild
|
||||
|
||||
// Orphans - don't override id() in C++
|
||||
|
||||
type TargetLangOrphanPerson struct{} // From OrphanPerson
|
||||
func (p *TargetLangOrphanPerson) Id() string {
|
||||
return "TargetLangOrphanPerson"
|
||||
}
|
||||
|
||||
type TargetLangOrphanChild struct{} // From OrphanChild
|
||||
func (p *TargetLangOrphanChild) Id() string {
|
||||
return "TargetLangOrphanChild"
|
||||
}
|
||||
|
||||
func check(person Person, expected string) {
|
||||
debug := false
|
||||
|
||||
// Normal target language polymorphic call
|
||||
ret := person.Id()
|
||||
if debug {
|
||||
fmt.Println(ret)
|
||||
}
|
||||
if ret != expected {
|
||||
panic("Failed. Received: " + ret + " Expected: " + expected)
|
||||
}
|
||||
|
||||
// Polymorphic call from C++
|
||||
caller := NewCaller()
|
||||
caller.SetCallback(person)
|
||||
ret = caller.Call()
|
||||
if debug {
|
||||
fmt.Println(ret)
|
||||
}
|
||||
if ret != expected {
|
||||
panic("Failed. Received: " + ret + " Expected: " + expected)
|
||||
}
|
||||
|
||||
// Polymorphic call of object created in target language and
|
||||
// passed to C++ and back again
|
||||
baseclass := caller.BaseClass()
|
||||
ret = baseclass.Id()
|
||||
if debug {
|
||||
fmt.Println(ret)
|
||||
}
|
||||
if ret != expected {
|
||||
panic("Failed. Received: " + ret + " Expected: " + expected)
|
||||
}
|
||||
|
||||
caller.ResetCallback()
|
||||
if debug {
|
||||
fmt.Println("----------------------------------------")
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
person := NewPerson()
|
||||
check(person, "Person")
|
||||
DeletePerson(person)
|
||||
|
||||
person = NewChild()
|
||||
check(person, "Child")
|
||||
DeletePerson(person)
|
||||
|
||||
person = NewGrandChild()
|
||||
check(person, "GrandChild")
|
||||
DeletePerson(person)
|
||||
|
||||
person = NewDirectorPerson(&TargetLangPerson{})
|
||||
check(person, "TargetLangPerson")
|
||||
DeleteDirectorPerson(person)
|
||||
|
||||
person = NewDirectorChild(&TargetLangChild{})
|
||||
check(person, "TargetLangChild")
|
||||
DeleteDirectorChild(person.(Child))
|
||||
|
||||
person = NewDirectorGrandChild(&TargetLangGrandChild{})
|
||||
check(person, "TargetLangGrandChild")
|
||||
DeleteDirectorGrandChild(person.(GrandChild))
|
||||
|
||||
// Semis - don't override id() in target language
|
||||
person = NewDirectorPerson(&TargetLangSemiPerson{})
|
||||
check(person, "Person")
|
||||
DeleteDirectorPerson(person)
|
||||
|
||||
person = NewDirectorChild(&TargetLangSemiChild{})
|
||||
check(person, "Child")
|
||||
DeleteDirectorChild(person.(Child))
|
||||
|
||||
person = NewDirectorGrandChild(&TargetLangSemiGrandChild{})
|
||||
check(person, "GrandChild")
|
||||
DeleteDirectorGrandChild(person.(GrandChild))
|
||||
|
||||
// Orphans - don't override id() in C++
|
||||
person = NewOrphanPerson()
|
||||
check(person, "Person")
|
||||
DeleteOrphanPerson(person.(OrphanPerson))
|
||||
|
||||
person = NewOrphanChild()
|
||||
check(person, "Child")
|
||||
DeleteOrphanChild(person.(OrphanChild))
|
||||
|
||||
person = NewDirectorOrphanPerson(&TargetLangOrphanPerson{})
|
||||
check(person, "TargetLangOrphanPerson")
|
||||
DeleteDirectorOrphanPerson(person.(OrphanPerson))
|
||||
|
||||
person = NewDirectorOrphanChild(&TargetLangOrphanChild{})
|
||||
check(person, "TargetLangOrphanChild")
|
||||
DeleteDirectorOrphanChild(person.(OrphanChild))
|
||||
}
|
||||
11
Examples/test-suite/go/director_default_runme.go
Normal file
11
Examples/test-suite/go/director_default_runme.go
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
package main
|
||||
|
||||
import . "./director_default"
|
||||
|
||||
func main() {
|
||||
NewFoo()
|
||||
NewFoo(1)
|
||||
|
||||
NewBar()
|
||||
NewBar(1)
|
||||
}
|
||||
46
Examples/test-suite/go/director_detect_runme.go
Normal file
46
Examples/test-suite/go/director_detect_runme.go
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
package main
|
||||
|
||||
import "./director_detect"
|
||||
|
||||
type MyBar struct {
|
||||
val int
|
||||
} // From director_detect.Bar
|
||||
|
||||
func NewMyBar() director_detect.Bar {
|
||||
return director_detect.NewDirectorBar(&MyBar{2})
|
||||
}
|
||||
|
||||
func (p *MyBar) Get_value() int {
|
||||
p.val++
|
||||
return p.val
|
||||
}
|
||||
|
||||
func (p *MyBar) Get_class() director_detect.A {
|
||||
p.val++
|
||||
return director_detect.NewA()
|
||||
}
|
||||
|
||||
func (p *MyBar) Just_do_it() {
|
||||
p.val++
|
||||
}
|
||||
|
||||
func (p *MyBar) Clone() director_detect.Bar {
|
||||
return director_detect.NewDirectorBar(&MyBar{p.val})
|
||||
}
|
||||
|
||||
func main() {
|
||||
b := NewMyBar()
|
||||
|
||||
f := b.Baseclass()
|
||||
|
||||
v := f.Get_value()
|
||||
_ = f.Get_class()
|
||||
f.Just_do_it()
|
||||
|
||||
c := b.DirectorInterface().(*MyBar).Clone()
|
||||
vc := c.Get_value()
|
||||
|
||||
if (v != 3) || (b.DirectorInterface().(*MyBar).val != 5) || (vc != 6) {
|
||||
panic("Bad virtual detection")
|
||||
}
|
||||
}
|
||||
17
Examples/test-suite/go/director_enum_runme.go
Normal file
17
Examples/test-suite/go/director_enum_runme.go
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
package main
|
||||
|
||||
import "./director_enum"
|
||||
|
||||
type MyFoo struct{} // From director_enum.Foo
|
||||
func (p *MyFoo) Say_hi(val director_enum.EnumDirectorHello) director_enum.EnumDirectorHello {
|
||||
return val
|
||||
}
|
||||
|
||||
func main() {
|
||||
b := director_enum.NewFoo()
|
||||
a := director_enum.NewDirectorFoo(&MyFoo{})
|
||||
|
||||
if a.Say_hi(director_enum.Hello) != b.Say_hello(director_enum.Hi) {
|
||||
panic(0)
|
||||
}
|
||||
}
|
||||
95
Examples/test-suite/go/director_exception_runme.go
Normal file
95
Examples/test-suite/go/director_exception_runme.go
Normal file
|
|
@ -0,0 +1,95 @@
|
|||
package main
|
||||
|
||||
import . "./director_exception"
|
||||
|
||||
type Exception struct {
|
||||
msg string
|
||||
}
|
||||
|
||||
func NewException(a, b string) *Exception {
|
||||
return &Exception{a + b}
|
||||
}
|
||||
|
||||
type MyFoo struct{} // From Foo
|
||||
func (p *MyFoo) Ping() string {
|
||||
panic("MyFoo::ping() EXCEPTION")
|
||||
}
|
||||
|
||||
type MyFoo2 struct{} // From Foo
|
||||
func (p *MyFoo2) Ping() bool {
|
||||
return true // should return a string
|
||||
}
|
||||
|
||||
type MyFoo3 struct{} // From Foo
|
||||
func (p *MyFoo3) Ping() string {
|
||||
panic(NewException("foo", "bar"))
|
||||
}
|
||||
|
||||
func main() {
|
||||
// Check that the NotImplementedError raised by MyFoo.ping()
|
||||
// is returned by MyFoo.pong().
|
||||
ok := false
|
||||
a := NewDirectorFoo(&MyFoo{})
|
||||
b := Launder(a)
|
||||
func() {
|
||||
defer func() {
|
||||
e := recover()
|
||||
if e.(string) == "MyFoo::ping() EXCEPTION" {
|
||||
ok = true
|
||||
} else {
|
||||
panic("Unexpected error message: " + e.(string))
|
||||
}
|
||||
}()
|
||||
b.Pong()
|
||||
}()
|
||||
if !ok {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
// Check that if the method has the wrong return type it is
|
||||
// not called.
|
||||
ok = false
|
||||
a = NewDirectorFoo(&MyFoo2{})
|
||||
b = Launder(a)
|
||||
e := b.Pong()
|
||||
if e != "Foo::pong();"+"Foo::ping()" {
|
||||
panic(e)
|
||||
}
|
||||
|
||||
// Check that the director can return an exception which
|
||||
// requires two arguments to the constructor, without mangling
|
||||
// it.
|
||||
ok = false
|
||||
a = NewDirectorFoo(&MyFoo3{})
|
||||
b = Launder(a)
|
||||
func() {
|
||||
defer func() {
|
||||
e := recover()
|
||||
if e.(*Exception).msg == "foobar" {
|
||||
ok = true
|
||||
} else {
|
||||
panic("Unexpected error message: " + e.(string))
|
||||
}
|
||||
}()
|
||||
b.Pong()
|
||||
}()
|
||||
if !ok {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
func() {
|
||||
defer func() {
|
||||
e := recover()
|
||||
_ = e.(Exception2)
|
||||
}()
|
||||
panic(NewException2())
|
||||
}()
|
||||
|
||||
func() {
|
||||
defer func() {
|
||||
e := recover()
|
||||
_ = e.(Exception1)
|
||||
}()
|
||||
panic(NewException1())
|
||||
}()
|
||||
}
|
||||
18
Examples/test-suite/go/director_extend_runme.go
Normal file
18
Examples/test-suite/go/director_extend_runme.go
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
// Test case from bug #1506850 "When threading is enabled, the
|
||||
// interpreter will infinitely wait on a mutex the second time this
|
||||
// type of extended method is called. Attached is an example program
|
||||
// that waits on the mutex to be unlocked."
|
||||
|
||||
package main
|
||||
|
||||
import . "./director_extend"
|
||||
|
||||
func main() {
|
||||
m := NewSpObject()
|
||||
if m.Dummy() != 666 {
|
||||
panic("1st call")
|
||||
}
|
||||
if m.Dummy() != 666 {
|
||||
panic("2nd call")
|
||||
}
|
||||
}
|
||||
37
Examples/test-suite/go/director_finalizer_runme.go
Normal file
37
Examples/test-suite/go/director_finalizer_runme.go
Normal file
|
|
@ -0,0 +1,37 @@
|
|||
package main
|
||||
|
||||
import . "./director_finalizer"
|
||||
|
||||
type MyFoo struct{} // From Foo
|
||||
func DeleteMyFoo(p Foo) {
|
||||
p.OrStatus(2)
|
||||
DeleteFoo(p)
|
||||
}
|
||||
|
||||
func main() {
|
||||
ResetStatus()
|
||||
|
||||
a := NewDirectorFoo(&MyFoo{})
|
||||
DeleteMyFoo(a)
|
||||
|
||||
if GetStatus() != 3 {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
ResetStatus()
|
||||
|
||||
a = NewDirectorFoo(&MyFoo{})
|
||||
Launder(a)
|
||||
|
||||
if GetStatus() != 0 {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
DeleteMyFoo(a)
|
||||
|
||||
if GetStatus() != 3 {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
ResetStatus()
|
||||
}
|
||||
12
Examples/test-suite/go/director_frob_runme.go
Normal file
12
Examples/test-suite/go/director_frob_runme.go
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
package main
|
||||
|
||||
import . "./director_frob"
|
||||
|
||||
func main() {
|
||||
foo := NewBravo()
|
||||
s := foo.Abs_method()
|
||||
|
||||
if s != "Bravo::abs_method()" {
|
||||
panic(s)
|
||||
}
|
||||
}
|
||||
79
Examples/test-suite/go/director_nested_runme.go
Normal file
79
Examples/test-suite/go/director_nested_runme.go
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
package main
|
||||
|
||||
import . "./director_nested"
|
||||
|
||||
type A struct{} // From FooBar_int
|
||||
func (p *A) Do_step() string {
|
||||
return "A::do_step;"
|
||||
}
|
||||
func (p *A) Get_value() string {
|
||||
return "A::get_value"
|
||||
}
|
||||
|
||||
func f1() {
|
||||
a := NewDirectorFooBar_int(&A{})
|
||||
if a.Step() != "Bar::step;Foo::advance;Bar::do_advance;A::do_step;" {
|
||||
panic("Bad A virtual resolution")
|
||||
}
|
||||
}
|
||||
|
||||
type B struct{} // From FooBar_int
|
||||
func (p *B) Do_advance() string {
|
||||
return "B::do_advance;" + p.Do_step()
|
||||
}
|
||||
func (p *B) Do_step() string {
|
||||
return "B::do_step;"
|
||||
}
|
||||
func (p *B) Get_value() int {
|
||||
return 1
|
||||
}
|
||||
|
||||
func f2() {
|
||||
b := NewDirectorFooBar_int(&B{})
|
||||
|
||||
if b.Step() != "Bar::step;Foo::advance;B::do_advance;B::do_step;" {
|
||||
panic("Bad B virtual resolution")
|
||||
}
|
||||
}
|
||||
|
||||
type C struct {
|
||||
fbi FooBar_int
|
||||
} // From FooBar_int
|
||||
|
||||
func (p *C) Do_advance() string {
|
||||
return "C::do_advance;" + DirectorFooBar_intDo_advance(p.fbi)
|
||||
}
|
||||
|
||||
func (p *C) Do_step() string {
|
||||
return "C::do_step;"
|
||||
}
|
||||
|
||||
func (p *C) Get_value() int {
|
||||
return 2
|
||||
}
|
||||
|
||||
func (p *C) Get_name() string {
|
||||
return DirectorFooBar_intGet_name(p.fbi) + " hello"
|
||||
}
|
||||
|
||||
func f3() {
|
||||
m := &C{nil}
|
||||
cc := NewDirectorFooBar_int(m)
|
||||
m.fbi = cc
|
||||
c := FooBar_intGet_self(cc)
|
||||
c.Advance()
|
||||
|
||||
if c.Get_name() != "FooBar::get_name hello" {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
if c.Name() != "FooBar::get_name hello" {
|
||||
panic(0)
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
f1()
|
||||
f2()
|
||||
f3()
|
||||
}
|
||||
49
Examples/test-suite/go/director_profile_runme.go
Normal file
49
Examples/test-suite/go/director_profile_runme.go
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
package main
|
||||
|
||||
import "fmt"
|
||||
import "./director_profile"
|
||||
|
||||
type MyB struct{} // From director_profile.B
|
||||
func (p *MyB) Vfi(a int) int {
|
||||
return a + 3
|
||||
}
|
||||
|
||||
func main() {
|
||||
_ = director_profile.NewA()
|
||||
myb := director_profile.NewDirectorB(&MyB{})
|
||||
b := director_profile.BGet_self(myb)
|
||||
|
||||
fi := func(a int) int {
|
||||
return b.Fi(a)
|
||||
}
|
||||
|
||||
i := 50000
|
||||
a := 1
|
||||
for i != 0 {
|
||||
a = fi(a) // 1
|
||||
a = fi(a) // 2
|
||||
a = fi(a) // 3
|
||||
a = fi(a) // 4
|
||||
a = fi(a) // 5
|
||||
a = fi(a) // 6
|
||||
a = fi(a) // 7
|
||||
a = fi(a) // 8
|
||||
a = fi(a) // 9
|
||||
a = fi(a) // 10
|
||||
a = fi(a) // 1
|
||||
a = fi(a) // 2
|
||||
a = fi(a) // 3
|
||||
a = fi(a) // 4
|
||||
a = fi(a) // 5
|
||||
a = fi(a) // 6
|
||||
a = fi(a) // 7
|
||||
a = fi(a) // 8
|
||||
a = fi(a) // 9
|
||||
a = fi(a) // 20
|
||||
i -= 1
|
||||
}
|
||||
|
||||
if false {
|
||||
fmt.Println(a)
|
||||
}
|
||||
}
|
||||
48
Examples/test-suite/go/director_protected_runme.go
Normal file
48
Examples/test-suite/go/director_protected_runme.go
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
package main
|
||||
|
||||
import . "./director_protected"
|
||||
|
||||
type FooBar struct{} // From Bar
|
||||
func (p *FooBar) Ping() string {
|
||||
return "FooBar::ping();"
|
||||
}
|
||||
|
||||
type FooBar2 struct{} // From Bar
|
||||
func (p *FooBar2) Ping() string {
|
||||
return "FooBar2::ping();"
|
||||
}
|
||||
func (p *FooBar2) Pang() string {
|
||||
return "FooBar2::pang();"
|
||||
}
|
||||
|
||||
func main() {
|
||||
b := NewBar()
|
||||
f := b.Create()
|
||||
fb := NewDirectorBar(&FooBar{})
|
||||
fb2 := NewDirectorBar(&FooBar2{})
|
||||
|
||||
s := fb.Used()
|
||||
if s != "Foo::pang();Bar::pong();Foo::pong();FooBar::ping();" {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
s = fb2.Used()
|
||||
if s != "FooBar2::pang();Bar::pong();Foo::pong();FooBar2::ping();" {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
s = b.Pong()
|
||||
if s != "Bar::pong();Foo::pong();Bar::ping();" {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
s = f.Pong()
|
||||
if s != "Bar::pong();Foo::pong();Bar::ping();" {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
s = fb.Pong()
|
||||
if s != "Bar::pong();Foo::pong();FooBar::ping();" {
|
||||
panic(0)
|
||||
}
|
||||
}
|
||||
39
Examples/test-suite/go/director_string_runme.go
Normal file
39
Examples/test-suite/go/director_string_runme.go
Normal file
|
|
@ -0,0 +1,39 @@
|
|||
package main
|
||||
|
||||
import . "./director_string"
|
||||
|
||||
type B struct { // From A
|
||||
abi A
|
||||
smem string
|
||||
}
|
||||
|
||||
func NewB(s string) A {
|
||||
p := &B{nil, ""}
|
||||
ret := NewDirectorA(p, s)
|
||||
p.abi = ret
|
||||
return ret
|
||||
}
|
||||
|
||||
func (p *B) Get_first() string {
|
||||
return DirectorAGet_first(p.abi) + " world!"
|
||||
}
|
||||
|
||||
func (p *B) Process_text(s string) {
|
||||
DirectorAProcess_text(p.abi, s)
|
||||
p.smem = "hello"
|
||||
}
|
||||
|
||||
func main() {
|
||||
b := NewB("hello")
|
||||
|
||||
b.Get(0)
|
||||
if b.Get_first() != "hello world!" {
|
||||
panic(b.Get_first())
|
||||
}
|
||||
|
||||
b.Call_process_func()
|
||||
|
||||
if b.DirectorInterface().(*B).smem != "hello" {
|
||||
panic(b.DirectorInterface().(*B).smem)
|
||||
}
|
||||
}
|
||||
28
Examples/test-suite/go/director_thread_runme.go
Normal file
28
Examples/test-suite/go/director_thread_runme.go
Normal file
|
|
@ -0,0 +1,28 @@
|
|||
package main
|
||||
|
||||
import . "./director_thread"
|
||||
|
||||
type Derived struct {
|
||||
abi Foo
|
||||
} // From Foo
|
||||
func (p *Derived) Do_foo() {
|
||||
p.abi.SetVal(p.abi.GetVal() - 1)
|
||||
}
|
||||
|
||||
func main() {
|
||||
|
||||
// FIXME: This test fails until we fix callbacks from a
|
||||
// different thread.
|
||||
return
|
||||
|
||||
p := &Derived{nil}
|
||||
d := NewDirectorFoo(p)
|
||||
p.abi = d
|
||||
d.Run()
|
||||
|
||||
if d.GetVal() >= 0 {
|
||||
panic(d.GetVal())
|
||||
}
|
||||
|
||||
d.Stop()
|
||||
}
|
||||
21
Examples/test-suite/go/director_unroll_runme.go
Normal file
21
Examples/test-suite/go/director_unroll_runme.go
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
package main
|
||||
|
||||
import "./director_unroll"
|
||||
|
||||
type MyFoo struct{} // From director_unroll.Foo
|
||||
func (p *MyFoo) Ping() string {
|
||||
return "MyFoo::ping()"
|
||||
}
|
||||
|
||||
func main() {
|
||||
a := director_unroll.NewDirectorFoo(&MyFoo{})
|
||||
|
||||
b := director_unroll.NewBar()
|
||||
|
||||
b.Set(a)
|
||||
c := b.Get()
|
||||
|
||||
if c.Ping() != "MyFoo::ping()" {
|
||||
panic(c.Ping())
|
||||
}
|
||||
}
|
||||
10
Examples/test-suite/go/disown_runme.go
Normal file
10
Examples/test-suite/go/disown_runme.go
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
package main
|
||||
|
||||
import . "./disown"
|
||||
|
||||
func main() {
|
||||
a := NewA()
|
||||
|
||||
b := NewB()
|
||||
b.Acquire(a)
|
||||
}
|
||||
16
Examples/test-suite/go/dynamic_cast_runme.go
Normal file
16
Examples/test-suite/go/dynamic_cast_runme.go
Normal file
|
|
@ -0,0 +1,16 @@
|
|||
package main
|
||||
|
||||
import "./dynamic_cast"
|
||||
|
||||
func main() {
|
||||
f := dynamic_cast.NewFoo()
|
||||
b := dynamic_cast.NewBar()
|
||||
|
||||
_ = f.Blah()
|
||||
y := b.Blah()
|
||||
|
||||
a := dynamic_cast.Do_test(dynamic_cast.FooToBar(y))
|
||||
if a != "Bar::test" {
|
||||
panic("Failed!!")
|
||||
}
|
||||
}
|
||||
6
Examples/test-suite/go/empty_runme.go
Normal file
6
Examples/test-suite/go/empty_runme.go
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
package main
|
||||
|
||||
import _ "./empty"
|
||||
|
||||
func main() {
|
||||
}
|
||||
11
Examples/test-suite/go/enum_template_runme.go
Normal file
11
Examples/test-suite/go/enum_template_runme.go
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
package main
|
||||
|
||||
import "./enum_template"
|
||||
|
||||
func main() {
|
||||
if enum_template.MakeETest() != 1 {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
enum_template.TakeETest(0)
|
||||
}
|
||||
25
Examples/test-suite/go/enums_runme.go
Normal file
25
Examples/test-suite/go/enums_runme.go
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
package main
|
||||
|
||||
import "./enums"
|
||||
|
||||
func main() {
|
||||
enums.Bar2(1)
|
||||
enums.Bar3(1)
|
||||
enums.Bar1(1)
|
||||
|
||||
if enums.GetEnumInstance() != 2 {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
if enums.GetSlap() != 10 {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
if enums.GetMine() != 11 {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
if enums.GetThigh() != 12 {
|
||||
panic(0)
|
||||
}
|
||||
}
|
||||
58
Examples/test-suite/go/exception_order_runme.go
Normal file
58
Examples/test-suite/go/exception_order_runme.go
Normal file
|
|
@ -0,0 +1,58 @@
|
|||
package main
|
||||
|
||||
import "strings"
|
||||
import . "./exception_order"
|
||||
|
||||
func main() {
|
||||
a := NewA()
|
||||
|
||||
func() {
|
||||
defer func() {
|
||||
e := recover()
|
||||
if strings.Index(e.(string), "E1") == -1 {
|
||||
panic(e.(string))
|
||||
}
|
||||
}()
|
||||
a.Foo()
|
||||
}()
|
||||
|
||||
func() {
|
||||
defer func() {
|
||||
e := recover()
|
||||
if strings.Index(e.(string), "E2") == -1 {
|
||||
panic(e.(string))
|
||||
}
|
||||
}()
|
||||
a.Bar()
|
||||
}()
|
||||
|
||||
func() {
|
||||
defer func() {
|
||||
e := recover()
|
||||
if e.(string) != "postcatch unknown" {
|
||||
panic("bad exception order")
|
||||
}
|
||||
}()
|
||||
a.Foobar()
|
||||
}()
|
||||
|
||||
func() {
|
||||
defer func() {
|
||||
e := recover()
|
||||
if strings.Index(e.(string), "E1") == -1 {
|
||||
panic(e.(string))
|
||||
}
|
||||
}()
|
||||
a.Barfoo(1)
|
||||
}()
|
||||
|
||||
func() {
|
||||
defer func() {
|
||||
e := recover()
|
||||
if strings.Index(e.(string), "E2") == -1 {
|
||||
panic(e.(string))
|
||||
}
|
||||
}()
|
||||
a.Barfoo(2)
|
||||
}()
|
||||
}
|
||||
47
Examples/test-suite/go/extend_placement_runme.go
Normal file
47
Examples/test-suite/go/extend_placement_runme.go
Normal file
|
|
@ -0,0 +1,47 @@
|
|||
package main
|
||||
|
||||
import "./extend_placement"
|
||||
|
||||
func main() {
|
||||
foo := extend_placement.NewFoo()
|
||||
foo = extend_placement.NewFoo(1)
|
||||
foo = extend_placement.NewFoo(1, 1)
|
||||
foo.Spam()
|
||||
foo.Spam("hello")
|
||||
foo.Spam(1)
|
||||
foo.Spam(1, 1)
|
||||
foo.Spam(1, 1, 1)
|
||||
foo.Spam(extend_placement.NewFoo())
|
||||
foo.Spam(extend_placement.NewFoo(), float64(1.0))
|
||||
|
||||
bar := extend_placement.NewBar()
|
||||
bar = extend_placement.NewBar(1)
|
||||
bar.Spam()
|
||||
bar.Spam("hello")
|
||||
bar.Spam(1)
|
||||
bar.Spam(1, 1)
|
||||
bar.Spam(1, 1, 1)
|
||||
bar.Spam(extend_placement.NewBar())
|
||||
bar.Spam(extend_placement.NewBar(), float64(1.0))
|
||||
|
||||
footi := extend_placement.NewFooTi()
|
||||
footi = extend_placement.NewFooTi(1)
|
||||
footi = extend_placement.NewFooTi(1, 1)
|
||||
footi.Spam()
|
||||
footi.Spam("hello")
|
||||
footi.Spam(1)
|
||||
footi.Spam(1, 1)
|
||||
footi.Spam(1, 1, 1)
|
||||
footi.Spam(extend_placement.NewFoo())
|
||||
footi.Spam(extend_placement.NewFoo(), float64(1.0))
|
||||
|
||||
barti := extend_placement.NewBarTi()
|
||||
barti = extend_placement.NewBarTi(1)
|
||||
barti.Spam()
|
||||
barti.Spam("hello")
|
||||
barti.Spam(1)
|
||||
barti.Spam(1, 1)
|
||||
barti.Spam(1, 1, 1)
|
||||
barti.Spam(extend_placement.NewBar())
|
||||
barti.Spam(extend_placement.NewBar(), float64(1.0))
|
||||
}
|
||||
14
Examples/test-suite/go/extend_template_ns_runme.go
Normal file
14
Examples/test-suite/go/extend_template_ns_runme.go
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
package main
|
||||
|
||||
import . "./extend_template_ns"
|
||||
|
||||
func main() {
|
||||
f := NewFoo_One()
|
||||
if f.Test1(37) != 37 {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
if f.Test2(42) != 42 {
|
||||
panic(0)
|
||||
}
|
||||
}
|
||||
14
Examples/test-suite/go/extend_template_runme.go
Normal file
14
Examples/test-suite/go/extend_template_runme.go
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
package main
|
||||
|
||||
import "./extend_template"
|
||||
|
||||
func main() {
|
||||
f := extend_template.NewFoo_0()
|
||||
if f.Test1(37) != 37 {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
if f.Test2(42) != 42 {
|
||||
panic(0)
|
||||
}
|
||||
}
|
||||
9
Examples/test-suite/go/extend_variable_runme.go
Normal file
9
Examples/test-suite/go/extend_variable_runme.go
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
package main
|
||||
|
||||
import . "./extend_variable"
|
||||
|
||||
func main() {
|
||||
if FooBar != 42 {
|
||||
panic(0)
|
||||
}
|
||||
}
|
||||
7
Examples/test-suite/go/extern_c_runme.go
Normal file
7
Examples/test-suite/go/extern_c_runme.go
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
package main
|
||||
|
||||
import "./extern_c"
|
||||
|
||||
func main() {
|
||||
extern_c.RealFunction(2)
|
||||
}
|
||||
50
Examples/test-suite/go/friends_runme.go
Normal file
50
Examples/test-suite/go/friends_runme.go
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
package main
|
||||
|
||||
import "./friends"
|
||||
|
||||
func main() {
|
||||
a := friends.NewA(2)
|
||||
|
||||
if friends.Get_val1(a).(int) != 2 {
|
||||
panic(0)
|
||||
}
|
||||
if friends.Get_val2(a) != 4 {
|
||||
panic(0)
|
||||
}
|
||||
if friends.Get_val3(a) != 6 {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
// nice overload working fine
|
||||
if friends.Get_val1(1, 2, 3).(int) != 1 {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
b := friends.NewB(3)
|
||||
|
||||
// David's case
|
||||
if friends.Mix(a, b) != 5 {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
di := friends.NewD_d(2)
|
||||
dd := friends.NewD_d(3.3)
|
||||
|
||||
// incredible template overloading working just fine
|
||||
if friends.Get_val1(di).(float64) != 2 {
|
||||
panic(0)
|
||||
}
|
||||
if friends.Get_val1(dd).(float64) != 3.3 {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
friends.Set(di, float64(4.0))
|
||||
friends.Set(dd, float64(1.3))
|
||||
|
||||
if friends.Get_val1(di).(float64) != 4 {
|
||||
panic(0)
|
||||
}
|
||||
if friends.Get_val1(dd).(float64) != 1.3 {
|
||||
panic(0)
|
||||
}
|
||||
}
|
||||
13
Examples/test-suite/go/fvirtual_runme.go
Normal file
13
Examples/test-suite/go/fvirtual_runme.go
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
package main
|
||||
|
||||
import . "./fvirtual"
|
||||
|
||||
func main() {
|
||||
sw := NewNodeSwitch()
|
||||
n := NewNode()
|
||||
i := sw.AddChild(n)
|
||||
|
||||
if i != 2 {
|
||||
panic("addChild")
|
||||
}
|
||||
}
|
||||
8
Examples/test-suite/go/global_ns_arg_runme.go
Normal file
8
Examples/test-suite/go/global_ns_arg_runme.go
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
package main
|
||||
|
||||
import . "./global_ns_arg"
|
||||
|
||||
func main() {
|
||||
Foo(1)
|
||||
Bar()
|
||||
}
|
||||
19
Examples/test-suite/go/grouping_runme.go
Normal file
19
Examples/test-suite/go/grouping_runme.go
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
package main
|
||||
|
||||
import "./grouping"
|
||||
|
||||
func main() {
|
||||
x := grouping.Test1(42)
|
||||
if x != 42 {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
grouping.Test2(42)
|
||||
|
||||
x = grouping.Do_unary(37, grouping.NEGATE)
|
||||
if x != -37 {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
grouping.SetTest3(42)
|
||||
}
|
||||
12
Examples/test-suite/go/import_nomodule_runme.go
Normal file
12
Examples/test-suite/go/import_nomodule_runme.go
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
package main
|
||||
|
||||
import . "./import_nomodule"
|
||||
|
||||
func main() {
|
||||
f := Create_Foo()
|
||||
Test1(f, 42)
|
||||
Delete_Foo(f)
|
||||
|
||||
b := NewBar()
|
||||
Test1(b, 37)
|
||||
}
|
||||
17
Examples/test-suite/go/imports_runme.go
Normal file
17
Examples/test-suite/go/imports_runme.go
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
// This is the import runtime testcase.
|
||||
|
||||
package main
|
||||
|
||||
import "imports_b"
|
||||
import "imports_a"
|
||||
|
||||
func main() {
|
||||
x := imports_b.NewB()
|
||||
x.Hello()
|
||||
|
||||
_ = imports_a.NewA()
|
||||
|
||||
c := imports_b.NewC()
|
||||
_ = c.Get_a(c)
|
||||
_ = c.Get_a_type(c)
|
||||
}
|
||||
18
Examples/test-suite/go/inctest_runme.go
Normal file
18
Examples/test-suite/go/inctest_runme.go
Normal file
|
|
@ -0,0 +1,18 @@
|
|||
package main
|
||||
|
||||
import "./inctest"
|
||||
|
||||
func main() {
|
||||
inctest.NewA()
|
||||
inctest.NewB()
|
||||
|
||||
// Check the import in subdirectory worked
|
||||
if inctest.Importtest1(5) != 15 {
|
||||
panic("import test 1 failed")
|
||||
}
|
||||
|
||||
a := []byte("black")
|
||||
if inctest.Importtest2(string(a)) != "white" {
|
||||
panic("import test 2 failed")
|
||||
}
|
||||
}
|
||||
26
Examples/test-suite/go/inherit_missing_runme.go
Normal file
26
Examples/test-suite/go/inherit_missing_runme.go
Normal file
|
|
@ -0,0 +1,26 @@
|
|||
package main
|
||||
|
||||
import "./inherit_missing"
|
||||
|
||||
func main() {
|
||||
a := inherit_missing.New_Foo()
|
||||
b := inherit_missing.NewBar()
|
||||
c := inherit_missing.NewSpam()
|
||||
|
||||
x := inherit_missing.Do_blah(a)
|
||||
if x != "Foo::blah" {
|
||||
panic(x)
|
||||
}
|
||||
|
||||
x = inherit_missing.Do_blah(b)
|
||||
if x != "Bar::blah" {
|
||||
panic(x)
|
||||
}
|
||||
|
||||
x = inherit_missing.Do_blah(c)
|
||||
if x != "Spam::blah" {
|
||||
panic(x)
|
||||
}
|
||||
|
||||
inherit_missing.Delete_Foo(a)
|
||||
}
|
||||
14
Examples/test-suite/go/input_runme.go
Normal file
14
Examples/test-suite/go/input_runme.go
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
package main
|
||||
|
||||
import . "./input"
|
||||
|
||||
func main() {
|
||||
f := NewFoo()
|
||||
if f.Foo(2) != 4 {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
if Sfoo("Hello") != "Hello world" {
|
||||
panic(0)
|
||||
}
|
||||
}
|
||||
8
Examples/test-suite/go/keyword_rename_runme.go
Normal file
8
Examples/test-suite/go/keyword_rename_runme.go
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
package main
|
||||
|
||||
import "./keyword_rename"
|
||||
|
||||
func main() {
|
||||
keyword_rename.Xgo(1)
|
||||
keyword_rename.Xchan(1)
|
||||
}
|
||||
90
Examples/test-suite/go/li_attribute_runme.go
Normal file
90
Examples/test-suite/go/li_attribute_runme.go
Normal file
|
|
@ -0,0 +1,90 @@
|
|||
package main
|
||||
|
||||
import "./li_attribute"
|
||||
|
||||
func main() {
|
||||
aa := li_attribute.NewA(1, 2, 3)
|
||||
|
||||
if aa.GetA() != 1 {
|
||||
panic(0)
|
||||
}
|
||||
aa.SetA(3)
|
||||
if aa.GetA() != 3 {
|
||||
panic(aa.GetA())
|
||||
}
|
||||
|
||||
if aa.GetB() != 2 {
|
||||
panic(aa.GetB())
|
||||
}
|
||||
aa.SetB(5)
|
||||
if aa.GetB() != 5 {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
if aa.GetD() != aa.GetB() {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
if aa.GetC() != 3 {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
pi := li_attribute.NewParam_i(7)
|
||||
if pi.GetValue() != 7 {
|
||||
panic(0)
|
||||
}
|
||||
pi.SetValue(3)
|
||||
if pi.GetValue() != 3 {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
b := li_attribute.NewB(aa)
|
||||
|
||||
if b.GetA().GetC() != 3 {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
// class/struct attribute with get/set methods using
|
||||
// return/pass by reference
|
||||
myFoo := li_attribute.NewMyFoo()
|
||||
myFoo.SetX(8)
|
||||
myClass := li_attribute.NewMyClass()
|
||||
myClass.SetFoo(myFoo)
|
||||
if myClass.GetFoo().GetX() != 8 {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
// class/struct attribute with get/set methods using
|
||||
// return/pass by value
|
||||
myClassVal := li_attribute.NewMyClassVal()
|
||||
if myClassVal.GetReadWriteFoo().GetX() != -1 {
|
||||
panic(0)
|
||||
}
|
||||
if myClassVal.GetReadOnlyFoo().GetX() != -1 {
|
||||
panic(0)
|
||||
}
|
||||
myClassVal.SetReadWriteFoo(myFoo)
|
||||
if myClassVal.GetReadWriteFoo().GetX() != 8 {
|
||||
panic(0)
|
||||
}
|
||||
if myClassVal.GetReadOnlyFoo().GetX() != 8 {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
// string attribute with get/set methods using return/pass by
|
||||
// value
|
||||
myStringyClass := li_attribute.NewMyStringyClass("initial string")
|
||||
if myStringyClass.GetReadWriteString() != "initial string" {
|
||||
panic(0)
|
||||
}
|
||||
if myStringyClass.GetReadOnlyString() != "initial string" {
|
||||
panic(0)
|
||||
}
|
||||
myStringyClass.SetReadWriteString("changed string")
|
||||
if myStringyClass.GetReadWriteString() != "changed string" {
|
||||
panic(0)
|
||||
}
|
||||
if myStringyClass.GetReadOnlyString() != "changed string" {
|
||||
panic(0)
|
||||
}
|
||||
}
|
||||
14
Examples/test-suite/go/li_carrays_runme.go
Normal file
14
Examples/test-suite/go/li_carrays_runme.go
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
package main
|
||||
|
||||
import . "./li_carrays"
|
||||
|
||||
func main() {
|
||||
d := NewDoubleArray(10)
|
||||
|
||||
d.Setitem(0, 7)
|
||||
d.Setitem(5, d.Getitem(0)+3)
|
||||
|
||||
if d.Getitem(5)+d.Getitem(0) != 17 {
|
||||
panic(0)
|
||||
}
|
||||
}
|
||||
13
Examples/test-suite/go/li_cdata_runme.go
Normal file
13
Examples/test-suite/go/li_cdata_runme.go
Normal file
|
|
@ -0,0 +1,13 @@
|
|||
package main
|
||||
|
||||
import . "./li_cdata"
|
||||
|
||||
func main() {
|
||||
s := "ABC abc"
|
||||
m := Malloc(256)
|
||||
Memmove(m, s, len(s))
|
||||
ss := Cdata(m, 7)
|
||||
if string(ss) != "ABC abc" {
|
||||
panic("failed")
|
||||
}
|
||||
}
|
||||
25
Examples/test-suite/go/li_cmalloc_runme.go
Normal file
25
Examples/test-suite/go/li_cmalloc_runme.go
Normal file
|
|
@ -0,0 +1,25 @@
|
|||
package main
|
||||
|
||||
import . "./li_cmalloc"
|
||||
|
||||
func main() {
|
||||
p := Malloc_int()
|
||||
Free_int(p)
|
||||
|
||||
ok := false
|
||||
func() {
|
||||
defer func() {
|
||||
if recover() != nil {
|
||||
ok = true
|
||||
}
|
||||
}()
|
||||
p = Calloc_int(-1)
|
||||
if p == nil {
|
||||
ok = true
|
||||
}
|
||||
Free_int(p)
|
||||
}()
|
||||
if !ok {
|
||||
panic(0)
|
||||
}
|
||||
}
|
||||
14
Examples/test-suite/go/li_cpointer_runme.go
Normal file
14
Examples/test-suite/go/li_cpointer_runme.go
Normal file
|
|
@ -0,0 +1,14 @@
|
|||
package main
|
||||
|
||||
import . "./li_cpointer"
|
||||
|
||||
func main() {
|
||||
p := New_intp()
|
||||
Intp_assign(p, 3)
|
||||
|
||||
if Intp_value(p) != 3 {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
Delete_intp(p)
|
||||
}
|
||||
30
Examples/test-suite/go/li_std_map_runme.go
Normal file
30
Examples/test-suite/go/li_std_map_runme.go
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
package main
|
||||
|
||||
import "./li_std_map"
|
||||
|
||||
func main() {
|
||||
a1 := li_std_map.NewA(3)
|
||||
a2 := li_std_map.NewA(7)
|
||||
|
||||
_ = li_std_map.NewPairii(1, 2)
|
||||
p1 := li_std_map.NewPairA(1, a1)
|
||||
m := li_std_map.NewMapA()
|
||||
m.Set(1, a1)
|
||||
m.Set(2, a2)
|
||||
|
||||
_ = li_std_map.P_identa(p1)
|
||||
_ = li_std_map.M_identa(m)
|
||||
|
||||
m = li_std_map.NewMapA()
|
||||
m.Set(1, a1)
|
||||
m.Set(2, a2)
|
||||
|
||||
mii := li_std_map.NewIntIntMap()
|
||||
|
||||
mii.Set(1, 1)
|
||||
mii.Set(1, 2)
|
||||
|
||||
if mii.Get(1) != 2 {
|
||||
panic(0)
|
||||
}
|
||||
}
|
||||
12
Examples/test-suite/go/li_std_vector_ptr_runme.go
Normal file
12
Examples/test-suite/go/li_std_vector_ptr_runme.go
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
package main
|
||||
|
||||
import . "./li_std_vector_ptr"
|
||||
|
||||
func main() {
|
||||
ip1 := MakeIntPtr(11)
|
||||
ip2 := MakeIntPtr(22)
|
||||
vi := NewIntPtrVector()
|
||||
vi.Add(ip1)
|
||||
vi.Add(ip2)
|
||||
DisplayVector(vi)
|
||||
}
|
||||
49
Examples/test-suite/go/member_pointer_runme.go
Normal file
49
Examples/test-suite/go/member_pointer_runme.go
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
// Example using pointers to member functions
|
||||
|
||||
package main
|
||||
|
||||
import "fmt"
|
||||
import . "./member_pointer"
|
||||
|
||||
func check(what string, expected float64, actual float64) {
|
||||
if expected != actual {
|
||||
panic(fmt.Sprintf("Failed: %s Expected: %f Actual; %f", what, expected, actual))
|
||||
}
|
||||
}
|
||||
|
||||
func main() {
|
||||
// Get the pointers
|
||||
|
||||
area_pt := Areapt()
|
||||
perim_pt := Perimeterpt()
|
||||
|
||||
// Create some objects
|
||||
|
||||
s := NewSquare(10)
|
||||
|
||||
// Do some calculations
|
||||
|
||||
check("Square area ", 100.0, Do_op(s, area_pt))
|
||||
check("Square perim", 40.0, Do_op(s, perim_pt))
|
||||
|
||||
_ = GetAreavar()
|
||||
_ = GetPerimetervar()
|
||||
|
||||
// Try the variables
|
||||
check("Square area ", 100.0, Do_op(s, GetAreavar()))
|
||||
check("Square perim", 40.0, Do_op(s, GetPerimetervar()))
|
||||
|
||||
// Modify one of the variables
|
||||
SetAreavar(perim_pt)
|
||||
|
||||
check("Square perimeter", 40.0, Do_op(s, GetAreavar()))
|
||||
|
||||
// Try the constants
|
||||
|
||||
_ = AREAPT
|
||||
_ = PERIMPT
|
||||
_ = NULLPT
|
||||
|
||||
check("Square area ", 100.0, Do_op(s, AREAPT))
|
||||
check("Square perim", 40.0, Do_op(s, PERIMPT))
|
||||
}
|
||||
11
Examples/test-suite/go/memberin_extend_c_runme.go
Normal file
11
Examples/test-suite/go/memberin_extend_c_runme.go
Normal file
|
|
@ -0,0 +1,11 @@
|
|||
package main
|
||||
|
||||
import "./memberin_extend_c"
|
||||
|
||||
func main() {
|
||||
t := memberin_extend_c.NewPerson()
|
||||
t.SetName("Fred Bloggs")
|
||||
if t.GetName() != "FRED BLOGGS" {
|
||||
panic("name wrong")
|
||||
}
|
||||
}
|
||||
82
Examples/test-suite/go/minherit_runme.go
Normal file
82
Examples/test-suite/go/minherit_runme.go
Normal file
|
|
@ -0,0 +1,82 @@
|
|||
package main
|
||||
|
||||
import "fmt"
|
||||
import "./minherit"
|
||||
|
||||
func main() {
|
||||
a := minherit.NewFoo()
|
||||
b := minherit.NewBar()
|
||||
c := minherit.NewFooBar()
|
||||
d := minherit.NewSpam()
|
||||
|
||||
if a.Xget() != 1 {
|
||||
panic("1 Bad attribute value")
|
||||
}
|
||||
|
||||
if b.Yget() != 2 {
|
||||
panic("2 Bad attribute value")
|
||||
}
|
||||
|
||||
if c.Xget() != 1 || c.Yget() != 2 || c.Zget() != 3 {
|
||||
panic("3 Bad attribute value")
|
||||
}
|
||||
|
||||
if d.Xget() != 1 || d.Yget() != 2 || d.Zget() != 3 || d.Wget() != 4 {
|
||||
panic("4 Bad attribute value")
|
||||
}
|
||||
|
||||
if minherit.Xget(a) != 1 {
|
||||
panic(fmt.Sprintf("5 Bad attribute value %d", minherit.Xget(a)))
|
||||
}
|
||||
|
||||
if minherit.Yget(b) != 2 {
|
||||
panic(fmt.Sprintf("6 Bad attribute value %d", minherit.Yget(b)))
|
||||
}
|
||||
|
||||
if minherit.Xget(c) != 1 || minherit.Yget(c.SwigGetBar()) != 2 || minherit.Zget(c) != 3 {
|
||||
panic(fmt.Sprintf("7 Bad attribute value %d %d %d", minherit.Xget(c), minherit.Yget(c.SwigGetBar()), minherit.Zget(c)))
|
||||
}
|
||||
|
||||
if minherit.Xget(d) != 1 || minherit.Yget(d.SwigGetBar()) != 2 || minherit.Zget(d) != 3 || minherit.Wget(d) != 4 {
|
||||
panic(fmt.Sprintf("8 Bad attribute value %d %d %d %d", minherit.Xget(d), minherit.Yget(d.SwigGetBar()), minherit.Zget(d), minherit.Wget(d)))
|
||||
}
|
||||
|
||||
// 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 {
|
||||
panic("9 Bad attribute value")
|
||||
}
|
||||
|
||||
if bb.Yget() != 2 {
|
||||
panic("10 Bad attribute value")
|
||||
}
|
||||
|
||||
if cc.Xget() != 1 || cc.Yget() != 2 || cc.Zget() != 3 {
|
||||
panic("11 Bad attribute value")
|
||||
}
|
||||
|
||||
if dd.Xget() != 1 || dd.Yget() != 2 || dd.Zget() != 3 || dd.Wget() != 4 {
|
||||
panic("12 Bad attribute value")
|
||||
}
|
||||
|
||||
if minherit.Xget(aa) != 1 {
|
||||
panic(fmt.Sprintf("13 Bad attribute value %d", minherit.Xget(aa)))
|
||||
}
|
||||
|
||||
if minherit.Yget(bb) != 2 {
|
||||
panic(fmt.Sprintf("14 Bad attribute value %d", minherit.Yget(bb)))
|
||||
}
|
||||
|
||||
if minherit.Xget(cc) != 1 || minherit.Yget(cc.SwigGetBar()) != 2 || minherit.Zget(cc) != 3 {
|
||||
panic(fmt.Sprintf("15 Bad attribute value %d %d %d", minherit.Xget(cc), minherit.Yget(cc.SwigGetBar()), minherit.Zget(cc)))
|
||||
}
|
||||
|
||||
if minherit.Xget(dd) != 1 || minherit.Yget(dd.SwigGetBar()) != 2 || minherit.Zget(dd) != 3 || minherit.Wget(dd) != 4 {
|
||||
panic(fmt.Sprintf("16 Bad attribute value %d %d %d %d", minherit.Xget(dd), minherit.Yget(dd.SwigGetBar()), minherit.Zget(dd), minherit.Wget(dd)))
|
||||
}
|
||||
}
|
||||
10
Examples/test-suite/go/mod_runme.go
Normal file
10
Examples/test-suite/go/mod_runme.go
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
package main
|
||||
|
||||
import "mod_a"
|
||||
import "mod_b"
|
||||
|
||||
func main() {
|
||||
c := mod_b.NewC()
|
||||
d := mod_b.NewD()
|
||||
d.DoSomething(mod_a.SwigcptrA(c.Swigcptr()))
|
||||
}
|
||||
29
Examples/test-suite/go/multi_import_runme.go
Normal file
29
Examples/test-suite/go/multi_import_runme.go
Normal file
|
|
@ -0,0 +1,29 @@
|
|||
package main
|
||||
|
||||
import "multi_import_a"
|
||||
import "multi_import_b"
|
||||
|
||||
func main() {
|
||||
x := multi_import_b.NewXXX()
|
||||
if x.Testx() != 0 {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
y := multi_import_b.NewYYY()
|
||||
if y.Testx() != 0 {
|
||||
panic(0)
|
||||
}
|
||||
if y.Testy() != 1 {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
z := multi_import_a.NewZZZ()
|
||||
if z.Testx() != 0 {
|
||||
println("z.Testx", z.Testx(), z.Testz())
|
||||
panic(0)
|
||||
}
|
||||
if z.Testz() != 2 {
|
||||
println("z.Testz", z.Testz())
|
||||
panic(0)
|
||||
}
|
||||
}
|
||||
19
Examples/test-suite/go/namespace_class_runme.go
Normal file
19
Examples/test-suite/go/namespace_class_runme.go
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
package main
|
||||
|
||||
import . "./namespace_class"
|
||||
|
||||
func main() {
|
||||
EulerT3DToFrame(1, 1, 1)
|
||||
|
||||
_ = NewBooT_i()
|
||||
_ = NewBooT_H()
|
||||
|
||||
f1 := NewFooT_i()
|
||||
f1.Quack(1)
|
||||
|
||||
f2 := NewFooT_d()
|
||||
f2.Moo(1)
|
||||
|
||||
f3 := NewFooT_H()
|
||||
f3.Foo(Hi)
|
||||
}
|
||||
116
Examples/test-suite/go/namespace_typemap_runme.go
Normal file
116
Examples/test-suite/go/namespace_typemap_runme.go
Normal file
|
|
@ -0,0 +1,116 @@
|
|||
package main
|
||||
|
||||
import . "./namespace_typemap"
|
||||
|
||||
func main() {
|
||||
if Stest1("hello") != "hello" {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
if Stest2("hello") != "hello" {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
if Stest3("hello") != "hello" {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
if Stest4("hello") != "hello" {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
if Stest5("hello") != "hello" {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
if Stest6("hello") != "hello" {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
if Stest7("hello") != "hello" {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
if Stest8("hello") != "hello" {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
if Stest9("hello") != "hello" {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
if Stest10("hello") != "hello" {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
if Stest11("hello") != "hello" {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
if Stest12("hello") != "hello" {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
c := cmplx(float64(2), float64(3))
|
||||
r := real(c)
|
||||
|
||||
if Ctest1(c) != r {
|
||||
println(Ctest1(c))
|
||||
panic(Ctest1(c))
|
||||
}
|
||||
|
||||
if Ctest2(c) != r {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
if Ctest3(c) != r {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
if Ctest4(c) != r {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
if Ctest5(c) != r {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
if Ctest6(c) != r {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
if Ctest7(c) != r {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
if Ctest8(c) != r {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
if Ctest9(c) != r {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
if Ctest10(c) != r {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
if Ctest11(c) != r {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
if Ctest12(c) != r {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
ok := false
|
||||
func() {
|
||||
defer func() {
|
||||
ok = recover() != nil
|
||||
}()
|
||||
Ttest1(-14)
|
||||
}()
|
||||
if !ok {
|
||||
panic(0)
|
||||
}
|
||||
}
|
||||
7
Examples/test-suite/go/namespace_virtual_method_runme.go
Normal file
7
Examples/test-suite/go/namespace_virtual_method_runme.go
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
package main
|
||||
|
||||
import "./namespace_virtual_method"
|
||||
|
||||
func main() {
|
||||
_ = namespace_virtual_method.NewSpam()
|
||||
}
|
||||
17
Examples/test-suite/go/naturalvar_runme.go
Normal file
17
Examples/test-suite/go/naturalvar_runme.go
Normal file
|
|
@ -0,0 +1,17 @@
|
|||
package main
|
||||
|
||||
import . "./naturalvar"
|
||||
|
||||
func main() {
|
||||
f := NewFoo()
|
||||
b := NewBar()
|
||||
|
||||
b.SetF(f)
|
||||
|
||||
SetS("hello")
|
||||
b.SetS("hello")
|
||||
|
||||
if b.GetS() != GetS() {
|
||||
panic(0)
|
||||
}
|
||||
}
|
||||
19
Examples/test-suite/go/nested_workaround_runme.go
Normal file
19
Examples/test-suite/go/nested_workaround_runme.go
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
package main
|
||||
|
||||
import . "./nested_workaround"
|
||||
|
||||
func main() {
|
||||
inner := NewInner(5)
|
||||
outer := NewOuter()
|
||||
newInner := outer.DoubleInnerValue(inner)
|
||||
if newInner.GetValue() != 10 {
|
||||
panic(0)
|
||||
}
|
||||
|
||||
outer = NewOuter()
|
||||
inner = outer.CreateInner(3)
|
||||
newInner = outer.DoubleInnerValue(inner)
|
||||
if outer.GetInnerValue(newInner) != 6 {
|
||||
panic(0)
|
||||
}
|
||||
}
|
||||
62
Examples/test-suite/go/overload_complicated_runme.go
Normal file
62
Examples/test-suite/go/overload_complicated_runme.go
Normal file
|
|
@ -0,0 +1,62 @@
|
|||
package main
|
||||
|
||||
import . "./overload_complicated"
|
||||
|
||||
func main() {
|
||||
var pInt *int
|
||||
|
||||
// Check the correct constructors are available
|
||||
p := NewPop(pInt)
|
||||
|
||||
p = NewPop(pInt, false)
|
||||
|
||||
// Check overloaded in const only and pointers/references
|
||||
// which target languages cannot disambiguate
|
||||
if p.Hip(false) != 701 {
|
||||
panic("Test 1 failed")
|
||||
}
|
||||
|
||||
if p.Hip(pInt) != 702 {
|
||||
panic("Test 2 failed")
|
||||
}
|
||||
|
||||
// Reverse the order for the above
|
||||
if p.Hop(pInt) != 805 {
|
||||
panic("Test 3 failed")
|
||||
}
|
||||
|
||||
if p.Hop(false) != 801 {
|
||||
panic("Test 4 failed")
|
||||
}
|
||||
|
||||
// Few more variations and order shuffled
|
||||
if p.Pop(false) != 901 {
|
||||
panic("Test 5 failed")
|
||||
}
|
||||
|
||||
if p.Pop(pInt) != 902 {
|
||||
panic("Test 6 failed")
|
||||
}
|
||||
|
||||
if p.Pop() != 905 {
|
||||
panic("Test 7 failed")
|
||||
}
|
||||
|
||||
// Overload on const only
|
||||
if p.Bop(pInt) != 1001 {
|
||||
panic("Test 8 failed")
|
||||
}
|
||||
|
||||
if p.Bip(pInt) != 2001 {
|
||||
panic("Test 9 failed")
|
||||
}
|
||||
|
||||
// Globals
|
||||
if Muzak(false) != 3001 {
|
||||
panic("Test 10 failed")
|
||||
}
|
||||
|
||||
if Muzak(pInt) != 3002 {
|
||||
panic("Test 11 failed")
|
||||
}
|
||||
}
|
||||
8
Examples/test-suite/go/overload_copy_runme.go
Normal file
8
Examples/test-suite/go/overload_copy_runme.go
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
package main
|
||||
|
||||
import . "./overload_copy"
|
||||
|
||||
func main() {
|
||||
f := NewFoo()
|
||||
_ = NewFoo(f)
|
||||
}
|
||||
22
Examples/test-suite/go/overload_extend_runme.go
Normal file
22
Examples/test-suite/go/overload_extend_runme.go
Normal file
|
|
@ -0,0 +1,22 @@
|
|||
package main
|
||||
|
||||
import "./overload_extend"
|
||||
|
||||
func main() {
|
||||
f := overload_extend.NewFoo()
|
||||
if f.Test().(int) != 0 {
|
||||
panic(0)
|
||||
}
|
||||
if f.Test(3).(int) != 1 {
|
||||
panic(0)
|
||||
}
|
||||
if f.Test("hello").(int) != 2 {
|
||||
panic(0)
|
||||
}
|
||||
if f.Test(float64(3), float64(2)).(float64) != 5 {
|
||||
panic(0)
|
||||
}
|
||||
if f.Test(float64(3.0)).(float64) != 1003 {
|
||||
panic(0)
|
||||
}
|
||||
}
|
||||
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue