mirror of
https://github.com/whoisclebs/lodash.git
synced 2026-02-08 18:17:48 +00:00
Add clone tests for array buffers.
This commit is contained in:
@@ -1221,7 +1221,7 @@
|
|||||||
}
|
}
|
||||||
switch (className) {
|
switch (className) {
|
||||||
case arrayBufferClass:
|
case arrayBufferClass:
|
||||||
return value.slice();
|
return value.slice(0);
|
||||||
|
|
||||||
case boolClass:
|
case boolClass:
|
||||||
case dateClass:
|
case dateClass:
|
||||||
|
|||||||
30
test/test.js
30
test/test.js
@@ -19,6 +19,7 @@
|
|||||||
var phantom = root.phantom,
|
var phantom = root.phantom,
|
||||||
amd = root.define && define.amd,
|
amd = root.define && define.amd,
|
||||||
argv = root.process && process.argv,
|
argv = root.process && process.argv,
|
||||||
|
ArrayBuffer = root.ArrayBuffer,
|
||||||
document = !phantom && root.document,
|
document = !phantom && root.document,
|
||||||
body = root.document && root.document.body,
|
body = root.document && root.document.body,
|
||||||
create = Object.create,
|
create = Object.create,
|
||||||
@@ -1284,16 +1285,33 @@
|
|||||||
|
|
||||||
_.each(typedArrays, function(type) {
|
_.each(typedArrays, function(type) {
|
||||||
test('`_.' + methodName + '` should clone ' + type + ' arrays', 2, function() {
|
test('`_.' + methodName + '` should clone ' + type + ' arrays', 2, function() {
|
||||||
var Ctor = root[type] || Array,
|
var Ctor = root[type];
|
||||||
buffer = Ctor == Array ? 4 : new ArrayBuffer(4),
|
if (Ctor) {
|
||||||
array = new Ctor(buffer),
|
var array = new Ctor(new ArrayBuffer(4)),
|
||||||
actual = func(array);
|
actual = func(array);
|
||||||
|
|
||||||
deepEqual(actual, array);
|
deepEqual(actual, array);
|
||||||
notStrictEqual(actual, array);
|
notStrictEqual(actual, array);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
skipTest(2);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
|
test('`_.' + methodName + '` should clone array buffers', 2, function() {
|
||||||
|
if (ArrayBuffer) {
|
||||||
|
var buffer = new ArrayBuffer(4),
|
||||||
|
actual = func(buffer);
|
||||||
|
|
||||||
|
strictEqual(actual.byteLength, buffer.byteLength);
|
||||||
|
notStrictEqual(actual, buffer);
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
skipTest(2);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
test('`_.' + methodName + '` should clone problem JScript properties (test in IE < 9)', 2, function() {
|
test('`_.' + methodName + '` should clone problem JScript properties (test in IE < 9)', 2, function() {
|
||||||
var actual = func(shadowedObject);
|
var actual = func(shadowedObject);
|
||||||
deepEqual(actual, shadowedObject);
|
deepEqual(actual, shadowedObject);
|
||||||
|
|||||||
Reference in New Issue
Block a user