1
0
Fork 0

Classes now return a more intuitive string representation

closure/master
Mike Gerwitz 2011-01-17 20:20:39 -05:00
parent 79be82e536
commit d19638be4f
2 changed files with 18 additions and 0 deletions

View File

@ -327,6 +327,12 @@ var extend = ( function( extending )
attachInstanceOf( this ); attachInstanceOf( this );
}; };
// provide a more intuitive string representation
__self.toString = function()
{
return '<Class>';
};
return __self; return __self;
} }
// abstract class // abstract class

View File

@ -224,3 +224,15 @@ assert.ok(
"Instances of subtypes do not share property references" "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(),
'<Class>',
"Converting class to string yields class string"
);
} )();