aboutsummaryrefslogtreecommitdiff
path: root/tests
diff options
context:
space:
mode:
authorChad Austin <caustin@gmail.com>2014-03-07 02:33:32 -0800
committerChad Austin <chad@chadaustin.me>2014-03-28 23:56:39 -0700
commit555cb8207b9b06f86284a88d97a74c43e20469fb (patch)
treed26598cb5f5bd64dfa1967fe03a57a6db4c4c408 /tests
parent61849992b28d205eca211a2530ed752839f1c60f (diff)
tests for val::as on strings and val too
Diffstat (limited to 'tests')
-rw-r--r--tests/embind/embind.test.js28
-rw-r--r--tests/embind/embind_test.cpp6
2 files changed, 26 insertions, 8 deletions
diff --git a/tests/embind/embind.test.js b/tests/embind/embind.test.js
index 67171822..033b47b5 100644
--- a/tests/embind/embind.test.js
+++ b/tests/embind/embind.test.js
@@ -1939,14 +1939,26 @@ module({
// Let the memory leak test superfixture check that no leaks occurred.
});
- test("val::as supports variety of types", function() {
- assert.equal(true, cm.val_as_bool(true));
- assert.equal(127, cm.val_as_char(127));
- assert.equal(32767, cm.val_as_short(32767));
- assert.equal(65536, cm.val_as_int(65536));
- assert.equal(65536, cm.val_as_long(65536));
- assert.equal(10.5, cm.val_as_float(10.5));
- assert.equal(10.5, cm.val_as_double(10.5));
+ BaseFixture.extend("val::as built-in types", function() {
+ test("primitives", function() {
+ assert.equal(true, cm.val_as_bool(true));
+ assert.equal(127, cm.val_as_char(127));
+ assert.equal(32767, cm.val_as_short(32767));
+ assert.equal(65536, cm.val_as_int(65536));
+ assert.equal(65536, cm.val_as_long(65536));
+ assert.equal(10.5, cm.val_as_float(10.5));
+ assert.equal(10.5, cm.val_as_double(10.5));
+
+ assert.equal("foo", cm.val_as_string("foo"));
+ assert.equal("foo", cm.val_as_wstring("foo"));
+
+ var obj = {};
+ assert.equal(obj, cm.val_as_val(obj));
+
+ // JS->C++ memory view not implemented
+ //var ab = cm.val_as_memory_view(new ArrayBuffer(13));
+ //assert.equal(13, ab.byteLength);
+ });
});
});
diff --git a/tests/embind/embind_test.cpp b/tests/embind/embind_test.cpp
index af8b2e8d..6aa543ef 100644
--- a/tests/embind/embind_test.cpp
+++ b/tests/embind/embind_test.cpp
@@ -2316,6 +2316,12 @@ EMSCRIPTEN_BINDINGS(val_as) {
function("val_as_short", &val_as<short>);
function("val_as_int", &val_as<int>);
function("val_as_long", &val_as<long>);
+
function("val_as_float", &val_as<float>);
function("val_as_double", &val_as<double>);
+
+ function("val_as_string", &val_as<std::string>);
+ function("val_as_wstring", &val_as<std::wstring>);
+ function("val_as_val", &val_as<val>);
+ //function("val_as_memory_view", &val_as<memory_view>);
}