MCPcopy Index your code
hub / github.com/nodejs/node / TestCopyWithin

Function TestCopyWithin

deps/v8/test/mjsunit/typedarray-growablesharedarraybuffer.js:965–1045  ·  view source on GitHub ↗
(helper)

Source from the content-addressed store, hash-verified

963})();
964
965function TestCopyWithin(helper) {
966 for (let ctor of ctors) {
967 const gsab = CreateGrowableSharedArrayBuffer(4 * ctor.BYTES_PER_ELEMENT,
968 8 * ctor.BYTES_PER_ELEMENT);
969 const fixedLength = new ctor(gsab, 0, 4);
970 const fixedLengthWithOffset = new ctor(gsab, 2 * ctor.BYTES_PER_ELEMENT, 2);
971 const lengthTracking = new ctor(gsab, 0);
972 const lengthTrackingWithOffset = new ctor(gsab, 2 * ctor.BYTES_PER_ELEMENT);
973
974 // Write some data into the array.
975 const taWrite = new ctor(gsab);
976 for (let i = 0; i < 4; ++i) {
977 WriteToTypedArray(taWrite, i, i);
978 }
979
980 // Orig. array: [0, 1, 2, 3]
981 // [0, 1, 2, 3] << fixedLength
982 // [2, 3] << fixedLengthWithOffset
983 // [0, 1, 2, 3, ...] << lengthTracking
984 // [2, 3, ...] << lengthTrackingWithOffset
985
986 helper(fixedLength, 0, 2);
987 assertEquals([2, 3, 2, 3], ToNumbers(fixedLength));
988
989 for (let i = 0; i < 4; ++i) {
990 WriteToTypedArray(taWrite, i, i);
991 }
992
993 helper(fixedLengthWithOffset, 0, 1);
994 assertEquals([3, 3], ToNumbers(fixedLengthWithOffset));
995
996 for (let i = 0; i < 4; ++i) {
997 WriteToTypedArray(taWrite, i, i);
998 }
999
1000 helper(lengthTracking, 0, 2);
1001 assertEquals([2, 3, 2, 3], ToNumbers(lengthTracking));
1002
1003 helper(lengthTrackingWithOffset, 0, 1);
1004 assertEquals([3, 3], ToNumbers(lengthTrackingWithOffset));
1005
1006 gsab.grow(6 * ctor.BYTES_PER_ELEMENT);
1007 for (let i = 0; i < 6; ++i) {
1008 WriteToTypedArray(taWrite, i, i);
1009 }
1010
1011 // Orig. array: [0, 1, 2, 3, 4, 5]
1012 // [0, 1, 2, 3] << fixedLength
1013 // [2, 3] << fixedLengthWithOffset
1014 // [0, 1, 2, 3, 4, 5, ...] << lengthTracking
1015 // [2, 3, 4, 5, ...] << lengthTrackingWithOffset
1016
1017 helper(fixedLength, 0, 2);
1018 assertEquals([2, 3, 2, 3], ToNumbers(fixedLength));
1019
1020 for (let i = 0; i < 6; ++i) {
1021 WriteToTypedArray(taWrite, i, i);
1022 }

Calls 5

WriteToTypedArrayFunction · 0.85
ToNumbersFunction · 0.85
helperFunction · 0.50
assertEqualsFunction · 0.50

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…