Conflicts:

.gitignore
	.project
	.travis.yml
	Examples/Makefile.in
	Examples/test-suite/director_nspace.i
This commit is contained in:
Oliver Buchtala 2013-09-27 02:29:02 +02:00
commit 6dcbbf07db
54 changed files with 10011 additions and 15 deletions

View file

@ -0,0 +1,181 @@
#######################################################################
# Makefile for javascript test-suite
#######################################################################
LANGUAGE = javascript
SCRIPTSUFFIX = _runme.js
srcdir = @srcdir@
top_srcdir = @top_srcdir@
top_builddir = @top_builddir@
SWIG = $(top_builddir)/preinst_swig
ifneq (, $(ENGINE))
JSENGINE=$(ENGINE)
else
JSENGINE=node
endif
# Note: the javascript generator is not ready yet for the real game.
# To be able keep the behavior continously tested that is expected to work already
# we have a 'light' version of the test-suite
# This will be removed and replaced by a list of 'BROKEN_TEST_CASES' when
# the number gets smaller (currently we have about 65 broken tests for JSC, and 85 for V8)
ifneq (,$(SMOKE))
C_TEST_CASES = \
preproc \
preproc_include
CPP_TEST_CASES = \
abstract_access \
abstract_typedef \
abstract_typedef2 \
abstract_virtual \
arrays_global \
array_member \
char_binary \
class_ignore \
class_scope_weird \
complextest \
constover \
constructor_copy \
cpp_enum \
cpp_namespace \
cpp_static \
enum_template \
namespace_virtual_method \
nspace \
nspace_extend \
overload_copy \
rename_simple \
rename_scope \
ret_by_value \
struct_value \
template_static \
typedef_class \
typedef_inherit \
typedef_scope \
typemap_arrays \
typemap_delete \
typemap_namespace \
typemap_ns_using \
using1 \
using2 \
javascript_unicode
SKIP_CPP_CASES = @SKIP_CPP_CASES@
SKIP_C_CASES = @SKIP_C_CASES@
SKIP_CPP_STD_CASES = @SKIP_CPP_STD_CASES@
SKIP_MULTI_CPP_CASES = @SKIP_MULTI_CPP_CASES@
endif
include $(srcdir)/../common.mk
_setup = \
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
echo "$(ACTION)ing testcase $* (with run test) under javascript ($(JSENGINE))" ; \
else \
echo "$(ACTION)ing testcase $* under javascript ($(JSENGINE))" ; \
fi;
ifneq (jsc,$(ENGINE))
# This test can not be run with v8 as it uses v8 API incompatible output typemaps
typemap_variables.cpptest:
echo "skipping testcase typemap_variables under javascript ($(JSENGINE))."
# with v8 we have to generate C++ wrappers only
# these tests did raise warnings which are ignored
nested.ctest: SWIGOPT += -w312,-325
nested_structs.ctest: SWIGOPT += -w312,-325
unions.ctest: SWIGOPT += -w312,-325
endif
ifeq (node,$(JSENGINE))
SWIGOPT += -v8 -DBUILDING_NODE_EXTENSION=1
# shut up some warnings
# contract macro has an empty 'else' at the end...
aggregate.cpptest: GYP_CFLAGS = \"-Wno-empty-body\"
contract.cpptest: GYP_CFLAGS = \"-Wno-empty-body\"
# dunno... ignoring generously
apply_signed_char.cpptest: GYP_CFLAGS = \"-Wno-ignored-qualifiers\"
constant_pointers.cpptest: GYP_CFLAGS = \"-Wno-ignored-qualifiers\"
enum_thorough.cpptest: GYP_CFLAGS = \"-Wno-ignored-qualifiers\"
__setup = \
sh ./setup_test.sh $* $(GYP_CFLAGS); \
$(SWIG) -c++ -javascript $(SWIGOPT) ../$*.i;
nodejs_swig_and_compile = \
node-gyp --loglevel=silent --directory $* configure build 1>>/dev/null
run_testcase = \
if [ -f $(srcdir)/$*$(SCRIPTSUFFIX) ]; then \
node $(srcdir)/$*$(SCRIPTSUFFIX); \
fi
%.cpptest:
$(_setup)
$(__setup)
$(nodejs_swig_and_compile)
$(run_testcase)
%.ctest:
$(_setup)
$(__setup)
$(nodejs_swig_and_compile)
$(run_testcase)
%.multicpptest:
$(_setup)
else
SWIGOPT += -$(JSENGINE)
run_testcase = \
if [ -f $(srcdir)/$*$(SCRIPTSUFFIX) ]; then \
$(top_srcdir)/Tools/javascript/javascript -$(JSENGINE) $(srcdir)/$*$(SCRIPTSUFFIX); \
fi
%.cpptest:
$(_setup)
+$(swig_and_compile_cpp)
$(run_testcase)
%.multicpptest:
$(_setup)
+$(swig_and_compile_multi_cpp)
$(run_testcase)
endif
ifeq (v8,$(ENGINE))
%.ctest:
$(_setup)
+$(swig_and_compile_cpp)
$(run_testcase)
endif
ifeq (jsc,$(ENGINE))
%.ctest:
$(_setup)
+$(swig_and_compile_c)
$(run_testcase)
endif
%.clean:
rm -rf $*
clean:
rm -f *_wrap.cxx
rm -f *_wrap.c
rm -f *.so
rm -f *.o

View file

@ -0,0 +1,6 @@
var abstract_access = require("./abstract_access");
var d = new abstract_access.D()
if (d.do_x() != 1) {
throw "Error";
}

View file

@ -0,0 +1,40 @@
var abstract_inherit = require("./abstract_inherit");
// Shouldn't be able to instantiate any of these classes
// since none of them implements the pure virtual function
// declared in the base class (Foo).
var Foo = abstract_inherit.Foo;
var Bar = abstract_inherit.Bar;
var Spam = abstract_inherit.Spam;
var caughtException = false;
try {
new Foo();
} catch (err) {
caughtException = true;
}
if (!caughtException) {
throw new Error("Foo should be instantiated as it is abstract");
}
caughtException = false;
try {
new Bar();
} catch (err) {
caughtException = true;
}
if (!caughtException) {
throw new Error("Bar should be instantiated as it is abstract");
}
caughtException = false;
try {
new Spam();
} catch (err) {
caughtException = true;
}
if (!caughtException) {
throw new Error("Spam should be instantiated as it is abstract");
}

View file

@ -0,0 +1,6 @@
var abstract_typedef2 = require("./abstract_typedef2");
var a = new abstract_typedef2.A_UF();
if (a == undefined)
throw "Error";

View file

@ -0,0 +1,8 @@
var abstract_typedef = require("./abstract_typedef");
var e = new abstract_typedef.Engine();
var a = new abstract_typedef.A()
if (a.write(e) != 1) {
throw "Error";
}

View file

@ -0,0 +1,11 @@
var abstract_virtual = require("./abstract_virtual");
d = new abstract_virtual.D()
if (d == undefined)
throw "Error";
e = new abstract_virtual.E()
if (e == undefined)
throw "Error";

View file

@ -0,0 +1,22 @@
var array_member = require("./array_member");
var f = new array_member.Foo();
f.data = array_member.global_data;
for (var i=0; i<8; i++) {
if (array_member.get_value(f.data,i) != array_member.get_value(array_member.global_data,i)) {
throw "Bad array assignment (1)";
}
}
for (var i=0; i<8; i++) {
array_member.set_value(f.data,i,-i);
}
array_member.global_data = f.data;
for (var i=0; i<8; i++){
if (array_member.get_value(f.data,i) != array_member.get_value(array_member.global_data,i)) {
throw "Bad array assignment (2)";
}
}

View file

@ -0,0 +1,18 @@
var arrays_global = require("./arrays_global");
arrays_global.array_i = arrays_global.array_const_i;
arrays_global.BeginString_FIX44a;
arrays_global.BeginString_FIX44b;
arrays_global.BeginString_FIX44c;
arrays_global.BeginString_FIX44d;
arrays_global.BeginString_FIX44d;
arrays_global.BeginString_FIX44b = "12"+'\0'+"45";
arrays_global.BeginString_FIX44b;
arrays_global.BeginString_FIX44d;
arrays_global.BeginString_FIX44e;
arrays_global.BeginString_FIX44f;
arrays_global.test_a("hello","hi","chello","chi");
arrays_global.test_b("1234567","hi");

View file

@ -0,0 +1,30 @@
var callback = require("./callback");
if (callback.foo(2) !== 2) {
throw new Error("Failed.");
}
if (callback.A_bar(2) !== 4) {
throw new Error("Failed.");
}
if (callback.foobar(3, callback.foo) != callback.foo(3)) {
throw new Error("Failed.");
}
if (callback.foobar(3, foo) != callback.foo(3)) {
throw new Error("Failed.");
}
if (callback.foobar(3, callback.A_bar) != callback.A_bar(3)) {
throw new Error("Failed.");
}
if (callback.foobar(3, callback.foof) != callback.foof(3)) {
throw new Error("Failed.");
}
if (callback.foobar_i(3, callback.foo_i) != callback.foo_i(3)) {
throw new Error("Failed.");
}
if (callback.foobar_d(3.5, callback.foo_d) != callback.foo_d(3.5)) {
throw new Error("Failed.");
}
var a = new callback.A();
if (callback.foobarm(3, a, callback.A.foom_cb_ptr) != a.foom(3)) {
throw new Error("Failed.");
}

View file

@ -0,0 +1,38 @@
var char_binary = require("./char_binary");
var t = new char_binary.Test();
if (t.strlen('hile') != 4) {
print(t.strlen('hile'));
throw("bad multi-arg typemap 1");
}
if (t.strlen('hil\0') != 4) {
throw("bad multi-arg typemap 2");
}
/*
* creating a raw char*
*/
var pc = char_binary.new_pchar(5);
char_binary.pchar_setitem(pc, 0, 'h');
char_binary.pchar_setitem(pc, 1, 'o');
char_binary.pchar_setitem(pc, 2, 'l');
char_binary.pchar_setitem(pc, 3, 'a');
char_binary.pchar_setitem(pc, 4, 0);
if (t.strlen(pc) != 4) {
throw("bad multi-arg typemap (3)");
}
char_binary.var_pchar = pc;
if (char_binary.var_pchar != "hola") {
print(char_binary.var_pchar);
throw("bad pointer case (1)");
}
char_binary.var_namet = pc;
if (char_binary.var_namet != "hola") {
throw("bad pointer case (2)");
}
char_binary.delete_pchar(pc);

View file

@ -0,0 +1,11 @@
var char_strings = require("./char_strings");
var assertIsEqual = function(expected, actual) {
if (expected !== actual) {
throw new Error("Expected "+expected+", was "+actual);
}
};
assertIsEqual("hi there", char_strings.CharPingPong("hi there"));
assertIsEqual("hi there", char_strings.CharArrayPingPong("hi there"));
assertIsEqual("hi there", char_strings.CharArrayDimsPingPong("hi there"));

View file

@ -0,0 +1,6 @@
var class_ignore = require("./class_ignore");
a = new class_ignore.Bar();
if (class_ignore.do_blah(a) != "Bar::blah")
throw "Error";

View file

@ -0,0 +1,6 @@
var class_scope_weird = require("./class_scope_weird");
f = new class_scope_weird.Foo();
g = new class_scope_weird.Foo(3);
if (f.bar(3) != 3)
throw RuntimeError;

View file

@ -0,0 +1,22 @@
var complextest = require("./complextest");
a = [-1,2];
expected = [-1, -2];
a_c = complextest.Conj(a);
if (a_c.toString() != expected.toString())
throw "Error in Conj(a)";
a_c_f = complextest.Conjf(a);
if (a_c_f.toString() != expected.toString())
throw "Error in Conjf(a)";
v = new complextest.VectorStdCplx();
v.add([1,2]);
v.add([2,3]);
v.add([4,3]);
v.add(1);
// TODO: how to check validity?
complextest.Copy_h(v);

View file

@ -0,0 +1,33 @@
var constover = require("./constover");
p = constover.test("test");
if (p != "test") {
throw "test failed!";
}
p = constover.test_pconst("test");
if (p != "test_pconst") {
throw "test_pconst failed!";
}
f = new constover.Foo();
p = f.test("test");
if (p != "test") {
throw "member-test failed!";
}
p = f.test_pconst("test");
if (p != "test_pconst") {
throw "member-test_pconst failed!";
}
p = f.test_constm("test");
if (p != "test_constmethod") {
throw "member-test_constm failed!";
}
p = f.test_pconstm("test");
if (p != "test_pconstmethod") {
throw "member-test_pconstm failed!";
}

View file

@ -0,0 +1,42 @@
var constructor_copy = require("./constructor_copy");
f1 = new constructor_copy.Foo1(3);
f11 = new constructor_copy.Foo1(f1);
if (f1.x != f11.x) {
throw "error in ctor copy for Foo1";
}
var good = 0;
f8 = new constructor_copy.Foo8()
try {
f81 = new constructor_copy.Foo8(f8);
good = 0;
} catch (err) {
good = 1;
}
if (good == 0) {
throw "Error: should not allow calling copy ctor for Foo8";
}
bi = new constructor_copy.Bari(5);
bc = new constructor_copy.Bari(bi);
if (bi.x != bc.x) {
throw "Error in copy ctor of Bari";
}
bd = new constructor_copy.Bard(5);
try {
bc = new constructor_copy.Bard(bd);
good = 0;
} catch (err) {
good = 1;
}
if (good == 0) {
throw "Error: should not allow calling copy ctor for Bard";
}

View file

@ -0,0 +1,28 @@
var cpp_enum = require("./cpp_enum");
var f = new cpp_enum.Foo()
if(f.hola != cpp_enum.Hello){
print(f.hola);
throw "Error";
}
f.hola = cpp_enum.Foo.Hi
if(f.hola != cpp_enum.Foo.Hi){
print(f.hola);
throw "Error";
}
f.hola = cpp_enum.Hello
if(f.hola != cpp_enum.Hello){
print(f.hola);
throw "Error";
}
cpp_enum.Foo.hi = cpp_enum.Hello
if(cpp_enum.Foo.hi != cpp_enum.Hello){
print(cpp_enum.Foo.hi);
throw "Error";
}

View file

@ -0,0 +1,47 @@
var cpp_namespace = require("./cpp_namespace");
var n = cpp_namespace.fact(4);
if (n != 24){
throw ("Bad return value error!");
}
if (cpp_namespace.Foo != 42){
throw ("Bad variable value error!");
}
t = new cpp_namespace.Test();
if (t.method() != "Test::method"){
throw ("Bad method return value error!");
}
if (cpp_namespace.do_method(t) != "Test::method"){
throw ("Bad return value error!");
}
if (cpp_namespace.do_method2(t) != "Test::method"){
throw ("Bad return value error!");
}
cpp_namespace.weird("hello", 4);
delete t;
t2 = new cpp_namespace.Test2();
t3 = new cpp_namespace.Test3();
t4 = new cpp_namespace.Test4();
t5 = new cpp_namespace.Test5();
if (cpp_namespace.foo3(42) != 42){
throw ("Bad return value error!");
}
if (cpp_namespace.do_method3(t2,40) != "Test2::method"){
throw ("Bad return value error!");
}
if (cpp_namespace.do_method3(t3,40) != "Test3::method"){
throw ("Bad return value error!");
}
if (cpp_namespace.do_method3(t4,40) != "Test4::method"){
throw ("Bad return value error!");
}
if (cpp_namespace.do_method3(t5,40) != "Test5::method"){
throw ("Bad return value error!");
}

View file

@ -0,0 +1,9 @@
var cpp_static = require("./cpp_static");
cpp_static.StaticFunctionTest.static_func();
cpp_static.StaticFunctionTest.static_func_2(1);
cpp_static.StaticFunctionTest.static_func_3(1,2);
cpp_static.StaticMemberTest.static_int = 10;
if (cpp_static.StaticMemberTest.static_int != 10)
throw "error";

View file

@ -0,0 +1,5 @@
var director_alternating = require("./director_alternating");
id = director_alternating.getBar().id();
if (id != director_alternating.idFromGetBar())
throw ("Error, Got wrong id: " + str(id));

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