From 14cac6b461f4d7f248d27bc8675d9558db9e744a Mon Sep 17 00:00:00 2001 From: Mike Gerwitz Date: Wed, 16 Mar 2011 19:24:02 -0400 Subject: [PATCH] Can now specify parent class in extend() when implementing atop an empty base --- lib/class.js | 2 +- test/test-class-implement.js | 19 +++++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/lib/class.js b/lib/class.js index 4eaac7e..a4b293b 100644 --- a/lib/class.js +++ b/lib/class.js @@ -113,7 +113,7 @@ module.exports.implement = function() { // implement on empty base return createImplement( - module.exports.extend(), + null, Array.prototype.slice.call( arguments ) ); }; diff --git a/test/test-class-implement.js b/test/test-class-implement.js index 54bf454..0bdad6e 100644 --- a/test/test-class-implement.js +++ b/test/test-class-implement.js @@ -213,3 +213,22 @@ var Type = Interface.extend( { ); } )(); + +/** + * Opposite of the above test. If a parent wasn't specified to begin with, then + * we're fine to specify it in extend(). + */ +( function testCanSpecifyParentIfImplementingAtopEmptyClass() +{ + assert.doesNotThrow( + function() + { + // this /should/ work + Class.implement( Type ).extend( PlainFoo, {} ); + }, + Error, + "Can specify parent for exetnd() when implementing atop an " + + "empty base" + ); +} )(); +