aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorChad Austin <chad@imvu.com>2013-07-17 11:49:17 -0700
committerChad Austin <chad@imvu.com>2013-07-17 11:50:17 -0700
commitb911d5d6e3d75acc1e790c7ac834de7403d18a1d (patch)
treed39cf1f65c568149850b911974a18e71c47f5589 /tests
parent3952582ab33d25419f12c45c37358ea12487ef63 (diff)
Add a test that shows JS objects can be modified if passed by reference into a C++ function
Diffstat (limited to 'tests')
-rw-r--r--tests/embind/embind.test.js10
-rw-r--r--tests/embind/embind_test.cpp8
2 files changed, 18 insertions, 0 deletions
diff --git a/tests/embind/embind.test.js b/tests/embind/embind.test.js
index c7cad079..da81a81e 100644
--- a/tests/embind/embind.test.js
+++ b/tests/embind/embind.test.js
@@ -1878,6 +1878,16 @@ module({
// setTimeout(fn, 0);
// });
});
+
+ BaseFixture.extend("references", function() {
+ test("JS object handles can be passed through to C++ by reference", function() {
+ var sh = new cm.StringHolder("Hello world");
+ assert.equal("Hello world", sh.get());
+ cm.clear_StringHolder(sh);
+ assert.equal("", sh.get());
+ sh.delete();
+ });
+ });
});
/* global run_all_tests */
diff --git a/tests/embind/embind_test.cpp b/tests/embind/embind_test.cpp
index 419c216e..d6b27bce 100644
--- a/tests/embind/embind_test.cpp
+++ b/tests/embind/embind_test.cpp
@@ -2235,3 +2235,11 @@ EMSCRIPTEN_BINDINGS(with_adjustment) {
function("return_Base_from_DerivedWithOffset", &return_Base_from_DerivedWithOffset);
}
+
+void clear_StringHolder(StringHolder& sh) {
+ sh.set("");
+}
+
+EMSCRIPTEN_BINDINGS(references) {
+ function("clear_StringHolder", &clear_StringHolder);
+}