diff --git a/lib/class.js b/lib/class.js index 75075c9..a5ee68e 100644 --- a/lib/class.js +++ b/lib/class.js @@ -327,6 +327,12 @@ var extend = ( function( extending ) attachInstanceOf( this ); }; + // provide a more intuitive string representation + __self.toString = function() + { + return ''; + }; + return __self; } // abstract class diff --git a/test/test-class-extend.js b/test/test-class-extend.js index 3061147..31c9e67 100644 --- a/test/test-class-extend.js +++ b/test/test-class-extend.js @@ -224,3 +224,15 @@ assert.ok( "Instances of subtypes do not share property references" ); + +// otherwise it'll output the internal constructor code, which is especially +// confusing since the user does not write it +( function testConvertingClassToStringYieldsClassString() +{ + assert.equal( + Class.extend( {} ).toString(), + '', + "Converting class to string yields class string" + ); +} )(); +