Altered class toString() representations to be more consistent with JS
parent
e2cba458d8
commit
81d03cb984
18
lib/class.js
18
lib/class.js
|
@ -434,19 +434,19 @@ var extend = ( function( extending )
|
|||
this.toString = ( cname )
|
||||
? function()
|
||||
{
|
||||
return 'Object #<' + cname + '>';
|
||||
return '[object #<' + cname + '>]';
|
||||
}
|
||||
: function()
|
||||
{
|
||||
return 'Object #<anonymous>';
|
||||
return '[object #<anonymous>]';
|
||||
}
|
||||
;
|
||||
};
|
||||
|
||||
// provide a more intuitive string representation
|
||||
__self.toString = ( cname )
|
||||
? function() { return '<class ' + cname + '>'; }
|
||||
: function() { return '<Class>'; }
|
||||
? function() { return '[object Class <' + cname + '>]'; }
|
||||
: function() { return '[object Class]'; }
|
||||
;
|
||||
|
||||
return __self;
|
||||
|
@ -463,8 +463,14 @@ var extend = ( function( extending )
|
|||
};
|
||||
|
||||
__abstract_self.toString = ( cname )
|
||||
? function() { return '<abstract class ' + cname + '>'; }
|
||||
: function() { return '<AbstractClass>'; }
|
||||
? function()
|
||||
{
|
||||
return '[object AbstractClass <' + cname + '>]';
|
||||
}
|
||||
: function()
|
||||
{
|
||||
return '[object AbstractClass]';
|
||||
}
|
||||
;
|
||||
|
||||
return __abstract_self;
|
||||
|
|
|
@ -61,14 +61,14 @@ var common = require( './common' ),
|
|||
// concrete
|
||||
assert.equal(
|
||||
Class( {} ).toString(),
|
||||
'<Class>',
|
||||
'[object Class]',
|
||||
"Converting anonymous class to string yields class string"
|
||||
);
|
||||
|
||||
// abstract
|
||||
assert.equal(
|
||||
Class( { 'abstract foo': [] } ).toString(),
|
||||
'<AbstractClass>',
|
||||
'[object AbstractClass]',
|
||||
"Converting abstract anonymous class to string yields class string"
|
||||
);
|
||||
} )();
|
||||
|
@ -85,14 +85,14 @@ var common = require( './common' ),
|
|||
// concrete
|
||||
assert.equal(
|
||||
Class( name, {} ).toString(),
|
||||
'<class ' + name + '>',
|
||||
'[object Class <' + name + '>]',
|
||||
"Converting named class to string yields string with name of class"
|
||||
);
|
||||
|
||||
// abstract
|
||||
assert.equal(
|
||||
Class( name, { 'abstract foo': [] } ).toString(),
|
||||
'<abstract class ' + name + '>',
|
||||
'[object AbstractClass <' + name + '>]',
|
||||
"Converting abstract named class to string yields string with name " +
|
||||
"of class"
|
||||
);
|
||||
|
@ -114,7 +114,7 @@ var common = require( './common' ),
|
|||
// anonymous
|
||||
assert.equal(
|
||||
anon.toString(),
|
||||
'Object #<anonymous>',
|
||||
'[object #<anonymous>]',
|
||||
"Converting anonymous class instance to string yields string " +
|
||||
"indiciating that the class is anonymous"
|
||||
);
|
||||
|
@ -122,7 +122,7 @@ var common = require( './common' ),
|
|||
// named
|
||||
assert.equal(
|
||||
named.toString(),
|
||||
'Object #<' + name + '>',
|
||||
'[object #<' + name + '>]',
|
||||
"Converting named class instance to string yields string with name " +
|
||||
"of class"
|
||||
);
|
||||
|
|
Loading…
Reference in New Issue