Skip to content

Commit

Permalink
test: sort methods as internal/util/types
Browse files Browse the repository at this point in the history
  • Loading branch information
ZYSzys committed Dec 28, 2018
1 parent 882b234 commit 09f2883
Showing 1 changed file with 18 additions and 19 deletions.
37 changes: 18 additions & 19 deletions test/parallel/test-util-types.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,43 +121,38 @@ for (const [ value, _method ] of [
{
const primitive = true;
const arrayBuffer = new ArrayBuffer();
const buffer = Buffer.from(arrayBuffer);
const dataView = new DataView(arrayBuffer);
const int32Array = new Int32Array(arrayBuffer);
const uint8Array = new Uint8Array(arrayBuffer);
const buffer = Buffer.from(arrayBuffer);

const uint8ClampedArray = new Uint8ClampedArray(arrayBuffer);
const uint16Array = new Uint16Array(arrayBuffer);
const uint32Array = new Uint32Array(arrayBuffer);
const int8Array = new Int8Array(arrayBuffer);
const int16Array = new Int16Array(arrayBuffer);
const int32Array = new Int32Array(arrayBuffer);
const float32Array = new Float32Array(arrayBuffer);
const float64Array = new Float64Array(arrayBuffer);
const bigInt64Array = new BigInt64Array(arrayBuffer);
const bigUint64Array = new BigUint64Array(arrayBuffer);

const fakeBuffer = Object.create(Buffer.prototype);
const fakeDataView = Object.create(DataView.prototype);
const fakeInt32Array = Object.create(Int32Array.prototype);
const fakeUint8Array = Object.create(Uint8Array.prototype);
const fakeBuffer = Object.create(Buffer.prototype);

const fakeUint8ClampedArray = Object.create(Uint8ClampedArray.prototype);
const fakeUint16Array = Object.create(Uint16Array.prototype);
const fakeUint32Array = Object.create(Uint32Array.prototype);
const fakeInt8Array = Object.create(Int8Array.prototype);
const fakeInt16Array = Object.create(Int16Array.prototype);
const fakeInt32Array = Object.create(Int32Array.prototype);
const fakeFloat32Array = Object.create(Float32Array.prototype);
const fakeFloat64Array = Object.create(Float64Array.prototype);
const fakeBigInt64Array = Object.create(BigInt64Array.prototype);
const fakeBigUint64Array = Object.create(BigUint64Array.prototype);

const stealthyDataView =
Object.setPrototypeOf(new DataView(arrayBuffer), Uint8Array.prototype);
const stealthyInt32Array =
Object.setPrototypeOf(new Int32Array(arrayBuffer), uint8Array);
const stealthyUint8Array =
Object.setPrototypeOf(new Uint8Array(arrayBuffer), ArrayBuffer.prototype);

const stealthyUint8ClampedArray =
Object.setPrototypeOf(
new Uint8ClampedArray(arrayBuffer), ArrayBuffer.prototype
Expand All @@ -170,6 +165,8 @@ for (const [ value, _method ] of [
Object.setPrototypeOf(new Int8Array(arrayBuffer), Int8Array.prototype);
const stealthyInt16Array =
Object.setPrototypeOf(new Int16Array(arrayBuffer), Int16Array.prototype);
const stealthyInt32Array =
Object.setPrototypeOf(new Int32Array(arrayBuffer), Int32Array.prototype);
const stealthyFloat32Array =
Object.setPrototypeOf(
new Float32Array(arrayBuffer), Float32Array.prototype
Expand All @@ -188,15 +185,15 @@ for (const [ value, _method ] of [
);

const all = [
primitive, arrayBuffer, dataView, int32Array, uint8Array, buffer,
fakeDataView, fakeInt32Array, fakeUint8Array, fakeBuffer,
stealthyDataView, stealthyInt32Array, stealthyUint8Array,

primitive, arrayBuffer, buffer, fakeBuffer,
dataView, fakeDataView, stealthyDataView,
uint8Array, fakeUint8Array, stealthyUint8Array,
uint8ClampedArray, fakeUint8ClampedArray, stealthyUint8ClampedArray,
uint16Array, fakeUint16Array, stealthyUint16Array,
uint32Array, fakeUint32Array, stealthyUint32Array,
int8Array, fakeInt8Array, stealthyInt8Array,
int16Array, fakeInt16Array, stealthyInt16Array,
int32Array, fakeInt32Array, stealthyInt32Array,
float32Array, fakeFloat32Array, stealthyFloat32Array,
float64Array, fakeFloat64Array, stealthyFloat64Array,
bigInt64Array, fakeBigInt64Array, stealthyBigInt64Array,
Expand All @@ -205,34 +202,36 @@ for (const [ value, _method ] of [

const expected = {
isArrayBufferView: [
dataView, int32Array, uint8Array, buffer,
stealthyDataView, stealthyInt32Array, stealthyUint8Array,

buffer,
dataView, stealthyDataView,
uint8Array, stealthyUint8Array,
uint8ClampedArray, stealthyUint8ClampedArray,
uint16Array, stealthyUint16Array,
uint32Array, stealthyUint32Array,
int8Array, stealthyInt8Array,
int16Array, stealthyInt16Array,
int32Array, stealthyInt32Array,
float32Array, stealthyFloat32Array,
float64Array, stealthyFloat64Array,
bigInt64Array, stealthyBigInt64Array,
bigUint64Array, stealthyBigUint64Array
],
isTypedArray: [
int32Array, uint8Array, buffer, stealthyInt32Array, stealthyUint8Array,

buffer,
uint8Array, stealthyUint8Array,
uint8ClampedArray, stealthyUint8ClampedArray,
uint16Array, stealthyUint16Array,
uint32Array, stealthyUint32Array,
int8Array, stealthyInt8Array,
int16Array, stealthyInt16Array,
int32Array, stealthyInt32Array,
float32Array, stealthyFloat32Array,
float64Array, stealthyFloat64Array,
bigInt64Array, stealthyBigInt64Array,
bigUint64Array, stealthyBigUint64Array
],
isUint8Array: [
uint8Array, buffer, stealthyUint8Array
buffer, uint8Array, stealthyUint8Array
],
isUint8ClampedArray: [
uint8ClampedArray, stealthyUint8ClampedArray
Expand Down

0 comments on commit 09f2883

Please sign in to comment.