From 09f28831860186a4c4c02b6fc1f81460bdd5866b Mon Sep 17 00:00:00 2001 From: ZYSzys <17367077526@163.com> Date: Wed, 26 Dec 2018 18:25:58 +0800 Subject: [PATCH] test: sort methods as internal/util/types --- test/parallel/test-util-types.js | 37 ++++++++++++++++---------------- 1 file changed, 18 insertions(+), 19 deletions(-) diff --git a/test/parallel/test-util-types.js b/test/parallel/test-util-types.js index 51bfbfc044c1a7..df9131e75df7a8 100644 --- a/test/parallel/test-util-types.js +++ b/test/parallel/test-util-types.js @@ -121,31 +121,29 @@ 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); @@ -153,11 +151,8 @@ for (const [ value, _method ] of [ 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 @@ -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 @@ -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, @@ -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