aboutsummaryrefslogtreecommitdiff
path: root/tests/embind/embind.test.js
diff options
context:
space:
mode:
authorChad Austin <chad@imvu.com>2013-04-09 18:01:15 -0700
committerJukka Jylänki <jujjyl@gmail.com>2013-04-18 20:08:05 +0300
commit17639c372a5f41177177c21c56731b103ad738ad (patch)
tree5f0e512d5824bf3581410af529461bc50b21ba76 /tests/embind/embind.test.js
parent927c8a5e44da6c5cc539fa7d4e0a2168dafa3d36 (diff)
allow optional implementation of non-abstract virtual methods
Diffstat (limited to 'tests/embind/embind.test.js')
-rwxr-xr-xtests/embind/embind.test.js22
1 files changed, 22 insertions, 0 deletions
diff --git a/tests/embind/embind.test.js b/tests/embind/embind.test.js
index 8155fd11..4a8665f4 100755
--- a/tests/embind/embind.test.js
+++ b/tests/embind/embind.test.js
@@ -1464,6 +1464,28 @@ module({
assert.equal(expected, cm.callAbstractMethod(impl));
impl.delete();
});
+
+ test("can implement optional methods in JavaScript", function() {
+ var expected = "my JS string";
+ function MyImplementation() {
+ this.rv = expected;
+ }
+ MyImplementation.prototype.optionalMethod = function() {
+ return this.rv;
+ };
+
+ var impl = cm.AbstractClass.implement(new MyImplementation);
+ assert.equal(expected, impl.optionalMethod(expected));
+ assert.equal(expected, cm.callOptionalMethod(impl, expected));
+ impl.delete();
+ });
+
+ test("if not implemented then optional method runs default", function() {
+ var impl = cm.AbstractClass.implement({});
+ assert.equal("optionalfoo", impl.optionalMethod("foo"));
+ assert.equal("optionalfoo", cm.callOptionalMethod(impl, "foo"));
+ impl.delete();
+ });
});
BaseFixture.extend("registration order", function() {