name: 'Core',
setUp: function () {
this.o = {
a1: {
a2: {
a3: 'a'
}
},
b1: {
b2: 'b'
},
c1: 'c'
};
},
tearDown: function () {
delete this.o;
},
test_create: function () {
var a = {o: {a: 1}, y: {a: 1}},
b = {o: {b: 1}, x: {b: 1}},
c = Y.Object(a),
d = Y.Object(b),
Assert.isUndefined(c.x);
Assert.isUndefined(d.y);
// Verify the prototype in browsers that support it.
if (Object.getPrototypeOf) {
cProto = Object.getPrototypeOf(c);
dProto = Object.getPrototypeOf(d);
} else if (c.__proto__) {
}
}
},
test_each: function () {
var calls = 0,
data = Y.Object(this.o),
data.a = 'foo';
data.b = 'bar';
data.c = null;
calls += 1;
});
}, thisObj);
calls = 0;
calls += 1;
}, null, true);
Assert.areSame(calls, 7, 'when the _proto_ argument is `true`, prototype properties should be iterated');
},
test_getValue: function () {
},
test_hasKey: function () {
},
test_hasValue: function () {
},
test_isEmpty: function () {
Assert.isTrue(Y.Object.isEmpty(Y.Object(this.o)), 'should return true for objects with no own properties');
},
'test: isEmpty() should work on non-objects': function () {
}
},
test_keys: function () {
Y.ArrayAssert.itemsAreSame(['a1', 'b1', 'c1'], Y.Object.keys(this.o), 'should return an array of keys');
if (Object.keys) {
Assert.areSame(Object.keys, Y.Object.keys, 'when native Object.keys is present, Y.Object.keys should be an alias');
}
// IE bugs.
Y.ArrayAssert.itemsAreSame(['toString', 'valueOf'], Y.Object.keys({toString: 1, valueOf: 1}), 'should include toString, valueOf, etc.');
},
test_owns: function () {
Assert.isFalse(Y.Object.owns(this.o, 'z'), 'should return false if the key is not owned by the object');
Assert.isFalse(Y.Object.owns(Y.Object(this.o), 'a1'), 'should return false for prototype properties');
},
test_setValue: function () {
},
test_size: function () {
},
'size() should return 0 for non-objects [legacy behavior]': function () {
},
test_some: function () {
var calls = 0,
data = Y.Object(this.o),
data.a = 'foo';
data.b = 'bar';
data.c = null;
calls += 1;
}), 'should return true');
}, thisObj), 'should return false');
calls = 0;
calls += 1;
});
calls = 0;
calls += 1;
}, null, true);
Assert.areSame(7, calls, 'prototype properties should be iterated when the _proto_ parameter is `true`');
},
test_values: function () {
Y.ArrayAssert.itemsAreSame(['foo', 'bar', null, 'baz', undefined], Y.Object.values(data), 'should return an array of values');
},
test_people_messing_up_object_prototype: function () {
var count = 0;
Y.Object.each({}, function () {
count++;
});
}
}));