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