Skip to content

Commit fc22df9

Browse files
ZYSzysaddaleax
authored andcommitted
test: more tests for internal/util/types
PR-URL: #25225 Reviewed-By: James M Snell <[email protected]> Reviewed-By: Michael Dawson <[email protected]>
1 parent d1ff107 commit fc22df9

File tree

1 file changed

+123
-15
lines changed

1 file changed

+123
-15
lines changed

‎test/parallel/test-util-types.js‎

Lines changed: 123 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -121,39 +121,147 @@ for (const [ value, _method ] of [
121121
{
122122
constprimitive=true;
123123
constarrayBuffer=newArrayBuffer();
124+
constbuffer=Buffer.from(arrayBuffer);
124125
constdataView=newDataView(arrayBuffer);
125-
constint32Array=newInt32Array(arrayBuffer);
126126
constuint8Array=newUint8Array(arrayBuffer);
127-
constbuffer=Buffer.from(arrayBuffer);
127+
constuint8ClampedArray=newUint8ClampedArray(arrayBuffer);
128+
constuint16Array=newUint16Array(arrayBuffer);
129+
constuint32Array=newUint32Array(arrayBuffer);
130+
constint8Array=newInt8Array(arrayBuffer);
131+
constint16Array=newInt16Array(arrayBuffer);
132+
constint32Array=newInt32Array(arrayBuffer);
133+
constfloat32Array=newFloat32Array(arrayBuffer);
134+
constfloat64Array=newFloat64Array(arrayBuffer);
135+
constbigInt64Array=newBigInt64Array(arrayBuffer);
136+
constbigUint64Array=newBigUint64Array(arrayBuffer);
128137

138+
constfakeBuffer=Object.create(Buffer.prototype);
129139
constfakeDataView=Object.create(DataView.prototype);
130-
constfakeInt32Array=Object.create(Int32Array.prototype);
131140
constfakeUint8Array=Object.create(Uint8Array.prototype);
132-
constfakeBuffer=Object.create(Buffer.prototype);
141+
constfakeUint8ClampedArray=Object.create(Uint8ClampedArray.prototype);
142+
constfakeUint16Array=Object.create(Uint16Array.prototype);
143+
constfakeUint32Array=Object.create(Uint32Array.prototype);
144+
constfakeInt8Array=Object.create(Int8Array.prototype);
145+
constfakeInt16Array=Object.create(Int16Array.prototype);
146+
constfakeInt32Array=Object.create(Int32Array.prototype);
147+
constfakeFloat32Array=Object.create(Float32Array.prototype);
148+
constfakeFloat64Array=Object.create(Float64Array.prototype);
149+
constfakeBigInt64Array=Object.create(BigInt64Array.prototype);
150+
constfakeBigUint64Array=Object.create(BigUint64Array.prototype);
133151

134152
conststealthyDataView=
135-
Object.setPrototypeOf(newDataView(arrayBuffer),Uint8Array.prototype);
136-
conststealthyInt32Array=
137-
Object.setPrototypeOf(newInt32Array(arrayBuffer),uint8Array);
153+
Object.setPrototypeOf(newDataView(arrayBuffer),Uint8Array.prototype);
138154
conststealthyUint8Array=
139-
Object.setPrototypeOf(newUint8Array(arrayBuffer),ArrayBuffer.prototype);
155+
Object.setPrototypeOf(newUint8Array(arrayBuffer),ArrayBuffer.prototype);
156+
conststealthyUint8ClampedArray=
157+
Object.setPrototypeOf(
158+
newUint8ClampedArray(arrayBuffer),ArrayBuffer.prototype
159+
);
160+
conststealthyUint16Array=
161+
Object.setPrototypeOf(newUint16Array(arrayBuffer),Uint16Array.prototype);
162+
conststealthyUint32Array=
163+
Object.setPrototypeOf(newUint32Array(arrayBuffer),Uint32Array.prototype);
164+
conststealthyInt8Array=
165+
Object.setPrototypeOf(newInt8Array(arrayBuffer),Int8Array.prototype);
166+
conststealthyInt16Array=
167+
Object.setPrototypeOf(newInt16Array(arrayBuffer),Int16Array.prototype);
168+
conststealthyInt32Array=
169+
Object.setPrototypeOf(newInt32Array(arrayBuffer),Int32Array.prototype);
170+
conststealthyFloat32Array=
171+
Object.setPrototypeOf(
172+
newFloat32Array(arrayBuffer),Float32Array.prototype
173+
);
174+
conststealthyFloat64Array=
175+
Object.setPrototypeOf(
176+
newFloat64Array(arrayBuffer),Float64Array.prototype
177+
);
178+
conststealthyBigInt64Array=
179+
Object.setPrototypeOf(
180+
newBigInt64Array(arrayBuffer),BigInt64Array.prototype
181+
);
182+
conststealthyBigUint64Array=
183+
Object.setPrototypeOf(
184+
newBigUint64Array(arrayBuffer),BigUint64Array.prototype
185+
);
140186

141187
constall=[
142-
primitive,arrayBuffer,dataView,int32Array,uint8Array,buffer,
143-
fakeDataView,fakeInt32Array,fakeUint8Array,fakeBuffer,
144-
stealthyDataView,stealthyInt32Array,stealthyUint8Array
188+
primitive,arrayBuffer,buffer,fakeBuffer,
189+
dataView,fakeDataView,stealthyDataView,
190+
uint8Array,fakeUint8Array,stealthyUint8Array,
191+
uint8ClampedArray,fakeUint8ClampedArray,stealthyUint8ClampedArray,
192+
uint16Array,fakeUint16Array,stealthyUint16Array,
193+
uint32Array,fakeUint32Array,stealthyUint32Array,
194+
int8Array,fakeInt8Array,stealthyInt8Array,
195+
int16Array,fakeInt16Array,stealthyInt16Array,
196+
int32Array,fakeInt32Array,stealthyInt32Array,
197+
float32Array,fakeFloat32Array,stealthyFloat32Array,
198+
float64Array,fakeFloat64Array,stealthyFloat64Array,
199+
bigInt64Array,fakeBigInt64Array,stealthyBigInt64Array,
200+
bigUint64Array,fakeBigUint64Array,stealthyBigUint64Array
145201
];
146202

147203
constexpected={
148204
isArrayBufferView: [
149-
dataView,int32Array,uint8Array,buffer,
150-
stealthyDataView,stealthyInt32Array,stealthyUint8Array
205+
buffer,
206+
dataView,stealthyDataView,
207+
uint8Array,stealthyUint8Array,
208+
uint8ClampedArray,stealthyUint8ClampedArray,
209+
uint16Array,stealthyUint16Array,
210+
uint32Array,stealthyUint32Array,
211+
int8Array,stealthyInt8Array,
212+
int16Array,stealthyInt16Array,
213+
int32Array,stealthyInt32Array,
214+
float32Array,stealthyFloat32Array,
215+
float64Array,stealthyFloat64Array,
216+
bigInt64Array,stealthyBigInt64Array,
217+
bigUint64Array,stealthyBigUint64Array
151218
],
152219
isTypedArray: [
153-
int32Array,uint8Array,buffer,stealthyInt32Array,stealthyUint8Array
220+
buffer,
221+
uint8Array,stealthyUint8Array,
222+
uint8ClampedArray,stealthyUint8ClampedArray,
223+
uint16Array,stealthyUint16Array,
224+
uint32Array,stealthyUint32Array,
225+
int8Array,stealthyInt8Array,
226+
int16Array,stealthyInt16Array,
227+
int32Array,stealthyInt32Array,
228+
float32Array,stealthyFloat32Array,
229+
float64Array,stealthyFloat64Array,
230+
bigInt64Array,stealthyBigInt64Array,
231+
bigUint64Array,stealthyBigUint64Array
154232
],
155233
isUint8Array: [
156-
uint8Array,buffer,stealthyUint8Array
234+
buffer,uint8Array,stealthyUint8Array
235+
],
236+
isUint8ClampedArray: [
237+
uint8ClampedArray,stealthyUint8ClampedArray
238+
],
239+
isUint16Array: [
240+
uint16Array,stealthyUint16Array
241+
],
242+
isUint32Array: [
243+
uint32Array,stealthyUint32Array
244+
],
245+
isInt8Array: [
246+
int8Array,stealthyInt8Array
247+
],
248+
isInt16Array: [
249+
int16Array,stealthyInt16Array
250+
],
251+
isInt32Array: [
252+
int32Array,stealthyInt32Array
253+
],
254+
isFloat32Array: [
255+
float32Array,stealthyFloat32Array
256+
],
257+
isFloat64Array: [
258+
float64Array,stealthyFloat64Array
259+
],
260+
isBigInt64Array: [
261+
bigInt64Array,stealthyBigInt64Array
262+
],
263+
isBigUint64Array: [
264+
bigUint64Array,stealthyBigUint64Array
157265
]
158266
};
159267

0 commit comments

Comments
(0)