Merge branch 'master' into javascript
* master:
Fix some typos
[PHP] The generated __isset() method now returns true for read-only properties.
Eliminate needless casting away const from string constants
Fix typos
Fix missing ")" in code example
Fix comment typos
Fix m4 quoting of checks for yodl2man and yodl2html versions
Fixed errors from previous commit.
Removed all unnecessary asserts
Remove unused variable
Another go html fix
Fix intgosize arg documentation
Optimize metamethods inheritance resolving
Updating documentation
Whitespace cleanup of Example Makefiles
.gitignore: ignore Lib/swigwarn.swg
Fixing unused variable warnings
Finish implementation with proxy functions
Remove duplicate declarations of strtoimax and strtoumax in inttypes.i
Ignored enum fixes.
Further shift operator regression fixes
Fix use of shift operators in expressions regression since 3.0.0
Fix seg fault with extra ) brackets and >>
More efficient end of template bracket (>>) handling
beautify scanner.c
Tidy up scanner.c
DOH readme correction
Fix typo in -lua -help output
Remove extra </div>
Update documentation for deprecation and removal of Close()
Fix segfault when there are too many closing round brackets in parsed code
Refix operator<< definition giving a syntax error
Fix regression in 3.0.0 where legal code following an operator<< definition might give a syntax error.
Remove unnecessary block from PHP version of SWIG_exception macro
[PHP] Fix wrapping director constructors with default parameters with a ZTS-enabled build of PHP.
Fix potential bugs found by Coverity analysis
Eliminate unused parameter from SWIG_Php_GetModule()
Fix comment typo
Fix compiler warnings in generated Lua code
[PHP] Pass the ZTS context we already have to avoid needing to call TSRMLS_FETCH, which is relatively expensive.
[PHP] Pass ZTS context through to t_output_helper() so it works with a ZTS-enabled build of PHP. Reported by Pierre Labastie in github PR#155.
Lua test-suite can now be run out of source
Fix out of source test-suite runs for Octave
Add runtime test for commit 7a96fba836
Add C++11 constexpr runtime test
This commit is contained in:
commit
f51be1ca5c
150 changed files with 935 additions and 410 deletions
|
|
@ -197,6 +197,7 @@ CPP_TEST_CASES += \
|
|||
disown \
|
||||
dynamic_cast \
|
||||
empty \
|
||||
enum_ignore \
|
||||
enum_plus \
|
||||
enum_rename \
|
||||
enum_scope_template \
|
||||
|
|
|
|||
|
|
@ -24,6 +24,14 @@ public:
|
|||
int operator<<(ABC &) { return 0; }
|
||||
};
|
||||
|
||||
class DEF {
|
||||
public:
|
||||
int a;
|
||||
int operator<<(DEF &) { return 0; }
|
||||
int operator>>(DEF &) { return 0; }
|
||||
};
|
||||
|
||||
|
||||
template<class T>
|
||||
class ABC2 {
|
||||
public:
|
||||
|
|
@ -37,3 +45,9 @@ public:
|
|||
};
|
||||
%}
|
||||
|
||||
// Test shifts are still working
|
||||
%inline %{
|
||||
int shift_init1 = 4 << 2 >> 1;
|
||||
int shift_init2 = 4 >> 2 << 1 << 1 >> 2;
|
||||
%}
|
||||
|
||||
|
|
|
|||
|
|
@ -30,6 +30,19 @@ class Foo {
|
|||
}
|
||||
|
||||
int (Foo::*func_ptr)(int);
|
||||
|
||||
const char* __str__() const { return "Foo"; }
|
||||
};
|
||||
|
||||
class FooSub : public Foo {
|
||||
public:
|
||||
FooSub() :Foo(42) {}
|
||||
};
|
||||
|
||||
class FooSubSub : public FooSub {
|
||||
public:
|
||||
FooSubSub() : FooSub() {}
|
||||
const char* __str__() const { return "FooSubSub"; }
|
||||
};
|
||||
|
||||
%}
|
||||
|
|
|
|||
|
|
@ -53,7 +53,7 @@ void main() {
|
|||
assert(-a == a);
|
||||
assert(-b == new Op(-5));
|
||||
|
||||
// Unfortunaly, there is no way to override conversion to boolean for
|
||||
// Unfortunately, there is no way to override conversion to boolean for
|
||||
// classes in D, opCast!("bool") is only used for structs.
|
||||
|
||||
// test []
|
||||
|
|
|
|||
20
Examples/test-suite/enum_ignore.i
Normal file
20
Examples/test-suite/enum_ignore.i
Normal file
|
|
@ -0,0 +1,20 @@
|
|||
%module enum_ignore
|
||||
|
||||
// Similar to enum_missing C test, but with namespaces and using %ignore
|
||||
|
||||
%ignore N::C;
|
||||
|
||||
%inline %{
|
||||
namespace N {
|
||||
enum C { Red, Green, Blue };
|
||||
|
||||
struct Draw {
|
||||
void DrawBW() {}
|
||||
void DrawC(C c) {}
|
||||
void DrawC_Ptr(C* c) {}
|
||||
void DrawC_ConstRef(C const& c) {}
|
||||
};
|
||||
}
|
||||
%}
|
||||
|
||||
|
||||
6
Examples/test-suite/errors/cpp_extra_brackets.i
Normal file
6
Examples/test-suite/errors/cpp_extra_brackets.i
Normal file
|
|
@ -0,0 +1,6 @@
|
|||
%module cpp_extra_brackets
|
||||
|
||||
// Extra brackets was segfaulting in SWIG-3.0.0
|
||||
struct ABC {
|
||||
int operator<<(ABC &))) { return 0; }
|
||||
};
|
||||
1
Examples/test-suite/errors/cpp_extra_brackets.stderr
Normal file
1
Examples/test-suite/errors/cpp_extra_brackets.stderr
Normal file
|
|
@ -0,0 +1 @@
|
|||
cpp_extra_brackets.i:5: Error: Syntax error in input(3).
|
||||
9
Examples/test-suite/errors/cpp_extra_brackets2.i
Normal file
9
Examples/test-suite/errors/cpp_extra_brackets2.i
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
%module cpp_extra_brackets
|
||||
|
||||
// Extra brackets was segfaulting in SWIG-3.0.0
|
||||
struct ABC {
|
||||
;
|
||||
)))
|
||||
int operator<<(ABC &) { return 0; }
|
||||
int operator>>(ABC &) { return 0; }
|
||||
};
|
||||
1
Examples/test-suite/errors/cpp_extra_brackets2.stderr
Normal file
1
Examples/test-suite/errors/cpp_extra_brackets2.stderr
Normal file
|
|
@ -0,0 +1 @@
|
|||
cpp_extra_brackets2.i:6: Error: Syntax error in input(3).
|
||||
33
Examples/test-suite/java/cpp11_constexpr_runme.java
Normal file
33
Examples/test-suite/java/cpp11_constexpr_runme.java
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
import cpp11_constexpr.*;
|
||||
|
||||
public class cpp11_constexpr_runme {
|
||||
|
||||
static {
|
||||
try {
|
||||
System.loadLibrary("cpp11_constexpr");
|
||||
} catch (UnsatisfiedLinkError e) {
|
||||
System.err.println("Native code library failed to load. See the chapter on Dynamic Linking Problems in the SWIG Java documentation for help.\n" + e);
|
||||
System.exit(1);
|
||||
}
|
||||
}
|
||||
|
||||
private static void check(int received, int expected) {
|
||||
if (expected != received)
|
||||
throw new RuntimeException("check failed, expected: " + expected + " received: " + received);
|
||||
}
|
||||
|
||||
public static void main(String argv[])
|
||||
{
|
||||
check(cpp11_constexpr.getAAA(), 10);
|
||||
check(cpp11_constexpr.getBBB(), 20);
|
||||
check(cpp11_constexpr.CCC(), 30);
|
||||
check(cpp11_constexpr.DDD(), 40);
|
||||
|
||||
ConstExpressions ce = new ConstExpressions();
|
||||
check(ce.JJJ, 100);
|
||||
check(ce.KKK, 200);
|
||||
check(ce.LLL, 300);
|
||||
check(ce.MMM(), 400);
|
||||
check(ce.NNN(), 500);
|
||||
}
|
||||
}
|
||||
|
|
@ -47,7 +47,7 @@ lua_no_module_global.%: SWIGOPT += -nomoduleglobal
|
|||
# a file is found which has _runme.lua appended after the testcase name.
|
||||
run_testcase = \
|
||||
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
|
||||
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(LUA) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
|
||||
env LUA_PATH="$(srcdir)/?.lua;" $(RUNTOOL) $(LUA) $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
|
||||
fi
|
||||
|
||||
# Clean: (does nothing, we dont generate extra lua code)
|
||||
|
|
|
|||
|
|
@ -76,3 +76,13 @@ assert(cb.test_func_ptr(f,2)==-8)
|
|||
|
||||
-- Test that __tostring metamethod produce no internal asserts
|
||||
f2_name = tostring(f2)
|
||||
|
||||
f3 = cb.FooSub()
|
||||
f3_name = tostring(f3)
|
||||
|
||||
f4 = cb.FooSubSub()
|
||||
f4_name = tostring(f4)
|
||||
|
||||
assert( f2_name == "Foo" )
|
||||
assert( f3_name == "Foo" )
|
||||
assert( f4_name == "FooSubSub" )
|
||||
|
|
|
|||
|
|
@ -78,6 +78,38 @@ assert(i(1,2)==6)
|
|||
assert(tostring(Op(1))=="Op(1)")
|
||||
assert(tostring(Op(-3))=="Op(-3)")
|
||||
|
||||
|
||||
-- check that operator overloads are correctly propogated down inheritance hierarchy
|
||||
|
||||
a_d=OpDerived()
|
||||
b_d=OpDerived(5)
|
||||
c_d=OpDerived(5)
|
||||
d_d=OpDerived(2)
|
||||
-- test equality
|
||||
assert(a_d~=b_d)
|
||||
assert(b_d==c_d)
|
||||
assert(a_d~=d_d)
|
||||
|
||||
-- test <
|
||||
assert(a_d<b_d)
|
||||
assert(a_d<=b_d)
|
||||
assert(b_d<=c_d)
|
||||
assert(b_d>=c_d)
|
||||
assert(b_d>d_d)
|
||||
assert(b_d>=d_d)
|
||||
--
|
||||
-- test + inheritance
|
||||
f_d=OpDerived(1)
|
||||
g_d=OpDerived(1)
|
||||
assert(f_d+g_d==Op(2))
|
||||
assert(f_d-g_d==Op(0))
|
||||
assert(f_d*g_d==Op(1))
|
||||
assert(f_d/g_d==Op(1))
|
||||
--
|
||||
-- plus add some code to check the __str__ fn inheritance
|
||||
assert(tostring(OpDerived(1))=="Op(1)")
|
||||
assert(tostring(OpDerived(-3))=="Op(-3)")
|
||||
|
||||
--[[
|
||||
/* Sample test code in C++
|
||||
|
||||
|
|
|
|||
|
|
@ -33,7 +33,7 @@ include $(srcdir)/../common.mk
|
|||
|
||||
# Overridden variables here
|
||||
LIBS = -L.
|
||||
CSRCS = octave_empty.c
|
||||
CSRCS = $(srcdir)/octave_empty.c
|
||||
|
||||
# Custom tests - tests with additional commandline options
|
||||
# none!
|
||||
|
|
|
|||
|
|
@ -230,10 +230,10 @@ __rshift__,__lshift__ >>,<<
|
|||
|
||||
__getitem__,__setitem__ for operator[]
|
||||
|
||||
Operators overloaded without C++ equivilents
|
||||
Operators overloaded without C++ equivalents
|
||||
__pow__ for power operator
|
||||
__str__ converts object to a string (should return a const char*)
|
||||
__concat__ for contatenation (if language supports)
|
||||
__concat__ for concatenation (if language supports)
|
||||
|
||||
*/
|
||||
|
||||
|
|
|
|||
|
|
@ -12,6 +12,7 @@ check::classname(simplestruct,$ss);
|
|||
$as=new arraystruct();
|
||||
$as->array_c="abc";
|
||||
check::equal($as->array_c,"a",'$as->array_c=="a"');
|
||||
check::equal(isset($as->array_const_i),TRUE,'isset($as->array_const_i)');
|
||||
|
||||
check::done();
|
||||
?>
|
||||
|
|
|
|||
35
Examples/test-suite/python/global_vars_runme.py
Normal file
35
Examples/test-suite/python/global_vars_runme.py
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
import global_vars
|
||||
|
||||
global_vars.init()
|
||||
b = global_vars.cvar.b
|
||||
if b != "string b":
|
||||
raise RuntimeError("Unexpected string: " + b)
|
||||
global_vars.cvar.b = "a string value"
|
||||
b = global_vars.cvar.b
|
||||
if b != "a string value":
|
||||
raise RuntimeError("Unexpected string: " + b)
|
||||
|
||||
x = global_vars.cvar.x
|
||||
if x != 1234:
|
||||
raise RuntimeError("Unexpected x: " + str(x))
|
||||
global_vars.cvar.x = 9876
|
||||
x = global_vars.cvar.x
|
||||
if x != 9876:
|
||||
raise RuntimeError("Unexpected string: " + str(x))
|
||||
|
||||
fail = True
|
||||
try:
|
||||
global_vars.cvar.notexist = "something"
|
||||
except AttributeError, e:
|
||||
fail = False
|
||||
if fail:
|
||||
raise RuntimeError("AttributeError should have been thrown")
|
||||
|
||||
fail = True
|
||||
try:
|
||||
g = global_vars.cvar.notexist
|
||||
except AttributeError, e:
|
||||
fail = False
|
||||
if fail:
|
||||
raise RuntimeError("AttributeError should have been thrown")
|
||||
|
||||
Loading…
Add table
Add a link
Reference in a new issue