Add tests for Object.extend and Object.clone.

This commit is contained in:
Thomas Fuchs 2007-10-06 12:24:46 +00:00
parent cca235b1eb
commit 746a905ef4
2 changed files with 23 additions and 0 deletions

View File

@ -1,5 +1,7 @@
*SVN*
* Add tests for Object.extend and Object.clone. [Tobie Langel]
* Add a test for Form.Observer. [Christoph Sturm]
* Make sure setting opacity works on elements that have "no layout" in IE. [Thomas Fuchs]

View File

@ -162,6 +162,27 @@
assertEqual(baz, baz.quux());
}},
testObjectExtend: function() { with(this) {
var object = {foo: 'foo', bar: [1, 2, 3]};
assertIdentical(object, Object.extend(object));
assertHashEqual({foo: 'foo', bar: [1, 2, 3]}, object);
assertIdentical(object, Object.extend(object, {bla: 123}));
assertHashEqual({foo: 'foo', bar: [1, 2, 3], bla: 123}, object);
assertHashEqual({foo: 'foo', bar: [1, 2, 3], bla: null},
Object.extend(object, {bla: null}));
}},
testObjectClone: function() { with(this) {
var object = {foo: 'foo', bar: [1, 2, 3]};
assertNotIdentical(object, Object.clone(object));
assertHashEqual(object, Object.clone(object));
assertHashEqual({}, Object.clone());
var clone = Object.clone(object);
delete clone.bar;
assertHashEqual({foo: 'foo'}, clone,
"Optimizing Object.clone perf using prototyping doesn't allow properties to be deleted.");
}},
testObjectInspect: function() { with(this) {
assertEqual('undefined', Object.inspect());
assertEqual('undefined', Object.inspect(undefined));