aboutsummaryrefslogtreecommitdiff
path: root/tests/embind/embind.test.js
diff options
context:
space:
mode:
authorChad Austin <chad@imvu.com>2013-12-05 18:12:06 -0800
committerBruce Mitchener <bruce.mitchener@gmail.com>2014-02-04 16:19:50 +0700
commitb09a5551ea298d0d8d95946a7131df342362ea51 (patch)
tree685d229644dcad45c80469c736876baab87768b9 /tests/embind/embind.test.js
parentdd8b8e71bfc4aff36909eab7cc23c03907f02ef1 (diff)
Add a test to verify we can use static constants defined in classes.
Diffstat (limited to 'tests/embind/embind.test.js')
-rw-r--r--tests/embind/embind.test.js24
1 files changed, 14 insertions, 10 deletions
diff --git a/tests/embind/embind.test.js b/tests/embind/embind.test.js
index 2a14ccde..0976c597 100644
--- a/tests/embind/embind.test.js
+++ b/tests/embind/embind.test.js
@@ -55,7 +55,7 @@ module({
});
});
});
-
+
}
BaseFixture.extend("access to base class members", function() {
@@ -609,7 +609,7 @@ module({
assert.equal("0", cm.unsigned_int_to_string(0));
assert.equal("0", cm.long_to_string(0));
assert.equal("0", cm.unsigned_long_to_string(0));
-
+
// all types should have positive values.
assert.equal("5", cm.char_to_string(5));
assert.equal("5", cm.signed_char_to_string(5));
@@ -650,7 +650,7 @@ module({
assert.equal("-32768", cm.short_to_string(-32768));
assert.equal("-2147483648", cm.int_to_string(-2147483648));
assert.equal("-2147483648", cm.long_to_string(-2147483648));
-
+
// passing out of range values should fail.
assert.throws(TypeError, function() { cm.char_to_string(-129); });
assert.throws(TypeError, function() { cm.char_to_string(128); });
@@ -733,7 +733,7 @@ module({
test("overloading of derived class member functions", function() {
var foo = new cm.MultipleOverloadsDerived();
-
+
// NOTE: In C++, default lookup rules will hide overloads from base class if derived class creates them.
// In JS, we make the base class overloads implicitly available. In C++, they would need to be explicitly
// invoked, like foo.MultipleOverloads::Func(10);
@@ -748,7 +748,7 @@ module({
assert.equal(foo.WhichFuncCalled(), 4);
foo.delete();
});
-
+
test("overloading of class static functions", function() {
assert.equal(cm.MultipleOverloads.StaticFunc(10), 1);
assert.equal(cm.MultipleOverloads.WhichStaticFuncCalled(), 1);
@@ -1441,7 +1441,7 @@ module({
test("repr includes enum value", function() {
assert.equal('<#Enum_ONE {}>', IMVU.repr(cm.Enum.ONE));
assert.equal('<#Enum_TWO {}>', IMVU.repr(cm.Enum.TWO));
- });
+ });
}
test("instanceof", function() {
@@ -1644,7 +1644,7 @@ module({
});
if (typeof INVOKED_FROM_EMSCRIPTEN_TEST_RUNNER === "undefined") { // TODO: Enable this to work in Emscripten runner as well!
-
+
BaseFixture.extend("unbound types", function() {
function assertMessage(fn, message) {
var e = assert.throws(cm.UnboundTypeError, fn);
@@ -1689,7 +1689,7 @@ module({
},
'Cannot construct HasConstructorUsingUnboundArgumentAndUnboundBase due to unbound types: 18SecondUnboundClass');
});
-
+
test('class function with unbound argument', function() {
var x = new cm.BoundClass;
assertMessage(
@@ -1719,12 +1719,12 @@ module({
}, 'Cannot access BoundClass.property due to unbound types: 12UnboundClass');
x.delete();
});
-
+
// todo: tuple elements
// todo: tuple element accessors
// todo: struct fields
});
-
+
}
BaseFixture.extend("noncopyable", function() {
@@ -1743,6 +1743,10 @@ module({
BaseFixture.extend("constants", function() {
assert.equal(10, cm.INT_CONSTANT);
+
+ assert.equal(1, cm.STATIC_CONST_INTEGER_VALUE_1);
+ assert.equal(1000, cm.STATIC_CONST_INTEGER_VALUE_1000);
+
assert.equal("some string", cm.STRING_CONSTANT);
assert.deepEqual([1, 2, 3, 4], cm.VALUE_ARRAY_CONSTANT);
assert.deepEqual({x:1,y:2,z:3,w:4}, cm.VALUE_OBJECT_CONSTANT);