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