prototype: Make Object.inspect more robust.

This commit is contained in:
Tobie Langel 2008-01-14 01:22:37 +00:00
parent cc69b9c614
commit ac48714ada
3 changed files with 4 additions and 1 deletions

View File

@ -1,5 +1,7 @@
*SVN*
* Make Object.inspect more robust. [Tobie Langel]
* Add a description to :test and :dist rake tasks. [Christoph Sturm]
* Fix Selector.matchElements to allow for coma-separated selectors in Element#up/next/previous and Event#findElement. [Samuel Lebeau, Tobie Langel]

View File

@ -71,7 +71,7 @@ Object.extend(Object, {
try {
if (Object.isUndefined(object)) return 'undefined';
if (object === null) return 'null';
return object.inspect ? object.inspect() : object.toString();
return object.inspect ? object.inspect() : String(object);
} catch (e) {
if (e instanceof RangeError) return '...';
throw e;

View File

@ -266,6 +266,7 @@
assertEqual('null', Object.inspect(null));
assertEqual("'foo\\\\b\\\'ar'", Object.inspect('foo\\b\'ar'));
assertEqual('[]', Object.inspect([]));
assertNothingRaised(function() { Object.inspect(window.Node) });
}},
testObjectToJSON: function() { with(this) {