1
0
Fork 0

Interface prototype contains defined methods

closure/master
Mike Gerwitz 2010-12-01 23:01:20 -05:00
parent 789c7f9b5e
commit 84dcca35d2
3 changed files with 19 additions and 3 deletions

View File

@ -54,7 +54,12 @@ function extend()
base = args.pop() || Interface, base = args.pop() || Interface,
prototype = new base(); 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 // freeze the interface (preventing additions), if supported
util.freeze( new_interface ); util.freeze( new_interface );

View File

@ -59,3 +59,14 @@ assert.doesNotThrow(
"Abstract method declarations are allowed within Interface definitions" "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"
);

View File

@ -32,8 +32,8 @@ var FooType = Interface.extend();
assert.ok( assert.ok(
( FooType instanceof Object ), ( FooType instanceof Function ),
"Interface extend method creates a new object" "Interface extend method creates a new interface object"
); );
assert.equal( assert.equal(