diff options
Diffstat (limited to 'tests')
-rw-r--r-- | tests/embind/embind.test.js | 12 | ||||
-rw-r--r-- | tests/embind/embind_test.cpp | 16 |
2 files changed, 27 insertions, 1 deletions
diff --git a/tests/embind/embind.test.js b/tests/embind/embind.test.js index 64b3e889..b303d51c 100644 --- a/tests/embind/embind.test.js +++ b/tests/embind/embind.test.js @@ -1973,6 +1973,18 @@ module({ assert.equal(cm.Enum.ONE, cm.val_as_enum(cm.Enum.ONE)); }); }); + + BaseFixture.extend("val::new_", function() { + test("variety of types", function() { + function factory() { + this.arguments = Array.prototype.slice.call(arguments, 0); + } + var instance = cm.construct_with_6_arguments(factory); + assert.deepEqual( + [6, -12.5, "a3", {x: 1, y: 2, z: 3, w: 4}, cm.EnumClass.TWO, [-1, -2, -3, -4]], + instance.arguments); + }); + }); }); /* global run_all_tests */ diff --git a/tests/embind/embind_test.cpp b/tests/embind/embind_test.cpp index 2f78fa2f..8dab6ec7 100644 --- a/tests/embind/embind_test.cpp +++ b/tests/embind/embind_test.cpp @@ -842,7 +842,7 @@ Enum emval_test_take_and_return_Enum(Enum e) { return e; } -enum class EnumClass { ONE, TWO }; +enum class EnumClass : char { ONE, TWO }; EnumClass emval_test_take_and_return_EnumClass(EnumClass e) { return e; @@ -2332,3 +2332,17 @@ EMSCRIPTEN_BINDINGS(val_as) { // memory_view is always JS -> C++ //function("val_as_memory_view", &val_as<memory_view>); } + +val construct_with_6(val factory) { + unsigned char a1 = 6; + double a2 = -12.5; + std::string a3("a3"); + StructVector a4(1, 2, 3, 4); + EnumClass a5 = EnumClass::TWO; + TupleVector a6(-1, -2, -3, -4); + return factory.new_(a1, a2, a3, a4, a5, a6); +} + +EMSCRIPTEN_BINDINGS(val_new_) { + function("construct_with_6_arguments", &construct_with_6); +} |