Skip to content

Commit

Permalink
Merge branch 'main' into addDuration
Browse files Browse the repository at this point in the history
  • Loading branch information
FrankYFTang authored Sep 26, 2024
2 parents 56e461f + 72ff7d1 commit 9aa6bad
Show file tree
Hide file tree
Showing 1,038 changed files with 30,807 additions and 17,348 deletions.
4 changes: 0 additions & 4 deletions features.txt
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,6 @@
# https://github.com/tc39/proposal-intl-locale-info
Intl.Locale-info

# FinalizationRegistry#cleanupSome
# https://github.com/tc39/proposal-cleanup-some
FinalizationRegistry.prototype.cleanupSome

# Intl.NumberFormat V3
# https://github.com/tc39/proposal-intl-numberformat-v3
Intl.NumberFormat-v3
Expand Down
57 changes: 0 additions & 57 deletions harness/async-gc.js

This file was deleted.

6 changes: 3 additions & 3 deletions harness/compareArray.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,14 @@ assert.compareArray = function(actual, expected, message) {
message = message.toString();
}

assert(actual != null, `First argument shouldn't be nullish. ${message}`);
assert(expected != null, `Second argument shouldn't be nullish. ${message}`);
assert(actual != null, `Actual argument shouldn't be nullish. ${message}`);
assert(expected != null, `Expected argument shouldn't be nullish. ${message}`);
var format = compareArray.format;
var result = compareArray(actual, expected);

// The following prevents actual and expected from being iterated and evaluated
// more than once unless absolutely necessary.
if (!result) {
assert(false, `Expected ${format(actual)} and ${format(expected)} to have the same contents. ${message}`);
assert(false, `Actual ${format(actual)} and expected ${format(expected)} should have the the same contents. ${message}`);
}
};
52 changes: 32 additions & 20 deletions harness/propertyHelper.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,16 @@ defines:

// @ts-check

// Capture primordial functions and receiver-uncurried primordial methods that
// are used in verification but might be destroyed *by* that process itself.
var __isArray = Array.isArray;
var __defineProperty = Object.defineProperty;
var __join = Function.prototype.call.bind(Array.prototype.join);
var __push = Function.prototype.call.bind(Array.prototype.push);
var __hasOwnProperty = Function.prototype.call.bind(Object.prototype.hasOwnProperty);
var __propertyIsEnumerable = Function.prototype.call.bind(Object.prototype.propertyIsEnumerable);
var nonIndexNumericPropertyName = Math.pow(2, 32) - 1;

/**
* @param {object} obj
* @param {string|symbol} name
Expand Down Expand Up @@ -46,7 +56,7 @@ function verifyProperty(obj, name, desc, options) {
}

assert(
Object.prototype.hasOwnProperty.call(obj, name),
__hasOwnProperty(obj, name),
"obj should have an own property " + nameStr
);

Expand Down Expand Up @@ -77,55 +87,56 @@ function verifyProperty(obj, name, desc, options) {

var failures = [];

if (Object.prototype.hasOwnProperty.call(desc, 'value')) {
if (__hasOwnProperty(desc, 'value')) {
if (!isSameValue(desc.value, originalDesc.value)) {
failures.push("descriptor value should be " + desc.value);
__push(failures, "descriptor value should be " + desc.value);
}
if (!isSameValue(desc.value, obj[name])) {
failures.push("object value should be " + desc.value);
__push(failures, "object value should be " + desc.value);
}
}

if (Object.prototype.hasOwnProperty.call(desc, 'enumerable')) {
if (__hasOwnProperty(desc, 'enumerable')) {
if (desc.enumerable !== originalDesc.enumerable ||
desc.enumerable !== isEnumerable(obj, name)) {
failures.push('descriptor should ' + (desc.enumerable ? '' : 'not ') + 'be enumerable');
__push(failures, 'descriptor should ' + (desc.enumerable ? '' : 'not ') + 'be enumerable');
}
}

if (Object.prototype.hasOwnProperty.call(desc, 'writable')) {
// Operations past this point are potentially destructive!

if (__hasOwnProperty(desc, 'writable')) {
if (desc.writable !== originalDesc.writable ||
desc.writable !== isWritable(obj, name)) {
failures.push('descriptor should ' + (desc.writable ? '' : 'not ') + 'be writable');
__push(failures, 'descriptor should ' + (desc.writable ? '' : 'not ') + 'be writable');
}
}

if (Object.prototype.hasOwnProperty.call(desc, 'configurable')) {
if (__hasOwnProperty(desc, 'configurable')) {
if (desc.configurable !== originalDesc.configurable ||
desc.configurable !== isConfigurable(obj, name)) {
failures.push('descriptor should ' + (desc.configurable ? '' : 'not ') + 'be configurable');
__push(failures, 'descriptor should ' + (desc.configurable ? '' : 'not ') + 'be configurable');
}
}

assert(!failures.length, failures.join('; '));
assert(!failures.length, __join(failures, '; '));

if (options && options.restore) {
Object.defineProperty(obj, name, originalDesc);
__defineProperty(obj, name, originalDesc);
}

return true;
}

function isConfigurable(obj, name) {
var hasOwnProperty = Object.prototype.hasOwnProperty;
try {
delete obj[name];
} catch (e) {
if (!(e instanceof TypeError)) {
throw new Test262Error("Expected TypeError, got " + e);
}
}
return !hasOwnProperty.call(obj, name);
return !__hasOwnProperty(obj, name);
}

function isEnumerable(obj, name) {
Expand All @@ -143,9 +154,7 @@ function isEnumerable(obj, name) {
stringCheck = true;
}

return stringCheck &&
Object.prototype.hasOwnProperty.call(obj, name) &&
Object.prototype.propertyIsEnumerable.call(obj, name);
return stringCheck && __hasOwnProperty(obj, name) && __propertyIsEnumerable(obj, name);
}

function isSameValue(a, b) {
Expand All @@ -155,16 +164,19 @@ function isSameValue(a, b) {
return a === b;
}

var __isArray = Array.isArray;
function isWritable(obj, name, verifyProp, value) {
var unlikelyValue = __isArray(obj) && name === "length" ?
Math.pow(2, 32) - 1 :
nonIndexNumericPropertyName :
"unlikelyValue";
var newValue = value || unlikelyValue;
var hadValue = Object.prototype.hasOwnProperty.call(obj, name);
var hadValue = __hasOwnProperty(obj, name);
var oldValue = obj[name];
var writeSucceeded;

if (arguments.length < 4 && newValue === oldValue) {
newValue = newValue + "2";
}

try {
obj[name] = newValue;
} catch (e) {
Expand Down
21 changes: 11 additions & 10 deletions harness/resizableArrayBufferUtils.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ defines:
- ctors
- MyBigInt64Array
- CreateResizableArrayBuffer
- WriteToTypedArray
- MayNeedBigInt
- Convert
- ToNumbers
- CreateRabForTest
Expand Down Expand Up @@ -74,14 +74,6 @@ function CreateResizableArrayBuffer(byteLength, maxByteLength) {
return new ArrayBuffer(byteLength, { maxByteLength: maxByteLength });
}

function WriteToTypedArray(array, index, value) {
if (array instanceof BigInt64Array || array instanceof BigUint64Array) {
array[index] = BigInt(value);
} else {
array[index] = value;
}
}

function Convert(item) {
if (typeof item == 'bigint') {
return Number(item);
Expand All @@ -98,12 +90,21 @@ function ToNumbers(array) {
return result;
}

function MayNeedBigInt(ta, n) {
assert.sameValue(typeof n, 'number');
if ((BigInt64Array !== 'undefined' && ta instanceof BigInt64Array)
|| (BigUint64Array !== 'undefined' && ta instanceof BigUint64Array)) {
return BigInt(n);
}
return n;
}

function CreateRabForTest(ctor) {
const rab = CreateResizableArrayBuffer(4 * ctor.BYTES_PER_ELEMENT, 8 * ctor.BYTES_PER_ELEMENT);
// Write some data into the array.
const taWrite = new ctor(rab);
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(taWrite, i, 2 * i);
taWrite[i] = MayNeedBigInt(taWrite, 2 * i);
}
return rab;
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ for (let ctor of ctors) {
// Write some data into the array.
let ta_write = new ctor(rab);
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(ta_write, i, i);
ta_write[i] = MayNeedBigInt(ta_write, i);
}
assert.sameValue(ArrayAtHelper(fixedLength, -1), 3);
assert.sameValue(ArrayAtHelper(lengthTracking, -1), 3);
Expand Down
18 changes: 9 additions & 9 deletions test/built-ins/Array/prototype/copyWithin/resizable-buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ for (let ctor of ctors) {
// Write some data into the array.
const taWrite = new ctor(rab);
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(taWrite, i, i);
taWrite[i] = MayNeedBigInt(taWrite, i);
}

// Orig. array: [0, 1, 2, 3]
Expand All @@ -41,15 +41,15 @@ for (let ctor of ctors) {
3
]);
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(taWrite, i, i);
taWrite[i] = MayNeedBigInt(taWrite, i);
}
ArrayCopyWithinHelper(fixedLengthWithOffset, 0, 1);
assert.compareArray(ToNumbers(fixedLengthWithOffset), [
3,
3
]);
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(taWrite, i, i);
taWrite[i] = MayNeedBigInt(taWrite, i);
}
ArrayCopyWithinHelper(lengthTracking, 0, 2);
assert.compareArray(ToNumbers(lengthTracking), [
Expand All @@ -67,7 +67,7 @@ for (let ctor of ctors) {
// Shrink so that fixed length TAs go out of bounds.
rab.resize(3 * ctor.BYTES_PER_ELEMENT);
for (let i = 0; i < 3; ++i) {
WriteToTypedArray(taWrite, i, i);
taWrite[i] = MayNeedBigInt(taWrite, i);
}

// Orig. array: [0, 1, 2]
Expand Down Expand Up @@ -99,7 +99,7 @@ for (let ctor of ctors) {

// Shrink so that the TAs with offset go out of bounds.
rab.resize(1 * ctor.BYTES_PER_ELEMENT);
WriteToTypedArray(taWrite, 0, 0);
taWrite[0] = MayNeedBigInt(taWrite, 0);
ArrayCopyWithinHelper(fixedLength, 0, 1, 1);
ArrayCopyWithinHelper(fixedLengthWithOffset, 0, 1, 1);
ArrayCopyWithinHelper(lengthTrackingWithOffset, 0, 1, 1);
Expand All @@ -121,7 +121,7 @@ for (let ctor of ctors) {
// Grow so that all TAs are back in-bounds.
rab.resize(6 * ctor.BYTES_PER_ELEMENT);
for (let i = 0; i < 6; ++i) {
WriteToTypedArray(taWrite, i, i);
taWrite[i] = MayNeedBigInt(taWrite, i);
}

// Orig. array: [0, 1, 2, 3, 4, 5]
Expand All @@ -138,15 +138,15 @@ for (let ctor of ctors) {
3
]);
for (let i = 0; i < 6; ++i) {
WriteToTypedArray(taWrite, i, i);
taWrite[i] = MayNeedBigInt(taWrite, i);
}
ArrayCopyWithinHelper(fixedLengthWithOffset, 0, 1);
assert.compareArray(ToNumbers(fixedLengthWithOffset), [
3,
3
]);
for (let i = 0; i < 6; ++i) {
WriteToTypedArray(taWrite, i, i);
taWrite[i] = MayNeedBigInt(taWrite, i);
}

// [0, 1, 2, 3, 4, 5, ...] << lengthTracking
Expand All @@ -161,7 +161,7 @@ for (let ctor of ctors) {
5
]);
for (let i = 0; i < 6; ++i) {
WriteToTypedArray(taWrite, i, i);
taWrite[i] = MayNeedBigInt(taWrite, i);
}

// [2, 3, 4, 5, ...] << lengthTrackingWithOffset
Expand Down
4 changes: 2 additions & 2 deletions test/built-ins/Array/prototype/entries/resizable-buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -35,7 +35,7 @@ for (let ctor of ctors) {
// Write some data into the array.
const taWrite = new ctor(rab);
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(taWrite, i, 2 * i);
taWrite[i] = MayNeedBigInt(taWrite, 2 * i);
}

// Orig. array: [0, 2, 4, 6]
Expand Down Expand Up @@ -128,7 +128,7 @@ for (let ctor of ctors) {
// Grow so that all TAs are back in-bounds.
rab.resize(6 * ctor.BYTES_PER_ELEMENT);
for (let i = 0; i < 6; ++i) {
WriteToTypedArray(taWrite, i, 2 * i);
taWrite[i] = MayNeedBigInt(taWrite, 2 * i);
}

// Orig. array: [0, 2, 4, 6, 8, 10]
Expand Down
4 changes: 2 additions & 2 deletions test/built-ins/Array/prototype/every/resizable-buffer.js
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ for (let ctor of ctors) {
// Write some data into the array.
const taWrite = new ctor(rab);
for (let i = 0; i < 4; ++i) {
WriteToTypedArray(taWrite, i, 2 * i);
taWrite[i] = MayNeedBigInt(taWrite, 2 * i);
}

// Orig. array: [0, 2, 4, 6]
Expand Down Expand Up @@ -86,7 +86,7 @@ for (let ctor of ctors) {
// Grow so that all TAs are back in-bounds.
rab.resize(6 * ctor.BYTES_PER_ELEMENT);
for (let i = 0; i < 6; ++i) {
WriteToTypedArray(taWrite, i, 2 * i);
taWrite[i] = MayNeedBigInt(taWrite, 2 * i);
}

// Orig. array: [0, 2, 4, 6, 8, 10]
Expand Down
Loading

0 comments on commit 9aa6bad

Please sign in to comment.