Conflicts:
	.project
	COPYRIGHT
	Doc/Manual/style.css
	Examples/Makefile.in
	Examples/test-suite/common.mk
	Lib/typemaps/strings.swg
	Makefile.in
	Source/DOH/fio.c
	Source/Makefile.am
	Source/Modules/emit.cxx
	Source/Modules/javascript.cxx
	configure.in

git-svn-id: https://swig.svn.sourceforge.net/svnroot/swig/branches/oliverb-javascript-v8@13764 626c5289-ae23-0410-ae9c-e8d60b6d4f22
This commit is contained in:
Oliver Buchtala 2012-09-08 00:56:48 +00:00
commit 050219d998
136 changed files with 7987 additions and 141 deletions

View file

@ -0,0 +1,94 @@
#######################################################################
# Makefile for javascript test-suite
#######################################################################
LANGUAGE = javascript
JAVASCRIPT_EXE = ../../../Tools/javascript/javascript
JAVASCRIPT_EXE_SRC = ../../../Tools/javascript/javascript.cxx
SCRIPTSUFFIX = _runme.js
srcdir = @srcdir@
top_srcdir = @top_srcdir@
top_builddir = @top_builddir@
JS_INCLUDE = @JSCOREINC@
JS_DLNK = @JSCOREDYNAMICLINKING@
JSCXXFLAGS = @JSCXXFLAGS@
C_TEST_CASES = \
preproc \
preproc_include
CPP_TEST_CASES = \
abstract_access \
abstract_typedef \
abstract_typedef2 \
abstract_virtual \
array_member \
arrays_global \
char_binary \
class_ignore \
class_scope_weird \
complextest \
constover \
cpp_enum \
cpp_namespace \
cpp_static \
director_alternating \
enum_template \
namespace_virtual_method \
overload_copy \
ret_by_value \
struct_value \
template_static \
typedef_class \
typedef_inherit \
typedef_scope \
typemap_arrays \
typemap_delete \
typemap_namespace \
typemap_ns_using \
using1 \
using2
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@
include $(srcdir)/../common.mk
# Overridden variables here
# Custom tests - tests with additional commandline options
javascript_exe:
$(CXX) $(JSCXXFLAGS) $(JS_INCLUDE) $(JAVASCRIPT_EXE_SRC) $(LIBS) $(JS_DLNK) -o $(JAVASCRIPT_EXE)
# Rules for the different types of tests
%.cpptest: javascript_exe
$(setup)
+$(swig_and_compile_cpp)
$(run_testcase)
%.ctest: javascript_exe
$(setup)
+$(swig_and_compile_c)
$(run_testcase)
%.multicpptest: javascript_exe
$(setup)
+$(swig_and_compile_multi_cpp)
$(run_testcase)
# Runs the testcase. A testcase is only run if
# a file is found which has _runme.js appended after the testcase name.
run_testcase = \
if [ -f $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX) ]; then \
env LD_LIBRARY_PATH=.:$$LD_LIBRARY_PATH $(RUNTOOL) $(JAVASCRIPT_EXE) -l $* $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \
fi
# Clean
%.clean:
clean:
$(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile javascript_clean

View file

@ -0,0 +1,4 @@
See ../README for common README file.
Any testcases which have _runme.js appended after the testcase name will be detected and run.

View file

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

View file

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

View file

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

View file

@ -0,0 +1,9 @@
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,20 @@
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,16 @@
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,36 @@
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,5 @@
a = new class_ignore.Bar();
if (class_ignore.do_blah(a) != "Bar::blah")
throw "Error";

View file

@ -0,0 +1,5 @@
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,21 @@
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,31 @@
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,26 @@
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,45 @@
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,7 @@
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,4 @@
id = director_alternating.getBar().id();
if (id != director_alternating.idFromGetBar())
throw ("Error, Got wrong id: " + str(id));

View file

@ -0,0 +1,6 @@
if (enum_template.MakeETest() != 1)
throw "RuntimeError";
if (enum_template.TakeETest(0) != null)
throw "RuntimeError";

View file

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

View file

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

View file

@ -0,0 +1,22 @@
if (preproc_include.multiply10(10) != 100)
throw "RuntimeError";
if (preproc_include.multiply20(10) != 200)
throw "RuntimeError";
if (preproc_include.multiply30(10) != 300)
throw "RuntimeError";
if (preproc_include.multiply40(10) != 400)
throw "RuntimeError";
if (preproc_include.multiply50(10) != 500)
throw "RuntimeError";
if (preproc_include.multiply60(10) != 600)
throw "RuntimeError";
if (preproc_include.multiply70(10) != 700)
throw "RuntimeError";

View file

@ -0,0 +1,13 @@
if (preproc.endif != 1)
throw "RuntimeError";
if (preproc.define != 1)
throw "RuntimeError";
if (preproc.defined != 1)
throw "RuntimeError";
if (2*preproc.one != preproc.two)
throw "RuntimeError";

View file

@ -0,0 +1,7 @@
a = ret_by_value.get_test();
if (a.myInt != 100)
throw "RuntimeError";
if (a.myShort != 200)
throw "RuntimeError";

View file

@ -0,0 +1,10 @@
b = new struct_value.Bar();
b.a.x = 3;
if (b.a.x != 3)
throw "RuntimeError";
b.b.x = 3;
if (b.b.x != 3)
throw "RuntimeError"

View file

@ -0,0 +1,2 @@
template_static.Foo.bar_double(1);

View file

@ -0,0 +1,5 @@
a = new typedef_class.RealA();
a.a = 3;
b = new typedef_class.B();
b.testA(a);

View file

@ -0,0 +1,22 @@
a = new typedef_inherit.Foo();
b = new typedef_inherit.Bar();
x = typedef_inherit.do_blah(a);
if (x != "Foo::blah")
print("Whoa! Bad return" + x);
x = typedef_inherit.do_blah(b);
if (x != "Bar::blah")
print("Whoa! Bad return" + x);
c = new typedef_inherit.Spam();
d = new typedef_inherit.Grok();
x = typedef_inherit.do_blah2(c);
if (x != "Spam::blah")
print("Whoa! Bad return" + x);
x = typedef_inherit.do_blah2(d);
if (x != "Grok::blah")
print ("Whoa! Bad return" + x);

View file

@ -0,0 +1,11 @@
b = new typedef_scope.Bar();
x = b.test1(42,"hello");
if (x != 42)
print("Failed!!");
x = b.test2(42,"hello");
if (x != "hello")
print("Failed!!");

View file

@ -0,0 +1,4 @@
if (typemap_arrays.sumA(null) != 60)
throw "RuntimeError, Sum is wrong";

View file

@ -0,0 +1,4 @@
r = new typemap_delete.Rect(123);
if (r.val != 123)
throw "RuntimeError";

View file

@ -0,0 +1,6 @@
if (typemap_namespace.test1("hello") != "hello")
throw "RuntimeError";
if (typemap_namespace.test2("hello") != "hello")
throw "RuntimeError";

View file

@ -0,0 +1,3 @@
if (typemap_ns_using.spam(37) != 37)
throw "RuntimeError";

View file

@ -0,0 +1,4 @@
if (using1.spam(37) != 37)
throw "RuntimeError";

View file

@ -0,0 +1,3 @@
if (using2.spam(37) != 37)
throw "RuntimeError";