diff --git a/.gitignore b/.gitignore index 147e44cb2..665699d05 100644 --- a/.gitignore +++ b/.gitignore @@ -75,6 +75,7 @@ Examples/test-suite/*/*.c Examples/test-suite/*/*.h Examples/test-suite/python/*.py Examples/javascript/*/*_wrap.c +Examples/test-suite/javascript/*/* Tools/javascript/javascript Tools/javascript/javascript_d .settings diff --git a/Examples/test-suite/javascript/Makefile.in b/Examples/test-suite/javascript/Makefile.in index e57081412..edc621c7e 100755 --- a/Examples/test-suite/javascript/Makefile.in +++ b/Examples/test-suite/javascript/Makefile.in @@ -10,25 +10,23 @@ top_builddir = @top_builddir@ JS_INCLUDE = @JSCOREINC@ JS_DLNK = @JSCOREDYNAMICLINKING@ JSCXXFLAGS = @JSCXXFLAGS@ -JAVASCRIPT_EXE = $(top_srcdir)/Tools/javascript/javascript +JAVASCRIPT_EXE = node +SWIG = $(top_builddir)/preinst_swig C_TEST_CASES = \ - preproc \ - preproc_include + preproc + CPP_TEST_CASES = \ abstract_access \ abstract_typedef \ abstract_typedef2 \ abstract_virtual \ - array_member \ arrays_global \ char_binary \ class_ignore \ class_scope_weird \ - complextest \ constover \ - constructor_copy \ cpp_enum \ cpp_namespace \ cpp_static \ @@ -50,6 +48,12 @@ CPP_TEST_CASES = \ using2 \ javascript_unicode +BROKEN_TEST_CASES = \ + array_member \ + complextest \ + constructor_copy \ + preproc_include + SKIP_CPP_CASES = @SKIP_CPP_CASES@ SKIP_C_CASES = @SKIP_C_CASES@ SKIP_CPP_STD_CASES = @SKIP_CPP_STD_CASES@ @@ -57,45 +61,47 @@ SKIP_MULTI_CPP_CASES = @SKIP_MULTI_CPP_CASES@ include $(srcdir)/../common.mk -ifeq (,$(V8)) -JSENGINEFLAG = -jsc -else -JSENGINEFLAG = -v8 -endif - # Overridden variables here # Custom tests - tests with additional commandline options -javascript_exe: - $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile JSCXXSRCS='$(JSCXXSRCS)' TOP='$(top_builddir)/$(EXAMPLES)' javascript_exe - # Rules for the different types of tests -%.cpptest: javascript_exe - $(setup) - +$(swig_and_compile_cpp) +%.cpptest: + $(prepare_test) + $(generate_cpp_wrapper) + $(build_module) $(run_testcase) -%.ctest: javascript_exe - $(setup) - +$(swig_and_compile_c) +%.ctest: + $(prepare_test) + $(generate_cpp_wrapper) + $(build_module) $(run_testcase) -%.multicpptest: javascript_exe - $(setup) - +$(swig_and_compile_multi_cpp) +%.multicpptest: + $(prepare_test) + $(generate_cpp_wrapper) + $(build_module) $(run_testcase) +prepare_test = \ + sh ./setup_test.sh $* + +generate_cpp_wrapper = \ + $(SWIG) -c++ -javascript -node -o $*/$*_wrap.cxx ../$*.i + +build_module = \ + cd $* && node-gyp configure build && cd .. + # 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) $(JSENGINEFLAG) -l $* $(srcdir)/$(SCRIPTPREFIX)$*$(SCRIPTSUFFIX); \ + if [ -f $(srcdir)/$*$(SCRIPTSUFFIX) ]; then \ + node $(srcdir)/$*$(SCRIPTSUFFIX); \ fi # Clean %.clean: - clean: $(MAKE) -f $(top_builddir)/$(EXAMPLES)/Makefile javascript_clean diff --git a/Examples/test-suite/javascript/abstract_access_runme.js b/Examples/test-suite/javascript/abstract_access_runme.js index 356d07ea7..8f87d2105 100644 --- a/Examples/test-suite/javascript/abstract_access_runme.js +++ b/Examples/test-suite/javascript/abstract_access_runme.js @@ -1,5 +1,6 @@ +var abstract_access = require("./abstract_access"); + var d = new abstract_access.D() if (d.do_x() != 1) { throw "Error"; } - diff --git a/Examples/test-suite/javascript/abstract_typedef2_runme.js b/Examples/test-suite/javascript/abstract_typedef2_runme.js index 8adc2e05b..c177e49c3 100644 --- a/Examples/test-suite/javascript/abstract_typedef2_runme.js +++ b/Examples/test-suite/javascript/abstract_typedef2_runme.js @@ -1,3 +1,5 @@ +var abstract_typedef2 = require("./abstract_typedef2"); + var a = new abstract_typedef2.A_UF(); if (a == undefined) diff --git a/Examples/test-suite/javascript/abstract_typedef_runme.js b/Examples/test-suite/javascript/abstract_typedef_runme.js index 106baea65..abcfc581d 100644 --- a/Examples/test-suite/javascript/abstract_typedef_runme.js +++ b/Examples/test-suite/javascript/abstract_typedef_runme.js @@ -1,3 +1,5 @@ +var abstract_typedef = require("./abstract_typedef"); + var e = new abstract_typedef.Engine(); var a = new abstract_typedef.A() diff --git a/Examples/test-suite/javascript/abstract_virtual_runme.js b/Examples/test-suite/javascript/abstract_virtual_runme.js index c15abb5f6..9e2814e41 100644 --- a/Examples/test-suite/javascript/abstract_virtual_runme.js +++ b/Examples/test-suite/javascript/abstract_virtual_runme.js @@ -1,3 +1,5 @@ +var abstract_virtual = require("./abstract_virtual"); + d = new abstract_virtual.D() if (d == undefined) diff --git a/Examples/test-suite/javascript/array_member_runme.js b/Examples/test-suite/javascript/array_member_runme.js index dee4c2ca9..8c4ef1da5 100644 --- a/Examples/test-suite/javascript/array_member_runme.js +++ b/Examples/test-suite/javascript/array_member_runme.js @@ -1,3 +1,5 @@ +var array_member = require("./array_member"); + var f = new array_member.Foo(); f.data = array_member.global_data; diff --git a/Examples/test-suite/javascript/arrays_global_runme.js b/Examples/test-suite/javascript/arrays_global_runme.js index 9668826f3..fdb365f83 100644 --- a/Examples/test-suite/javascript/arrays_global_runme.js +++ b/Examples/test-suite/javascript/arrays_global_runme.js @@ -1,3 +1,5 @@ +var arrays_global = require("./arrays_global"); + arrays_global.array_i = arrays_global.array_const_i; arrays_global.BeginString_FIX44a; diff --git a/Examples/test-suite/javascript/char_binary_runme.js b/Examples/test-suite/javascript/char_binary_runme.js index 7cd09bd5c..42abe6060 100644 --- a/Examples/test-suite/javascript/char_binary_runme.js +++ b/Examples/test-suite/javascript/char_binary_runme.js @@ -1,3 +1,5 @@ +var char_binary = require("./char_binary"); + var t = new char_binary.Test(); if (t.strlen('hile') != 4) { print(t.strlen('hile')); diff --git a/Examples/test-suite/javascript/class_ignore_runme.js b/Examples/test-suite/javascript/class_ignore_runme.js index 00bb2591e..f0a32a1c4 100644 --- a/Examples/test-suite/javascript/class_ignore_runme.js +++ b/Examples/test-suite/javascript/class_ignore_runme.js @@ -1,3 +1,4 @@ +var class_ignore = require("./class_ignore"); a = new class_ignore.Bar(); diff --git a/Examples/test-suite/javascript/class_scope_weird_runme.js b/Examples/test-suite/javascript/class_scope_weird_runme.js index c442cc7f6..ac745d023 100644 --- a/Examples/test-suite/javascript/class_scope_weird_runme.js +++ b/Examples/test-suite/javascript/class_scope_weird_runme.js @@ -1,3 +1,4 @@ +var class_scope_weird = require("./class_scope_weird"); f = new class_scope_weird.Foo(); g = new class_scope_weird.Foo(3); diff --git a/Examples/test-suite/javascript/complextest_runme.js b/Examples/test-suite/javascript/complextest_runme.js index 9d3cf4264..1fcc97648 100644 --- a/Examples/test-suite/javascript/complextest_runme.js +++ b/Examples/test-suite/javascript/complextest_runme.js @@ -1,3 +1,4 @@ +var complextest = require("./complextest"); a = [-1,2]; diff --git a/Examples/test-suite/javascript/constover_runme.js b/Examples/test-suite/javascript/constover_runme.js index f131ef444..764d8b328 100644 --- a/Examples/test-suite/javascript/constover_runme.js +++ b/Examples/test-suite/javascript/constover_runme.js @@ -1,3 +1,5 @@ +var constover = require("./constover"); + p = constover.test("test"); if (p != "test") { throw "test failed!"; @@ -7,7 +9,7 @@ p = constover.test_pconst("test"); if (p != "test_pconst") { throw "test_pconst failed!"; } - + f = new constover.Foo(); p = f.test("test"); diff --git a/Examples/test-suite/javascript/constructor_copy_runme.js b/Examples/test-suite/javascript/constructor_copy_runme.js index 627b0936b..39dce52ce 100644 --- a/Examples/test-suite/javascript/constructor_copy_runme.js +++ b/Examples/test-suite/javascript/constructor_copy_runme.js @@ -1,3 +1,4 @@ +var constructor_copy = require("./constructor_copy"); f1 = new constructor_copy.Foo1(3); f11 = new constructor_copy.Foo1(f1); diff --git a/Examples/test-suite/javascript/cpp_enum_runme.js b/Examples/test-suite/javascript/cpp_enum_runme.js index f5a9e3595..35f7c60ac 100644 --- a/Examples/test-suite/javascript/cpp_enum_runme.js +++ b/Examples/test-suite/javascript/cpp_enum_runme.js @@ -1,3 +1,5 @@ +var cpp_enum = require("./cpp_enum"); + var f = new cpp_enum.Foo() if(f.hola != cpp_enum.Hello){ diff --git a/Examples/test-suite/javascript/cpp_namespace_runme.js b/Examples/test-suite/javascript/cpp_namespace_runme.js index 5795536bd..3bdfef3e9 100644 --- a/Examples/test-suite/javascript/cpp_namespace_runme.js +++ b/Examples/test-suite/javascript/cpp_namespace_runme.js @@ -1,3 +1,5 @@ +var cpp_namespace = require("./cpp_namespace"); + var n = cpp_namespace.fact(4); if (n != 24){ throw ("Bad return value error!"); @@ -16,7 +18,7 @@ if (cpp_namespace.do_method(t) != "Test::method"){ if (cpp_namespace.do_method2(t) != "Test::method"){ throw ("Bad return value error!"); -} +} cpp_namespace.weird("hello", 4); delete t; diff --git a/Examples/test-suite/javascript/cpp_static_runme.js b/Examples/test-suite/javascript/cpp_static_runme.js index 0ff28b4ee..2579aeafe 100644 --- a/Examples/test-suite/javascript/cpp_static_runme.js +++ b/Examples/test-suite/javascript/cpp_static_runme.js @@ -1,3 +1,5 @@ +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); diff --git a/Examples/test-suite/javascript/director_alternating_runme.js b/Examples/test-suite/javascript/director_alternating_runme.js index 3c2c883a1..a0411eace 100644 --- a/Examples/test-suite/javascript/director_alternating_runme.js +++ b/Examples/test-suite/javascript/director_alternating_runme.js @@ -1,3 +1,4 @@ +var director_alternating = require("./director_alternating"); id = director_alternating.getBar().id(); if (id != director_alternating.idFromGetBar()) diff --git a/Examples/test-suite/javascript/enum_template_runme.js b/Examples/test-suite/javascript/enum_template_runme.js index 54195c78b..20f8c3482 100644 --- a/Examples/test-suite/javascript/enum_template_runme.js +++ b/Examples/test-suite/javascript/enum_template_runme.js @@ -1,6 +1,8 @@ +var enum_template = require("./enum_template"); + if (enum_template.MakeETest() != 1) throw "RuntimeError"; if (enum_template.TakeETest(0) != null) throw "RuntimeError"; - + diff --git a/Examples/test-suite/javascript/javascript_unicode_runme.js b/Examples/test-suite/javascript/javascript_unicode_runme.js index 4974ef40b..f5f747aa7 100644 --- a/Examples/test-suite/javascript/javascript_unicode_runme.js +++ b/Examples/test-suite/javascript/javascript_unicode_runme.js @@ -1,3 +1,5 @@ +var javascript_unicode = require("./javascript_unicode"); + var str = "olé"; var copy = javascript_unicode.copy_string(str); diff --git a/Examples/test-suite/javascript/namespace_virtual_method_runme.js b/Examples/test-suite/javascript/namespace_virtual_method_runme.js index bb187b993..24d3bd487 100644 --- a/Examples/test-suite/javascript/namespace_virtual_method_runme.js +++ b/Examples/test-suite/javascript/namespace_virtual_method_runme.js @@ -1,2 +1,3 @@ +var namespace_virtual_method = require("./namespace_virtual_method"); x = new namespace_virtual_method.Spam(); diff --git a/Examples/test-suite/javascript/overload_copy_runme.js b/Examples/test-suite/javascript/overload_copy_runme.js index 88fab3720..1039ffda1 100644 --- a/Examples/test-suite/javascript/overload_copy_runme.js +++ b/Examples/test-suite/javascript/overload_copy_runme.js @@ -1,3 +1,4 @@ +var overload_copy = require("./overload_copy"); f = new overload_copy.Foo(); g = new overload_copy.Foo(f); diff --git a/Examples/test-suite/javascript/preproc_include_runme.js b/Examples/test-suite/javascript/preproc_include_runme.js index d52ef97c1..4b827fbcc 100644 --- a/Examples/test-suite/javascript/preproc_include_runme.js +++ b/Examples/test-suite/javascript/preproc_include_runme.js @@ -1,3 +1,4 @@ +var preproc_include = require("./preproc_include"); if (preproc_include.multiply10(10) != 100) throw "RuntimeError"; diff --git a/Examples/test-suite/javascript/preproc_runme.js b/Examples/test-suite/javascript/preproc_runme.js index b708385da..669f9d1f0 100644 --- a/Examples/test-suite/javascript/preproc_runme.js +++ b/Examples/test-suite/javascript/preproc_runme.js @@ -1,3 +1,4 @@ +var preproc = require("./preproc"); if (preproc.endif != 1) throw "RuntimeError"; diff --git a/Examples/test-suite/javascript/ret_by_value_runme.js b/Examples/test-suite/javascript/ret_by_value_runme.js index 720cd398f..d9a77a20b 100644 --- a/Examples/test-suite/javascript/ret_by_value_runme.js +++ b/Examples/test-suite/javascript/ret_by_value_runme.js @@ -1,3 +1,4 @@ +var ret_by_value = require("./ret_by_value"); a = ret_by_value.get_test(); if (a.myInt != 100) diff --git a/Examples/test-suite/javascript/setup_test.sh b/Examples/test-suite/javascript/setup_test.sh new file mode 100644 index 000000000..03ce3bc90 --- /dev/null +++ b/Examples/test-suite/javascript/setup_test.sh @@ -0,0 +1,6 @@ +#!/bin/sh +if [ ! -d $1 ]; then + mkdir $1; +fi +echo "module.exports = require('./build/Release/$1')" > $1/index.js +echo "{\"targets\":[{\"target_name\": \"$1\",\"sources\":[\"$1_wrap.cxx\"]}]}" > $1/binding.gyp diff --git a/Examples/test-suite/javascript/struct_value_runme.js b/Examples/test-suite/javascript/struct_value_runme.js index 314551688..d6b26f726 100644 --- a/Examples/test-suite/javascript/struct_value_runme.js +++ b/Examples/test-suite/javascript/struct_value_runme.js @@ -1,10 +1,11 @@ +var struct_value = require("./struct_value"); b = new struct_value.Bar(); b.a.x = 3; -if (b.a.x != 3) +if (b.a.x != 3) throw "RuntimeError"; b.b.x = 3; -if (b.b.x != 3) +if (b.b.x != 3) throw "RuntimeError" diff --git a/Examples/test-suite/javascript/template_static_runme.js b/Examples/test-suite/javascript/template_static_runme.js index 338e2c55c..477d97249 100644 --- a/Examples/test-suite/javascript/template_static_runme.js +++ b/Examples/test-suite/javascript/template_static_runme.js @@ -1,2 +1,3 @@ +var template_static = require("./template_static"); template_static.Foo.bar_double(1); diff --git a/Examples/test-suite/javascript/typedef_class_runme.js b/Examples/test-suite/javascript/typedef_class_runme.js index accefb499..3e4dc9093 100644 --- a/Examples/test-suite/javascript/typedef_class_runme.js +++ b/Examples/test-suite/javascript/typedef_class_runme.js @@ -1,5 +1,7 @@ +var typedef_class = require("./typedef_class"); + a = new typedef_class.RealA(); -a.a = 3; - +a.a = 3; + b = new typedef_class.B(); -b.testA(a); +b.testA(a); diff --git a/Examples/test-suite/javascript/typedef_inherit_runme.js b/Examples/test-suite/javascript/typedef_inherit_runme.js index f16c1787e..4abcc2536 100644 --- a/Examples/test-suite/javascript/typedef_inherit_runme.js +++ b/Examples/test-suite/javascript/typedef_inherit_runme.js @@ -1,3 +1,4 @@ +var typedef_inherit = require("./typedef_inherit"); a = new typedef_inherit.Foo(); b = new typedef_inherit.Bar(); diff --git a/Examples/test-suite/javascript/typedef_scope_runme.js b/Examples/test-suite/javascript/typedef_scope_runme.js index 8a08ffb9b..0ac56884c 100644 --- a/Examples/test-suite/javascript/typedef_scope_runme.js +++ b/Examples/test-suite/javascript/typedef_scope_runme.js @@ -1,3 +1,4 @@ +var typedef_scope = require("./typedef_scope"); b = new typedef_scope.Bar(); x = b.test1(42,"hello"); @@ -7,5 +8,5 @@ if (x != 42) x = b.test2(42,"hello"); if (x != "hello") print("Failed!!"); - - + + diff --git a/Examples/test-suite/javascript/typemap_arrays_runme.js b/Examples/test-suite/javascript/typemap_arrays_runme.js index 2126ed15f..cd6827ac9 100644 --- a/Examples/test-suite/javascript/typemap_arrays_runme.js +++ b/Examples/test-suite/javascript/typemap_arrays_runme.js @@ -1,3 +1,4 @@ +var typemap_arrays = require("./typemap_arrays"); if (typemap_arrays.sumA(null) != 60) throw "RuntimeError, Sum is wrong"; diff --git a/Examples/test-suite/javascript/typemap_delete_runme.js b/Examples/test-suite/javascript/typemap_delete_runme.js index d58684df4..4b3174956 100644 --- a/Examples/test-suite/javascript/typemap_delete_runme.js +++ b/Examples/test-suite/javascript/typemap_delete_runme.js @@ -1,3 +1,4 @@ +var typemap_delete = require("./typemap_delete"); r = new typemap_delete.Rect(123); if (r.val != 123) diff --git a/Examples/test-suite/javascript/typemap_namespace_runme.js b/Examples/test-suite/javascript/typemap_namespace_runme.js index d679f3b0b..614e0ffeb 100644 --- a/Examples/test-suite/javascript/typemap_namespace_runme.js +++ b/Examples/test-suite/javascript/typemap_namespace_runme.js @@ -1,3 +1,4 @@ +var typemap_namespace = require("./typemap_namespace"); if (typemap_namespace.test1("hello") != "hello") throw "RuntimeError"; diff --git a/Examples/test-suite/javascript/typemap_ns_using_runme.js b/Examples/test-suite/javascript/typemap_ns_using_runme.js index d05f7f0c1..9115c16ae 100644 --- a/Examples/test-suite/javascript/typemap_ns_using_runme.js +++ b/Examples/test-suite/javascript/typemap_ns_using_runme.js @@ -1,3 +1,4 @@ +var typemap_ns_using = require("./typemap_ns_using"); if (typemap_ns_using.spam(37) != 37) throw "RuntimeError"; diff --git a/Examples/test-suite/javascript/using1_runme.js b/Examples/test-suite/javascript/using1_runme.js index cb54a62fa..a2e37fcb6 100644 --- a/Examples/test-suite/javascript/using1_runme.js +++ b/Examples/test-suite/javascript/using1_runme.js @@ -1,4 +1,4 @@ - +var using1 = require("./using1"); if (using1.spam(37) != 37) throw "RuntimeError"; diff --git a/Examples/test-suite/javascript/using2_runme.js b/Examples/test-suite/javascript/using2_runme.js index 948f58ead..aa5e9b15f 100644 --- a/Examples/test-suite/javascript/using2_runme.js +++ b/Examples/test-suite/javascript/using2_runme.js @@ -1,3 +1,4 @@ +var using2 = require("./using2"); if (using2.spam(37) != 37) throw "RuntimeError";