From 84dcca35d2eecb0cd2ebb2a5de8b08ee01308b3f Mon Sep 17 00:00:00 2001 From: Mike Gerwitz Date: Wed, 1 Dec 2010 23:01:20 -0500 Subject: [PATCH] Interface prototype contains defined methods --- lib/interface.js | 7 ++++++- test/test-interface-extend.js | 11 +++++++++++ test/test-interface.js | 4 ++-- 3 files changed, 19 insertions(+), 3 deletions(-) diff --git a/lib/interface.js b/lib/interface.js index 24d8d3c..f164fff 100644 --- a/lib/interface.js +++ b/lib/interface.js @@ -54,7 +54,12 @@ function extend() base = args.pop() || Interface, prototype = new base(); - var new_interface = {}; + var new_interface = function() {}; + + util.propCopy( props, prototype ); + + new_interface.prototype = prototype; + new_interface.constructor = new_interface; // freeze the interface (preventing additions), if supported util.freeze( new_interface ); diff --git a/test/test-interface-extend.js b/test/test-interface-extend.js index 2b2310e..8e231f1 100644 --- a/test/test-interface-extend.js +++ b/test/test-interface-extend.js @@ -59,3 +59,14 @@ assert.doesNotThrow( "Abstract method declarations are allowed within Interface definitions" ); + +var BaseType = Interface.extend( +{ + method: abstractMethod(), +}); + +assert.ok( + ( BaseType.prototype.method instanceof Function ), + "Interface contains defined abstract methods" +); + diff --git a/test/test-interface.js b/test/test-interface.js index 05b6cb2..b6a37cb 100644 --- a/test/test-interface.js +++ b/test/test-interface.js @@ -32,8 +32,8 @@ var FooType = Interface.extend(); assert.ok( - ( FooType instanceof Object ), - "Interface extend method creates a new object" + ( FooType instanceof Function ), + "Interface extend method creates a new interface object" ); assert.equal(