From e744e8031c09b09922e5fef69f3c4731eb3ee5b0 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 6 Jan 2025 14:43:07 -0800 Subject: [PATCH 1/4] [Tests] some cleanups --- package.json | 2 - test/tests.js | 1000 +++++++++++++++++++++++++++---------------------- 2 files changed, 553 insertions(+), 449 deletions(-) diff --git a/package.json b/package.json index 986833a8..ec04c059 100644 --- a/package.json +++ b/package.json @@ -132,9 +132,7 @@ "has-strict-mode": "^1.0.1", "in-publish": "^2.0.1", "is-core-module": "^2.16.1", - "is-registered-symbol": "^1.1.1", "jackspeak": "=2.1.1", - "make-arrow-function": "^1.2.0", "make-async-function": "^1.0.0", "make-async-generator-function": "^1.0.0", "make-generator-function": "^2.0.0", diff --git a/test/tests.js b/test/tests.js index 9bd42e84..684044b6 100644 --- a/test/tests.js +++ b/test/tests.js @@ -1,7 +1,6 @@ 'use strict'; var tape = require('tape'); -var Test = require('tape/lib/test'); var forEach = require('for-each'); var debug = require('object-inspect'); @@ -9,7 +8,6 @@ var assign = require('object.assign'); var keys = require('object-keys'); var flatMap = require('array.prototype.flatmap'); var hasOwn = require('hasown'); -var arrowFns = require('make-arrow-function').list(); var hasStrictMode = require('has-strict-mode')(); var functionsHaveNames = require('functions-have-names')(); var functionsHaveConfigurableNames = require('functions-have-names').functionsHaveConfigurableNames(); @@ -24,7 +22,6 @@ var isCore = require('is-core-module'); var isRegex = require('is-regex'); var v = require('es-value-fixtures'); var mockProperty = require('mock-property'); -var isRegisteredSymbol = require('is-registered-symbol'); var hasNamedCaptures = require('has-named-captures')(); var $defineProperty = require('es-define-property'); var MAX_SAFE_INTEGER = require('math-intrinsics/constants/maxSafeInteger'); @@ -57,6 +54,23 @@ var reProtoIsRegex = isRegex(RegExp.prototype); var twoSixtyFour = hasBigInts && safeBigInt(Math.pow(2, 64)); var twoSixtyThree = hasBigInts && safeBigInt(Math.pow(2, 63)); +var unknowns = [].concat( + v.primitives, + v.objects +); +var allButSyms = [].concat( + v.objects, + v.nonSymbolPrimitives +); +var invalidTATypes = [].concat( + v.nonStrings, + 'not a valid type' +); +var nonFiniteNumbers = [].concat( + v.infinities, + NaN +); + var elementSizes = { __proto__: null, $Int8Array: 1, @@ -85,22 +99,52 @@ var unclampedSignedIntegerTypes = [ 'Uint16', 'Uint32' ]; -var unclampedIntegerTypes = unclampedUnsignedIntegerTypes.concat(unclampedSignedIntegerTypes); +var unclampedIntegerTypes = [].concat( + unclampedUnsignedIntegerTypes, + unclampedSignedIntegerTypes +); var floatTypes = [ 'Float32', 'Float64' ]; -var integerTypes = unclampedIntegerTypes.concat(clampedTypes, floatTypes); +var integerTypes = [].concat( + unclampedIntegerTypes, + clampedTypes +); var bigIntTypes = [ 'BigInt64', 'BigUint64' ]; -var numberTypes = floatTypes.concat(integerTypes); -var nonIntegerTypes = floatTypes.concat(bigIntTypes); -var unsignedElementTypes = unclampedSignedIntegerTypes.concat([ - 'BigUint64' -]); -var signedElementTypes = unclampedUnsignedIntegerTypes; +var numberTypes = [].concat( + floatTypes, + integerTypes +); +var nonUnclampedIntegerTypes = [].concat( + floatTypes, + bigIntTypes +); +var unsignedElementTypes = [].concat( + unclampedSignedIntegerTypes, + hasBigInts ? 'BigUint64' : [] +); +var signedElementTypes = [].concat( + unclampedUnsignedIntegerTypes, + floatTypes, + hasBigInts ? 'BigInt64' : [] +); +var allTypes = [].concat( + numberTypes, + hasBigInts ? bigIntTypes : [] +); +var nonTATypes = [].concat( + v.nonStrings, + '', + 'Byte' +); + +var isBigIntTAType = function isBigIntTAType(type) { + return type.slice(0, 3) === 'Big'; +}; var canDistinguishSparseFromUndefined = 0 in [undefined]; // IE 6 - 8 have a bug where this returns false @@ -120,7 +164,7 @@ var clearBuffer = function clearBuffer(buffer) { var testSetValueInBuffer = function (ES, st, testCase, isTypedArray, order) { return function (type) { - var isBigInt = type === 'BigInt64' || type === 'BigUint64'; + var isBigInt = isBigIntTAType(type); var Z = isBigInt ? safeBigInt : Number; var elementSize = elementSizes['$' + (type === 'Uint8C' ? 'Uint8Clamped' : type) + 'Array']; var hasBigEndian = type !== 'Int8' && type !== 'Uint8' && type !== 'Uint8C'; // the 8-bit types are special, they don't have big-endian @@ -131,7 +175,7 @@ var testSetValueInBuffer = function (ES, st, testCase, isTypedArray, order) { return; } - var valToSet = type === 'Uint8Clamped' && value > 255 ? 255 : Z(value); + var valToSet = type === 'Uint8C' && value > 255 ? 255 : Z(value); /* st.equal( @@ -151,9 +195,10 @@ var testSetValueInBuffer = function (ES, st, testCase, isTypedArray, order) { void undefined, 'returns undefined' ); + var resultObj = result[type === 'Float64' ? 'setAsLittle' : 'setAsTruncatedLittle']; st.deepEqual( Array.prototype.slice.call(copyBytes, 0, elementSize), - Array.prototype.slice.call(new Uint8Array(result[type === 'Float64' ? 'setAsLittle' : 'setAsTruncatedLittle'].bytes), 0, elementSize), + Array.prototype.slice.call(new Uint8Array(resultObj.bytes), 0, elementSize), 'buffer holding ' + debug(value) + ' with type ' + type + ', little endian, yields expected value' ); @@ -165,9 +210,10 @@ var testSetValueInBuffer = function (ES, st, testCase, isTypedArray, order) { void undefined, 'returns undefined' ); + var bigResultObj = result[type === 'Float64' ? 'setAsBig' : 'setAsTruncatedBig']; st.deepEqual( Array.prototype.slice.call(copyBytes, 0, elementSize), - Array.prototype.slice.call(new Uint8Array(result[type === 'Float64' ? 'setAsBig' : 'setAsTruncatedBig'].bytes), 0, elementSizes[type + 'Array']), + Array.prototype.slice.call(new Uint8Array(bigResultObj.bytes), 0, elementSize), 'buffer holding ' + debug(value) + ' with type ' + type + ', big endian, yields expected value' ); } @@ -394,7 +440,11 @@ var testToNumber = function (t, ES, ToNumber) { t.test('numbers', function (st) { st.equal(NaN, ToNumber(NaN), 'NaN returns itself'); - forEach(v.zeroes.concat(v.infinities, 42), function (num) { + forEach([].concat( + v.zeroes, + v.infinities, + 42 + ), function (num) { st.equal(num, ToNumber(num), num + ' returns itself'); }); st.end(); @@ -581,7 +631,11 @@ var es5 = function ES5(ES, ops, expectedMissing, skips) { forEach(v.zeroes.concat(NaN), function (falsyNumber) { st.equal(false, ES.ToBoolean(falsyNumber), 'falsy number ' + falsyNumber + ' coerces to false'); }); - forEach(v.infinities.concat([42, 1]), function (truthyNumber) { + forEach([].concat( + v.infinities, + 42, + 1 + ), function (truthyNumber) { st.equal(true, ES.ToBoolean(truthyNumber), 'truthy number ' + truthyNumber + ' coerces to true'); }); @@ -611,7 +665,11 @@ var es5 = function ES5(ES, ops, expectedMissing, skips) { t.test('numbers', function (st) { st.equal(NaN, ES.ToNumber(NaN), 'NaN returns itself'); - forEach(v.zeroes.concat(v.infinities, 42), function (num) { + forEach([].concat( + v.zeroes, + v.infinities, + 42 + ), function (num) { st.equal(num, ES.ToNumber(num), num + ' returns itself'); }); forEach(['foo', '0', '4a', '2.0', 'Infinity', '-Infinity'], function (numString) { @@ -688,7 +746,11 @@ var es5 = function ES5(ES, ops, expectedMissing, skips) { forEach([NaN], function (num) { t.equal(0, ES.ToInteger(num), debug(num) + ' returns +0'); }); - forEach(v.zeroes.concat(v.infinities, 42), function (num) { + forEach([].concat( + v.zeroes, + v.infinities, + 42 + ), function (num) { t.equal(num, ES.ToInteger(num), debug(num) + ' returns itself'); t.equal(-num, ES.ToInteger(-num), '-' + debug(num) + ' returns itself'); }); @@ -699,7 +761,10 @@ var es5 = function ES5(ES, ops, expectedMissing, skips) { test('ToInt32', function (t) { t.equal(ES.ToInt32(NaN), 0, 'NaN coerces to +0'); - forEach(v.zeroes.concat(v.infinities), function (num) { + forEach([].concat( + v.zeroes, + v.infinities + ), function (num) { t.equal(ES.ToInt32(num), 0, num + ' returns +0'); t.equal(ES.ToInt32(-num), 0, '-' + num + ' returns +0'); }); @@ -750,7 +815,7 @@ var es5 = function ES5(ES, ops, expectedMissing, skips) { }); test('ToString', function (t) { - forEach(v.objects.concat(v.nonSymbolPrimitives), function (item) { + forEach(allButSyms, function (item) { t.equal(ES.ToString(item), String(item), 'ES.ToString(' + debug(item) + ') ToStrings to String(' + debug(item) + ')'); }); @@ -774,16 +839,24 @@ var es5 = function ES5(ES, ops, expectedMissing, skips) { test('CheckObjectCoercible', function (t) { t['throws'](function () { return ES.CheckObjectCoercible(undefined); }, TypeError, 'undefined throws'); t['throws'](function () { return ES.CheckObjectCoercible(null); }, TypeError, 'null throws'); - var checkCoercible = function (value) { + forEach([].concat( + v.objects, + v.nonNullPrimitives + ), function (value) { t.doesNotThrow(function () { return ES.CheckObjectCoercible(value); }, debug(value) + ' does not throw'); - }; - forEach(v.objects.concat(v.nonNullPrimitives), checkCoercible); + }); t.end(); }); test('IsCallable', function (t) { t.equal(true, ES.IsCallable(function () {}), 'function is callable'); - var nonCallables = [/a/g, {}, Object.prototype, NaN].concat(v.nonFunctions); + var nonCallables = [].concat( + /a/g, + {}, + Object.prototype, + NaN, + v.nonFunctions + ); forEach(nonCallables, function (nonCallable) { t.equal(false, ES.IsCallable(nonCallable), debug(nonCallable) + ' is not callable'); }); @@ -793,7 +866,7 @@ var es5 = function ES5(ES, ops, expectedMissing, skips) { test('SameValue', function (t) { t.equal(true, ES.SameValue(NaN, NaN), 'NaN is SameValue as NaN'); t.equal(false, ES.SameValue(0, -0), '+0 is not SameValue as -0'); - forEach(v.objects.concat(v.primitives), function (val) { + forEach(unknowns, function (val) { t.equal(val === val, ES.SameValue(val, val), debug(val) + ' is SameValue to itself'); }); t.end(); @@ -879,7 +952,7 @@ var es5 = function ES5(ES, ops, expectedMissing, skips) { t.equal(ES.FromPropertyDescriptor(), undefined, 'no value begets undefined'); t.equal(ES.FromPropertyDescriptor(undefined), undefined, 'undefined value begets undefined'); - forEach(v.nonNullPrimitives.concat(null), function (primitive) { + forEach(v.nonUndefinedPrimitives, function (primitive) { t['throws']( function () { ES.FromPropertyDescriptor(primitive); }, TypeError, @@ -1004,7 +1077,7 @@ var es5 = function ES5(ES, ops, expectedMissing, skips) { test('Abstract Equality Comparison', function (t) { t.test('same types use ===', function (st) { - forEach(v.primitives.concat(v.objects), function (value) { + forEach(unknowns, function (value) { st.equal(ES['Abstract Equality Comparison'](value, value), value === value, debug(value) + ' is abstractly equal to itself'); }); st.end(); @@ -1044,7 +1117,7 @@ var es5 = function ES5(ES, ops, expectedMissing, skips) { test('Strict Equality Comparison', function (t) { t.test('same types use ===', function (st) { - forEach(v.primitives.concat(v.objects), function (value) { + forEach(unknowns, function (value) { st.equal(ES['Strict Equality Comparison'](value, value), value === value, debug(value) + ' is strictly equal to itself'); }); st.end(); @@ -1364,7 +1437,7 @@ var es5 = function ES5(ES, ops, expectedMissing, skips) { }); test('MakeDate', function (t) { - forEach(v.infinities.concat(NaN), function (nonFiniteNumber) { + forEach(nonFiniteNumbers, function (nonFiniteNumber) { t.equal(ES.MakeDate(nonFiniteNumber, 0), NaN, debug(nonFiniteNumber) + ' is not a finite `day`'); t.equal(ES.MakeDate(0, nonFiniteNumber), NaN, debug(nonFiniteNumber) + ' is not a finite `time`'); }); @@ -1379,7 +1452,7 @@ var es5 = function ES5(ES, ops, expectedMissing, skips) { }); test('MakeTime', function (t) { - forEach(v.infinities.concat(NaN), function (nonFiniteNumber) { + forEach(nonFiniteNumbers, function (nonFiniteNumber) { t.equal(ES.MakeTime(nonFiniteNumber, 0, 0, 0), NaN, debug(nonFiniteNumber) + ' is not a finite `hour`'); t.equal(ES.MakeTime(0, nonFiniteNumber, 0, 0), NaN, debug(nonFiniteNumber) + ' is not a finite `min`'); t.equal(ES.MakeTime(0, 0, nonFiniteNumber, 0), NaN, debug(nonFiniteNumber) + ' is not a finite `sec`'); @@ -1396,13 +1469,18 @@ var es5 = function ES5(ES, ops, expectedMissing, skips) { }); test('TimeClip', function (t) { - forEach(v.infinities.concat(NaN), function (nonFiniteNumber) { + forEach(nonFiniteNumbers, function (nonFiniteNumber) { t.equal(ES.TimeClip(nonFiniteNumber), NaN, debug(nonFiniteNumber) + ' is not a finite `time`'); }); t.equal(ES.TimeClip(8.64e15 + 1), NaN, '8.64e15 is the largest magnitude considered "finite"'); t.equal(ES.TimeClip(-8.64e15 - 1), NaN, '-8.64e15 is the largest magnitude considered "finite"'); - forEach(v.zeroes.concat([-10, 10, +new Date()]), function (time) { + forEach([].concat( + v.zeroes, + -10, + 10, + +new Date() + ), function (time) { t.looseEqual(ES.TimeClip(time), time, debug(time) + ' is a time of ' + debug(time)); }); @@ -1490,10 +1568,14 @@ var es2015 = function ES2015(ES, ops, expectedMissing, skips) { ); }); - var notInts = v.nonNumbers.concat( + var notInts = [].concat( + v.nonNumbers, v.nonIntegerNumbers, - v.infinities, - [NaN, [], new Date(), Math.pow(2, 53), -1] + nonFiniteNumbers, + [], + new Date(), + Math.pow(2, 53), + -1 ); forEach(notInts, function (nonInt) { t['throws']( @@ -1590,7 +1672,7 @@ var es2015 = function ES2015(ES, ops, expectedMissing, skips) { }); test('ArraySetLength', function (t) { - forEach(v.primitives.concat(v.objects), function (nonArray) { + forEach(unknowns, function (nonArray) { t['throws']( function () { ES.ArraySetLength(nonArray, { '[[Value]]': 0 }); }, TypeError, @@ -1642,7 +1724,11 @@ var es2015 = function ES2015(ES, ops, expectedMissing, skips) { st.end(); }); - forEach([-1, Math.pow(2, 32)].concat(v.nonIntegerNumbers), function (nonLength) { + forEach([].concat( + -1, + Math.pow(2, 32), + v.nonIntegerNumbers + ), function (nonLength) { t['throws']( function () { ES.ArraySetLength([], v.descriptors.value(nonLength)); }, RangeError, @@ -1701,7 +1787,7 @@ var es2015 = function ES2015(ES, ops, expectedMissing, skips) { }); t.test('works with a non-array', function (st) { - forEach(v.objects.concat(v.primitives), function (nonArray) { + forEach(unknowns, function (nonArray) { var arr = ES.ArraySpeciesCreate(nonArray, 0); st.ok(ES.IsArray(arr), 'is an array'); st.equal(arr.length, 0, 'length is correct'); @@ -1805,7 +1891,11 @@ var es2015 = function ES2015(ES, ops, expectedMissing, skips) { test('Call', function (t) { var receiver = {}; - var notFuncs = v.nonFunctions.concat([/a/g, new RegExp('a', 'g')]); + var notFuncs = [].concat( + v.nonFunctions, + /a/g, + new RegExp('a', 'g') + ); t.plan(notFuncs.length + v.nonArrays.length + 5); forEach(notFuncs, function (notFunc) { @@ -2469,7 +2559,7 @@ var es2015 = function ES2015(ES, ops, expectedMissing, skips) { }); test('DetachArrayBuffer', function (t) { - forEach(v.primitives.concat(v.objects), function (nonArrayBuffer) { + forEach(unknowns, function (nonArrayBuffer) { t['throws']( function () { ES.DetachArrayBuffer(nonArrayBuffer); }, TypeError, @@ -2761,7 +2851,7 @@ var es2015 = function ES2015(ES, ops, expectedMissing, skips) { ); }); - forEach(arrowFns, function (arrowFn) { + forEach(v.arrowFunctions, function (arrowFn) { t['throws']( function () { ES.GetPrototypeFromConstructor(arrowFn, '%Array%'); }, TypeError, @@ -2968,7 +3058,7 @@ var es2015 = function ES2015(ES, ops, expectedMissing, skips) { }); test('GetValueFromBuffer', function (t) { - forEach(v.primitives.concat(v.objects), function (nonAB) { + forEach(unknowns, function (nonAB) { t['throws']( function () { ES.GetValueFromBuffer(nonAB, 0, 'Int8'); }, TypeError, @@ -2985,7 +3075,7 @@ var es2015 = function ES2015(ES, ops, expectedMissing, skips) { ); }); - forEach(v.nonStrings.concat('not a valid type'), function (nonString) { + forEach(invalidTATypes, function (nonString) { st['throws']( function () { ES.GetValueFromBuffer(new ArrayBuffer(8), 0, nonString); }, TypeError, @@ -3016,17 +3106,7 @@ var es2015 = function ES2015(ES, ops, expectedMissing, skips) { forEach(bufferTestCases, function (testCase, name) { st.test(name + ': ' + debug(testCase.value), function (s2t) { - forEach([ - 'Int8', - 'Uint8', - 'Uint8C', - 'Int16', - 'Uint16', - 'Int32', - 'Uint32', - 'Float32', - 'Float64' - ], function (type) { + forEach(numberTypes, function (type) { var view = new DataView(new ArrayBuffer(elementSizes.$Float64Array)); var method = type === 'Uint8C' ? 'Uint8' : type; // var value = unserialize(testCase.value); @@ -3209,7 +3289,7 @@ var es2015 = function ES2015(ES, ops, expectedMissing, skips) { ); }); - forEach(v.primitives.concat(v.objects), function (nonTA) { + forEach(unknowns, function (nonTA) { t['throws']( function () { ES.IntegerIndexedElementGet(nonTA, 0); }, TypeError, @@ -3219,7 +3299,7 @@ var es2015 = function ES2015(ES, ops, expectedMissing, skips) { t.test('actual typed arrays', { skip: availableTypedArrays.length === 0 }, function (st) { forEach(availableTypedArrays, function (typedArray) { - var isBigInt = typedArray.slice(0, 3) === 'Big'; + var isBigInt = isBigIntTAType(typedArray); if (isBigInt && 'ToBigInt' in ES) { var Z = isBigInt ? safeBigInt : Number; var TA = global[typedArray]; @@ -3355,7 +3435,7 @@ var es2015 = function ES2015(ES, ops, expectedMissing, skips) { t.equal(true, ES.IsArray([]), '[] is array'); t.equal(false, ES.IsArray({}), '{} is not array'); t.equal(false, ES.IsArray({ length: 1, 0: true }), 'arraylike object is not array'); - forEach(v.objects.concat(v.primitives), function (value) { + forEach(unknowns, function (value) { t.equal(false, ES.IsArray(value), debug(value) + ' is not array'); }); t.end(); @@ -3474,7 +3554,7 @@ var es2015 = function ES2015(ES, ops, expectedMissing, skips) { }); test('IsDetachedBuffer', function (t) { - forEach(v.primitives.concat(v.objects), function (nonArrayBuffer) { + forEach(unknowns, function (nonArrayBuffer) { t['throws']( function () { ES.IsDetachedBuffer(nonArrayBuffer); }, TypeError, @@ -3545,7 +3625,7 @@ var es2015 = function ES2015(ES, ops, expectedMissing, skips) { }); test('IsPromise', function (t) { - forEach(v.objects.concat(v.primitives), function (nonPromise) { + forEach(unknowns, function (nonPromise) { t.equal(ES.IsPromise(nonPromise), false, debug(nonPromise) + ' is not a Promise'); }); @@ -3562,7 +3642,10 @@ var es2015 = function ES2015(ES, ops, expectedMissing, skips) { }); test('IsPropertyKey', function (t) { - forEach(v.numbers.concat(v.objects), function (notKey) { + forEach([].concat( + v.numbers, + v.objects + ), function (notKey) { t.equal(false, ES.IsPropertyKey(notKey), debug(notKey) + ' is not property key'); }); @@ -3579,7 +3662,7 @@ var es2015 = function ES2015(ES, ops, expectedMissing, skips) { t.equal(true, ES.IsRegExp(regex), regex + ' is regex'); }); - forEach(v.objects.concat(v.primitives), function (nonRegex) { + forEach(unknowns, function (nonRegex) { t.equal(false, ES.IsRegExp(nonRegex), debug(nonRegex) + ' is not regex'); }); @@ -3646,7 +3729,13 @@ var es2015 = function ES2015(ES, ops, expectedMissing, skips) { t.equal(false, ES.IsInteger(i + 0.2), (i + 0.2) + ' is not integer'); } t.equal(true, ES.IsInteger(-0), '-0 is integer'); - var notInts = v.nonNumbers.concat(v.nonIntegerNumbers, v.infinities, [NaN, [], new Date()]); + var notInts = [].concat( + v.nonNumbers, + v.nonIntegerNumbers, + nonFiniteNumbers, + [], + new Date() + ); forEach(notInts, function (notInt) { t.equal(false, ES.IsInteger(notInt), debug(notInt) + ' is not integer'); }); @@ -3724,7 +3813,7 @@ var es2015 = function ES2015(ES, ops, expectedMissing, skips) { }); test('IteratorStep', function (t) { - forEach(v.primitives.concat(v.objects), function (nonIteratorRecord) { + forEach(unknowns, function (nonIteratorRecord) { t['throws']( function () { ES.IteratorStep(nonIteratorRecord); }, TypeError, @@ -3870,7 +3959,10 @@ var es2015 = function ES2015(ES, ops, expectedMissing, skips) { }); test('NewPromiseCapability', function (t) { - forEach(v.nonFunctions.concat(v.nonConstructorFunctions), function (nonConstructor) { + forEach([].concat( + v.nonFunctions, + v.nonConstructorFunctions + ), function (nonConstructor) { t['throws']( function () { ES.NewPromiseCapability(nonConstructor); }, TypeError, @@ -4057,7 +4149,7 @@ var es2015 = function ES2015(ES, ops, expectedMissing, skips) { ); }); - forEach(arrowFns, function (arrowFn) { + forEach(v.arrowFunctions, function (arrowFn) { t['throws']( function () { ES.OrdinaryCreateFromConstructor(arrowFn, '%Array.prototype%'); }, TypeError, @@ -4411,17 +4503,19 @@ var es2015 = function ES2015(ES, ops, expectedMissing, skips) { t.equal(false, 'CheckObjectCoercible' in ES, 'CheckObjectCoercible -> RequireObjectCoercible in ES6'); t['throws'](function () { return ES.RequireObjectCoercible(undefined); }, TypeError, 'undefined throws'); t['throws'](function () { return ES.RequireObjectCoercible(null); }, TypeError, 'null throws'); - var isCoercible = function (value) { + forEach([].concat( + v.objects, + v.nonNullPrimitives + ), function (value) { t.doesNotThrow(function () { return ES.RequireObjectCoercible(value); }, debug(value) + ' does not throw'); - }; - forEach(v.objects.concat(v.nonNullPrimitives), isCoercible); + }); t.end(); }); test('SameValueZero', function (t) { t.equal(true, ES.SameValueZero(NaN, NaN), 'NaN is SameValueZero as NaN'); t.equal(true, ES.SameValueZero(0, -0), '+0 is SameValueZero as -0'); - forEach(v.objects.concat(v.primitives), function (val) { + forEach(unknowns, function (val) { t.equal(val === val, ES.SameValueZero(val, val), debug(val) + ' is SameValueZero to itself'); }); t.end(); @@ -4628,7 +4722,7 @@ var es2015 = function ES2015(ES, ops, expectedMissing, skips) { }); test('SetValueInBuffer', function (t) { - forEach(v.primitives.concat(v.objects), function (nonAB) { + forEach(unknowns, function (nonAB) { t['throws']( function () { ES.SetValueInBuffer(nonAB, 0, 'Int8', 0); }, TypeError, @@ -4645,7 +4739,7 @@ var es2015 = function ES2015(ES, ops, expectedMissing, skips) { ); }); - forEach(v.nonStrings.concat('not a valid type'), function (nonString) { + forEach(invalidTATypes, function (nonString) { st['throws']( function () { ES.SetValueInBuffer(new ArrayBuffer(8), 0, nonString, 0); }, TypeError, @@ -4683,17 +4777,7 @@ var es2015 = function ES2015(ES, ops, expectedMissing, skips) { }); forEach(bufferTestCases, function (testCase, name) { - forEach([].concat( - 'Int8', - 'Uint8', - 'Uint8C', - 'Int16', - 'Uint16', - 'Int32', - 'Uint32', - 'Float32', - 'Float64' - ), function (type) { + forEach(numberTypes, function (type) { var hasBigEndian = type !== 'Int8' && type !== 'Uint8' && type !== 'Uint8C'; // the 8-bit types are special, they don't have big-endian var result = testCase[type === 'Uint8C' ? 'Uint8Clamped' : type]; var value = unserialize(testCase.value); @@ -4811,11 +4895,18 @@ var es2015 = function ES2015(ES, ops, expectedMissing, skips) { ); }); - forEach(v.nonNumbers.concat(v.nonIntegerNumbers), function (nonIntegerNumber) { + var notInts = [].concat( + v.nonNumbers, + v.nonIntegerNumbers, + nonFiniteNumbers, + [], + new Date() + ); + forEach(notInts, function (nonInteger) { t['throws']( - function () { ES.SplitMatch('', nonIntegerNumber, ''); }, + function () { ES.SplitMatch('', nonInteger, ''); }, TypeError, - 'q: ' + debug(nonIntegerNumber) + ' is not an integer' + 'q: ' + debug(nonInteger) + ' is not an integer' ); }); @@ -4867,7 +4958,10 @@ var es2015 = function ES2015(ES, ops, expectedMissing, skips) { }); test('StringGetIndexProperty', function (t) { - forEach(v.nonStrings.concat(v.strings), function (nonStringObjects) { + forEach([].concat( + v.nonStrings, + v.strings + ), function (nonStringObjects) { t['throws']( function () { ES.StringGetIndexProperty(nonStringObjects); }, TypeError, @@ -4892,7 +4986,12 @@ var es2015 = function ES2015(ES, ops, expectedMissing, skips) { }); // a string where CanonicalNumericIndexString returns undefined, a non-integer, or -0 - forEach(['-1', '-0', 'undefined'].concat(v.nonIntegerNumbers), function (nonIndex) { + forEach([].concat( + '-1', + '-0', + 'undefined', + v.nonIntegerNumbers + ), function (nonIndex) { var S = Object('abc'); t.equal( ES.StringGetIndexProperty(S, String(nonIndex)), @@ -4927,7 +5026,7 @@ var es2015 = function ES2015(ES, ops, expectedMissing, skips) { }); test('SymbolDescriptiveString', function (t) { - forEach(v.nonSymbolPrimitives.concat(v.objects), function (nonSymbol) { + forEach(allButSyms, function (nonSymbol) { t['throws']( function () { ES.SymbolDescriptiveString(nonSymbol); }, TypeError, @@ -5058,7 +5157,7 @@ var es2015 = function ES2015(ES, ops, expectedMissing, skips) { }); test('thisTimeValue', function (t) { - forEach(v.primitives.concat(v.objects), function (nonDate) { + forEach(unknowns, function (nonDate) { t['throws']( function () { ES.thisTimeValue(nonDate); }, TypeError, @@ -5188,7 +5287,7 @@ var es2015 = function ES2015(ES, ops, expectedMissing, skips) { }); test('ToPropertyKey', function (t) { - forEach(v.objects.concat(v.nonSymbolPrimitives), function (value) { + forEach(allButSyms, function (value) { t.equal(ES.ToPropertyKey(value), String(value), 'ToPropertyKey(value) === String(value) for non-Symbols'); }); @@ -5209,7 +5308,7 @@ var es2015 = function ES2015(ES, ops, expectedMissing, skips) { }); test('ToString', function (t) { - forEach(v.objects.concat(v.nonSymbolPrimitives), function (item) { + forEach(allButSyms, function (item) { t.equal(ES.ToString(item), String(item), 'ES.ToString(' + debug(item) + ') ToStrings to String(' + debug(item) + ')'); }); @@ -5674,7 +5773,10 @@ var es2015 = function ES2015(ES, ops, expectedMissing, skips) { }); test('ValidateTypedArray', function (t) { - forEach(v.primitives.concat(v.objects, [[]]), function (nonTA) { + forEach([].concat( + unknowns, + [[]] + ), function (nonTA) { t['throws']( function () { ES.ValidateTypedArray(nonTA); }, TypeError, @@ -5826,7 +5928,10 @@ var es2016 = function ES2016(ES, ops, expectedMissing, skips) { t['throws'](function () { return ES.SameValueNonNumber.apply(ES, nums); }, TypeError, 'value must be same type and non-number'); }); - forEach(v.objects.concat(v.nonNumberPrimitives), function (val) { + forEach([].concat( + v.objects, + v.nonNumberPrimitives + ), function (val) { t.equal(val === val, ES.SameValueNonNumber(val, val), debug(val) + ' is SameValueNonNumber to itself'); }); @@ -5913,7 +6018,7 @@ var es2016 = function ES2016(ES, ops, expectedMissing, skips) { test('TypedArraySpeciesCreate', function (t) { t.test('no Typed Array support', { skip: availableTypedArrays.length > 0 }, function (st) { - forEach(v.primitives.concat(v.objects), function (nonTA) { + forEach(unknowns, function (nonTA) { st['throws']( function () { ES.TypedArraySpeciesCreate(nonTA, []); }, SyntaxError, @@ -5932,7 +6037,7 @@ var es2016 = function ES2016(ES, ops, expectedMissing, skips) { }); t.test('Typed Array support', { skip: availableTypedArrays.length === 0 }, function (st) { - forEach(v.primitives.concat(v.objects), function (nonTA) { + forEach(unknowns, function (nonTA) { st['throws']( function () { ES.TypedArraySpeciesCreate(nonTA, []); }, TypeError, @@ -5941,7 +6046,10 @@ var es2016 = function ES2016(ES, ops, expectedMissing, skips) { }); var nonArrayTA = new global[availableTypedArrays[0]](); - forEach(v.primitives.concat(v.nonArrays), function (nonArray) { + forEach([].concat( + v.primitives, + v.nonArrays + ), function (nonArray) { st['throws']( function () { ES.TypedArraySpeciesCreate(nonArrayTA, nonArray); }, TypeError, @@ -6217,8 +6325,9 @@ var es2017 = function ES2017(ES, ops, expectedMissing, skips) { test('GetValueFromBuffer', function (t) { var isTypedArray = true; + var order = 'Unordered'; - forEach(v.primitives.concat(v.objects), function (nonAB) { + forEach(unknowns, function (nonAB) { t['throws']( function () { ES.GetValueFromBuffer(nonAB, 0, 'Int8', isTypedArray, 'order'); }, TypeError, @@ -6229,15 +6338,15 @@ var es2017 = function ES2017(ES, ops, expectedMissing, skips) { t.test('ArrayBuffers supported', { skip: typeof ArrayBuffer !== 'function' }, function (st) { forEach(v.notNonNegativeIntegers, function (nonNonNegativeInteger) { st['throws']( - function () { ES.GetValueFromBuffer(new ArrayBuffer(8), nonNonNegativeInteger, 'Int8', isTypedArray, 'order'); }, + function () { ES.GetValueFromBuffer(new ArrayBuffer(8), nonNonNegativeInteger, 'Int8', isTypedArray, order); }, TypeError, debug(nonNonNegativeInteger) + ' is not a valid byte index' ); }); - forEach(v.nonStrings.concat('not a valid type'), function (nonString) { + forEach(invalidTATypes, function (nonString) { st['throws']( - function () { ES.GetValueFromBuffer(new ArrayBuffer(8), 0, nonString, isTypedArray, 'order'); }, + function () { ES.GetValueFromBuffer(new ArrayBuffer(8), 0, nonString, isTypedArray, order); }, TypeError, debug(nonString) + ' is not a valid String (or type) value' ); @@ -6245,13 +6354,13 @@ var es2017 = function ES2017(ES, ops, expectedMissing, skips) { forEach(v.nonBooleans, function (nonBoolean) { st['throws']( - function () { ES.GetValueFromBuffer(new ArrayBuffer(8), 0, 'Int8', nonBoolean, 'order'); }, + function () { ES.GetValueFromBuffer(new ArrayBuffer(8), 0, 'Int8', nonBoolean, order); }, TypeError, 'isTypedArray: ' + debug(nonBoolean) + ' is not a valid Boolean value' ); st['throws']( - function () { ES.GetValueFromBuffer(new ArrayBuffer(8), 0, 'Int8', isTypedArray, 'order', nonBoolean); }, + function () { ES.GetValueFromBuffer(new ArrayBuffer(8), 0, 'Int8', isTypedArray, order, nonBoolean); }, TypeError, 'isLittleEndian: ' + debug(nonBoolean) + ' is not a valid Boolean value' ); @@ -6270,7 +6379,7 @@ var es2017 = function ES2017(ES, ops, expectedMissing, skips) { s2t.equal(ES.DetachArrayBuffer(buffer), null, 'detaching returns null'); s2t['throws']( - function () { ES.GetValueFromBuffer(buffer, 0, 'Int8', isTypedArray, 'order'); }, + function () { ES.GetValueFromBuffer(buffer, 0, 'Int8', isTypedArray, order); }, TypeError, 'detached buffers throw' ); @@ -6280,17 +6389,7 @@ var es2017 = function ES2017(ES, ops, expectedMissing, skips) { forEach(bufferTestCases, function (testCase, name) { st.test(name + ': ' + debug(testCase.value), function (s2t) { - forEach([ - 'Int8', - 'Uint8', - 'Uint8C', - 'Int16', - 'Uint16', - 'Int32', - 'Uint32', - 'Float32', - 'Float64' - ], function (type) { + forEach(numberTypes, function (type) { var view = new DataView(new ArrayBuffer(elementSizes.$Float64Array)); var method = type === 'Uint8C' ? 'Uint8' : type; // var value = unserialize(testCase.value); @@ -6306,33 +6405,33 @@ var es2017 = function ES2017(ES, ops, expectedMissing, skips) { clearBuffer(view.buffer); var littleVal = unserialize(result.setAsLittle.asLittle); - view['set' + method](0, type.slice(0, 3) === 'Big' ? safeBigInt(littleVal) : littleVal, true); + view['set' + method](0, isBigIntTAType(type) ? safeBigInt(littleVal) : littleVal, true); s2t.equal( - ES.GetValueFromBuffer(view.buffer, 0, type, isTypedArray, 'order', true), + ES.GetValueFromBuffer(view.buffer, 0, type, isTypedArray, order, true), littleVal, 'buffer with type ' + type + ', little -> little, yields expected value' ); if (hasBigEndian) { s2t.equal( - ES.GetValueFromBuffer(view.buffer, 0, type, isTypedArray, 'order', false), + ES.GetValueFromBuffer(view.buffer, 0, type, isTypedArray, order, false), view['get' + method](0, false), 'buffer with type ' + type + ', little -> big, yields expected value' ); clearBuffer(view.buffer); var bigVal = unserialize(result.setAsBig.asBig); - view['set' + method](0, type.slice(0, 3) === 'Big' ? safeBigInt(bigVal) : bigVal, false); + view['set' + method](0, isBigIntTAType(type) ? safeBigInt(bigVal) : bigVal, false); s2t.equal( - ES.GetValueFromBuffer(view.buffer, 0, type, isTypedArray, 'order', false), + ES.GetValueFromBuffer(view.buffer, 0, type, isTypedArray, order, false), bigVal, 'buffer with type ' + type + ', big -> big, yields expected value' ); s2t.equal( - ES.GetValueFromBuffer(view.buffer, 0, type, isTypedArray, 'order', true), + ES.GetValueFromBuffer(view.buffer, 0, type, isTypedArray, order, true), view['get' + method](0, true), 'buffer with type ' + type + ', big -> little, yields expected value' ); @@ -6390,7 +6489,7 @@ var es2017 = function ES2017(ES, ops, expectedMissing, skips) { }); test('NumberToRawBytes', function (t) { - forEach(v.nonStrings.concat('', 'Byte'), function (nonTAType) { + forEach(nonTATypes, function (nonTAType) { t['throws']( function () { ES.NumberToRawBytes(nonTAType, 0, false); }, TypeError, @@ -6418,17 +6517,7 @@ var es2017 = function ES2017(ES, ops, expectedMissing, skips) { var value = unserialize(testCase.value); t.test(name + ': ' + value, function (st) { - forEach([].concat( - 'Int8', - 'Uint8', - 'Uint8C', - 'Int16', - 'Uint16', - 'Int32', - 'Uint32', - 'Float32', - 'Float64' - ), function (type) { + forEach(numberTypes, function (type) { var hasBigEndian = type !== 'Int8' && type !== 'Uint8' && type !== 'Uint8C'; // the 8-bit types are special, they don't have big-endian var result = testCase[type === 'Uint8C' ? 'Uint8Clamped' : type]; var valToSet = type === 'Uint8C' && value > 0xFF ? 0xFF : value; @@ -6572,7 +6661,7 @@ var es2017 = function ES2017(ES, ops, expectedMissing, skips) { }); test('RawBytesToNumber', function (t) { - forEach(v.nonStrings.concat('', 'Byte'), function (nonTAType) { + forEach(nonTATypes, function (nonTAType) { t['throws']( function () { ES.RawBytesToNumber(nonTAType, [], false); }, TypeError, @@ -6580,7 +6669,7 @@ var es2017 = function ES2017(ES, ops, expectedMissing, skips) { ); }); - forEach(v.primitives.concat(v.objects), function (nonArray) { + forEach(unknowns, function (nonArray) { t['throws']( function () { ES.RawBytesToNumber('Int8', nonArray, false); }, TypeError, @@ -6606,17 +6695,7 @@ var es2017 = function ES2017(ES, ops, expectedMissing, skips) { forEach(bufferTestCases, function (testCase, name) { var value = unserialize(testCase.value); t.test(name + ': ' + value, function (st) { - forEach([].concat( - 'Int8', - 'Uint8', - 'Uint8C', - 'Int16', - 'Uint16', - 'Int32', - 'Uint32', - 'Float32', - 'Float64' - ), function (type) { + forEach(numberTypes, function (type) { var result = testCase[type === 'Uint8C' ? 'Uint8Clamped' : type]; var hasBigEndian = type !== 'Int8' && type !== 'Uint8' && type !== 'Uint8C'; // the 8-bit types are special, they don't have big-endian @@ -6749,7 +6828,7 @@ var es2017 = function ES2017(ES, ops, expectedMissing, skips) { test('SetValueInBuffer', function (t) { var order = 'Unordered'; - forEach(v.primitives.concat(v.objects), function (nonAB) { + forEach(unknowns, function (nonAB) { t['throws']( function () { ES.SetValueInBuffer(nonAB, 0, 'Int8', 0, false, order); }, TypeError, @@ -6768,7 +6847,7 @@ var es2017 = function ES2017(ES, ops, expectedMissing, skips) { ); }); - forEach(v.nonStrings.concat('not a valid type'), function (nonString) { + forEach(invalidTATypes, function (nonString) { st['throws']( function () { ES.SetValueInBuffer(new ArrayBuffer(8), 0, nonString, 0, isTypedArray, order); }, TypeError, @@ -6798,20 +6877,6 @@ var es2017 = function ES2017(ES, ops, expectedMissing, skips) { ); }); - if (hasBigInts) { - st['throws']( - function () { ES.SetValueInBuffer(new ArrayBuffer(8), 0, 'Int8', $BigInt(0), isTypedArray, order); }, - TypeError, - debug($BigInt(0)) + ' is not a number, but the given type requires one' - ); - - st['throws']( - function () { ES.SetValueInBuffer(new ArrayBuffer(8), 0, 'BigUint64', 0, isTypedArray, order); }, - TypeError, - debug(0) + ' is not a bigint, but the given type requires one' - ); - } - st['throws']( function () { ES.SetValueInBuffer(new ArrayBuffer(8), 0, 'Int8', 0, isTypedArray, 'invalid order'); }, TypeError, @@ -6831,28 +6896,8 @@ var es2017 = function ES2017(ES, ops, expectedMissing, skips) { s2t.end(); }); - st.test('SharedArrayBuffers supported', { skip: typeof SharedArrayBuffer !== 'function' }, function (s2t) { - s2t['throws']( - function () { ES.SetValueInBuffer(new SharedArrayBuffer(0), 0, 'Int8', 0, true, order); }, - SyntaxError, - 'SAB not yet supported' - ); - - s2t.end(); - }); - forEach(bufferTestCases, function (testCase, name) { - forEach([].concat( - 'Int8', - 'Uint8', - 'Uint8C', - 'Int16', - 'Uint16', - 'Int32', - 'Uint32', - 'Float32', - 'Float64' - ), testSetValueInBuffer(ES, st, testCase, isTypedArray, order)); + forEach(numberTypes, testSetValueInBuffer(ES, st, testCase, isTypedArray, order)); }); st.end(); @@ -6862,7 +6907,10 @@ var es2017 = function ES2017(ES, ops, expectedMissing, skips) { }); test('StringGetOwnProperty', function (t) { - forEach(v.nonStrings.concat(v.strings), function (nonBoxedString) { + forEach([].concat( + v.nonStrings, + v.strings + ), function (nonBoxedString) { t['throws']( function () { ES.StringGetOwnProperty(nonBoxedString, '0'); }, TypeError, @@ -6948,7 +6996,10 @@ var es2017 = function ES2017(ES, ops, expectedMissing, skips) { }); test('ValidateAtomicAccess', function (t) { - forEach(v.primitives.concat(v.objects, [[]]), function (nonTA) { + forEach([].concat( + unknowns, + [[]] + ), function (nonTA) { t['throws']( function () { ES.ValidateAtomicAccess(nonTA, 0); }, TypeError, @@ -7097,7 +7148,7 @@ var es2018 = function ES2018(ES, ops, expectedMissing, skips) { }); t.test('third argument: excludedItems', function (st) { - forEach(v.objects.concat(v.primitives), function (nonArray) { + forEach(unknowns, function (nonArray) { st['throws']( function () { ES.CopyDataProperties({}, {}, nonArray); }, TypeError, @@ -7146,7 +7197,7 @@ var es2018 = function ES2018(ES, ops, expectedMissing, skips) { }); test('CreateAsyncFromSyncIterator', function (t) { - forEach(v.primitives.concat(v.objects), function (nonIteratorRecord) { + forEach(unknowns, function (nonIteratorRecord) { t['throws']( function () { ES.CreateAsyncFromSyncIterator(nonIteratorRecord); }, TypeError, @@ -7306,7 +7357,10 @@ var es2018 = function ES2018(ES, ops, expectedMissing, skips) { }); test('DateString', function (t) { - forEach(v.nonNumbers.concat(NaN), function (nonNumberOrNaN) { + forEach([].concat( + v.nonNumbers, + NaN + ), function (nonNumberOrNaN) { t['throws']( function () { ES.DateString(nonNumberOrNaN); }, TypeError, @@ -7641,7 +7695,13 @@ var es2018 = function ES2018(ES, ops, expectedMissing, skips) { ); }); - forEach([-1, -42, -Infinity, Infinity].concat(v.nonIntegerNumbers), function (nonPositiveInteger) { + forEach([].concat( + -1, + -42, + -Infinity, + Infinity, + v.nonIntegerNumbers + ), function (nonPositiveInteger) { st['throws']( function () { ES.SetFunctionLength(HasNoLength, nonPositiveInteger); }, TypeError, @@ -7658,7 +7718,7 @@ var es2018 = function ES2018(ES, ops, expectedMissing, skips) { }); test('thisSymbolValue', function (t) { - forEach(v.nonSymbolPrimitives.concat(v.objects), function (nonSymbol) { + forEach(allButSyms, function (nonSymbol) { t['throws']( function () { ES.thisSymbolValue(nonSymbol); }, v.hasSymbols ? TypeError : SyntaxError, @@ -7667,7 +7727,7 @@ var es2018 = function ES2018(ES, ops, expectedMissing, skips) { }); t.test('no native Symbols', { skip: v.hasSymbols }, function (st) { - forEach(v.objects.concat(v.primitives), function (value) { + forEach(unknowns, function (value) { st['throws']( function () { ES.thisSymbolValue(value); }, SyntaxError, @@ -7708,7 +7768,10 @@ var es2018 = function ES2018(ES, ops, expectedMissing, skips) { }); test('TimeString', function (t) { - forEach(v.nonNumbers.concat(NaN), function (nonNumberOrNaN) { + forEach([].concat( + v.nonNumbers, + NaN + ), function (nonNumberOrNaN) { t['throws']( function () { ES.TimeString(nonNumberOrNaN); }, TypeError, @@ -7766,7 +7829,7 @@ var es2018 = function ES2018(ES, ops, expectedMissing, skips) { }); test('AsyncIteratorClose', function (t) { - forEach(v.primitives.concat(v.objects), function (nonIteratorRecord) { + forEach(unknowns, function (nonIteratorRecord) { t['throws']( function () { ES.AsyncIteratorClose(nonIteratorRecord); }, TypeError, @@ -7779,7 +7842,7 @@ var es2018 = function ES2018(ES, ops, expectedMissing, skips) { }; var iteratorRecord = makeIteratorRecord(iterator); - forEach(v.primitives.concat(v.objects), function (nonCompletionRecord) { + forEach(unknowns, function (nonCompletionRecord) { t['throws']( function () { ES.AsyncIteratorClose(iteratorRecord, nonCompletionRecord); }, TypeError, @@ -7914,7 +7977,10 @@ var es2018 = function ES2018(ES, ops, expectedMissing, skips) { }); test('TimeZoneString', function (t) { - forEach(v.nonNumbers.concat(NaN), function (nonIntegerNumber) { + forEach([].concat( + v.nonNumbers, + NaN + ), function (nonIntegerNumber) { t['throws']( function () { ES.TimeZoneString(nonIntegerNumber); }, TypeError, @@ -8022,24 +8088,6 @@ var es2019 = function ES2019(ES, ops, expectedMissing, skips) { t.end(); }); - test('AsyncFromSyncIteratorContinuation', function (t) { - forEach(v.primitives, function (nonObject) { - t['throws']( - function () { ES.AsyncFromSyncIteratorContinuation(nonObject); }, - TypeError, - debug(nonObject) + ' is not an Object' - ); - }); - - t['throws']( - function () { ES.AsyncFromSyncIteratorContinuation({}, null); }, - SyntaxError, - 'passing a promisecapability is not supported in es-abstract' - ); - - t.end(); - }); - test('FlattenIntoArray', function (t) { t.test('no mapper function', function (st) { var testDepth = function testDepth(tt, depth, expected) { @@ -8464,9 +8512,9 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { 'x: ' + debug(nonBigInt) + ' is not a BigInt' ); t['throws']( - function () { ES.Number.equal($BigInt(0), nonBigInt); }, + function () { ES.BigInt.equal($BigInt(0), nonBigInt); }, TypeError, - 'y: ' + debug(nonBigInt) + ' is not a Number' + 'y: ' + debug(nonBigInt) + ' is not a BigInt' ); }); @@ -8529,7 +8577,10 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { ); }); - forEach([0].concat(v.int32s), function (int32) { + forEach([].concat( + 0, + v.int32s + ), function (int32) { var bigInt32 = $BigInt(int32); forEach([1, 3, 5, 31, 32, 33], function (bits) { var bitsN = $BigInt(bits); @@ -8693,7 +8744,10 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { ); }); - forEach([0].concat(v.int32s), function (int32) { + forEach([].concat( + 0, + v.int32s + ), function (int32) { var bigInt32 = $BigInt(int32); forEach([1, 3, 5, 31, 32, 33], function (bits) { var bitsN = $BigInt(bits); @@ -8782,7 +8836,10 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { ); }); - forEach([0].concat(v.int32s), function (int32) { + forEach([].concat( + 0, + v.int32s + ), function (int32) { var bigInt32 = $BigInt(int32); forEach([1, 3, 5, 31, 32, 33], function (bits) { var bitsN = $BigInt(bits); @@ -8840,7 +8897,11 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { t.equal(ES.BinaryAnd(1, 0), 0); t.equal(ES.BinaryAnd(1, 1), 1); - forEach(v.nonIntegerNumbers.concat(v.nonNumberPrimitives, v.objects), function (nonBit) { + forEach([].concat( + v.nonIntegerNumbers, + v.nonNumberPrimitives, + v.objects + ), function (nonBit) { t['throws']( function () { ES.BinaryAnd(0, nonBit); }, TypeError @@ -8859,7 +8920,11 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { t.equal(ES.BinaryOr(1, 0), 1); t.equal(ES.BinaryOr(1, 1), 1); - forEach(v.nonIntegerNumbers.concat(v.nonNumberPrimitives, v.objects), function (nonBit) { + forEach([].concat( + v.nonIntegerNumbers, + v.nonNumberPrimitives, + v.objects + ), function (nonBit) { t['throws']( function () { ES.BinaryOr(0, nonBit); }, TypeError @@ -8878,7 +8943,11 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { t.equal(ES.BinaryXor(1, 0), 1); t.equal(ES.BinaryXor(1, 1), 0); - forEach(v.nonIntegerNumbers.concat(v.nonNumberPrimitives, v.objects), function (nonBit) { + forEach([].concat( + v.nonIntegerNumbers, + v.nonNumberPrimitives, + v.objects + ), function (nonBit) { t['throws']( function () { ES.BinaryXor(0, nonBit); }, TypeError @@ -9165,7 +9234,7 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { st.end(); }); - t.test('no Symbol.asyncIterator', { skip: v.hasAsyncIterator }, function (st) { + t.test('no Symbol.asyncIterator', { skip: !v.hasSymbols || !Symbol.asyncIterator }, function (st) { st['throws']( function () { ES.GetIterator(arr, 'async'); }, SyntaxError, @@ -9218,7 +9287,7 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { test('GetValueFromBuffer', function (t) { var isTypedArray = true; - forEach(v.primitives.concat(v.objects), function (nonAB) { + forEach(unknowns, function (nonAB) { t['throws']( function () { ES.GetValueFromBuffer(nonAB, 0, 'Int8', isTypedArray, 'Unordered'); }, TypeError, @@ -9235,7 +9304,7 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { ); }); - forEach(v.nonStrings.concat('not a valid type'), function (nonString) { + forEach(invalidTATypes, function (nonString) { st['throws']( function () { ES.GetValueFromBuffer(new ArrayBuffer(8), 0, nonString, isTypedArray, 'Unordered'); }, TypeError, @@ -9280,19 +9349,8 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { forEach(bufferTestCases, function (testCase, name) { st.test(name + ': ' + debug(testCase.value), function (s2t) { - forEach([].concat( - 'Int8', - 'Uint8', - 'Uint8C', - 'Int16', - 'Uint16', - 'Int32', - 'Uint32', - hasBigInts ? bigIntTypes : [], - 'Float32', - 'Float64' - ), function (type) { - var isBigInt = type.slice(0, 3) === 'Big'; + forEach(allTypes, function (type) { + var isBigInt = isBigIntTAType(type); var view = new DataView(new ArrayBuffer(elementSizes.$Float64Array)); var method = type === 'Uint8C' ? 'Uint8' : type; // var value = unserialize(testCase.value); @@ -9411,7 +9469,10 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { ); }); - forEach(clampedTypes.concat(nonIntegerTypes), function (type) { + forEach([].concat( + clampedTypes, + nonUnclampedIntegerTypes + ), function (type) { t.equal( ES.IsUnclampedIntegerElementType(type), false, @@ -9431,7 +9492,10 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { ); }); - forEach(v.zeroes.concat(v.integerNumbers), function (nonNegativeInteger) { + forEach([].concat( + v.zeroes, + v.integerNumbers + ), function (nonNegativeInteger) { t.equal( ES.IsNonNegativeInteger(nonNegativeInteger), true, @@ -9483,7 +9547,10 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { }); test('IsValidIntegerIndex', function (t) { - forEach(v.primitives.concat(v.objects, [[]]), function (nonTA) { + forEach([].concat( + unknowns, + [[]] + ), function (nonTA) { t['throws']( function () { ES.IsValidIntegerIndex(nonTA, 0); }, TypeError, @@ -9785,7 +9852,10 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { t.equal(ES.Number.exponentiate(-0.9, Infinity), 0, '-0.9 ** +∞ is +0'); t.equal(ES.Number.exponentiate(-0.9, -Infinity), Infinity, '-0.9 ** -∞ is +∞'); - forEach(v.numbers.concat(NaN), function (number) { + forEach([].concat( + v.numbers, + NaN + ), function (number) { t.equal(ES.Number.exponentiate(number, NaN), NaN, debug(number) + ' ** NaN is NaN'); if (number !== 0) { @@ -9793,11 +9863,6 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { t.equal(ES.Number.exponentiate(number, -0), 1, debug(number) + ' ** -0 is 1'); t.equal(ES.Number.exponentiate(NaN, number), NaN, 'NaN ** ' + debug(number) + ' is NaN'); } - - if (number !== 0 && isFinite(number)) { - t.equal(ES.Number.equal(number, number), true, debug(number) + ' is equal to itself'); - t.equal(ES.Number.equal(number, number + 1), false, debug(number) + ' is not equal to itself plus 1'); - } }); t.end(); @@ -9817,7 +9882,10 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { ); }); - forEach([0].concat(v.int32s), function (int32) { + forEach([].concat( + 0, + v.int32s + ), function (int32) { forEach([1, 3, 5, 31, 32, 33], function (bits) { t.equal(ES.Number.leftShift(int32, bits), int32 << bits, debug(int32) + ' << ' + bits + ' is ' + debug(int32 << bits)); }); @@ -9852,7 +9920,10 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { t.equal(ES.Number.lessThan(-Infinity, +Infinity), true, '-∞ < +∞ is true'); t.equal(ES.Number.lessThan(-Infinity, -Infinity), false, '-∞ < -∞ is false'); - forEach(v.numbers.concat(v.infinities), function (number) { + forEach([].concat( + v.numbers, + v.infinities + ), function (number) { t.equal(ES.Number.lessThan(NaN, number), undefined, 'NaN < ' + debug(number) + ' is undefined'); t.equal(ES.Number.lessThan(number, NaN), undefined, debug(number) + ' < NaN is undefined'); @@ -9904,7 +9975,10 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { t.equal(ES.Number.multiply(-0, +0), -0, '-0 * 0 is -0'); t.equal(ES.Number.multiply(-0, -0), +0, '-0 * -0 is +0'); - forEach(v.numbers.concat(NaN), function (number) { + forEach([].concat( + v.numbers, + NaN + ), function (number) { t.equal(ES.Number.multiply(NaN, number), NaN, 'NaN * ' + debug(number) + ' is NaN'); t.equal(ES.Number.multiply(number, NaN), NaN, debug(number) + ' * NaN is NaN'); @@ -10037,7 +10111,10 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { ); }); - forEach([0].concat(v.int32s), function (int32) { + forEach([].concat( + 0, + v.int32s + ), function (int32) { forEach([1, 3, 5, 31, 32, 33], function (bits) { t.equal(ES.Number.signedRightShift(int32, bits), int32 >> bits, debug(int32) + ' >> ' + bits + ' is ' + debug(int32 >> bits)); }); @@ -10124,7 +10201,10 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { ); }); - forEach([0].concat(v.int32s), function (int32) { + forEach([].concat( + 0, + v.int32s + ), function (int32) { forEach([1, 3, 5, 31, 32, 33], function (bits) { t.equal(ES.Number.unsignedRightShift(int32, bits), int32 >>> bits, debug(int32) + ' >>> ' + bits + ' is ' + debug(int32 >>> bits)); }); @@ -10184,7 +10264,7 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { }); test('NumericToRawBytes', function (t) { - forEach(v.nonStrings.concat('', 'Byte'), function (nonTAType) { + forEach(nonTATypes, function (nonTAType) { t['throws']( function () { ES.NumericToRawBytes(nonTAType, 0, false); }, TypeError, @@ -10212,19 +10292,8 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { var value = unserialize(testCase.value); t.test(name + ': ' + value, function (st) { - forEach([].concat( - 'Int8', - 'Uint8', - 'Uint8C', - 'Int16', - 'Uint16', - 'Int32', - 'Uint32', - hasBigInts ? bigIntTypes : [], - 'Float32', - 'Float64' - ), function (type) { - var isBigInt = type.slice(0, 3) === 'Big'; + forEach(allTypes, function (type) { + var isBigInt = isBigIntTAType(type); var hasBigEndian = type !== 'Int8' && type !== 'Uint8' && type !== 'Uint8C'; // the 8-bit types are special, they don't have big-endian var result = testCase[type === 'Uint8C' ? 'Uint8Clamped' : type]; @@ -10420,7 +10489,7 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { }); test('RawBytesToNumeric', function (t) { - forEach(v.nonStrings.concat('', 'Byte'), function (nonTAType) { + forEach(nonTATypes, function (nonTAType) { t['throws']( function () { ES.RawBytesToNumeric(nonTAType, [], false); }, TypeError, @@ -10428,7 +10497,7 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { ); }); - forEach(v.primitives.concat(v.objects), function (nonArray) { + forEach(unknowns, function (nonArray) { t['throws']( function () { ES.RawBytesToNumeric('Int8', nonArray, false); }, TypeError, @@ -10454,18 +10523,7 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { forEach(bufferTestCases, function (testCase, name) { var value = unserialize(testCase.value); t.test(name + ': ' + value, function (st) { - forEach([].concat( - 'Int8', - 'Uint8', - 'Uint8C', - 'Int16', - 'Uint16', - 'Int32', - 'Uint32', - hasBigInts ? bigIntTypes : [], - 'Float32', - 'Float64' - ), function (type) { + forEach(allTypes, function (type) { var result = testCase[type === 'Uint8C' ? 'Uint8Clamped' : type]; var hasBigEndian = type !== 'Int8' && type !== 'Uint8' && type !== 'Uint8C'; // the 8-bit types are special, they don't have big-endian @@ -10558,7 +10616,7 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { 'Int16 with less than 2 bytes throws a RangeError' ); st['throws']( - function () { ES.RawBytesToNumeric('Uint8C', [0, 0, 0], false); }, + function () { ES.RawBytesToNumeric('Int16', [0, 0, 0], false); }, RangeError, 'Int16 with more than 2 bytes throws a RangeError' ); @@ -10661,7 +10719,10 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { t['throws'](function () { return ES.SameValueNonNumeric.apply(ES, nums); }, TypeError, 'value must be same type and non-number/bigint: got ' + debug(nums[0]) + ' and ' + debug(nums[1])); }); - forEach(v.objects.concat(v.nonNumberPrimitives), function (val) { + forEach([].concat( + v.objects, + v.nonNumberPrimitives + ), function (val) { t.equal(val === val, ES.SameValueNonNumeric(val, val), debug(val) + ' is SameValueNonNumeric to itself'); }); @@ -10671,7 +10732,7 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { test('SetValueInBuffer', function (t) { var order = 'Unordered'; - forEach(v.primitives.concat(v.objects), function (nonAB) { + forEach(unknowns, function (nonAB) { t['throws']( function () { ES.SetValueInBuffer(nonAB, 0, 'Int8', 0, false, order); }, TypeError, @@ -10690,7 +10751,7 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { ); }); - forEach(v.nonStrings.concat('not a valid type'), function (nonString) { + forEach(invalidTATypes, function (nonString) { st['throws']( function () { ES.SetValueInBuffer(new ArrayBuffer(8), 0, nonString, 0, isTypedArray, order); }, TypeError, @@ -10764,18 +10825,7 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { }); forEach(bufferTestCases, function (testCase, name) { - forEach([].concat( - 'Int8', - 'Uint8', - 'Uint8C', - 'Int16', - 'Uint16', - 'Int32', - 'Uint32', - hasBigInts ? bigIntTypes : [], - 'Float32', - 'Float64' - ), testSetValueInBuffer(ES, st, testCase, isTypedArray, order)); + forEach(allTypes, testSetValueInBuffer(ES, st, testCase, isTypedArray, order)); }); st.end(); @@ -10785,7 +10835,7 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { }); test('StringToBigInt', function (t) { - test('actual BigInts', { skip: !hasBigInts }, function (st) { + t.test('actual BigInts', { skip: !hasBigInts }, function (st) { forEach(v.bigints, function (bigint) { st.equal( ES.StringToBigInt(String(bigint)), @@ -10817,7 +10867,7 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { st.end(); }); - test('BigInt not supported', { skip: hasBigInts }, function (st) { + t.test('BigInt not supported', { skip: hasBigInts }, function (st) { st['throws']( function () { ES.StringToBigInt('0'); }, SyntaxError, @@ -10860,7 +10910,7 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { }); test('thisBigIntValue', function (t) { - test('actual BigInts', { skip: !hasBigInts }, function (st) { + t.test('actual BigInts', { skip: !hasBigInts }, function (st) { st.equal(ES.thisBigIntValue(BigInt(42)), BigInt(42)); st.equal(ES.thisBigIntValue(Object(BigInt(42))), BigInt(42)); @@ -10879,7 +10929,11 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { }); test('ToBigInt', function (t) { - forEach([null, undefined].concat(v.symbols, v.numbers), function (nonBigIntCoercible) { + forEach([].concat( + v.nullPrimitives, + v.symbols, + v.numbers + ), function (nonBigIntCoercible) { t['throws']( function () { ES.ToBigInt(nonBigIntCoercible); }, hasBigInts ? TypeError : SyntaxError, @@ -10895,7 +10949,7 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { ); }); - test('actual BigInts', { skip: !hasBigInts }, function (st) { + t.test('actual BigInts', { skip: !hasBigInts }, function (st) { st.equal(ES.ToBigInt(true), BigInt(1), 'true becomes 1n'); st.equal(ES.ToBigInt(false), BigInt(0), 'true becomes 0n'); @@ -11139,7 +11193,13 @@ var es2021 = function ES2021(ES, ops, expectedMissing, skips) { }); test('ApplyStringOrNumericBinaryOperator', function (t) { - forEach(v.nonStrings.concat('', '^^', '//', '***'), function (nonOp) { + forEach([].concat( + v.nonStrings, + '', + '^^', + '//', + '***' + ), function (nonOp) { t['throws']( function () { ES.ApplyStringOrNumericBinaryOperator(null, nonOp, null); }, TypeError, @@ -11384,7 +11444,7 @@ var es2021 = function ES2021(ES, ops, expectedMissing, skips) { }); test('CloneArrayBuffer', function (t) { - forEach(v.primitives.concat(v.objects), function (nonArrayBuffer) { + forEach(unknowns, function (nonArrayBuffer) { t['throws']( function () { ES.CloneArrayBuffer(nonArrayBuffer, 0, 0, Object); }, TypeError, @@ -11410,7 +11470,10 @@ var es2021 = function ES2021(ES, ops, expectedMissing, skips) { }); // node < 6 lacks Reflect.construct, so `v.nonConstructorFunctions` can't be detected - forEach(v.nonFunctions.concat(typeof Reflect === 'object' ? v.nonConstructorFunctions : []), function (nonConstructor) { + forEach([].concat( + v.nonFunctions, + typeof Reflect === 'object' ? v.nonConstructorFunctions : [] + ), function (nonConstructor) { st['throws']( function () { ES.CloneArrayBuffer(emptyBuffer, 0, 0, nonConstructor); }, TypeError, @@ -11448,7 +11511,10 @@ var es2021 = function ES2021(ES, ops, expectedMissing, skips) { ); }); - forEach(v.notNonNegativeIntegers.concat(0x10FFFF + 1), function (nonCodePoint) { + forEach([].concat( + v.notNonNegativeIntegers, + 0x10FFFF + 1 + ), function (nonCodePoint) { t['throws']( function () { ES.CodePointsToString([nonCodePoint]); }, TypeError, @@ -11462,7 +11528,10 @@ var es2021 = function ES2021(ES, ops, expectedMissing, skips) { }); test('GetPromiseResolve', function (t) { - forEach(v.nonFunctions.concat(v.nonConstructorFunctions), function (nonConstructor) { + forEach([].concat( + v.nonFunctions, + v.nonConstructorFunctions + ), function (nonConstructor) { t['throws']( function () { ES.GetPromiseResolve(nonConstructor); }, TypeError, @@ -11501,7 +11570,13 @@ var es2021 = function ES2021(ES, ops, expectedMissing, skips) { t.equal(false, ES.IsIntegralNumber(i + 0.2), (i + 0.2) + ' is not integer'); } t.equal(true, ES.IsIntegralNumber(-0), '-0 is integer'); - var notInts = v.nonNumbers.concat(v.nonIntegerNumbers, v.infinities, [NaN, [], new Date()]); + var notInts = [].concat( + v.nonNumbers, + v.nonIntegerNumbers, + nonFiniteNumbers, + [], + new Date() + ); forEach(notInts, function (notInt) { t.equal(false, ES.IsIntegralNumber(notInt), debug(notInt) + ' is not integer'); }); @@ -11522,7 +11597,10 @@ var es2021 = function ES2021(ES, ops, expectedMissing, skips) { }); test('SetTypedArrayFromArrayLike', function (t) { - forEach(v.primitives.concat(v.objects, [[]]), function (nonTA) { + forEach([].concat( + unknowns, + [[]] + ), function (nonTA) { t['throws']( function () { ES.SetTypedArrayFromArrayLike(nonTA, 0, []); }, TypeError, @@ -11567,7 +11645,7 @@ var es2021 = function ES2021(ES, ops, expectedMissing, skips) { }); forEach(availableTypedArrays, function (name) { - var isBigInt = name.slice(0, 3) === 'Big'; + var isBigInt = isBigIntTAType(name); var Z = isBigInt ? safeBigInt : Number; var TA = global[name]; @@ -11605,7 +11683,10 @@ var es2021 = function ES2021(ES, ops, expectedMissing, skips) { }); test('SetTypedArrayFromTypedArray', { skip: availableTypedArrays.length === 0 }, function (t) { - forEach(v.primitives.concat(v.objects, [[]]), function (nonTA) { + forEach([].concat( + unknowns, + [[]] + ), function (nonTA) { t['throws']( function () { ES.SetTypedArrayFromTypedArray(nonTA, 0, new Uint8Array(0)); }, TypeError, @@ -11655,7 +11736,7 @@ var es2021 = function ES2021(ES, ops, expectedMissing, skips) { }); forEach(availableTypedArrays, function (name) { - var isBigInt = name.slice(0, 3) === 'Big'; + var isBigInt = isBigIntTAType(name); var Z = isBigInt ? safeBigInt : Number; var TA = global[name]; @@ -11762,7 +11843,12 @@ var es2021 = function ES2021(ES, ops, expectedMissing, skips) { ); }); - forEach([-1, -42, -Infinity].concat(v.nonIntegerNumbers), function (nonPositiveInteger) { + forEach([].concat( + -1, + -42, + -Infinity, + v.nonIntegerNumbers + ), function (nonPositiveInteger) { st['throws']( function () { ES.SetFunctionLength(HasNoLength, nonPositiveInteger); }, TypeError, @@ -11793,7 +11879,14 @@ var es2021 = function ES2021(ES, ops, expectedMissing, skips) { ); }); - forEach(v.nonNumbers.concat(v.nonIntegerNumbers), function (nonIntegerNumber) { + var notInts = [].concat( + v.nonNumbers, + v.nonIntegerNumbers, + nonFiniteNumbers, + [], + new Date() + ); + forEach(notInts, function (nonIntegerNumber) { t['throws']( function () { ES.SplitMatch('', nonIntegerNumber, ''); }, TypeError, @@ -11896,7 +11989,14 @@ var es2021 = function ES2021(ES, ops, expectedMissing, skips) { ); }); - forEach(v.nonNumbers.concat(v.nonIntegerNumbers), function (nonIntegerNumber) { + var notInts = [].concat( + v.nonNumbers, + v.nonIntegerNumbers, + nonFiniteNumbers, + [], + new Date() + ); + forEach(notInts, function (nonIntegerNumber) { t['throws']( function () { ES.substring('', nonIntegerNumber); }, TypeError, @@ -12004,7 +12104,10 @@ var es2021 = function ES2021(ES, ops, expectedMissing, skips) { }); test('ValidateAtomicAccess', function (t) { - forEach(v.primitives.concat(v.objects, [[]]), function (nonTA) { + forEach([].concat( + unknowns, + [[]] + ), function (nonTA) { t['throws']( function () { ES.ValidateAtomicAccess(nonTA, 0); }, TypeError, @@ -12064,7 +12167,10 @@ var es2021 = function ES2021(ES, ops, expectedMissing, skips) { ); }); - forEach(v.primitives.concat(v.objects, [[]]), function (nonTA) { + forEach([].concat( + unknowns, + [[]] + ), function (nonTA) { t['throws']( function () { ES.ValidateIntegerTypedArray(nonTA); }, TypeError, @@ -12121,7 +12227,7 @@ var es2021 = function ES2021(ES, ops, expectedMissing, skips) { }); test('WeakRefDeref', function (t) { - forEach(v.primitives.concat(v.objects), function (nonWeakRef) { + forEach(unknowns, function (nonWeakRef) { t['throws']( function () { ES.WeakRefDeref(nonWeakRef); }, TypeError, @@ -12352,8 +12458,8 @@ var es2022 = function ES2022(ES, ops, expectedMissing, skips) { ); }); - forEach(v.primitives.concat( - v.objects, + forEach([].concat( + unknowns, { '[[StartIndex]]': -1 }, { '[[StartIndex]]': 1.2, '[[EndIndex]]': 0 }, { '[[StartIndex]]': 1, '[[EndIndex]]': 0 } @@ -12400,8 +12506,8 @@ var es2022 = function ES2022(ES, ops, expectedMissing, skips) { ); }); - forEach(v.primitives.concat( - v.objects, + forEach([].concat( + unknowns, { '[[StartIndex]]': -1 }, { '[[StartIndex]]': 1.2, '[[EndIndex]]': 0 }, { '[[StartIndex]]': 1, '[[EndIndex]]': 0 } @@ -12719,7 +12825,7 @@ var es2022 = function ES2022(ES, ops, expectedMissing, skips) { test('IsStrictlyEqual', function (t) { t.test('same types use ===', function (st) { - forEach(v.primitives.concat(v.objects), function (value) { + forEach(unknowns, function (value) { st.equal(ES.IsStrictlyEqual(value, value), value === value, debug(value) + ' is strictly equal to itself'); }); st.end(); @@ -12756,7 +12862,7 @@ var es2022 = function ES2022(ES, ops, expectedMissing, skips) { test('IsLooselyEqual', function (t) { t.test('same types use ===', function (st) { - forEach(v.primitives.concat(v.objects), function (value) { + forEach(unknowns, function (value) { st.equal(ES.IsLooselyEqual(value, value), value === value, debug(value) + ' is abstractly equal to itself'); }); st.end(); @@ -12918,7 +13024,10 @@ var es2022 = function ES2022(ES, ops, expectedMissing, skips) { ); }); - forEach(v.strings.concat(wholePoo), function (string) { + forEach([].concat( + v.strings, + wholePoo + ), function (string) { t.equal(ES.IsStringWellFormedUnicode(string), true, debug(string) + ' is well-formed unicode'); }); @@ -13105,11 +13214,12 @@ var es2022 = function ES2022(ES, ops, expectedMissing, skips) { }); forEach( - v.nonFunctions.concat( + [].concat( + v.nonFunctions, function () {}, function f(a, b) { return 0; }, function (a) { return 0; }, - arrowFns.length > 0 ? [ + v.arrowFunctions.length > 0 ? [ /* eslint no-new-func: 1 */ Function('return () => {}')(), Function('return (a) => {}')(), @@ -13125,12 +13235,13 @@ var es2022 = function ES2022(ES, ops, expectedMissing, skips) { } ); - forEach([ - function (a, b) { return 0; } - ].concat(arrowFns.length > 0 ? [ - /* eslint no-new-func: 1 */ - Function('return (a, b) => 0')() - ] : []), function (ac) { + forEach([].concat( + function (a, b) { return 0; }, + v.arrowFunctions.length > 0 ? [ + /* eslint no-new-func: 1 */ + Function('return (a, b) => 0')() + ] : [] + ), function (ac) { t.doesNotThrow( function () { ES.SortIndexedProperties({}, 0, ac); }, 'an abstract closure taking two args is accepted' @@ -13181,7 +13292,7 @@ var es2022 = function ES2022(ES, ops, expectedMissing, skips) { }); test('StringToBigInt', function (t) { - test('actual BigInts', { skip: !hasBigInts }, function (st) { + t.test('actual BigInts', { skip: !hasBigInts }, function (st) { forEach(v.bigints, function (bigint) { st.equal( ES.StringToBigInt(String(bigint)), @@ -13213,7 +13324,7 @@ var es2022 = function ES2022(ES, ops, expectedMissing, skips) { st.end(); }); - test('BigInt not supported', { skip: hasBigInts }, function (st) { + t.test('BigInt not supported', { skip: hasBigInts }, function (st) { st['throws']( function () { ES.StringToBigInt('0'); }, SyntaxError, @@ -13265,7 +13376,7 @@ var es2022 = function ES2022(ES, ops, expectedMissing, skips) { }); test('TypedArrayElementSize', function (t) { - forEach(v.primitives.concat(v.objects), function (nonTA) { + forEach(unknowns, function (nonTA) { t['throws']( function () { ES.TypedArrayElementSize(nonTA); }, TypeError, @@ -13292,7 +13403,7 @@ var es2022 = function ES2022(ES, ops, expectedMissing, skips) { }); test('TypedArrayElementType', function (t) { - forEach(v.primitives.concat(v.objects), function (nonTA) { + forEach(unknowns, function (nonTA) { t['throws']( function () { ES.TypedArrayElementType(nonTA); }, TypeError, @@ -13370,10 +13481,15 @@ var es2023 = function ES2023(ES, ops, expectedMissing, skips) { ); }); - test('BigInts are supported', { skip: !hasBigInts }, function (st) { - forEach(v.nonIntegerNumbers.concat(0, 1, 37), function (nonIntegerNumber) { + t.test('BigInts are supported', { skip: !hasBigInts }, function (st) { + forEach([].concat( + v.nonIntegerNumbers, + 0, + 1, + 37 + ), function (nonIntegerNumber) { st['throws']( - function () { ES.Number.toString($BigInt(0), nonIntegerNumber); }, + function () { ES.BigInt.toString($BigInt(0), nonIntegerNumber); }, TypeError, debug(nonIntegerNumber) + ' is not an integer [2, 36]' ); @@ -13672,9 +13788,8 @@ var es2023 = function ES2023(ES, ops, expectedMissing, skips) { TypeError, 'can not install ' + debug(propertyKey) + ' on non-extensible object' ); - t.notEqual( - notExtensible[propertyKey], - sentinel, + t.notOk( + propertyKey in notExtensible, debug(sentinel) + ' is not installed on "' + debug(propertyKey) + '" on the object' ); } @@ -14465,7 +14580,7 @@ var es2023 = function ES2023(ES, ops, expectedMissing, skips) { }); test('IteratorStep', function (t) { - forEach(v.primitives.concat(v.objects), function (nonIteratorRecord) { + forEach(unknowns, function (nonIteratorRecord) { t['throws']( function () { ES.IteratorStep(nonIteratorRecord); }, TypeError, @@ -14541,7 +14656,12 @@ var es2023 = function ES2023(ES, ops, expectedMissing, skips) { ); }); - forEach(v.nonIntegerNumbers.concat(0, 1, 37), function (nonIntegerNumber) { + forEach([].concat( + v.nonIntegerNumbers, + 0, + 1, + 37 + ), function (nonIntegerNumber) { t['throws']( function () { ES.Number.toString(0, nonIntegerNumber); }, TypeError, @@ -14651,7 +14771,11 @@ var es2023 = function ES2023(ES, ops, expectedMissing, skips) { t['throws'](function () { return ES.SameValueNonNumber.apply(ES, nums); }, TypeError, 'value must be same type and non-number: got ' + debug(nums[0]) + ' and ' + debug(nums[1])); }); - forEach(v.objects.concat(v.nonNumberPrimitives).concat(v.bigints), function (val) { + forEach([].concat( + v.objects, + v.nonNumberPrimitives, + v.bigints + ), function (val) { t.equal(val === val, ES.SameValueNonNumber(val, val), debug(val) + ' is SameValueNonNumber to itself'); }); @@ -14659,7 +14783,10 @@ var es2023 = function ES2023(ES, ops, expectedMissing, skips) { }); test('SetTypedArrayFromArrayLike', function (t) { - forEach(v.primitives.concat(v.objects, [[]]), function (nonTA) { + forEach([].concat( + unknowns, + [[]] + ), function (nonTA) { t['throws']( function () { ES.SetTypedArrayFromArrayLike(nonTA, 0, []); }, TypeError, @@ -14704,7 +14831,7 @@ var es2023 = function ES2023(ES, ops, expectedMissing, skips) { }); forEach(availableTypedArrays, function (name) { - var isBigInt = name.slice(0, 3) === 'Big'; + var isBigInt = isBigIntTAType(name); var Z = isBigInt ? safeBigInt : Number; var TA = global[name]; @@ -14763,11 +14890,12 @@ var es2023 = function ES2023(ES, ops, expectedMissing, skips) { }); forEach( - v.nonFunctions.concat( + [].concat( + v.nonFunctions, function () {}, function f(a, b) { return 0; }, function (a) { return 0; }, - arrowFns.length > 0 ? [ + v.arrowFunctions.length > 0 ? [ /* eslint no-new-func: 1 */ Function('return () => {}')(), Function('return (a) => {}')(), @@ -14783,12 +14911,13 @@ var es2023 = function ES2023(ES, ops, expectedMissing, skips) { } ); - forEach([ - function (a, b) { return 0; } - ].concat(arrowFns.length > 0 ? [ - /* eslint no-new-func: 1 */ - Function('return (a, b) => 0')() - ] : []), function (ac) { + forEach([].concat( + function (a, b) { return 0; }, + v.arrowFunctions.length > 0 ? [ + /* eslint no-new-func: 1 */ + Function('return (a, b) => 0')() + ] : [] + ), function (ac) { t.doesNotThrow( function () { ES.SortIndexedProperties({}, 0, ac, 'skip-holes'); }, 'an abstract closure taking two args is accepted' @@ -14854,7 +14983,10 @@ var es2023 = function ES2023(ES, ops, expectedMissing, skips) { }); test('TimeZoneString', function (t) { - forEach(v.nonIntegerNumbers.concat(v.infinities, NaN), function (nonIntegerNumber) { + forEach([].concat( + v.nonIntegerNumbers, + nonFiniteNumbers + ), function (nonIntegerNumber) { t['throws']( function () { ES.TimeZoneString(nonIntegerNumber); }, TypeError, @@ -14871,7 +15003,7 @@ var es2023 = function ES2023(ES, ops, expectedMissing, skips) { test('TypedArrayCreateSameType', function (t) { t.test('no Typed Array support', { skip: availableTypedArrays.length > 0 }, function (st) { - forEach(v.primitives.concat(v.objects), function (nonTA) { + forEach(unknowns, function (nonTA) { st['throws']( function () { ES.TypedArrayCreateSameType(nonTA, []); }, SyntaxError, @@ -14881,7 +15013,7 @@ var es2023 = function ES2023(ES, ops, expectedMissing, skips) { forEach(v.nonArrays, function (nonArray) { st['throws']( - function () { ES.TypedArrayCreate(Array, nonArray); }, + function () { ES.TypedArrayCreateSameType(Array, nonArray); }, SyntaxError, 'no Typed Array support' ); @@ -14891,7 +15023,7 @@ var es2023 = function ES2023(ES, ops, expectedMissing, skips) { }); t.test('Typed Array support', { skip: availableTypedArrays.length === 0 }, function (st) { - forEach(v.primitives.concat(v.objects), function (nonTA) { + forEach(unknowns, function (nonTA) { st['throws']( function () { ES.TypedArrayCreateSameType(nonTA, []); }, TypeError, @@ -14943,7 +15075,7 @@ var es2023 = function ES2023(ES, ops, expectedMissing, skips) { }); test('WordCharacters', function (t) { - forEach([].concat(v.primitives, v.objects), function (nonRER) { + forEach(unknowns, function (nonRER) { t['throws']( function () { ES.WordCharacters(nonRER); }, TypeError, @@ -15051,10 +15183,7 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { test('ArrayBufferByteLength', function (t) { var order = 'UNORDERED'; - forEach([].concat( - v.primitives, - v.objects - ), function (nonAB) { + forEach(unknowns, function (nonAB) { t['throws']( function () { ES.ArrayBufferByteLength(nonAB, order); }, TypeError, @@ -15095,10 +15224,7 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { }); test('ArrayBufferCopyAndDetach', function (t) { - forEach([].concat( - v.primitives, - v.objects - ), function (nonAB) { + forEach(unknowns, function (nonAB) { t['throws']( function () { ES.ArrayBufferCopyAndDetach(nonAB, 0, 'FIXED-LENGTH'); }, TypeError, @@ -15783,7 +15909,7 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { var isTypedArray = true; var order = 'UNORDERED'; - forEach(v.primitives.concat(v.objects), function (nonAB) { + forEach(unknowns, function (nonAB) { t['throws']( function () { ES.GetValueFromBuffer(nonAB, 0, 'int8', isTypedArray, order); }, TypeError, @@ -15800,7 +15926,7 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { ); }); - forEach(v.nonStrings.concat('not a valid type'), function (nonString) { + forEach(invalidTATypes, function (nonString) { st['throws']( function () { ES.GetValueFromBuffer(new ArrayBuffer(8), 0, nonString, isTypedArray, order); }, TypeError, @@ -15845,19 +15971,8 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { forEach(bufferTestCases, function (testCase, name) { st.test(name + ': ' + debug(testCase.value), function (s2t) { - forEach([].concat( - 'Int8', - 'Uint8', - 'Uint8C', - 'Int16', - 'Uint16', - 'Int32', - 'Uint32', - hasBigInts ? bigIntTypes : [], - 'Float32', - 'Float64' - ), function (type) { - var isBigInt = type.slice(0, 3) === 'Big'; + forEach(allTypes, function (type) { + var isBigInt = isBigIntTAType(type); var view = new DataView(new ArrayBuffer(elementSizes.$Float64Array)); var method = type === 'Uint8C' ? 'Uint8' : type; // var value = unserialize(testCase.value); @@ -15928,7 +16043,7 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { }); test('GetViewByteLength', function (t) { - forEach(v.primitives.concat(v.objects), function (nonDVWBWRecord) { + forEach(unknowns, function (nonDVWBWRecord) { t['throws']( function () { ES.GetViewByteLength(nonDVWBWRecord); }, TypeError, @@ -16055,7 +16170,7 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { }); test('HasEitherUnicodeFlag', function (t) { - forEach([].concat(v.primitives, v.objects), function (nonRER) { + forEach(unknowns, function (nonRER) { t['throws']( function () { ES.HasEitherUnicodeFlag(nonRER); }, TypeError, @@ -16104,7 +16219,7 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { }); test('IsArrayBufferViewOutOfBounds', function (t) { - forEach([].concat(v.primitives, v.objects), function (nonABV) { + forEach(unknowns, function (nonABV) { t['throws']( function () { ES.IsArrayBufferViewOutOfBounds(nonABV); }, TypeError, @@ -16169,7 +16284,7 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { }); test('IsFixedLengthArrayBuffer', function (t) { - forEach(v.primitives.concat(v.objects), function (nonAB) { + forEach(unknowns, function (nonAB) { t['throws']( function () { ES.IsFixedLengthArrayBuffer(nonAB); }, TypeError, @@ -16233,7 +16348,10 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { }); test('IsTypedArrayOutOfBounds', function (t) { - forEach(v.primitives.concat(v.objects, [[]]), function (nonTAWBWR) { + forEach([].concat( + unknowns, + [[]] + ), function (nonTAWBWR) { t['throws']( function () { ES.IsTypedArrayOutOfBounds(nonTAWBWR); }, TypeError, @@ -16276,7 +16394,10 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { ); }); - forEach(clampedTypes.concat(nonIntegerTypes), function (type) { + forEach([].concat( + clampedTypes, + nonUnclampedIntegerTypes + ), function (type) { t.equal( ES.IsUnclampedIntegerElementType(type.toUpperCase()), false, @@ -16308,7 +16429,7 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { }); test('IsViewOutOfBounds', function (t) { - forEach(v.primitives.concat(v.objects), function (nonDVWBWRecord) { + forEach(unknowns, function (nonDVWBWRecord) { t['throws']( function () { ES.IsViewOutOfBounds(nonDVWBWRecord); }, TypeError, @@ -16353,7 +16474,7 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { }); test('IteratorStepValue', function (t) { - forEach(v.primitives.concat(v.objects), function (nonIteratorRecord) { + forEach(unknowns, function (nonIteratorRecord) { t['throws']( function () { ES.IteratorStepValue(nonIteratorRecord); }, TypeError, @@ -16593,7 +16714,7 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { }); test('NumericToRawBytes', function (t) { - forEach(v.nonStrings.concat('', 'Byte'), function (nonTAType) { + forEach(nonTATypes, function (nonTAType) { t['throws']( function () { ES.NumericToRawBytes(nonTAType, 0, false); }, TypeError, @@ -16621,19 +16742,8 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { var value = unserialize(testCase.value); t.test(name + ': ' + value, function (st) { - forEach([].concat( - 'Int8', - 'Uint8', - 'Uint8C', - 'Int16', - 'Uint16', - 'Int32', - 'Uint32', - hasBigInts ? bigIntTypes : [], - 'Float32', - 'Float64' - ), function (type) { - var isBigInt = type.slice(0, 3) === 'Big'; + forEach(allTypes, function (type) { + var isBigInt = isBigIntTAType(type); var hasBigEndian = type !== 'Int8' && type !== 'Uint8' && type !== 'Uint8C'; // the 8-bit types are special, they don't have big-endian var result = testCase[type === 'Uint8C' ? 'Uint8Clamped' : type]; @@ -16762,7 +16872,7 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { }); test('RawBytesToNumeric', function (t) { - forEach(v.nonStrings.concat('', 'Byte'), function (nonTAType) { + forEach(nonTATypes, function (nonTAType) { t['throws']( function () { ES.RawBytesToNumeric(nonTAType, [], false); }, TypeError, @@ -16770,7 +16880,7 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { ); }); - forEach(v.primitives.concat(v.objects), function (nonArray) { + forEach(unknowns, function (nonArray) { t['throws']( function () { ES.RawBytesToNumeric('INT8', nonArray, false); }, TypeError, @@ -16796,18 +16906,7 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { forEach(bufferTestCases, function (testCase, name) { var value = unserialize(testCase.value); t.test(name + ': ' + value, function (st) { - forEach([].concat( - 'Int8', - 'Uint8', - 'Uint8C', - 'Int16', - 'Uint16', - 'Int32', - 'Uint32', - hasBigInts ? bigIntTypes : [], - 'Float32', - 'Float64' - ), function (type) { + forEach(allTypes, function (type) { var result = testCase[type === 'Uint8C' ? 'Uint8Clamped' : type]; var hasBigEndian = type !== 'Int8' && type !== 'Uint8' && type !== 'Uint8C'; // the 8-bit types are special, they don't have big-endian @@ -16983,7 +17082,7 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { test('SetValueInBuffer', function (t) { var order = 'UNORDERED'; - forEach(v.primitives.concat(v.objects), function (nonAB) { + forEach(unknowns, function (nonAB) { t['throws']( function () { ES.SetValueInBuffer(nonAB, 0, 'INT8', 0, true, order); }, TypeError, @@ -17000,11 +17099,11 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { ); }); - forEach(v.nonStrings.concat('not a valid type'), function (nonString) { + forEach(invalidTATypes, function (invalidType) { st['throws']( - function () { ES.SetValueInBuffer(new ArrayBuffer(8), 0, nonString, 0, true, order); }, + function () { ES.SetValueInBuffer(new ArrayBuffer(8), 0, invalidType, 0, true, order); }, TypeError, - 'type: ' + debug(nonString) + ' is not a valid String (or type) value' + 'type: ' + debug(invalidType) + ' is not a valid String (or type) value' ); }); @@ -17056,19 +17155,8 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { }); forEach(bufferTestCases, function (testCase, name) { - forEach([].concat( - 'Int8', - 'Uint8', - 'Uint8C', - 'Int16', - 'Uint16', - 'Int32', - 'Uint32', - hasBigInts ? bigIntTypes : [], - 'Float32', - 'Float64' - ), function (type) { - var isBigInt = type === 'BigInt64' || type === 'BigUint64'; + forEach(allTypes, function (type) { + var isBigInt = isBigIntTAType(type); var Z = isBigInt ? safeBigInt : Number; var hasBigEndian = type !== 'Int8' && type !== 'Uint8' && type !== 'Uint8C'; // the 8-bit types are special, they don't have big-endian var result = testCase[type === 'Uint8C' ? 'Uint8Clamped' : type]; @@ -17224,7 +17312,7 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { }); test('ThisBigIntValue', function (t) { - test('actual BigInts', { skip: !hasBigInts }, function (st) { + t.test('actual BigInts', { skip: !hasBigInts }, function (st) { st.equal(ES.ThisBigIntValue(BigInt(42)), BigInt(42)); st.equal(ES.ThisBigIntValue(Object(BigInt(42))), BigInt(42)); @@ -17297,7 +17385,7 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { }); test('ThisSymbolValue', function (t) { - forEach(v.nonSymbolPrimitives.concat(v.objects), function (nonSymbol) { + forEach(allButSyms, function (nonSymbol) { t['throws']( function () { ES.ThisSymbolValue(nonSymbol); }, v.hasSymbols ? TypeError : SyntaxError, @@ -17306,7 +17394,7 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { }); t.test('no native Symbols', { skip: v.hasSymbols }, function (st) { - forEach(v.objects.concat(v.primitives), function (value) { + forEach(unknowns, function (value) { st['throws']( function () { ES.ThisSymbolValue(value); }, SyntaxError, @@ -17334,7 +17422,10 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { }); test('TypedArrayByteLength', function (t) { - forEach(v.primitives.concat(v.objects, [[]]), function (nonTAWBWR) { + forEach([].concat( + unknowns, + [[]] + ), function (nonTAWBWR) { t['throws']( function () { ES.TypedArrayByteLength(nonTAWBWR); }, TypeError, @@ -17460,7 +17551,7 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { }); test('TypedArrayElementType', function (t) { - forEach(v.primitives.concat(v.objects), function (nonTA) { + forEach(unknowns, function (nonTA) { t['throws']( function () { ES.TypedArrayElementType(nonTA); }, TypeError, @@ -17485,7 +17576,7 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { }); test('TypedArrayGetElement', function (t) { - forEach(v.primitives.concat(v.objects), function (nonTA) { + forEach(unknowns, function (nonTA) { t['throws']( function () { ES.TypedArrayGetElement(nonTA, 0); }, TypeError, @@ -17505,7 +17596,7 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { }); forEach(availableTypedArrays, function (TypedArray) { - var isBigInt = TypedArray.slice(0, 3) === 'Big'; + var isBigInt = isBigIntTAType(TypedArray); var Z = isBigInt ? safeBigInt : Number; var TA = global[TypedArray]; @@ -17524,7 +17615,10 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { }); test('TypedArrayLength', function (t) { - forEach(v.primitives.concat(v.objects, [[]]), function (nonTAWBWR) { + forEach([].concat( + unknowns, + [[]] + ), function (nonTAWBWR) { t['throws']( function () { ES.TypedArrayLength(nonTAWBWR); }, TypeError, @@ -17570,7 +17664,10 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { }); test('ValidateAtomicAccess', function (t) { - forEach(v.primitives.concat(v.objects, [[]]), function (nonTAWBWR) { + forEach([].concat( + unknowns, + [[]] + ), function (nonTAWBWR) { t['throws']( function () { ES.ValidateAtomicAccess(nonTAWBWR, 0); }, TypeError, @@ -17623,7 +17720,10 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { }); test('ValidateAtomicAccessOnIntegerTypedArray', function (t) { - forEach(v.primitives.concat(v.objects, [[]]), function (nonTA) { + forEach([].concat( + unknowns, + [[]] + ), function (nonTA) { t['throws']( function () { ES.ValidateAtomicAccessOnIntegerTypedArray(nonTA, 0); }, TypeError, @@ -17714,7 +17814,10 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { ); }); - forEach(v.primitives.concat(v.objects, [[]]), function (nonTA) { + forEach([].concat( + unknowns, + [[]] + ), function (nonTA) { t['throws']( function () { ES.ValidateIntegerTypedArray(nonTA, false); }, TypeError, @@ -17763,7 +17866,10 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { test('ValidateTypedArray', function (t) { var order = 'UNORDERED'; - forEach(v.primitives.concat(v.objects, [[]]), function (nonTA) { + forEach([].concat( + unknowns, + [[]] + ), function (nonTA) { t['throws']( function () { ES.ValidateTypedArray(nonTA, order); }, TypeError, From b39976e43b5b16909d3741fd13b918f3c6af98c7 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Thu, 9 Jan 2025 23:27:41 -0800 Subject: [PATCH 2/4] [Tests] increase coverage --- test/tests.js | 585 ++++++++++++++++++++++++++++++++++++++++++-------- 1 file changed, 496 insertions(+), 89 deletions(-) diff --git a/test/tests.js b/test/tests.js index 684044b6..5e1aeae4 100644 --- a/test/tests.js +++ b/test/tests.js @@ -70,6 +70,13 @@ var nonFiniteNumbers = [].concat( v.infinities, NaN ); +var notInts = [].concat( + v.nonNumbers, + v.nonIntegerNumbers, + nonFiniteNumbers, + [], + new Date() +); var elementSizes = { __proto__: null, @@ -531,6 +538,18 @@ var es5 = function ES5(ES, ops, expectedMissing, skips) { t.end(); }); + test('abs', function (t) { + t.equal(ES.abs(0), 0, '+0 -> +0'); + t.equal(ES.abs(-0), 0, '-0 -> +0'); + + t.equal(ES.abs(1), 1, '+1 -> +1'); + t.equal(ES.abs(-1), 1, '-1 -> +1'); + + t.equal(ES.abs(NaN), NaN, 'NaN -> NaN'); + + t.end(); + }); + test('Canonicalize', function (t) { forEach(v.nonStrings, function (nonString) { t['throws']( @@ -549,6 +568,7 @@ var es5 = function ES5(ES, ops, expectedMissing, skips) { }); t.equal(ES.Canonicalize(leadingPoo, false), leadingPoo, 'when IgnoreCase is false, ch is returned'); + t.equal(ES.Canonicalize('ƒ', true), 'Ƒ', 'when IgnoreCase is true, ch is canonicalized'); t.end(); }); @@ -1568,15 +1588,6 @@ var es2015 = function ES2015(ES, ops, expectedMissing, skips) { ); }); - var notInts = [].concat( - v.nonNumbers, - v.nonIntegerNumbers, - nonFiniteNumbers, - [], - new Date(), - Math.pow(2, 53), - -1 - ); forEach(notInts, function (nonInt) { t['throws']( function () { ES.AdvanceStringIndex('abc', nonInt); }, @@ -3122,7 +3133,7 @@ var es2015 = function ES2015(ES, ops, expectedMissing, skips) { clearBuffer(view.buffer); var littleVal = unserialize(result.setAsLittle.asLittle); - view['set' + method](0, type.slice(0, 3) === 'Big' ? safeBigInt(littleVal) : littleVal, true); + view['set' + method](0, littleVal, true); s2t.equal( ES.GetValueFromBuffer(view.buffer, 0, type, true), @@ -3139,7 +3150,7 @@ var es2015 = function ES2015(ES, ops, expectedMissing, skips) { clearBuffer(view.buffer); var bigVal = unserialize(result.setAsBig.asBig); - view['set' + method](0, type.slice(0, 3) === 'Big' ? safeBigInt(bigVal) : bigVal, false); + view['set' + method](0, bigVal, false); s2t.equal( ES.GetValueFromBuffer(view.buffer, 0, type, false), @@ -3300,7 +3311,7 @@ var es2015 = function ES2015(ES, ops, expectedMissing, skips) { t.test('actual typed arrays', { skip: availableTypedArrays.length === 0 }, function (st) { forEach(availableTypedArrays, function (typedArray) { var isBigInt = isBigIntTAType(typedArray); - if (isBigInt && 'ToBigInt' in ES) { + if (!isBigInt || 'ToBigInt' in ES) { var Z = isBigInt ? safeBigInt : Number; var TA = global[typedArray]; @@ -3317,12 +3328,97 @@ var es2015 = function ES2015(ES, ops, expectedMissing, skips) { t.end(); }); + test('IntegerIndexedElementSet', function (t) { + forEach(v.nonNumbers, function (nonNumber) { + t['throws']( + function () { ES.IntegerIndexedElementSet(null, nonNumber, null); }, + TypeError, + debug(nonNumber) + ' is not a Number' + ); + }); + + forEach([].concat( + unknowns, + [[]] + ), function (nonTA) { + t['throws']( + function () { ES.IntegerIndexedElementSet(nonTA, 0, null); }, + TypeError, + debug(nonTA) + ' is not a TypedArray' + ); + }); + + t.test('actual typed arrays', { skip: availableTypedArrays.length === 0 }, function (st) { + if (hasBigInts) { + forEach(bigIntTypes, function (bigIntType) { + var TA = global[bigIntType + 'Array']; + var ta = new TA(0); + st['throws']( + function () { ES.IntegerIndexedElementSet(ta, 0, null); }, + SyntaxError, + bigIntType + ' is not supported until ES2020' + ); + }); + } + + forEach(availableTypedArrays, function (TypedArray) { + if (!isBigIntTAType(TypedArray)) { + var ta = new global[TypedArray](8); + + st.test('can detach', { skip: !canDetach }, function (s2t) { + var taD = new global[TypedArray](8); + ES.DetachArrayBuffer(taD.buffer); + + s2t['throws']( + function () { ES.IntegerIndexedElementSet(taD, 0, null); }, + TypeError, + debug(taD) + ' is a detached TypedArray' + ); + + s2t.end(); + }); + + forEach(v.nonNumbers, function (nonNumber) { + st['throws']( + function () { ES.IntegerIndexedElementSet(ta, nonNumber, null); }, + TypeError, + debug(nonNumber) + ' is not a number, throws' + ); + }); + + forEach([].concat( + v.notNonNegativeIntegers, + -0 + ), function (notNonNegativeInt) { + if (typeof notNonNegativeInt === 'number') { + st.equal( + ES.IntegerIndexedElementSet(ta, notNonNegativeInt, null), + false, + debug(notNonNegativeInt) + ' is not a non-negative-integer number, returns false' + ); + } + }); + + st.equal(ta[0], 0, 'is initially zero'); + st.equal( + ES.IntegerIndexedElementSet(ta, 0, 42), + true, + 'set is successful' + ); + st.equal(ta[0], 42, 'has expected value'); + } + }); + + st.end(); + }); + }); + test('InternalizeJSONProperty', function (t) { forEach(v.primitives, function (primitive) { t['throws']( function () { ES.InternalizeJSONProperty(primitive, '', function () {}); }, TypeError, - debug(primitive) + ' is not an Object' + 'holder: ' + debug(primitive) + ' is not an Object' ); }); @@ -3330,7 +3426,7 @@ var es2015 = function ES2015(ES, ops, expectedMissing, skips) { t['throws']( function () { ES.InternalizeJSONProperty({}, nonString, function () {}); }, TypeError, - debug(nonString) + ' is not a String' + 'name: ' + debug(nonString) + ' is not a String' ); }); @@ -3338,7 +3434,7 @@ var es2015 = function ES2015(ES, ops, expectedMissing, skips) { t['throws']( function () { ES.InternalizeJSONProperty({}, 'a', nonFunction); }, TypeError, - debug(nonFunction) + ' is not a function' + 'reviver: ' + debug(nonFunction) + ' is not a function' ); }); @@ -3386,8 +3482,6 @@ var es2015 = function ES2015(ES, ops, expectedMissing, skips) { 1 ); - // stuff with the reviver - t.end(); }); @@ -3729,13 +3823,6 @@ var es2015 = function ES2015(ES, ops, expectedMissing, skips) { t.equal(false, ES.IsInteger(i + 0.2), (i + 0.2) + ' is not integer'); } t.equal(true, ES.IsInteger(-0), '-0 is integer'); - var notInts = [].concat( - v.nonNumbers, - v.nonIntegerNumbers, - nonFiniteNumbers, - [], - new Date() - ); forEach(notInts, function (notInt) { t.equal(false, ES.IsInteger(notInt), debug(notInt) + ' is not integer'); }); @@ -4895,13 +4982,6 @@ var es2015 = function ES2015(ES, ops, expectedMissing, skips) { ); }); - var notInts = [].concat( - v.nonNumbers, - v.nonIntegerNumbers, - nonFiniteNumbers, - [], - new Date() - ); forEach(notInts, function (nonInteger) { t['throws']( function () { ES.SplitMatch('', nonInteger, ''); }, @@ -6274,6 +6354,7 @@ var es2017 = function ES2017(ES, ops, expectedMissing, skips) { 'arg 3: ' + debug(nonArray) + ' is not an Array' ); }); + forEach(v.nonStrings, function (nonString) { t['throws']( function () { return ES.IsWordChar(0, 0, [nonString], false, false); }, @@ -8202,6 +8283,7 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { CopyDataProperties: true, GetIterator: true, GetValueFromBuffer: true, + IntegerIndexedElementSet: true, NumberToRawBytes: true, NumberToString: true, ObjectCreate: true, @@ -8214,6 +8296,15 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { })); var test = makeTest(ES, skips); + test('abs (with BigInts)', { skip: !hasBigInts }, function (t) { + t.equal(ES.abs(BigInt(0)), BigInt(0), '0n -> 0n'); + + t.equal(ES.abs(BigInt(1)), BigInt(1), '+1n -> +1n'); + t.equal(ES.abs(BigInt(-1)), BigInt(1), '-1n -> +1n'); + + t.end(); + }); + test('Abstract Equality Comparison', { skip: !hasBigInts }, function (t) { t.equal( ES['Abstract Equality Comparison'](BigInt(1), 1), @@ -9420,6 +9511,80 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { t.end(); }); + test('IntegerIndexedElementSet', function (t) { + forEach(v.nonNumbers, function (nonNumber) { + t['throws']( + function () { ES.IntegerIndexedElementSet(null, nonNumber, null); }, + TypeError, + debug(nonNumber) + ' is not a Number' + ); + }); + + forEach([].concat( + unknowns, + [[]] + ), function (nonTA) { + t['throws']( + function () { ES.IntegerIndexedElementSet(nonTA, 0, null); }, + TypeError, + debug(nonTA) + ' is not a TypedArray' + ); + }); + + t.test('actual typed arrays', { skip: availableTypedArrays.length === 0 }, function (st) { + forEach(availableTypedArrays, function (TypedArray) { + var isBigInt = isBigIntTAType(TypedArray); + var Z = isBigInt ? safeBigInt : Number; + + var ta = new global[TypedArray](8); + + st.test('can detach', { skip: !canDetach }, function (s2t) { + var taD = new global[TypedArray](8); + ES.DetachArrayBuffer(taD.buffer); + + s2t['throws']( + function () { ES.IntegerIndexedElementSet(taD, 0, Z(0)); }, + TypeError, + debug(taD) + ' is a detached TypedArray' + ); + + s2t.end(); + }); + + forEach(v.nonNumbers, function (nonNumber) { + st['throws']( + function () { ES.IntegerIndexedElementSet(ta, nonNumber, Z(0)); }, + TypeError, + debug(nonNumber) + ' is not a number, throws' + ); + }); + + forEach([].concat( + v.notNonNegativeIntegers, + -0 + ), function (notNonNegativeInt) { + if (typeof notNonNegativeInt === 'number') { + st.equal( + ES.IntegerIndexedElementSet(ta, notNonNegativeInt, Z(0)), + false, + debug(notNonNegativeInt) + ' is not a non-negative-integer number, returns false' + ); + } + }); + + st.equal(ta[0], Z(0), 'is initially zero'); + st.equal( + ES.IntegerIndexedElementSet(ta, 0, Z(42)), + true, + 'set is successful' + ); + st.equal(ta[0], Z(42), 'has expected value'); + }); + + st.end(); + }); + }); + test('IsBigIntElementType', function (t) { forEach(bigIntTypes, function (type) { t.equal( @@ -10805,11 +10970,13 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { var buffer = new ArrayBuffer(8); s2t.equal(ES.DetachArrayBuffer(buffer), null, 'detaching returns null'); - s2t['throws']( - function () { ES.SetValueInBuffer(buffer, 0, 'Int8', 0, isTypedArray, order); }, - TypeError, - 'detached buffers throw' - ); + forEach([true, false], function (bool) { + s2t['throws']( + function () { ES.SetValueInBuffer(buffer, 0, 'Int8', 0, bool, order); }, + TypeError, + 'detached buffers throw (isTypedArray ' + bool + ')' + ); + }); s2t.end(); }); @@ -10831,6 +10998,20 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { st.end(); }); + t.test('bigints', { skip: !hasBigInts }, function (st) { + forEach(v.bigints, function (bigint) { + var buffer = new ArrayBuffer(8); + ES.SetValueInBuffer(buffer, 0, 'BigUint64', bigint, true, order); + st.equal( + new BigUint64Array(buffer)[0], + bigint, + debug(bigint) + ' is set' + ); + }); + + st.end(); + }); + t.end(); }); @@ -11167,6 +11348,7 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { var es2021 = function ES2021(ES, ops, expectedMissing, skips) { es2020(ES, ops, expectedMissing, assign({}, skips, { + IntegerIndexedElementSet: true, IsInteger: true, IsNonNegativeInteger: true, SetFunctionLength: true, @@ -11564,19 +11746,86 @@ var es2021 = function ES2021(ES, ops, expectedMissing, skips) { t.end(); }); + test('IntegerIndexedElementSet', function (t) { + forEach(v.nonNumbers, function (nonNumber) { + t['throws']( + function () { ES.IntegerIndexedElementSet(null, nonNumber, null); }, + TypeError, + debug(nonNumber) + ' is not a Number' + ); + }); + + forEach([].concat( + unknowns, + [[]] + ), function (nonTA) { + t['throws']( + function () { ES.IntegerIndexedElementSet(nonTA, 0, null); }, + TypeError, + debug(nonTA) + ' is not a TypedArray' + ); + }); + + t.test('actual typed arrays', { skip: availableTypedArrays.length === 0 }, function (st) { + forEach(availableTypedArrays, function (TypedArray) { + var isBigInt = isBigIntTAType(TypedArray); + var Z = isBigInt ? safeBigInt : Number; + + var ta = new global[TypedArray](8); + + st.test('can detach', { skip: !canDetach }, function (s2t) { + var taD = new global[TypedArray](8); + ES.DetachArrayBuffer(taD.buffer); + + s2t.equal( + ES.IntegerIndexedElementSet(taD, 0, Z(0)), + undefined, + debug(taD) + ' is a detached TypedArray, returns undefined' + ); + + s2t.end(); + }); + + forEach(v.nonNumbers, function (nonNumber) { + st['throws']( + function () { ES.IntegerIndexedElementSet(ta, nonNumber, Z(0)); }, + TypeError, + debug(nonNumber) + ' is not a number, throws' + ); + }); + + forEach([].concat( + v.notNonNegativeIntegers, + -0 + ), function (notNonNegativeInt) { + if (typeof notNonNegativeInt === 'number') { + st.equal( + ES.IntegerIndexedElementSet(ta, notNonNegativeInt, Z(0)), + undefined, + debug(notNonNegativeInt) + ' is not a non-negative-integer number, returns undefined' + ); + } + }); + + st.equal(ta[0], Z(0), 'is initially zero'); + st.equal( + ES.IntegerIndexedElementSet(ta, 0, Z(42)), + undefined, + 'returns undefined' + ); + st.equal(ta[0], Z(42), 'has expected value'); + }); + + st.end(); + }); + }); + test('IsIntegralNumber', function (t) { for (var i = -100; i < 100; i += 10) { t.equal(true, ES.IsIntegralNumber(i), i + ' is integer'); t.equal(false, ES.IsIntegralNumber(i + 0.2), (i + 0.2) + ' is not integer'); } t.equal(true, ES.IsIntegralNumber(-0), '-0 is integer'); - var notInts = [].concat( - v.nonNumbers, - v.nonIntegerNumbers, - nonFiniteNumbers, - [], - new Date() - ); forEach(notInts, function (notInt) { t.equal(false, ES.IsIntegralNumber(notInt), debug(notInt) + ' is not integer'); }); @@ -11879,13 +12128,6 @@ var es2021 = function ES2021(ES, ops, expectedMissing, skips) { ); }); - var notInts = [].concat( - v.nonNumbers, - v.nonIntegerNumbers, - nonFiniteNumbers, - [], - new Date() - ); forEach(notInts, function (nonIntegerNumber) { t['throws']( function () { ES.SplitMatch('', nonIntegerNumber, ''); }, @@ -11989,13 +12231,6 @@ var es2021 = function ES2021(ES, ops, expectedMissing, skips) { ); }); - var notInts = [].concat( - v.nonNumbers, - v.nonIntegerNumbers, - nonFiniteNumbers, - [], - new Date() - ); forEach(notInts, function (nonIntegerNumber) { t['throws']( function () { ES.substring('', nonIntegerNumber); }, @@ -14302,13 +14537,13 @@ var es2023 = function ES2023(ES, ops, expectedMissing, skips) { forEach(v.nonBooleans, function (nonBoolean) { t['throws']( - function () { ES.Canonicalize(assign({}, rer, { '[[IgnoreCase]]': nonBoolean }), ''); }, + function () { ES.IsWordChar(assign({}, rer, { '[[IgnoreCase]]': nonBoolean }), '', 0); }, TypeError, '[[IgnoreCase]]: ' + debug(nonBoolean) + ' is not a Boolean' ); t['throws']( - function () { ES.Canonicalize(assign({}, rer, { '[[Unicode]]': nonBoolean }), ''); }, + function () { ES.IsWordChar(assign({}, rer, { '[[Unicode]]': nonBoolean }), '', 0); }, TypeError, '[[Unicode]]: ' + debug(nonBoolean) + ' is not a Boolean' ); @@ -15695,6 +15930,36 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { 'supports named captures with a missing namedCapture' ); + st.test('named captures, native', { skip: !hasNamedCaptures }, function (rt) { + var str = 'abcdefghi'; + var regex = new RegExp('(?abcdef)'); + rt.equal( + str.replace(regex, 'a>$abcdef$$z'), + 'a>abcdef$zghi', + 'works with a $z' + ); + + rt.equal( + str.replace(regex, '$$ throws', { todo: 'blocked on native resizable ABs/growable SABs' }); + s2t.test( + 'AB non-fixed length, detached -> throws', + { skip: !('resizable' in ArrayBuffer.prototype) }, + function (s3t) { + var rab = new ArrayBuffer(12, { maxByteLength: 64 }); + var rdv = new DataView(rab, 8); + + record = ES.MakeDataViewWithBufferWitnessRecord(rdv, 'UNORDERED'); + + ES.DetachArrayBuffer(rab); + + s3t['throws']( + function () { ES.GetViewByteLength(record); }, + TypeError, + 'detached RAB with non-detached DVBWR throws' + ); + + record = ES.MakeDataViewWithBufferWitnessRecord(rdv, 'UNORDERED'); + s3t['throws']( + function () { ES.GetViewByteLength(record); }, + TypeError, + 'detached RAB with detached DVBWR throws' + ); + + s3t.end(); + } + ); s2t.end(); }); @@ -16439,16 +16758,14 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { t.test('DataViews supported', { skip: typeof DataView !== 'function' }, function (st) { var ab = new ArrayBuffer(8); - var dv = new DataView(ab); - - var record = ES.MakeDataViewWithBufferWitnessRecord(dv, 'UNORDERED'); st.test('can detach', { skip: !canDetach }, function (s2t) { var dab = new ArrayBuffer(1); var ddv = new DataView(dab); - ES.DetachArrayBuffer(dab); - var ndRecord = { '[[Object]]': ddv, '[[CachedBufferByteLength]]': 1 }; + var ndRecord = ES.MakeDataViewWithBufferWitnessRecord(ddv, 'UNORDERED'); + + ES.DetachArrayBuffer(dab); s2t['throws']( function () { ES.IsViewOutOfBounds(ndRecord); }, @@ -16456,7 +16773,7 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { 'detached view with no-detached record throws' ); - var dRecord = { '[[Object]]': ddv, '[[CachedBufferByteLength]]': 'DETACHED' }; + var dRecord = ES.MakeDataViewWithBufferWitnessRecord(ddv, 'UNORDERED'); s2t.equal(ES.IsViewOutOfBounds(dRecord), true, 'detached view with detached record is out of bounds'); @@ -16464,10 +16781,15 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { }); // TODO true for byteOffsetStart > bufferByteLength || byteOffsetEnd > bufferByteLength + // not sure how to produce these DataViews - // else false - - // ES.IsViewOutOfBounds + for (var i = 0; i < 8; i += 1) { + st.equal( + ES.IsViewOutOfBounds(ES.MakeDataViewWithBufferWitnessRecord(new DataView(ab, i), 'UNORDERED')), + false, + 'byteOffset ' + i + ' is not out of bounds' + ); + } }); t.end(); @@ -16724,7 +17046,7 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { forEach(v.nonNumbers, function (nonNumber) { t['throws']( - function () { ES.NumericToRawBytes('int8', nonNumber, false); }, + function () { ES.NumericToRawBytes('INT8', nonNumber, false); }, TypeError, debug(nonNumber) + ' is not a Number' ); @@ -16732,7 +17054,7 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { forEach(v.nonBooleans, function (nonBoolean) { t['throws']( - function () { ES.NumericToRawBytes('int8', 0, nonBoolean); }, + function () { ES.NumericToRawBytes('INT8', 0, nonBoolean); }, TypeError, debug(nonBoolean) + ' is not a Boolean' ); @@ -17145,11 +17467,13 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { var buffer = new ArrayBuffer(8); s2t.equal(ES.DetachArrayBuffer(buffer), null, 'detaching returns null'); - s2t['throws']( - function () { ES.SetValueInBuffer(buffer, 0, 'INT8', 0, true, order); }, - TypeError, - 'detached buffers throw' - ); + forEach([true, false], function (bool) { + s2t['throws']( + function () { ES.SetValueInBuffer(buffer, 0, 'INT8', 0, bool, order); }, + TypeError, + 'detached buffers throw (isTypedArray ' + bool + ')' + ); + }); s2t.end(); }); @@ -17162,6 +17486,18 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { var result = testCase[type === 'Uint8C' ? 'Uint8Clamped' : type]; var value = unserialize(testCase.value); + var elementSize = elementSizes['$' + (type === 'Uint8C' ? 'Uint8Clamped' : type) + 'Array']; + + var buffer = new ArrayBuffer(elementSizes.$Float64Array); + + if (isBigInt) { + st['throws']( + function () { ES.SetValueInBuffer(buffer, 0, type.toUpperCase(), 0, false, order, true); }, + TypeError, + 'bigint type throws with a Number value' + ); + } + if (isBigInt && (!isFinite(value) || Math.floor(value) !== value)) { return; } @@ -17175,10 +17511,6 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { 'buffer holding ' + debug(testCase.value) + ' (' + testCase.endian + ' endian) with type ' + type + ', default endian, yields expected value' ); */ - - var elementSize = elementSizes['$' + (type === 'Uint8C' ? 'Uint8Clamped' : type) + 'Array']; - - var buffer = new ArrayBuffer(elementSizes.$Float64Array); var copyBytes = new Uint8Array(buffer); clearBuffer(buffer); @@ -17462,9 +17794,33 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { // TODO: actual TA byteLength auto, but not fixed length? (may not be possible) - tat.test('non-fixed length, return length * elementSize', { todo: 'blocked on native resizable ABs/growable SABs' }); + tat.test('non-fixed length, return length * elementSize', { skip: !('resizable' in ArrayBuffer.prototype) }, function (tast) { + var ab = new ArrayBuffer(8, { maxByteLength: 64 }); + var rta = new Uint8Array(ab); - tat.test('non-fixed length, detached throws', { todo: 'blocked on native resizable ABs/growable SABs' }); + tast.equal( + ES.TypedArrayByteLength(ES.MakeTypedArrayWithBufferWitnessRecord(rta, 'UNORDERED')), + 8, + 'resizable ArrayBuffer’s Typed Array has expected byteLength' + ); + + tast.end(); + }); + + tat.test('non-fixed length, detached returns zero', function (tast) { + var ab = new ArrayBuffer(8, { maxByteLength: 64 }); + var rta = new Uint8Array(ab); + + ES.DetachArrayBuffer(ab); + + tast.equal( + ES.TypedArrayByteLength(ES.MakeTypedArrayWithBufferWitnessRecord(rta, 'UNORDERED')), + 0, + 'resizable ArrayBuffer’s detached Typed Array returns zero' + ); + + tast.end(); + }); }); }); }); @@ -17663,6 +18019,57 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { t.end(); }); + test('TypedArraySetElement', function (t) { + forEach(unknowns, function (nonTA) { + t['throws']( + function () { ES.TypedArraySetElement(nonTA, 0, 0); }, + TypeError, + debug(nonTA) + ' is not a Typed Array' + ); + }); + + t.test('actual typed arrays', { skip: availableTypedArrays.length === 0 }, function (st) { + forEach(availableTypedArrays, function (typedArray) { + var isBigInt = isBigIntTAType(typedArray); + var Z = isBigInt ? safeBigInt : Number; + var TA = global[typedArray]; + var ta = new TA(16); + + forEach(v.nonNumbers, function (nonNumber) { + st['throws']( + function () { ES.TypedArraySetElement(ta, nonNumber, 0); }, + TypeError, + 'index: ' + debug(nonNumber) + ' is not a Number' + ); + }); + + st.equal(ta[0], Z(0), 'is initially zero'); + ES.TypedArraySetElement(ta, 0, Z(42)); + st.equal(ta[0], Z(42), 'is set as expected'); + + st['throws']( + function () { ES.TypedArraySetElement(ta, 0, v.uncoercibleObject); }, + TypeError, + 'non-number/bigint-coercible value ' + debug(v.uncoercibleObject) + ' throws' + ); + + st.test('can detach', { skip: !canDetach }, function (s2t) { + ES.DetachArrayBuffer(ta.buffer); + + s2t.equal(ta[0], undefined, 'is initially undefined'); + ES.TypedArraySetElement(ta, 0, Z(7)); + s2t.equal(ta[0], undefined, 'is not set, as expected'); + + s2t.end(); + }); + }); + + st.end(); + }); + + t.end(); + }); + test('ValidateAtomicAccess', function (t) { forEach([].concat( unknowns, From bfe049d9c87b4c83a9de88389da1acef0a3e769f Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Mon, 20 Jan 2025 18:11:04 -0800 Subject: [PATCH 3/4] [Fix] `ES2024`+: `GetViewByteLength`, `TypedArrayByteLength`, `TypedArrayLength`: properly handle resizable arrays --- 2024/GetViewByteLength.js | 6 +++-- 2024/TypedArrayByteLength.js | 6 ++++- 2024/TypedArrayLength.js | 8 +++--- test/tests.js | 47 ++++++++++++++++++++++++++++++++++-- 4 files changed, 59 insertions(+), 8 deletions(-) diff --git a/2024/GetViewByteLength.js b/2024/GetViewByteLength.js index 7d11ae3a..a5837e8b 100644 --- a/2024/GetViewByteLength.js +++ b/2024/GetViewByteLength.js @@ -24,12 +24,14 @@ module.exports = function GetViewByteLength(viewRecord) { var view = viewRecord['[[Object]]']; // step 2 - var viewByteLength = dataViewByteLength(view); // view.[[ByteLength]] + var isFixed = IsFixedLengthArrayBuffer(dataViewBuffer(view)); + + var viewByteLength = isFixed ? dataViewByteLength(view) : 'AUTO'; // view.[[ByteLength]] if (viewByteLength !== 'AUTO') { return viewByteLength; // step 3 } - if (IsFixedLengthArrayBuffer(dataViewBuffer(view))) { + if (isFixed) { throw new $TypeError('Assertion failed: DataView’s ArrayBuffer is not fixed length'); // step 4 } diff --git a/2024/TypedArrayByteLength.js b/2024/TypedArrayByteLength.js index c455cd75..703ef0ab 100644 --- a/2024/TypedArrayByteLength.js +++ b/2024/TypedArrayByteLength.js @@ -2,12 +2,14 @@ var $TypeError = require('es-errors/type'); +var IsFixedLengthArrayBuffer = require('./IsFixedLengthArrayBuffer'); var IsTypedArrayOutOfBounds = require('./IsTypedArrayOutOfBounds'); var TypedArrayElementSize = require('./TypedArrayElementSize'); var TypedArrayLength = require('./TypedArrayLength'); var isTypedArrayWithBufferWitnessRecord = require('../helpers/records/typed-array-with-buffer-witness-record'); +var typedArrayByffer = require('typed-array-buffer'); var typedArrayByteLength = require('typed-array-byte-length'); // https://262.ecma-international.org/15.0/#sec-typedarraybytelength @@ -28,7 +30,9 @@ module.exports = function TypedArrayByteLength(taRecord) { var O = taRecord['[[Object]]']; // step 4 - var byteLength = typedArrayByteLength(O); + var isFixed = IsFixedLengthArrayBuffer(typedArrayByffer(O)); + + var byteLength = isFixed ? typedArrayByteLength(O) : 'AUTO'; if (byteLength !== 'AUTO') { return byteLength; // step 5 } diff --git a/2024/TypedArrayLength.js b/2024/TypedArrayLength.js index d07519d3..30b21acd 100644 --- a/2024/TypedArrayLength.js +++ b/2024/TypedArrayLength.js @@ -13,7 +13,7 @@ var typedArrayBuffer = require('typed-array-buffer'); var typedArrayByteOffset = require('typed-array-byte-offset'); var typedArrayLength = require('typed-array-length'); -// http://www.ecma-international.org/ecma-262/15.0/#sec-typedarraylength +// https://www.ecma-international.org/ecma-262/15.0/#sec-typedarraylength module.exports = function TypedArrayLength(taRecord) { if (!isTypedArrayWithBufferWitnessRecord(taRecord)) { @@ -26,12 +26,14 @@ module.exports = function TypedArrayLength(taRecord) { var O = taRecord['[[Object]]']; // step 2 - var length = typedArrayLength(O); + var isFixed = IsFixedLengthArrayBuffer(typedArrayBuffer(O)); + + var length = isFixed ? typedArrayLength(O) : 'AUTO'; if (length !== 'AUTO') { return length; // step 3 } - if (IsFixedLengthArrayBuffer(typedArrayBuffer(O))) { + if (isFixed) { throw new $TypeError('Assertion failed: array buffer is not fixed length'); // step 4 } diff --git a/test/tests.js b/test/tests.js index 5e1aeae4..0efc52b4 100644 --- a/test/tests.js +++ b/test/tests.js @@ -18007,9 +18007,52 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { // TODO: actual TA byteLength auto, but not fixed length? (may not be possible) - tat.test('non-fixed length, return floor((byteLength - byteOffset) / elementSize)', { todo: 'blocked on native resizable ABs/growable SABs' }); + var elementSize = elementSizes['$' + type]; + + tat.test( + 'non-fixed length, return floor((byteLength - byteOffset) / elementSize)', + { skip: !('resizable' in ArrayBuffer.prototype) }, + function (tsat) { + var rab = new ArrayBuffer(17, { maxByteLength: 64 }); + var arr = new TA(rab, 8); + record = ES.MakeTypedArrayWithBufferWitnessRecord(arr, 'UNORDERED'); + + tsat.equal( + ES.TypedArrayLength(record), + Math.floor((17 - 8) / elementSize), + type + ' + resizable AB: has expected length' + ); + + tsat.end(); + } + ); + + tat.test( + 'non-fixed length, detached throws', + { skip: !('resizable' in ArrayBuffer.prototype) || !canDetach }, + function (tsat) { + var rab = new ArrayBuffer(17, { maxByteLength: 64 }); + var arr = new TA(rab, 8); + record = ES.MakeTypedArrayWithBufferWitnessRecord(arr, 'UNORDERED'); + + ES.DetachArrayBuffer(rab); - tat.test('non-fixed length, detached throws', { todo: 'blocked on native resizable ABs/growable SABs' }); + tsat['throws']( + function () { ES.TypedArrayLength(record); }, + TypeError, + 'detached RAB with a non-detached TAWBR throws' + ); + + record = ES.MakeTypedArrayWithBufferWitnessRecord(arr, 'UNORDERED'); + tsat['throws']( + function () { ES.TypedArrayLength(record); }, + TypeError, + 'detached RAB with a detached TAWBR throws' + ); + + tsat.end(); + } + ); }); }); From c370ecfbeaedc882ce5ec1e64ae08e2033b334cb Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Wed, 15 Jan 2025 13:44:23 -0800 Subject: [PATCH 4/4] [Tests] extract common helpers --- test/helpers/clearBuffer.js | 5 + test/helpers/getNamelessFunction.js | 9 + test/helpers/kludgeMatch.js | 18 + test/helpers/makeAsyncFromSyncIterator.js | 24 + test/helpers/makeIteratorRecord.js | 9 + test/helpers/testAsyncIterator.js | 18 + test/helpers/testIterator.js | 11 + test/helpers/testRESIterator.js | 18 + test/helpers/throwsSentinel.js | 10 + test/helpers/v.js | 164 ++++ test/tests.js | 944 +++++++++------------- 11 files changed, 653 insertions(+), 577 deletions(-) create mode 100644 test/helpers/clearBuffer.js create mode 100644 test/helpers/getNamelessFunction.js create mode 100644 test/helpers/kludgeMatch.js create mode 100644 test/helpers/makeAsyncFromSyncIterator.js create mode 100644 test/helpers/makeIteratorRecord.js create mode 100644 test/helpers/testAsyncIterator.js create mode 100644 test/helpers/testIterator.js create mode 100644 test/helpers/testRESIterator.js create mode 100644 test/helpers/throwsSentinel.js create mode 100644 test/helpers/v.js diff --git a/test/helpers/clearBuffer.js b/test/helpers/clearBuffer.js new file mode 100644 index 00000000..8db92cb8 --- /dev/null +++ b/test/helpers/clearBuffer.js @@ -0,0 +1,5 @@ +'use strict'; + +module.exports = function clearBuffer(buffer) { + new DataView(buffer).setFloat64(0, 0, true); // clear the buffer +}; diff --git a/test/helpers/getNamelessFunction.js b/test/helpers/getNamelessFunction.js new file mode 100644 index 00000000..2161a4a6 --- /dev/null +++ b/test/helpers/getNamelessFunction.js @@ -0,0 +1,9 @@ +'use strict'; + +module.exports = function getNamelessFunction() { + var f = Object(function () {}); + try { + delete f.name; + } catch (e) { /**/ } + return f; +}; diff --git a/test/helpers/kludgeMatch.js b/test/helpers/kludgeMatch.js new file mode 100644 index 00000000..32305414 --- /dev/null +++ b/test/helpers/kludgeMatch.js @@ -0,0 +1,18 @@ +'use strict'; + +var assign = require('object.assign'); + +var hasLastIndex = 'lastIndex' in (/a/).exec('a'); // IE 8 +var hasGroups = 'groups' in (/a/).exec('a'); // modern engines + +module.exports = function kludgeMatch(R, matchObject) { + if (hasGroups) { + assign(matchObject, { groups: matchObject.groups }); + } + if (hasLastIndex) { + assign(matchObject, { lastIndex: matchObject.lastIndex || R.lastIndex }); + } else { + delete matchObject.lastIndex; // eslint-disable-line no-param-reassign + } + return matchObject; +}; diff --git a/test/helpers/makeAsyncFromSyncIterator.js b/test/helpers/makeAsyncFromSyncIterator.js new file mode 100644 index 00000000..d2442628 --- /dev/null +++ b/test/helpers/makeAsyncFromSyncIterator.js @@ -0,0 +1,24 @@ +'use strict'; + +var makeIteratorRecord = require('./makeIteratorRecord'); + +module.exports = function makeAsyncFromSyncIterator(CreateAsyncFromSyncIterator, end, throwMethod, returnMethod) { + var i = 0; + var iterator = { + next: function next() { + try { + return { + done: i > end, + value: i + }; + } finally { + i += 1; + } + }, + 'return': returnMethod, + 'throw': throwMethod + }; + var syncIteratorRecord = makeIteratorRecord(iterator); + + return CreateAsyncFromSyncIterator(syncIteratorRecord); +}; diff --git a/test/helpers/makeIteratorRecord.js b/test/helpers/makeIteratorRecord.js new file mode 100644 index 00000000..b1100bf2 --- /dev/null +++ b/test/helpers/makeIteratorRecord.js @@ -0,0 +1,9 @@ +'use strict'; + +module.exports = function makeIteratorRecord(iterator) { + return { + '[[Iterator]]': iterator, + '[[NextMethod]]': iterator.next, + '[[Done]]': false + }; +}; diff --git a/test/helpers/testAsyncIterator.js b/test/helpers/testAsyncIterator.js new file mode 100644 index 00000000..1ba0e790 --- /dev/null +++ b/test/helpers/testAsyncIterator.js @@ -0,0 +1,18 @@ +'use strict'; + +module.exports = function testAsyncIterator(t, asyncIterator, expected) { + var results = arguments.length > 3 ? arguments[3] : []; + + var nextResult = asyncIterator.next(); + + return Promise.resolve(nextResult).then(function (result) { + results.push(result); + if (!result.done && results.length < expected.length) { + t.deepEqual(result, { done: false, value: expected[results.length - 1] }, 'result ' + (results.length - 1)); + return testAsyncIterator(t, asyncIterator, expected, results); + } + + t.equal(results.length, expected.length, 'expected ' + expected.length + ', got ' + (result.done ? '' : 'more than ') + results.length); + return results.length; + }); +}; diff --git a/test/helpers/testIterator.js b/test/helpers/testIterator.js new file mode 100644 index 00000000..d37bb529 --- /dev/null +++ b/test/helpers/testIterator.js @@ -0,0 +1,11 @@ +'use strict'; + +module.exports = function testIterator(t, iterator, expected) { + var resultCount = 0; + var result; + while (result = iterator.next(), !result.done && resultCount < expected.length + 1) { // eslint-disable-line no-sequences + t.deepEqual(result, { done: false, value: expected[resultCount] }, 'result ' + resultCount); + resultCount += 1; + } + t.equal(resultCount, expected.length, 'expected ' + expected.length + ', got ' + (result.done ? '' : 'more than ') + resultCount); +}; diff --git a/test/helpers/testRESIterator.js b/test/helpers/testRESIterator.js new file mode 100644 index 00000000..760f1b03 --- /dev/null +++ b/test/helpers/testRESIterator.js @@ -0,0 +1,18 @@ +'use strict'; + +var v = require('es-value-fixtures'); + +var testIterator = require('./testIterator'); + +module.exports = function testRegExpStringIterator(CreateRegExpStringIterator, t, regex, str, global, unicode, expected) { + var iterator = CreateRegExpStringIterator(regex, str, global, unicode); + t.equal(typeof iterator, 'object', 'iterator is an object'); + t.equal(typeof iterator.next, 'function', '`.next` is a function'); + + t.test('has symbols', { skip: !v.hasSymbols }, function (st) { + st.equal(typeof iterator[Symbol.iterator], 'function', '[`Symbol.iterator`] is a function'); + st.end(); + }); + + testIterator(t, iterator, expected); +}; diff --git a/test/helpers/throwsSentinel.js b/test/helpers/throwsSentinel.js new file mode 100644 index 00000000..7642afcf --- /dev/null +++ b/test/helpers/throwsSentinel.js @@ -0,0 +1,10 @@ +'use strict'; + +module.exports = function throwsSentinel(fn, sentinel, message) { + try { + fn(); + this.fail('did not throw: ' + message); + } catch (e) { + this.equal(e, sentinel, message); + } +}; diff --git a/test/helpers/v.js b/test/helpers/v.js new file mode 100644 index 00000000..f404eef8 --- /dev/null +++ b/test/helpers/v.js @@ -0,0 +1,164 @@ +'use strict'; + +var v = require('es-value-fixtures'); +var hasBigInts = require('has-bigints')(); +var isCore = require('is-core-module'); + +var leadingPoo = '\uD83D'; +var trailingPoo = '\uDCA9'; +var wholePoo = leadingPoo + trailingPoo; + +var msPerSecond = 1e3; +var msPerMinute = 60 * msPerSecond; +var msPerHour = 60 * msPerMinute; +var msPerDay = 24 * msPerHour; + +var unknowns = [].concat( + v.primitives, + v.objects +); +var allButSyms = [].concat( + v.objects, + v.nonSymbolPrimitives +); +var invalidTATypes = [].concat( + v.nonStrings, + 'not a valid type' +); +var nonFiniteNumbers = [].concat( + v.infinities, + NaN +); +var notInts = [].concat( + v.nonNumbers, + v.nonIntegerNumbers, + nonFiniteNumbers, + [], + new Date() +); + +var elementSizes = { + __proto__: null, + $Int8Array: 1, + $Uint8Array: 1, + $Uint8ClampedArray: 1, + $Int16Array: 2, + $Uint16Array: 2, + $Int32Array: 4, + $Uint32Array: 4, + $BigInt64Array: 8, + $BigUint64Array: 8, + $Float32Array: 4, + $Float64Array: 8 +}; + +var unclampedUnsignedIntegerTypes = [ + 'Int8', + 'Int16', + 'Int32' +]; +var clampedTypes = [ + 'Uint8C' +]; +var unclampedSignedIntegerTypes = [ + 'Uint8', + 'Uint16', + 'Uint32' +]; +var unclampedIntegerTypes = [].concat( + unclampedUnsignedIntegerTypes, + unclampedSignedIntegerTypes +); +var floatTypes = [ + 'Float32', + 'Float64' +]; +var integerTypes = [].concat( + unclampedIntegerTypes, + clampedTypes +); +var bigIntTypes = [ + 'BigInt64', + 'BigUint64' +]; +var numberTypes = [].concat( + floatTypes, + integerTypes +); +var nonUnclampedIntegerTypes = [].concat( + floatTypes, + bigIntTypes +); +var unsignedElementTypes = [].concat( + unclampedSignedIntegerTypes, + hasBigInts ? 'BigUint64' : [] +); +var signedElementTypes = [].concat( + unclampedUnsignedIntegerTypes, + floatTypes, + hasBigInts ? 'BigInt64' : [] +); +var allTypes = [].concat( + numberTypes, + hasBigInts ? bigIntTypes : [] +); +var nonTATypes = [].concat( + v.nonStrings, + '', + 'Byte' +); + +var canDistinguishSparseFromUndefined = 0 in [undefined]; // IE 6 - 8 have a bug where this returns false + +// IE 9 does not throw in strict mode when writability/configurability/extensibility is violated +var noThrowOnStrictViolation = (function () { + try { + delete [].length; + return true; + } catch (e) { + } + return false; +}()); + +var isBigIntTAType = function isBigIntTAType(type) { + return type.slice(0, 3) === 'Big'; +}; + +/* globals postMessage */ +var canDetach = typeof structuredClone === 'function' || typeof postMessage === 'function' || isCore('worker_threads'); + +module.exports = { + poo: { + leading: leadingPoo, + trailing: trailingPoo, + whole: wholePoo + }, + hasBigInts: hasBigInts, + msPerSecond: msPerSecond, + msPerMinute: msPerMinute, + msPerHour: msPerHour, + msPerDay: msPerDay, + unknowns: unknowns, + allButSyms: allButSyms, + invalidTATypes: invalidTATypes, + nonFiniteNumbers: nonFiniteNumbers, + notInts: notInts, + elementSizes: elementSizes, + unclampedUnsignedIntegerTypes: unclampedUnsignedIntegerTypes, + clampedTypes: clampedTypes, + unclampedSignedIntegerTypes: unclampedSignedIntegerTypes, + unclampedIntegerTypes: unclampedIntegerTypes, + floatTypes: floatTypes, + integerTypes: integerTypes, + bigIntTypes: bigIntTypes, + numberTypes: numberTypes, + nonUnclampedIntegerTypes: nonUnclampedIntegerTypes, + unsignedElementTypes: unsignedElementTypes, + signedElementTypes: signedElementTypes, + allTypes: allTypes, + nonTATypes: nonTATypes, + canDistinguishSparseFromUndefined: canDistinguishSparseFromUndefined, + noThrowOnStrictViolation: noThrowOnStrictViolation, + isBigIntTAType: isBigIntTAType, + canDetach: canDetach +}; diff --git a/test/tests.js b/test/tests.js index 0efc52b4..ca75f295 100644 --- a/test/tests.js +++ b/test/tests.js @@ -12,7 +12,6 @@ var hasStrictMode = require('has-strict-mode')(); var functionsHaveNames = require('functions-have-names')(); var functionsHaveConfigurableNames = require('functions-have-names').functionsHaveConfigurableNames(); var boundFunctionsHaveNames = require('functions-have-names').boundFunctionsHaveNames(); -var hasBigInts = require('has-bigints')(); var getOwnPropertyDescriptor = require('gopd'); var SLOT = require('internal-slot'); var availableTypedArrays = require('available-typed-arrays')(); @@ -39,141 +38,28 @@ var isPromiseCapabilityRecord = require('../helpers/records/promise-capability-r var reduce = require('../helpers/reduce'); var safeBigInt = require('safe-bigint'); var unserialize = require('./helpers/unserializeNumeric'); +var getNamelessFunction = require('./helpers/getNamelessFunction'); -var $BigInt = hasBigInts ? BigInt : null; +var esV = require('./helpers/v'); + +var $BigInt = esV.hasBigInts ? BigInt : null; var supportedRegexFlags = require('available-regexp-flags'); var whichTypedArray = require('which-typed-array'); -/* globals postMessage */ -var canDetach = typeof structuredClone === 'function' || typeof postMessage === 'function' || isCore('worker_threads'); - // in node < 6, RegExp.prototype is an actual regex var reProtoIsRegex = isRegex(RegExp.prototype); -var twoSixtyFour = hasBigInts && safeBigInt(Math.pow(2, 64)); -var twoSixtyThree = hasBigInts && safeBigInt(Math.pow(2, 63)); - -var unknowns = [].concat( - v.primitives, - v.objects -); -var allButSyms = [].concat( - v.objects, - v.nonSymbolPrimitives -); -var invalidTATypes = [].concat( - v.nonStrings, - 'not a valid type' -); -var nonFiniteNumbers = [].concat( - v.infinities, - NaN -); -var notInts = [].concat( - v.nonNumbers, - v.nonIntegerNumbers, - nonFiniteNumbers, - [], - new Date() -); - -var elementSizes = { - __proto__: null, - $Int8Array: 1, - $Uint8Array: 1, - $Uint8ClampedArray: 1, - $Int16Array: 2, - $Uint16Array: 2, - $Int32Array: 4, - $Uint32Array: 4, - $BigInt64Array: 8, - $BigUint64Array: 8, - $Float32Array: 4, - $Float64Array: 8 -}; - -var unclampedUnsignedIntegerTypes = [ - 'Int8', - 'Int16', - 'Int32' -]; -var clampedTypes = [ - 'Uint8C' -]; -var unclampedSignedIntegerTypes = [ - 'Uint8', - 'Uint16', - 'Uint32' -]; -var unclampedIntegerTypes = [].concat( - unclampedUnsignedIntegerTypes, - unclampedSignedIntegerTypes -); -var floatTypes = [ - 'Float32', - 'Float64' -]; -var integerTypes = [].concat( - unclampedIntegerTypes, - clampedTypes -); -var bigIntTypes = [ - 'BigInt64', - 'BigUint64' -]; -var numberTypes = [].concat( - floatTypes, - integerTypes -); -var nonUnclampedIntegerTypes = [].concat( - floatTypes, - bigIntTypes -); -var unsignedElementTypes = [].concat( - unclampedSignedIntegerTypes, - hasBigInts ? 'BigUint64' : [] -); -var signedElementTypes = [].concat( - unclampedUnsignedIntegerTypes, - floatTypes, - hasBigInts ? 'BigInt64' : [] -); -var allTypes = [].concat( - numberTypes, - hasBigInts ? bigIntTypes : [] -); -var nonTATypes = [].concat( - v.nonStrings, - '', - 'Byte' -); - -var isBigIntTAType = function isBigIntTAType(type) { - return type.slice(0, 3) === 'Big'; -}; - -var canDistinguishSparseFromUndefined = 0 in [undefined]; // IE 6 - 8 have a bug where this returns false - -// IE 9 does not throw in strict mode when writability/configurability/extensibility is violated -var noThrowOnStrictViolation = (function () { - try { - delete [].length; - return true; - } catch (e) { - } - return false; -}()); +var twoSixtyFour = safeBigInt && safeBigInt(Math.pow(2, 64)); +var twoSixtyThree = safeBigInt && safeBigInt(Math.pow(2, 63)); -var clearBuffer = function clearBuffer(buffer) { - new DataView(buffer).setFloat64(0, 0, true); // clear the buffer -}; +var clearBuffer = require('./helpers/clearBuffer'); var testSetValueInBuffer = function (ES, st, testCase, isTypedArray, order) { return function (type) { - var isBigInt = isBigIntTAType(type); + var isBigInt = esV.isBigIntTAType(type); var Z = isBigInt ? safeBigInt : Number; - var elementSize = elementSizes['$' + (type === 'Uint8C' ? 'Uint8Clamped' : type) + 'Array']; + var elementSize = esV.elementSizes['$' + (type === 'Uint8C' ? 'Uint8Clamped' : type) + 'Array']; var hasBigEndian = type !== 'Int8' && type !== 'Uint8' && type !== 'Uint8C'; // the 8-bit types are special, they don't have big-endian var result = testCase[type === 'Uint8C' ? 'Uint8Clamped' : type]; var value = unserialize(testCase.value); @@ -192,7 +78,7 @@ var testSetValueInBuffer = function (ES, st, testCase, isTypedArray, order) { ); */ - var buffer = new ArrayBuffer(elementSizes.$Float64Array); + var buffer = new ArrayBuffer(esV.elementSizes.$Float64Array); var copyBytes = new Uint8Array(buffer); clearBuffer(buffer); @@ -269,18 +155,7 @@ var makeTest = function makeTest(ES, skips) { }; }; -var throwsSentinel = function throwsSentinel(fn, sentinel, message) { - try { - fn(); - this.fail('did not throw: ' + message); - } catch (e) { - this.equal(e, sentinel, message); - } -}; - -var leadingPoo = '\uD83D'; -var trailingPoo = '\uDCA9'; -var wholePoo = leadingPoo + trailingPoo; +var throwsSentinel = require('./helpers/throwsSentinel'); var getArraySubclassWithSpeciesConstructor = function getArraySubclass(speciesConstructor) { var Bar = function Bar() { @@ -296,69 +171,16 @@ var getArraySubclassWithSpeciesConstructor = function getArraySubclass(speciesCo return Bar; }; -var testIterator = function (t, iterator, expected) { - var resultCount = 0; - var result; - while (result = iterator.next(), !result.done && resultCount < expected.length + 1) { // eslint-disable-line no-sequences - t.deepEqual(result, { done: false, value: expected[resultCount] }, 'result ' + resultCount); - resultCount += 1; - } - t.equal(resultCount, expected.length, 'expected ' + expected.length + ', got ' + (result.done ? '' : 'more than ') + resultCount); -}; - -var testAsyncIterator = function (t, asyncIterator, expected) { - var results = arguments.length > 3 ? arguments[3] : []; +var testIterator = require('./helpers/testIterator'); +var testAsyncIterator = require('./helpers/testAsyncIterator'); - var nextResult = asyncIterator.next(); +var testRESIterator = require('./helpers/testRESIterator'); - return Promise.resolve(nextResult).then(function (result) { - results.push(result); - if (!result.done && results.length < expected.length) { - t.deepEqual(result, { done: false, value: expected[results.length - 1] }, 'result ' + (results.length - 1)); - return testAsyncIterator(t, asyncIterator, expected, results); - } - - t.equal(results.length, expected.length, 'expected ' + expected.length + ', got ' + (result.done ? '' : 'more than ') + results.length); - return results.length; - }); -}; - -var testRESIterator = function testRegExpStringIterator(ES, t, regex, str, global, unicode, expected) { - var iterator = ES.CreateRegExpStringIterator(regex, str, global, unicode); - t.equal(typeof iterator, 'object', 'iterator is an object'); - t.equal(typeof iterator.next, 'function', '`.next` is a function'); - - t.test('has symbols', { skip: !v.hasSymbols }, function (st) { - st.equal(typeof iterator[Symbol.iterator], 'function', '[`Symbol.iterator`] is a function'); - st.end(); - }); - - testIterator(t, iterator, expected); -}; - -var makeIteratorRecord = function makeIteratorRecord(iterator) { - return { - '[[Iterator]]': iterator, - '[[NextMethod]]': iterator.next, - '[[Done]]': false - }; -}; +var makeIteratorRecord = require('./helpers/makeIteratorRecord'); var hasSpecies = v.hasSymbols && Symbol.species; -var hasLastIndex = 'lastIndex' in (/a/).exec('a'); // IE 8 -var hasGroups = 'groups' in (/a/).exec('a'); // modern engines -var kludgeMatch = function kludgeMatch(R, matchObject) { - if (hasGroups) { - assign(matchObject, { groups: matchObject.groups }); - } - if (hasLastIndex) { - assign(matchObject, { lastIndex: matchObject.lastIndex || R.lastIndex }); - } else { - delete matchObject.lastIndex; // eslint-disable-line no-param-reassign - } - return matchObject; -}; +var kludgeMatch = require('./helpers/kludgeMatch'); var testEnumerableOwnNames = function (t, enumerableOwnNames) { forEach(v.primitives, function (nonObject) { @@ -567,7 +389,7 @@ var es5 = function ES5(ES, ops, expectedMissing, skips) { ); }); - t.equal(ES.Canonicalize(leadingPoo, false), leadingPoo, 'when IgnoreCase is false, ch is returned'); + t.equal(ES.Canonicalize(esV.poo.leading, false), esV.poo.leading, 'when IgnoreCase is false, ch is returned'); t.equal(ES.Canonicalize('ƒ', true), 'Ƒ', 'when IgnoreCase is true, ch is canonicalized'); t.end(); @@ -835,7 +657,7 @@ var es5 = function ES5(ES, ops, expectedMissing, skips) { }); test('ToString', function (t) { - forEach(allButSyms, function (item) { + forEach(esV.allButSyms, function (item) { t.equal(ES.ToString(item), String(item), 'ES.ToString(' + debug(item) + ') ToStrings to String(' + debug(item) + ')'); }); @@ -886,7 +708,7 @@ var es5 = function ES5(ES, ops, expectedMissing, skips) { test('SameValue', function (t) { t.equal(true, ES.SameValue(NaN, NaN), 'NaN is SameValue as NaN'); t.equal(false, ES.SameValue(0, -0), '+0 is not SameValue as -0'); - forEach(unknowns, function (val) { + forEach(esV.unknowns, function (val) { t.equal(val === val, ES.SameValue(val, val), debug(val) + ' is SameValue to itself'); }); t.end(); @@ -1097,7 +919,7 @@ var es5 = function ES5(ES, ops, expectedMissing, skips) { test('Abstract Equality Comparison', function (t) { t.test('same types use ===', function (st) { - forEach(unknowns, function (value) { + forEach(esV.unknowns, function (value) { st.equal(ES['Abstract Equality Comparison'](value, value), value === value, debug(value) + ' is abstractly equal to itself'); }); st.end(); @@ -1137,7 +959,7 @@ var es5 = function ES5(ES, ops, expectedMissing, skips) { test('Strict Equality Comparison', function (t) { t.test('same types use ===', function (st) { - forEach(unknowns, function (value) { + forEach(esV.unknowns, function (value) { st.equal(ES['Strict Equality Comparison'](value, value), value === value, debug(value) + ' is strictly equal to itself'); }); st.end(); @@ -1262,15 +1084,10 @@ var es5 = function ES5(ES, ops, expectedMissing, skips) { t.end(); }); - var msPerSecond = 1e3; - var msPerMinute = 60 * msPerSecond; - var msPerHour = 60 * msPerMinute; - var msPerDay = 24 * msPerHour; - test('Day', function (t) { var time = Date.UTC(2019, 8, 10, 2, 3, 4, 5); var add = 2.5; - var later = new Date(time + (add * msPerDay)); + var later = new Date(time + (add * esV.msPerDay)); t.equal(ES.Day(later.getTime()), ES.Day(time) + Math.floor(add), 'adding 2.5 days worth of ms, gives a Day delta of 2'); t.end(); @@ -1289,9 +1106,9 @@ var es5 = function ES5(ES, ops, expectedMissing, skips) { test('TimeWithinDay', function (t) { var time = Date.UTC(2019, 8, 10, 2, 3, 4, 5); var add = 2.5; - var later = new Date(time + (add * msPerDay)); + var later = new Date(time + (add * esV.msPerDay)); - t.equal(ES.TimeWithinDay(later.getTime()), ES.TimeWithinDay(time) + (0.5 * msPerDay), 'adding 2.5 days worth of ms, gives a TimeWithinDay delta of +0.5'); + t.equal(ES.TimeWithinDay(later.getTime()), ES.TimeWithinDay(time) + (0.5 * esV.msPerDay), 'adding 2.5 days worth of ms, gives a TimeWithinDay delta of +0.5'); t.end(); }); @@ -1314,7 +1131,7 @@ var es5 = function ES5(ES, ops, expectedMissing, skips) { var now = new Date(); var today = now.getUTCDay(); for (var i = 0; i < 7; i += 1) { - var weekDay = ES.WeekDay(now.getTime() + (i * msPerDay)); + var weekDay = ES.WeekDay(now.getTime() + (i * esV.msPerDay)); t.equal(weekDay, (today + i) % 7, i + ' days after today (' + today + '), WeekDay is ' + weekDay); } t.end(); @@ -1457,22 +1274,22 @@ var es5 = function ES5(ES, ops, expectedMissing, skips) { }); test('MakeDate', function (t) { - forEach(nonFiniteNumbers, function (nonFiniteNumber) { + forEach(esV.nonFiniteNumbers, function (nonFiniteNumber) { t.equal(ES.MakeDate(nonFiniteNumber, 0), NaN, debug(nonFiniteNumber) + ' is not a finite `day`'); t.equal(ES.MakeDate(0, nonFiniteNumber), NaN, debug(nonFiniteNumber) + ' is not a finite `time`'); }); t.equal(ES.MakeDate(0, 0), 0, 'zero day and zero time is zero date'); t.equal(ES.MakeDate(0, 123), 123, 'zero day and nonzero time is a date of the "time"'); - t.equal(ES.MakeDate(1, 0), msPerDay, 'day of 1 and zero time is a date of "ms per day"'); - t.equal(ES.MakeDate(3, 0), 3 * msPerDay, 'day of 3 and zero time is a date of thrice "ms per day"'); - t.equal(ES.MakeDate(1, 123), msPerDay + 123, 'day of 1 and nonzero time is a date of "ms per day" plus the "time"'); - t.equal(ES.MakeDate(3, 123), (3 * msPerDay) + 123, 'day of 3 and nonzero time is a date of thrice "ms per day" plus the "time"'); + t.equal(ES.MakeDate(1, 0), esV.msPerDay, 'day of 1 and zero time is a date of "ms per day"'); + t.equal(ES.MakeDate(3, 0), 3 * esV.msPerDay, 'day of 3 and zero time is a date of thrice "ms per day"'); + t.equal(ES.MakeDate(1, 123), esV.msPerDay + 123, 'day of 1 and nonzero time is a date of "ms per day" plus the "time"'); + t.equal(ES.MakeDate(3, 123), (3 * esV.msPerDay) + 123, 'day of 3 and nonzero time is a date of thrice "ms per day" plus the "time"'); t.end(); }); test('MakeTime', function (t) { - forEach(nonFiniteNumbers, function (nonFiniteNumber) { + forEach(esV.nonFiniteNumbers, function (nonFiniteNumber) { t.equal(ES.MakeTime(nonFiniteNumber, 0, 0, 0), NaN, debug(nonFiniteNumber) + ' is not a finite `hour`'); t.equal(ES.MakeTime(0, nonFiniteNumber, 0, 0), NaN, debug(nonFiniteNumber) + ' is not a finite `min`'); t.equal(ES.MakeTime(0, 0, nonFiniteNumber, 0), NaN, debug(nonFiniteNumber) + ' is not a finite `sec`'); @@ -1481,7 +1298,7 @@ var es5 = function ES5(ES, ops, expectedMissing, skips) { t.equal( ES.MakeTime(1.2, 2.3, 3.4, 4.5), - (1 * msPerHour) + (2 * msPerMinute) + (3 * msPerSecond) + 4, + (1 * esV.msPerHour) + (2 * esV.msPerMinute) + (3 * esV.msPerSecond) + 4, 'all numbers are converted to integer, multiplied by the right number of ms, and summed' ); @@ -1489,7 +1306,7 @@ var es5 = function ES5(ES, ops, expectedMissing, skips) { }); test('TimeClip', function (t) { - forEach(nonFiniteNumbers, function (nonFiniteNumber) { + forEach(esV.nonFiniteNumbers, function (nonFiniteNumber) { t.equal(ES.TimeClip(nonFiniteNumber), NaN, debug(nonFiniteNumber) + ' is not a finite `time`'); }); t.equal(ES.TimeClip(8.64e15 + 1), NaN, '8.64e15 is the largest magnitude considered "finite"'); @@ -1537,14 +1354,6 @@ var es2015 = function ES2015(ES, ops, expectedMissing, skips) { })); var test = makeTest(ES, skips); - var getNamelessFunction = function () { - var f = Object(function () {}); - try { - delete f.name; - } catch (e) { /**/ } - return f; - }; - test('Abstract Equality Comparison', { skip: !v.hasSymbols }, function (t) { t.equal( ES['Abstract Equality Comparison'](Symbol(), Symbol()), @@ -1588,7 +1397,7 @@ var es2015 = function ES2015(ES, ops, expectedMissing, skips) { ); }); - forEach(notInts, function (nonInt) { + forEach(esV.notInts, function (nonInt) { t['throws']( function () { ES.AdvanceStringIndex('abc', nonInt); }, TypeError, @@ -1604,7 +1413,7 @@ var es2015 = function ES2015(ES, ops, expectedMissing, skips) { ); }); - var str = 'a' + wholePoo + 'c'; + var str = 'a' + esV.poo.whole + 'c'; t.test('non-unicode mode', function (st) { for (var i = 0; i < str.length + 2; i += 1) { @@ -1625,7 +1434,7 @@ var es2015 = function ES2015(ES, ops, expectedMissing, skips) { }); t.test('lone surrogates', function (st) { - var halfPoo = 'a' + leadingPoo + 'c'; + var halfPoo = 'a' + esV.poo.leading + 'c'; st.equal(ES.AdvanceStringIndex(halfPoo, 0, true), 1, '0 advances to 1'); st.equal(ES.AdvanceStringIndex(halfPoo, 1, true), 2, '1 advances to 2'); @@ -1641,7 +1450,7 @@ var es2015 = function ES2015(ES, ops, expectedMissing, skips) { st.equal(ES.AdvanceStringIndex(lowestPair, 0, true), 2, 'lowest surrogate pair, 0 -> 2'); st.equal(ES.AdvanceStringIndex(highestPair, 0, true), 2, 'highest surrogate pair, 0 -> 2'); - st.equal(ES.AdvanceStringIndex(wholePoo, 0, true), 2, 'poop, 0 -> 2'); + st.equal(ES.AdvanceStringIndex(esV.poo.whole, 0, true), 2, 'poop, 0 -> 2'); st.end(); }); @@ -1683,7 +1492,7 @@ var es2015 = function ES2015(ES, ops, expectedMissing, skips) { }); test('ArraySetLength', function (t) { - forEach(unknowns, function (nonArray) { + forEach(esV.unknowns, function (nonArray) { t['throws']( function () { ES.ArraySetLength(nonArray, { '[[Value]]': 0 }); }, TypeError, @@ -1798,7 +1607,7 @@ var es2015 = function ES2015(ES, ops, expectedMissing, skips) { }); t.test('works with a non-array', function (st) { - forEach(unknowns, function (nonArray) { + forEach(esV.unknowns, function (nonArray) { var arr = ES.ArraySpeciesCreate(nonArray, 0); st.ok(ES.IsArray(arr), 'is an array'); st.equal(arr.length, 0, 'length is correct'); @@ -1985,7 +1794,7 @@ var es2015 = function ES2015(ES, ops, expectedMissing, skips) { ); }); - t.equal(ES.Canonicalize(leadingPoo, false, false), leadingPoo, 'when IgnoreCase is false, ch is returned'); + t.equal(ES.Canonicalize(esV.poo.leading, false, false), esV.poo.leading, 'when IgnoreCase is false, ch is returned'); forEach(keys(caseFolding.C), function (input) { var output = caseFolding.C[input]; @@ -2570,7 +2379,7 @@ var es2015 = function ES2015(ES, ops, expectedMissing, skips) { }); test('DetachArrayBuffer', function (t) { - forEach(unknowns, function (nonArrayBuffer) { + forEach(esV.unknowns, function (nonArrayBuffer) { t['throws']( function () { ES.DetachArrayBuffer(nonArrayBuffer); }, TypeError, @@ -2586,7 +2395,7 @@ var es2015 = function ES2015(ES, ops, expectedMissing, skips) { new ArrayBuffer(420) ]; - st.test('can detach', { skip: !canDetach }, function (s2t) { + st.test('can detach', { skip: !esV.canDetach }, function (s2t) { forEach(buffers, function (buffer) { s2t.doesNotThrow( function () { return new Float32Array(buffer); }, @@ -2611,7 +2420,7 @@ var es2015 = function ES2015(ES, ops, expectedMissing, skips) { }); // throws SyntaxError in node < 11 - st.test('can not detach', { skip: canDetach }, function (s2t) { + st.test('can not detach', { skip: esV.canDetach }, function (s2t) { forEach(buffers, function (buffer) { s2t.doesNotThrow( function () { return new Float32Array(buffer); }, @@ -3069,7 +2878,7 @@ var es2015 = function ES2015(ES, ops, expectedMissing, skips) { }); test('GetValueFromBuffer', function (t) { - forEach(unknowns, function (nonAB) { + forEach(esV.unknowns, function (nonAB) { t['throws']( function () { ES.GetValueFromBuffer(nonAB, 0, 'Int8'); }, TypeError, @@ -3086,7 +2895,7 @@ var es2015 = function ES2015(ES, ops, expectedMissing, skips) { ); }); - forEach(invalidTATypes, function (nonString) { + forEach(esV.invalidTATypes, function (nonString) { st['throws']( function () { ES.GetValueFromBuffer(new ArrayBuffer(8), 0, nonString); }, TypeError, @@ -3102,7 +2911,7 @@ var es2015 = function ES2015(ES, ops, expectedMissing, skips) { ); }); - st.test('can detach', { skip: !canDetach }, function (s2t) { + st.test('can detach', { skip: !esV.canDetach }, function (s2t) { var buffer = new ArrayBuffer(8); s2t.equal(ES.DetachArrayBuffer(buffer), null, 'detaching returns null'); @@ -3117,8 +2926,8 @@ var es2015 = function ES2015(ES, ops, expectedMissing, skips) { forEach(bufferTestCases, function (testCase, name) { st.test(name + ': ' + debug(testCase.value), function (s2t) { - forEach(numberTypes, function (type) { - var view = new DataView(new ArrayBuffer(elementSizes.$Float64Array)); + forEach(esV.numberTypes, function (type) { + var view = new DataView(new ArrayBuffer(esV.elementSizes.$Float64Array)); var method = type === 'Uint8C' ? 'Uint8' : type; // var value = unserialize(testCase.value); var result = testCase[type === 'Uint8C' ? 'Uint8Clamped' : type]; @@ -3300,7 +3109,7 @@ var es2015 = function ES2015(ES, ops, expectedMissing, skips) { ); }); - forEach(unknowns, function (nonTA) { + forEach(esV.unknowns, function (nonTA) { t['throws']( function () { ES.IntegerIndexedElementGet(nonTA, 0); }, TypeError, @@ -3310,7 +3119,7 @@ var es2015 = function ES2015(ES, ops, expectedMissing, skips) { t.test('actual typed arrays', { skip: availableTypedArrays.length === 0 }, function (st) { forEach(availableTypedArrays, function (typedArray) { - var isBigInt = isBigIntTAType(typedArray); + var isBigInt = esV.isBigIntTAType(typedArray); if (!isBigInt || 'ToBigInt' in ES) { var Z = isBigInt ? safeBigInt : Number; var TA = global[typedArray]; @@ -3338,7 +3147,7 @@ var es2015 = function ES2015(ES, ops, expectedMissing, skips) { }); forEach([].concat( - unknowns, + esV.unknowns, [[]] ), function (nonTA) { t['throws']( @@ -3349,8 +3158,8 @@ var es2015 = function ES2015(ES, ops, expectedMissing, skips) { }); t.test('actual typed arrays', { skip: availableTypedArrays.length === 0 }, function (st) { - if (hasBigInts) { - forEach(bigIntTypes, function (bigIntType) { + if (esV.hasBigInts) { + forEach(esV.bigIntTypes, function (bigIntType) { var TA = global[bigIntType + 'Array']; var ta = new TA(0); st['throws']( @@ -3362,10 +3171,10 @@ var es2015 = function ES2015(ES, ops, expectedMissing, skips) { } forEach(availableTypedArrays, function (TypedArray) { - if (!isBigIntTAType(TypedArray)) { + if (!esV.isBigIntTAType(TypedArray)) { var ta = new global[TypedArray](8); - st.test('can detach', { skip: !canDetach }, function (s2t) { + st.test('can detach', { skip: !esV.canDetach }, function (s2t) { var taD = new global[TypedArray](8); ES.DetachArrayBuffer(taD.buffer); @@ -3529,7 +3338,7 @@ var es2015 = function ES2015(ES, ops, expectedMissing, skips) { t.equal(true, ES.IsArray([]), '[] is array'); t.equal(false, ES.IsArray({}), '{} is not array'); t.equal(false, ES.IsArray({ length: 1, 0: true }), 'arraylike object is not array'); - forEach(unknowns, function (value) { + forEach(esV.unknowns, function (value) { t.equal(false, ES.IsArray(value), debug(value) + ' is not array'); }); t.end(); @@ -3648,7 +3457,7 @@ var es2015 = function ES2015(ES, ops, expectedMissing, skips) { }); test('IsDetachedBuffer', function (t) { - forEach(unknowns, function (nonArrayBuffer) { + forEach(esV.unknowns, function (nonArrayBuffer) { t['throws']( function () { ES.IsDetachedBuffer(nonArrayBuffer); }, TypeError, @@ -3664,7 +3473,7 @@ var es2015 = function ES2015(ES, ops, expectedMissing, skips) { new ArrayBuffer(420) ]; - st.test('can detach', { skip: !canDetach }, function (s2t) { + st.test('can detach', { skip: !esV.canDetach }, function (s2t) { forEach(buffers, function (buffer) { s2t.equal(ES.IsDetachedBuffer(buffer), false, debug(buffer) + ' is not detached'); s2t.doesNotThrow( @@ -3686,7 +3495,7 @@ var es2015 = function ES2015(ES, ops, expectedMissing, skips) { }); // throws SyntaxError in node < 11 - st.test('can not detach', { skip: canDetach }, function (s2t) { + st.test('can not detach', { skip: esV.canDetach }, function (s2t) { forEach(buffers, function (buffer) { s2t.doesNotThrow( function () { return new Float32Array(buffer); }, @@ -3719,7 +3528,7 @@ var es2015 = function ES2015(ES, ops, expectedMissing, skips) { }); test('IsPromise', function (t) { - forEach(unknowns, function (nonPromise) { + forEach(esV.unknowns, function (nonPromise) { t.equal(ES.IsPromise(nonPromise), false, debug(nonPromise) + ' is not a Promise'); }); @@ -3756,7 +3565,7 @@ var es2015 = function ES2015(ES, ops, expectedMissing, skips) { t.equal(true, ES.IsRegExp(regex), regex + ' is regex'); }); - forEach(unknowns, function (nonRegex) { + forEach(esV.unknowns, function (nonRegex) { t.equal(false, ES.IsRegExp(nonRegex), debug(nonRegex) + ' is not regex'); }); @@ -3823,7 +3632,7 @@ var es2015 = function ES2015(ES, ops, expectedMissing, skips) { t.equal(false, ES.IsInteger(i + 0.2), (i + 0.2) + ' is not integer'); } t.equal(true, ES.IsInteger(-0), '-0 is integer'); - forEach(notInts, function (notInt) { + forEach(esV.notInts, function (notInt) { t.equal(false, ES.IsInteger(notInt), debug(notInt) + ' is not integer'); }); t.equal(false, ES.IsInteger(v.uncoercibleObject), 'uncoercibleObject is not integer'); @@ -3900,7 +3709,7 @@ var es2015 = function ES2015(ES, ops, expectedMissing, skips) { }); test('IteratorStep', function (t) { - forEach(unknowns, function (nonIteratorRecord) { + forEach(esV.unknowns, function (nonIteratorRecord) { t['throws']( function () { ES.IteratorStep(nonIteratorRecord); }, TypeError, @@ -4486,9 +4295,9 @@ var es2015 = function ES2015(ES, ops, expectedMissing, skips) { t.equal(ES.QuoteJSONString('\\'), '"\\\\"', '"\\\\" gets properly JSON-quoted'); t.equal(ES.QuoteJSONString('\u000B'), '"\\u000b"', '"\\u000B" gets properly JSON-quoted'); t.equal(ES.QuoteJSONString('\u0019'), '"\\u0019"', '"\\u0019" gets properly JSON-quoted'); - t.equal(ES.QuoteJSONString(leadingPoo), '"\ud83d"', 'leading poo gets properly JSON-quoted'); - t.equal(ES.QuoteJSONString(trailingPoo), '"\udca9"', 'trailing poo gets properly JSON-quoted'); - t.equal(ES.QuoteJSONString(wholePoo), '"\ud83d\udca9"', 'whole poo gets properly JSON-quoted'); + t.equal(ES.QuoteJSONString(esV.poo.leading), '"\ud83d"', 'leading poo gets properly JSON-quoted'); + t.equal(ES.QuoteJSONString(esV.poo.trailing), '"\udca9"', 'trailing poo gets properly JSON-quoted'); + t.equal(ES.QuoteJSONString(esV.poo.whole), '"\ud83d\udca9"', 'whole poo gets properly JSON-quoted'); t.end(); }); @@ -4602,7 +4411,7 @@ var es2015 = function ES2015(ES, ops, expectedMissing, skips) { test('SameValueZero', function (t) { t.equal(true, ES.SameValueZero(NaN, NaN), 'NaN is SameValueZero as NaN'); t.equal(true, ES.SameValueZero(0, -0), '+0 is SameValueZero as -0'); - forEach(unknowns, function (val) { + forEach(esV.unknowns, function (val) { t.equal(val === val, ES.SameValueZero(val, val), debug(val) + ' is SameValueZero to itself'); }); t.end(); @@ -4668,7 +4477,7 @@ var es2015 = function ES2015(ES, ops, expectedMissing, skips) { st.end(); }); - t.test('doesn’t call [[Get]] in conforming strict mode environments', { skip: noThrowOnStrictViolation }, function (st) { + t.test('doesn’t call [[Get]] in conforming strict mode environments', { skip: esV.noThrowOnStrictViolation }, function (st) { var getterCalled = false; var setterCalls = 0; var obj = {}; @@ -4783,7 +4592,7 @@ var es2015 = function ES2015(ES, ops, expectedMissing, skips) { ); var O = { a: 1 }; - t.test('sealed', { skip: !Object.preventExtensions || noThrowOnStrictViolation }, function (st) { + t.test('sealed', { skip: !Object.preventExtensions || esV.noThrowOnStrictViolation }, function (st) { st.equal(ES.SetIntegrityLevel(O, 'sealed'), true); st['throws']( function () { O.b = 2; }, @@ -4795,7 +4604,7 @@ var es2015 = function ES2015(ES, ops, expectedMissing, skips) { st.end(); }); - t.test('frozen', { skip: !Object.freeze || noThrowOnStrictViolation }, function (st) { + t.test('frozen', { skip: !Object.freeze || esV.noThrowOnStrictViolation }, function (st) { st.equal(ES.SetIntegrityLevel(O, 'frozen'), true); st['throws']( function () { O.a = 3; }, @@ -4809,7 +4618,7 @@ var es2015 = function ES2015(ES, ops, expectedMissing, skips) { }); test('SetValueInBuffer', function (t) { - forEach(unknowns, function (nonAB) { + forEach(esV.unknowns, function (nonAB) { t['throws']( function () { ES.SetValueInBuffer(nonAB, 0, 'Int8', 0); }, TypeError, @@ -4826,7 +4635,7 @@ var es2015 = function ES2015(ES, ops, expectedMissing, skips) { ); }); - forEach(invalidTATypes, function (nonString) { + forEach(esV.invalidTATypes, function (nonString) { st['throws']( function () { ES.SetValueInBuffer(new ArrayBuffer(8), 0, nonString, 0); }, TypeError, @@ -4850,7 +4659,7 @@ var es2015 = function ES2015(ES, ops, expectedMissing, skips) { ); }); - st.test('can detach', { skip: !canDetach }, function (s2t) { + st.test('can detach', { skip: !esV.canDetach }, function (s2t) { var buffer = new ArrayBuffer(8); s2t.equal(ES.DetachArrayBuffer(buffer), null, 'detaching returns null'); @@ -4864,7 +4673,7 @@ var es2015 = function ES2015(ES, ops, expectedMissing, skips) { }); forEach(bufferTestCases, function (testCase, name) { - forEach(numberTypes, function (type) { + forEach(esV.numberTypes, function (type) { var hasBigEndian = type !== 'Int8' && type !== 'Uint8' && type !== 'Uint8C'; // the 8-bit types are special, they don't have big-endian var result = testCase[type === 'Uint8C' ? 'Uint8Clamped' : type]; var value = unserialize(testCase.value); @@ -4878,9 +4687,9 @@ var es2015 = function ES2015(ES, ops, expectedMissing, skips) { ); */ - var elementSize = elementSizes['$' + (type === 'Uint8C' ? 'Uint8Clamped' : type) + 'Array']; + var elementSize = esV.elementSizes['$' + (type === 'Uint8C' ? 'Uint8Clamped' : type) + 'Array']; - var buffer = new ArrayBuffer(elementSizes.$Float64Array); + var buffer = new ArrayBuffer(esV.elementSizes.$Float64Array); var copyBytes = new Uint8Array(buffer); clearBuffer(buffer); @@ -4982,7 +4791,7 @@ var es2015 = function ES2015(ES, ops, expectedMissing, skips) { ); }); - forEach(notInts, function (nonInteger) { + forEach(esV.notInts, function (nonInteger) { t['throws']( function () { ES.SplitMatch('', nonInteger, ''); }, TypeError, @@ -5004,8 +4813,8 @@ var es2015 = function ES2015(ES, ops, expectedMissing, skips) { t.equal(ES.SplitMatch('a', 0, 'ab'), false, 'R longer than S yields false'); - var s = 'a' + wholePoo + 'c'; - t.equal(ES.SplitMatch(s, 1, wholePoo), 3, debug(wholePoo) + ' is found at index 1, before index 3, in ' + debug(s)); + var s = 'a' + esV.poo.whole + 'c'; + t.equal(ES.SplitMatch(s, 1, esV.poo.whole), 3, debug(esV.poo.whole) + ' is found at index 1, before index 3, in ' + debug(s)); t.end(); }); @@ -5106,7 +4915,7 @@ var es2015 = function ES2015(ES, ops, expectedMissing, skips) { }); test('SymbolDescriptiveString', function (t) { - forEach(allButSyms, function (nonSymbol) { + forEach(esV.allButSyms, function (nonSymbol) { t['throws']( function () { ES.SymbolDescriptiveString(nonSymbol); }, TypeError, @@ -5237,7 +5046,7 @@ var es2015 = function ES2015(ES, ops, expectedMissing, skips) { }); test('thisTimeValue', function (t) { - forEach(unknowns, function (nonDate) { + forEach(esV.unknowns, function (nonDate) { t['throws']( function () { ES.thisTimeValue(nonDate); }, TypeError, @@ -5367,7 +5176,7 @@ var es2015 = function ES2015(ES, ops, expectedMissing, skips) { }); test('ToPropertyKey', function (t) { - forEach(allButSyms, function (value) { + forEach(esV.allButSyms, function (value) { t.equal(ES.ToPropertyKey(value), String(value), 'ToPropertyKey(value) === String(value) for non-Symbols'); }); @@ -5388,7 +5197,7 @@ var es2015 = function ES2015(ES, ops, expectedMissing, skips) { }); test('ToString', function (t) { - forEach(allButSyms, function (item) { + forEach(esV.allButSyms, function (item) { t.equal(ES.ToString(item), String(item), 'ES.ToString(' + debug(item) + ') ToStrings to String(' + debug(item) + ')'); }); @@ -5854,7 +5663,7 @@ var es2015 = function ES2015(ES, ops, expectedMissing, skips) { test('ValidateTypedArray', function (t) { forEach([].concat( - unknowns, + esV.unknowns, [[]] ), function (nonTA) { t['throws']( @@ -5872,7 +5681,7 @@ var es2015 = function ES2015(ES, ops, expectedMissing, skips) { debug(ta) + ' is a TypedArray' ); - st.test('can detach', { skip: !canDetach }, function (s2t) { + st.test('can detach', { skip: !esV.canDetach }, function (s2t) { ES.DetachArrayBuffer(ta.buffer); s2t['throws']( @@ -6098,7 +5907,7 @@ var es2016 = function ES2016(ES, ops, expectedMissing, skips) { test('TypedArraySpeciesCreate', function (t) { t.test('no Typed Array support', { skip: availableTypedArrays.length > 0 }, function (st) { - forEach(unknowns, function (nonTA) { + forEach(esV.unknowns, function (nonTA) { st['throws']( function () { ES.TypedArraySpeciesCreate(nonTA, []); }, SyntaxError, @@ -6117,7 +5926,7 @@ var es2016 = function ES2016(ES, ops, expectedMissing, skips) { }); t.test('Typed Array support', { skip: availableTypedArrays.length === 0 }, function (st) { - forEach(unknowns, function (nonTA) { + forEach(esV.unknowns, function (nonTA) { st['throws']( function () { ES.TypedArraySpeciesCreate(nonTA, []); }, TypeError, @@ -6212,26 +6021,26 @@ var es2016 = function ES2016(ES, ops, expectedMissing, skips) { '0x10FFFF + 1 is > 0x10FFFF' ); - t.equal(ES.UTF16Encoding(0xD83D), leadingPoo, '0xD83D is the first half of ' + wholePoo); - t.equal(ES.UTF16Encoding(0xDCA9), trailingPoo, '0xDCA9 is the last half of ' + wholePoo); - t.equal(ES.UTF16Encoding(0x1F4A9), wholePoo, '0xDCA9 is the last half of ' + wholePoo); + t.equal(ES.UTF16Encoding(0xD83D), esV.poo.leading, '0xD83D is the first half of ' + esV.poo.whole); + t.equal(ES.UTF16Encoding(0xDCA9), esV.poo.trailing, '0xDCA9 is the last half of ' + esV.poo.whole); + t.equal(ES.UTF16Encoding(0x1F4A9), esV.poo.whole, '0xDCA9 is the last half of ' + esV.poo.whole); t.end(); }); test('UTF16Decode', function (t) { t['throws']( - function () { ES.UTF16Decode('a'.charCodeAt(0), trailingPoo.charCodeAt(0)); }, + function () { ES.UTF16Decode('a'.charCodeAt(0), esV.poo.trailing.charCodeAt(0)); }, TypeError, '"a" is not a leading surrogate' ); t['throws']( - function () { ES.UTF16Decode(leadingPoo.charCodeAt(0), 'b'.charCodeAt(0)); }, + function () { ES.UTF16Decode(esV.poo.leading.charCodeAt(0), 'b'.charCodeAt(0)); }, TypeError, '"b" is not a trailing surrogate' ); - t.equal(ES.UTF16Decode(leadingPoo.charCodeAt(0), trailingPoo.charCodeAt(0)), wholePoo); + t.equal(ES.UTF16Decode(esV.poo.leading.charCodeAt(0), esV.poo.trailing.charCodeAt(0)), esV.poo.whole); t.end(); }); @@ -6408,7 +6217,7 @@ var es2017 = function ES2017(ES, ops, expectedMissing, skips) { var isTypedArray = true; var order = 'Unordered'; - forEach(unknowns, function (nonAB) { + forEach(esV.unknowns, function (nonAB) { t['throws']( function () { ES.GetValueFromBuffer(nonAB, 0, 'Int8', isTypedArray, 'order'); }, TypeError, @@ -6425,7 +6234,7 @@ var es2017 = function ES2017(ES, ops, expectedMissing, skips) { ); }); - forEach(invalidTATypes, function (nonString) { + forEach(esV.invalidTATypes, function (nonString) { st['throws']( function () { ES.GetValueFromBuffer(new ArrayBuffer(8), 0, nonString, isTypedArray, order); }, TypeError, @@ -6455,7 +6264,7 @@ var es2017 = function ES2017(ES, ops, expectedMissing, skips) { ); }); - st.test('can detach', { skip: !canDetach }, function (s2t) { + st.test('can detach', { skip: !esV.canDetach }, function (s2t) { var buffer = new ArrayBuffer(8); s2t.equal(ES.DetachArrayBuffer(buffer), null, 'detaching returns null'); @@ -6470,8 +6279,8 @@ var es2017 = function ES2017(ES, ops, expectedMissing, skips) { forEach(bufferTestCases, function (testCase, name) { st.test(name + ': ' + debug(testCase.value), function (s2t) { - forEach(numberTypes, function (type) { - var view = new DataView(new ArrayBuffer(elementSizes.$Float64Array)); + forEach(esV.numberTypes, function (type) { + var view = new DataView(new ArrayBuffer(esV.elementSizes.$Float64Array)); var method = type === 'Uint8C' ? 'Uint8' : type; // var value = unserialize(testCase.value); var result = testCase[type === 'Uint8C' ? 'Uint8Clamped' : type]; @@ -6486,7 +6295,7 @@ var es2017 = function ES2017(ES, ops, expectedMissing, skips) { clearBuffer(view.buffer); var littleVal = unserialize(result.setAsLittle.asLittle); - view['set' + method](0, isBigIntTAType(type) ? safeBigInt(littleVal) : littleVal, true); + view['set' + method](0, esV.isBigIntTAType(type) ? safeBigInt(littleVal) : littleVal, true); s2t.equal( ES.GetValueFromBuffer(view.buffer, 0, type, isTypedArray, order, true), @@ -6503,7 +6312,7 @@ var es2017 = function ES2017(ES, ops, expectedMissing, skips) { clearBuffer(view.buffer); var bigVal = unserialize(result.setAsBig.asBig); - view['set' + method](0, isBigIntTAType(type) ? safeBigInt(bigVal) : bigVal, false); + view['set' + method](0, esV.isBigIntTAType(type) ? safeBigInt(bigVal) : bigVal, false); s2t.equal( ES.GetValueFromBuffer(view.buffer, 0, type, isTypedArray, order, false), @@ -6570,7 +6379,7 @@ var es2017 = function ES2017(ES, ops, expectedMissing, skips) { }); test('NumberToRawBytes', function (t) { - forEach(nonTATypes, function (nonTAType) { + forEach(esV.nonTATypes, function (nonTAType) { t['throws']( function () { ES.NumberToRawBytes(nonTAType, 0, false); }, TypeError, @@ -6598,7 +6407,7 @@ var es2017 = function ES2017(ES, ops, expectedMissing, skips) { var value = unserialize(testCase.value); t.test(name + ': ' + value, function (st) { - forEach(numberTypes, function (type) { + forEach(esV.numberTypes, function (type) { var hasBigEndian = type !== 'Int8' && type !== 'Uint8' && type !== 'Uint8C'; // the 8-bit types are special, they don't have big-endian var result = testCase[type === 'Uint8C' ? 'Uint8Clamped' : type]; var valToSet = type === 'Uint8C' && value > 0xFF ? 0xFF : value; @@ -6742,7 +6551,7 @@ var es2017 = function ES2017(ES, ops, expectedMissing, skips) { }); test('RawBytesToNumber', function (t) { - forEach(nonTATypes, function (nonTAType) { + forEach(esV.nonTATypes, function (nonTAType) { t['throws']( function () { ES.RawBytesToNumber(nonTAType, [], false); }, TypeError, @@ -6750,7 +6559,7 @@ var es2017 = function ES2017(ES, ops, expectedMissing, skips) { ); }); - forEach(unknowns, function (nonArray) { + forEach(esV.unknowns, function (nonArray) { t['throws']( function () { ES.RawBytesToNumber('Int8', nonArray, false); }, TypeError, @@ -6776,7 +6585,7 @@ var es2017 = function ES2017(ES, ops, expectedMissing, skips) { forEach(bufferTestCases, function (testCase, name) { var value = unserialize(testCase.value); t.test(name + ': ' + value, function (st) { - forEach(numberTypes, function (type) { + forEach(esV.numberTypes, function (type) { var result = testCase[type === 'Uint8C' ? 'Uint8Clamped' : type]; var hasBigEndian = type !== 'Int8' && type !== 'Uint8' && type !== 'Uint8C'; // the 8-bit types are special, they don't have big-endian @@ -6909,7 +6718,7 @@ var es2017 = function ES2017(ES, ops, expectedMissing, skips) { test('SetValueInBuffer', function (t) { var order = 'Unordered'; - forEach(unknowns, function (nonAB) { + forEach(esV.unknowns, function (nonAB) { t['throws']( function () { ES.SetValueInBuffer(nonAB, 0, 'Int8', 0, false, order); }, TypeError, @@ -6928,7 +6737,7 @@ var es2017 = function ES2017(ES, ops, expectedMissing, skips) { ); }); - forEach(invalidTATypes, function (nonString) { + forEach(esV.invalidTATypes, function (nonString) { st['throws']( function () { ES.SetValueInBuffer(new ArrayBuffer(8), 0, nonString, 0, isTypedArray, order); }, TypeError, @@ -6964,7 +6773,7 @@ var es2017 = function ES2017(ES, ops, expectedMissing, skips) { 'invalid order' ); - st.test('can detach', { skip: !canDetach }, function (s2t) { + st.test('can detach', { skip: !esV.canDetach }, function (s2t) { var buffer = new ArrayBuffer(8); s2t.equal(ES.DetachArrayBuffer(buffer), null, 'detaching returns null'); @@ -6978,7 +6787,7 @@ var es2017 = function ES2017(ES, ops, expectedMissing, skips) { }); forEach(bufferTestCases, function (testCase, name) { - forEach(numberTypes, testSetValueInBuffer(ES, st, testCase, isTypedArray, order)); + forEach(esV.numberTypes, testSetValueInBuffer(ES, st, testCase, isTypedArray, order)); }); st.end(); @@ -7078,7 +6887,7 @@ var es2017 = function ES2017(ES, ops, expectedMissing, skips) { test('ValidateAtomicAccess', function (t) { forEach([].concat( - unknowns, + esV.unknowns, [[]] ), function (nonTA) { t['throws']( @@ -7154,26 +6963,7 @@ var es2017 = function ES2017(ES, ops, expectedMissing, skips) { }); }; -var makeAsyncFromSyncIterator = function makeAsyncFromSyncIterator(ES, end, throwMethod, returnMethod) { - var i = 0; - var iterator = { - next: function next() { - try { - return { - done: i > end, - value: i - }; - } finally { - i += 1; - } - }, - 'return': returnMethod, - 'throw': throwMethod - }; - var syncIteratorRecord = makeIteratorRecord(iterator); - - return ES.CreateAsyncFromSyncIterator(syncIteratorRecord); -}; +var makeAsyncFromSyncIterator = require('./helpers/makeAsyncFromSyncIterator'); var es2018 = function ES2018(ES, ops, expectedMissing, skips) { es2017(ES, ops, expectedMissing, assign({}, skips, { @@ -7229,7 +7019,7 @@ var es2018 = function ES2018(ES, ops, expectedMissing, skips) { }); t.test('third argument: excludedItems', function (st) { - forEach(unknowns, function (nonArray) { + forEach(esV.unknowns, function (nonArray) { st['throws']( function () { ES.CopyDataProperties({}, {}, nonArray); }, TypeError, @@ -7278,7 +7068,7 @@ var es2018 = function ES2018(ES, ops, expectedMissing, skips) { }); test('CreateAsyncFromSyncIterator', function (t) { - forEach(unknowns, function (nonIteratorRecord) { + forEach(esV.unknowns, function (nonIteratorRecord) { t['throws']( function () { ES.CreateAsyncFromSyncIterator(nonIteratorRecord); }, TypeError, @@ -7287,7 +7077,7 @@ var es2018 = function ES2018(ES, ops, expectedMissing, skips) { }); t.test('with Promise support', { skip: typeof Promise === 'undefined' }, function (st) { - var asyncIteratorRecord = makeAsyncFromSyncIterator(ES, 5); + var asyncIteratorRecord = makeAsyncFromSyncIterator(ES.CreateAsyncFromSyncIterator, 5); st.deepEqual( keys(asyncIteratorRecord).sort(), @@ -7344,7 +7134,7 @@ var es2018 = function ES2018(ES, ops, expectedMissing, skips) { st.test('.throw()', function (s2t) { var asyncThrows = makeAsyncFromSyncIterator( - ES, + ES.CreateAsyncFromSyncIterator, 5, function throws(x) { s2t.equal(x, arguments.length === 1 ? false : void undefined, '.throw() called with `false`, or nothing'); @@ -7354,7 +7144,7 @@ var es2018 = function ES2018(ES, ops, expectedMissing, skips) { )['[[Iterator]]']; var asyncThrowReturnsNonObject = makeAsyncFromSyncIterator( - ES, + ES.CreateAsyncFromSyncIterator, 5, function throws(x) { s2t.equal(x, arguments.length === 1 ? false : void undefined, '.throw() called with `false`, or nothing'); @@ -7362,7 +7152,7 @@ var es2018 = function ES2018(ES, ops, expectedMissing, skips) { )['[[Iterator]]']; var asyncThrowReturnsObject = makeAsyncFromSyncIterator( - ES, + ES.CreateAsyncFromSyncIterator, 5, function throws(x) { s2t.equal(x, arguments.length === 1 ? false : void undefined, '.throw() called with `false`, or nothing'); @@ -7388,7 +7178,7 @@ var es2018 = function ES2018(ES, ops, expectedMissing, skips) { st.test('.return()', function (s2t) { var asyncThrows = makeAsyncFromSyncIterator( - ES, + ES.CreateAsyncFromSyncIterator, 5, void undefined, function returns(x) { @@ -7399,7 +7189,7 @@ var es2018 = function ES2018(ES, ops, expectedMissing, skips) { )['[[Iterator]]']; var asyncThrowReturnsNonObject = makeAsyncFromSyncIterator( - ES, + ES.CreateAsyncFromSyncIterator, 5, void undefined, function returns(x) { @@ -7408,7 +7198,7 @@ var es2018 = function ES2018(ES, ops, expectedMissing, skips) { )['[[Iterator]]']; var asyncThrowReturnsObject = makeAsyncFromSyncIterator( - ES, + ES.CreateAsyncFromSyncIterator, 5, void undefined, function returns(x) { @@ -7799,7 +7589,7 @@ var es2018 = function ES2018(ES, ops, expectedMissing, skips) { }); test('thisSymbolValue', function (t) { - forEach(allButSyms, function (nonSymbol) { + forEach(esV.allButSyms, function (nonSymbol) { t['throws']( function () { ES.thisSymbolValue(nonSymbol); }, v.hasSymbols ? TypeError : SyntaxError, @@ -7808,7 +7598,7 @@ var es2018 = function ES2018(ES, ops, expectedMissing, skips) { }); t.test('no native Symbols', { skip: v.hasSymbols }, function (st) { - forEach(unknowns, function (value) { + forEach(esV.unknowns, function (value) { st['throws']( function () { ES.thisSymbolValue(value); }, SyntaxError, @@ -7887,8 +7677,8 @@ var es2018 = function ES2018(ES, ops, expectedMissing, skips) { t.equal(ES.UnicodeEscape(' '), '\\u0020'); t.equal(ES.UnicodeEscape('a'), '\\u0061'); - t.equal(ES.UnicodeEscape(leadingPoo), '\\ud83d'); - t.equal(ES.UnicodeEscape(trailingPoo), '\\udca9'); + t.equal(ES.UnicodeEscape(esV.poo.leading), '\\ud83d'); + t.equal(ES.UnicodeEscape(esV.poo.trailing), '\\udca9'); t.end(); }); @@ -7910,7 +7700,7 @@ var es2018 = function ES2018(ES, ops, expectedMissing, skips) { }); test('AsyncIteratorClose', function (t) { - forEach(unknowns, function (nonIteratorRecord) { + forEach(esV.unknowns, function (nonIteratorRecord) { t['throws']( function () { ES.AsyncIteratorClose(nonIteratorRecord); }, TypeError, @@ -7923,7 +7713,7 @@ var es2018 = function ES2018(ES, ops, expectedMissing, skips) { }; var iteratorRecord = makeIteratorRecord(iterator); - forEach(unknowns, function (nonCompletionRecord) { + forEach(esV.unknowns, function (nonCompletionRecord) { t['throws']( function () { ES.AsyncIteratorClose(iteratorRecord, nonCompletionRecord); }, TypeError, @@ -8245,9 +8035,9 @@ var es2019 = function ES2019(ES, ops, expectedMissing, skips) { t.equal(ES.QuoteJSONString('\\'), '"\\\\"', '"\\\\" gets properly JSON-quoted'); t.equal(ES.QuoteJSONString('\u000B'), '"\\u000b"', '"\\u000B" gets properly JSON-quoted'); t.equal(ES.QuoteJSONString('\u0019'), '"\\u0019"', '"\\u0019" gets properly JSON-quoted'); - t.equal(ES.QuoteJSONString(leadingPoo), '"\\ud83d"', 'leading poo gets properly JSON-quoted'); - t.equal(ES.QuoteJSONString(trailingPoo), '"\\udca9"', 'trailing poo gets properly JSON-quoted'); - t.equal(ES.QuoteJSONString(wholePoo), '"\\ud83d\\udca9"', 'whole poo gets properly JSON-quoted'); + t.equal(ES.QuoteJSONString(esV.poo.leading), '"\\ud83d"', 'leading poo gets properly JSON-quoted'); + t.equal(ES.QuoteJSONString(esV.poo.trailing), '"\\udca9"', 'trailing poo gets properly JSON-quoted'); + t.equal(ES.QuoteJSONString(esV.poo.whole), '"\\ud83d\\udca9"', 'whole poo gets properly JSON-quoted'); t.end(); }); @@ -8296,7 +8086,7 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { })); var test = makeTest(ES, skips); - test('abs (with BigInts)', { skip: !hasBigInts }, function (t) { + test('abs (with BigInts)', { skip: !esV.hasBigInts }, function (t) { t.equal(ES.abs(BigInt(0)), BigInt(0), '0n -> 0n'); t.equal(ES.abs(BigInt(1)), BigInt(1), '+1n -> +1n'); @@ -8305,7 +8095,7 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { t.end(); }); - test('Abstract Equality Comparison', { skip: !hasBigInts }, function (t) { + test('Abstract Equality Comparison', { skip: !esV.hasBigInts }, function (t) { t.equal( ES['Abstract Equality Comparison'](BigInt(1), 1), true, @@ -8388,7 +8178,7 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { t.end(); }); - test('Abstract Relational Comparison', { skip: !hasBigInts }, function (t) { + test('Abstract Relational Comparison', { skip: !esV.hasBigInts }, function (t) { forEach(v.bigints, function (bigint) { t.equal( ES['Abstract Relational Comparison'](bigint, bigint + BigInt(1), false), @@ -8461,7 +8251,7 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { t.end(); }); - test('BigInt::add', { skip: !hasBigInts }, function (t) { + test('BigInt::add', { skip: !esV.hasBigInts }, function (t) { forEach(v.nonBigInts, function (nonBigInt) { t['throws']( function () { ES.BigInt.add(nonBigInt, 0); }, @@ -8488,7 +8278,7 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { t.end(); }); - test('BigInt::bitwiseAND', { skip: !hasBigInts }, function (t) { + test('BigInt::bitwiseAND', { skip: !esV.hasBigInts }, function (t) { forEach(v.nonBigInts, function (nonBigInt) { t['throws']( function () { ES.BigInt.bitwiseAND(nonBigInt, $BigInt(0)); }, @@ -8516,7 +8306,7 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { ); }); - t.test('actual BigInts', { skip: !hasBigInts }, function (st) { + t.test('actual BigInts', { skip: !esV.hasBigInts }, function (st) { forEach(v.int32s, function (int32) { var bigInt32 = $BigInt(int32); st.equal(ES.BigInt.bitwiseNOT(bigInt32), ~bigInt32, debug(bigInt32) + ' becomes ~' + debug(bigInt32)); @@ -8527,7 +8317,7 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { t.end(); }); - test('BigInt::bitwiseOR', { skip: !hasBigInts }, function (t) { + test('BigInt::bitwiseOR', { skip: !esV.hasBigInts }, function (t) { forEach(v.nonBigInts, function (nonBigInt) { t['throws']( function () { ES.BigInt.bitwiseOR(nonBigInt, $BigInt(0)); }, @@ -8546,7 +8336,7 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { t.end(); }); - test('BigInt::bitwiseXOR', { skip: !hasBigInts }, function (t) { + test('BigInt::bitwiseXOR', { skip: !esV.hasBigInts }, function (t) { forEach(v.nonBigInts, function (nonBigInt) { t['throws']( function () { ES.BigInt.bitwiseXOR(nonBigInt, $BigInt(0)); }, @@ -8565,7 +8355,7 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { t.end(); }); - test('BigInt::divide', { skip: !hasBigInts }, function (t) { + test('BigInt::divide', { skip: !esV.hasBigInts }, function (t) { forEach(v.nonBigInts, function (nonBigInt) { t['throws']( function () { ES.BigInt.divide(nonBigInt, $BigInt(0)); }, @@ -8595,7 +8385,7 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { t.end(); }); - test('BigInt::equal', { skip: !hasBigInts }, function (t) { + test('BigInt::equal', { skip: !esV.hasBigInts }, function (t) { forEach(v.nonBigInts, function (nonBigInt) { t['throws']( function () { ES.BigInt.equal(nonBigInt, $BigInt(0)); }, @@ -8619,7 +8409,7 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { t.end(); }); - test('BigInt::exponentiate', { skip: !hasBigInts }, function (t) { + test('BigInt::exponentiate', { skip: !esV.hasBigInts }, function (t) { forEach(v.nonBigInts, function (nonBigInt) { t['throws']( function () { ES.BigInt.exponentiate(nonBigInt, $BigInt(0)); }, @@ -8654,7 +8444,7 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { t.end(); }); - test('BigInt::leftShift', { skip: !hasBigInts }, function (t) { + test('BigInt::leftShift', { skip: !esV.hasBigInts }, function (t) { forEach(v.nonBigInts, function (nonBigInt) { t['throws']( function () { ES.BigInt.leftShift(nonBigInt, $BigInt(0)); }, @@ -8686,7 +8476,7 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { t.end(); }); - test('BigInt::lessThan', { skip: !hasBigInts }, function (t) { + test('BigInt::lessThan', { skip: !esV.hasBigInts }, function (t) { forEach(v.nonBigInts, function (nonBigInt) { t['throws']( function () { ES.BigInt.lessThan(nonBigInt, $BigInt(0)); }, @@ -8712,7 +8502,7 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { t.end(); }); - test('BigInt::multiply', { skip: !hasBigInts }, function (t) { + test('BigInt::multiply', { skip: !esV.hasBigInts }, function (t) { forEach(v.nonBigInts, function (nonBigInt) { t['throws']( function () { ES.BigInt.multiply(nonBigInt, $BigInt(0)); }, @@ -8739,7 +8529,7 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { t.end(); }); - test('BigInt::remainder', { skip: !hasBigInts }, function (t) { + test('BigInt::remainder', { skip: !esV.hasBigInts }, function (t) { forEach(v.nonBigInts, function (nonBigInt) { t['throws']( function () { ES.BigInt.remainder(nonBigInt, $BigInt(0)); }, @@ -8777,7 +8567,7 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { t.end(); }); - test('BigInt::sameValue', { skip: !hasBigInts }, function (t) { + test('BigInt::sameValue', { skip: !esV.hasBigInts }, function (t) { forEach(v.nonBigInts, function (nonBigInt) { t['throws']( function () { ES.BigInt.sameValue(nonBigInt, $BigInt(0)); }, @@ -8800,7 +8590,7 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { t.end(); }); - test('BigInt::sameValueZero', { skip: !hasBigInts }, function (t) { + test('BigInt::sameValueZero', { skip: !esV.hasBigInts }, function (t) { forEach(v.nonBigInts, function (nonBigInt) { t['throws']( function () { ES.BigInt.sameValueZero(nonBigInt, $BigInt(0)); }, @@ -8821,7 +8611,7 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { t.end(); }); - test('BigInt::signedRightShift', { skip: !hasBigInts }, function (t) { + test('BigInt::signedRightShift', { skip: !esV.hasBigInts }, function (t) { forEach(v.nonBigInts, function (nonBigInt) { t['throws']( function () { ES.BigInt.signedRightShift(nonBigInt, $BigInt(0)); }, @@ -8853,7 +8643,7 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { t.end(); }); - test('BigInt::subtract', { skip: !hasBigInts }, function (t) { + test('BigInt::subtract', { skip: !esV.hasBigInts }, function (t) { forEach(v.nonBigInts, function (nonBigInt) { t['throws']( function () { ES.BigInt.subtract(nonBigInt, $BigInt(0)); }, @@ -8903,7 +8693,7 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { ); }); - t.test('actual BigInts', { skip: !hasBigInts }, function (st) { + t.test('actual BigInts', { skip: !esV.hasBigInts }, function (st) { forEach(v.bigints, function (bigint) { st.equal(ES.BigInt.unaryMinus(bigint), -bigint, debug(bigint) + ' produces -' + debug(bigint)); }); @@ -8913,7 +8703,7 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { t.end(); }); - test('BigInt::unsignedRightShift', { skip: !hasBigInts }, function (t) { + test('BigInt::unsignedRightShift', { skip: !esV.hasBigInts }, function (t) { forEach(v.nonBigInts, function (nonBigInt) { t['throws']( function () { ES.BigInt.unsignedRightShift(nonBigInt, $BigInt(0)); }, @@ -8954,7 +8744,7 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { ); }); - t.test('BigInt support', { skip: !hasBigInts }, function (st) { + t.test('BigInt support', { skip: !esV.hasBigInts }, function (st) { st['throws']( function () { ES.BigIntBitwiseOp('&', 1, BigInt(1)); }, TypeError, @@ -9087,8 +8877,8 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { '[[IsUnpairedSurrogate]]': false }); - var strWithHalfPoo = 'a' + leadingPoo + 'c'; - var strWithWholePoo = 'a' + wholePoo + 'd'; + var strWithHalfPoo = 'a' + esV.poo.leading + 'c'; + var strWithWholePoo = 'a' + esV.poo.whole + 'd'; t.deepEqual(ES.CodePointAt(strWithHalfPoo, 0), { '[[CodePoint]]': 'a', @@ -9096,7 +8886,7 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { '[[IsUnpairedSurrogate]]': false }); t.deepEqual(ES.CodePointAt(strWithHalfPoo, 1), { - '[[CodePoint]]': leadingPoo, + '[[CodePoint]]': esV.poo.leading, '[[CodeUnitCount]]': 1, '[[IsUnpairedSurrogate]]': true }); @@ -9112,12 +8902,12 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { '[[IsUnpairedSurrogate]]': false }); t.deepEqual(ES.CodePointAt(strWithWholePoo, 1), { - '[[CodePoint]]': wholePoo, + '[[CodePoint]]': esV.poo.whole, '[[CodeUnitCount]]': 2, '[[IsUnpairedSurrogate]]': false }); t.deepEqual(ES.CodePointAt(strWithWholePoo, 2), { - '[[CodePoint]]': trailingPoo, + '[[CodePoint]]': esV.poo.trailing, '[[CodeUnitCount]]': 1, '[[IsUnpairedSurrogate]]': true }); @@ -9130,7 +8920,7 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { t.end(); }); - test('CreateListFromArrayLike', { skip: !hasBigInts }, function (t) { + test('CreateListFromArrayLike', { skip: !esV.hasBigInts }, function (t) { t.deepEqual( ES.CreateListFromArrayLike({ length: 2, 0: BigInt(1), 1: 'b', 2: 'c' }), [BigInt(1), 'b'], @@ -9184,17 +8974,17 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { var expected = [ assign(['a'], kludgeMatch(regex, { index: 0, input: str, lastIndex: 1 })) ]; - testRESIterator(ES, s2t, regex, str, false, false, expected); + testRESIterator(ES.CreateRegExpStringIterator, s2t, regex, str, false, false, expected); s2t.end(); }); st.test('non-global unicode regex', { skip: !('unicode' in RegExp.prototype) }, function (s2t) { - var regex = new RegExp(wholePoo, 'u'); - var str = 'a' + wholePoo + 'ca' + wholePoo + 'c'; + var regex = new RegExp(esV.poo.whole, 'u'); + var str = 'a' + esV.poo.whole + 'ca' + esV.poo.whole + 'c'; var expected = [ - assign([wholePoo], kludgeMatch(regex, { index: 1, input: str, lastIndex: 1 })) + assign([esV.poo.whole], kludgeMatch(regex, { index: 1, input: str, lastIndex: 1 })) ]; - testRESIterator(ES, s2t, regex, str, false, true, expected); + testRESIterator(ES.CreateRegExpStringIterator, s2t, regex, str, false, true, expected); s2t.end(); }); @@ -9205,7 +8995,7 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { assign(['a'], kludgeMatch(regex, { index: 0, input: str, lastIndex: 1 })), assign(['a'], kludgeMatch(regex, { index: 3, input: str, lastIndex: 4 })) ]; - testRESIterator(ES, s2t, regex, str, true, false, expected); + testRESIterator(ES.CreateRegExpStringIterator, s2t, regex, str, true, false, expected); var emptyRegex = /(?:)/g; var abc = 'abc'; @@ -9215,19 +9005,19 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { assign([''], kludgeMatch(emptyRegex, { index: 2, input: abc, lastIndex: 3 })), assign([''], kludgeMatch(emptyRegex, { index: 3, input: abc, lastIndex: 4 })) ]; - testRESIterator(ES, s2t, emptyRegex, abc, true, false, expected2); + testRESIterator(ES.CreateRegExpStringIterator, s2t, emptyRegex, abc, true, false, expected2); s2t.end(); }); st.test('global unicode regex', { skip: !('unicode' in RegExp.prototype) }, function (s2t) { - var regex = new RegExp(wholePoo, 'gu'); - var str = 'a' + wholePoo + 'ca' + wholePoo + 'c'; + var regex = new RegExp(esV.poo.whole, 'gu'); + var str = 'a' + esV.poo.whole + 'ca' + esV.poo.whole + 'c'; var expected = [ - assign([wholePoo], kludgeMatch(regex, { index: 1, input: str })), - assign([wholePoo], kludgeMatch(regex, { index: 5, input: str })) + assign([esV.poo.whole], kludgeMatch(regex, { index: 1, input: str })), + assign([esV.poo.whole], kludgeMatch(regex, { index: 5, input: str })) ]; - testRESIterator(ES, s2t, regex, str, true, true, expected); + testRESIterator(ES.CreateRegExpStringIterator, s2t, regex, str, true, true, expected); s2t.end(); }); @@ -9242,17 +9032,17 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { var expected = [ assign(['a'], kludgeMatch(regex, { index: 0, input: str })) ]; - testRESIterator(ES, s2t, regex, str, true, false, expected); + testRESIterator(ES.CreateRegExpStringIterator, s2t, regex, str, true, false, expected); s2t.end(); }); st.test('non-global unicode regex', { skip: !('unicode' in RegExp.prototype) }, function (s2t) { - var regex = new RegExp(wholePoo, 'u'); - var str = 'a' + wholePoo + 'ca' + wholePoo + 'c'; + var regex = new RegExp(esV.poo.whole, 'u'); + var str = 'a' + esV.poo.whole + 'ca' + esV.poo.whole + 'c'; var expected = [ - assign([wholePoo], kludgeMatch(regex, { index: 1, input: str })) + assign([esV.poo.whole], kludgeMatch(regex, { index: 1, input: str })) ]; - testRESIterator(ES, s2t, regex, str, true, true, expected); + testRESIterator(ES.CreateRegExpStringIterator, s2t, regex, str, true, true, expected); s2t.end(); }); @@ -9263,18 +9053,18 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { assign(['a'], kludgeMatch(regex, { index: 0, input: str })), assign(['a'], kludgeMatch(regex, { index: 3, input: str })) ]; - testRESIterator(ES, s2t, regex, str, false, false, expected); + testRESIterator(ES.CreateRegExpStringIterator, s2t, regex, str, false, false, expected); s2t.end(); }); st.test('global unicode regex', { skip: !('unicode' in RegExp.prototype) }, function (s2t) { - var regex = new RegExp(wholePoo, 'gu'); - var str = 'a' + wholePoo + 'ca' + wholePoo + 'c'; + var regex = new RegExp(esV.poo.whole, 'gu'); + var str = 'a' + esV.poo.whole + 'ca' + esV.poo.whole + 'c'; var expected = [ - assign([wholePoo], kludgeMatch(regex, { index: 1, input: str })), - assign([wholePoo], kludgeMatch(regex, { index: 5, input: str })) + assign([esV.poo.whole], kludgeMatch(regex, { index: 1, input: str })), + assign([esV.poo.whole], kludgeMatch(regex, { index: 5, input: str })) ]; - testRESIterator(ES, s2t, regex, str, false, true, expected); + testRESIterator(ES.CreateRegExpStringIterator, s2t, regex, str, false, true, expected); s2t.end(); }); @@ -9295,7 +9085,7 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { t.end(); }); - test('floor (with BigInts)', { skip: !hasBigInts }, function (t) { + test('floor (with BigInts)', { skip: !esV.hasBigInts }, function (t) { t.equal(ES.floor(BigInt(3)), BigInt(3), 'floor(3n) is 3n'); t.equal(ES.floor(BigInt(-3)), BigInt(-3), 'floor(-3n) is -3n'); t.equal(ES.floor(BigInt(0)), BigInt(0), 'floor(0n) is 0n'); @@ -9378,7 +9168,7 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { test('GetValueFromBuffer', function (t) { var isTypedArray = true; - forEach(unknowns, function (nonAB) { + forEach(esV.unknowns, function (nonAB) { t['throws']( function () { ES.GetValueFromBuffer(nonAB, 0, 'Int8', isTypedArray, 'Unordered'); }, TypeError, @@ -9395,7 +9185,7 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { ); }); - forEach(invalidTATypes, function (nonString) { + forEach(esV.invalidTATypes, function (nonString) { st['throws']( function () { ES.GetValueFromBuffer(new ArrayBuffer(8), 0, nonString, isTypedArray, 'Unordered'); }, TypeError, @@ -9425,7 +9215,7 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { ); }); - st.test('can detach', { skip: !canDetach }, function (s2t) { + st.test('can detach', { skip: !esV.canDetach }, function (s2t) { var buffer = new ArrayBuffer(8); s2t.equal(ES.DetachArrayBuffer(buffer), null, 'detaching returns null'); @@ -9440,9 +9230,9 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { forEach(bufferTestCases, function (testCase, name) { st.test(name + ': ' + debug(testCase.value), function (s2t) { - forEach(allTypes, function (type) { - var isBigInt = isBigIntTAType(type); - var view = new DataView(new ArrayBuffer(elementSizes.$Float64Array)); + forEach(esV.allTypes, function (type) { + var isBigInt = esV.isBigIntTAType(type); + var view = new DataView(new ArrayBuffer(esV.elementSizes.$Float64Array)); var method = type === 'Uint8C' ? 'Uint8' : type; // var value = unserialize(testCase.value); var result = testCase[type === 'Uint8C' ? 'Uint8Clamped' : type]; @@ -9521,7 +9311,7 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { }); forEach([].concat( - unknowns, + esV.unknowns, [[]] ), function (nonTA) { t['throws']( @@ -9533,12 +9323,12 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { t.test('actual typed arrays', { skip: availableTypedArrays.length === 0 }, function (st) { forEach(availableTypedArrays, function (TypedArray) { - var isBigInt = isBigIntTAType(TypedArray); + var isBigInt = esV.isBigIntTAType(TypedArray); var Z = isBigInt ? safeBigInt : Number; var ta = new global[TypedArray](8); - st.test('can detach', { skip: !canDetach }, function (s2t) { + st.test('can detach', { skip: !esV.canDetach }, function (s2t) { var taD = new global[TypedArray](8); ES.DetachArrayBuffer(taD.buffer); @@ -9586,7 +9376,7 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { }); test('IsBigIntElementType', function (t) { - forEach(bigIntTypes, function (type) { + forEach(esV.bigIntTypes, function (type) { t.equal( ES.IsBigIntElementType(type), true, @@ -9594,7 +9384,7 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { ); }); - forEach(numberTypes, function (type) { + forEach(esV.numberTypes, function (type) { t.equal( ES.IsBigIntElementType(type), false, @@ -9606,7 +9396,7 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { }); test('IsUnsignedElementType', function (t) { - forEach(unsignedElementTypes, function (type) { + forEach(esV.unsignedElementTypes, function (type) { t.equal( ES.IsUnsignedElementType(type), true, @@ -9614,7 +9404,7 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { ); }); - forEach(signedElementTypes, function (type) { + forEach(esV.signedElementTypes, function (type) { t.equal( ES.IsUnsignedElementType(type), false, @@ -9626,7 +9416,7 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { }); test('IsUnclampedIntegerElementType', function (t) { - forEach(unclampedIntegerTypes, function (type) { + forEach(esV.unclampedIntegerTypes, function (type) { t.equal( ES.IsUnclampedIntegerElementType(type), true, @@ -9635,8 +9425,8 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { }); forEach([].concat( - clampedTypes, - nonUnclampedIntegerTypes + esV.clampedTypes, + esV.nonUnclampedIntegerTypes ), function (type) { t.equal( ES.IsUnclampedIntegerElementType(type), @@ -9672,7 +9462,7 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { }); test('IsNoTearConfiguration', function (t) { - forEach(unclampedIntegerTypes, function (type) { + forEach(esV.unclampedIntegerTypes, function (type) { t.equal( ES.IsNoTearConfiguration(type), true, @@ -9680,7 +9470,7 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { ); }); - forEach(bigIntTypes, function (type) { + forEach(esV.bigIntTypes, function (type) { t.equal( ES.IsNoTearConfiguration(type, 'Init'), false, @@ -9700,7 +9490,7 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { ); }); - forEach(clampedTypes, function (type) { + forEach(esV.clampedTypes, function (type) { t.equal( ES.IsNoTearConfiguration(type), false, @@ -9713,7 +9503,7 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { test('IsValidIntegerIndex', function (t) { forEach([].concat( - unknowns, + esV.unknowns, [[]] ), function (nonTA) { t['throws']( @@ -10395,7 +10185,7 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { ); }); - t.test('actual BigInts', { skip: !hasBigInts }, function (st) { + t.test('actual BigInts', { skip: !esV.hasBigInts }, function (st) { forEach(v.integerNumbers, function (int) { if (int >= 1e17) { // BigInt(1e17) throws on node v10.4 - v10.8 @@ -10415,7 +10205,7 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { st.end(); }); - t.test('no BigInts', { skip: hasBigInts }, function (st) { + t.test('no BigInts', { skip: esV.hasBigInts }, function (st) { st['throws']( function () { ES.NumberToBigInt(0); }, SyntaxError, @@ -10429,7 +10219,7 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { }); test('NumericToRawBytes', function (t) { - forEach(nonTATypes, function (nonTAType) { + forEach(esV.nonTATypes, function (nonTAType) { t['throws']( function () { ES.NumericToRawBytes(nonTAType, 0, false); }, TypeError, @@ -10457,8 +10247,8 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { var value = unserialize(testCase.value); t.test(name + ': ' + value, function (st) { - forEach(allTypes, function (type) { - var isBigInt = isBigIntTAType(type); + forEach(esV.allTypes, function (type) { + var isBigInt = esV.isBigIntTAType(type); var hasBigEndian = type !== 'Int8' && type !== 'Uint8' && type !== 'Uint8C'; // the 8-bit types are special, they don't have big-endian var result = testCase[type === 'Uint8C' ? 'Uint8Clamped' : type]; @@ -10500,7 +10290,7 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { }); t.test('BigInt64', function (st) { - st.test('bigints available', { skip: !hasBigInts }, function (s2t) { + st.test('bigints available', { skip: !esV.hasBigInts }, function (s2t) { forEach([ [BigInt(0), [0, 0, 0, 0, 0, 0, 0, 0]], [BigInt(1), [1, 0, 0, 0, 0, 0, 0, 0]], @@ -10542,7 +10332,7 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { }); t.test('BigUint64', function (st) { - st.test('bigints available', { skip: !hasBigInts }, function (s2t) { + st.test('bigints available', { skip: !esV.hasBigInts }, function (s2t) { forEach([ [BigInt(0), [0, 0, 0, 0, 0, 0, 0, 0]], [BigInt(1), [1, 0, 0, 0, 0, 0, 0, 0]], @@ -10654,7 +10444,7 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { }); test('RawBytesToNumeric', function (t) { - forEach(nonTATypes, function (nonTAType) { + forEach(esV.nonTATypes, function (nonTAType) { t['throws']( function () { ES.RawBytesToNumeric(nonTAType, [], false); }, TypeError, @@ -10662,7 +10452,7 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { ); }); - forEach(unknowns, function (nonArray) { + forEach(esV.unknowns, function (nonArray) { t['throws']( function () { ES.RawBytesToNumeric('Int8', nonArray, false); }, TypeError, @@ -10688,7 +10478,7 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { forEach(bufferTestCases, function (testCase, name) { var value = unserialize(testCase.value); t.test(name + ': ' + value, function (st) { - forEach(allTypes, function (type) { + forEach(esV.allTypes, function (type) { var result = testCase[type === 'Uint8C' ? 'Uint8Clamped' : type]; var hasBigEndian = type !== 'Int8' && type !== 'Uint8' && type !== 'Uint8C'; // the 8-bit types are special, they don't have big-endian @@ -10844,7 +10634,7 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { st.end(); }); - t.test('bigint types, no bigints', { skip: hasBigInts }, function (st) { + t.test('bigint types, no bigints', { skip: esV.hasBigInts }, function (st) { st['throws']( function () { ES.RawBytesToNumeric('BigInt64', [0, 0, 0, 0, 0, 0, 0, 0], false); }, SyntaxError, @@ -10897,7 +10687,7 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { test('SetValueInBuffer', function (t) { var order = 'Unordered'; - forEach(unknowns, function (nonAB) { + forEach(esV.unknowns, function (nonAB) { t['throws']( function () { ES.SetValueInBuffer(nonAB, 0, 'Int8', 0, false, order); }, TypeError, @@ -10916,7 +10706,7 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { ); }); - forEach(invalidTATypes, function (nonString) { + forEach(esV.invalidTATypes, function (nonString) { st['throws']( function () { ES.SetValueInBuffer(new ArrayBuffer(8), 0, nonString, 0, isTypedArray, order); }, TypeError, @@ -10946,7 +10736,7 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { ); }); - if (hasBigInts) { + if (esV.hasBigInts) { st['throws']( function () { ES.SetValueInBuffer(new ArrayBuffer(8), 0, 'Int8', $BigInt(0), isTypedArray, order); }, TypeError, @@ -10966,7 +10756,7 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { 'invalid order' ); - st.test('can detach', { skip: !canDetach }, function (s2t) { + st.test('can detach', { skip: !esV.canDetach }, function (s2t) { var buffer = new ArrayBuffer(8); s2t.equal(ES.DetachArrayBuffer(buffer), null, 'detaching returns null'); @@ -10992,13 +10782,13 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { }); forEach(bufferTestCases, function (testCase, name) { - forEach(allTypes, testSetValueInBuffer(ES, st, testCase, isTypedArray, order)); + forEach(esV.allTypes, testSetValueInBuffer(ES, st, testCase, isTypedArray, order)); }); st.end(); }); - t.test('bigints', { skip: !hasBigInts }, function (st) { + t.test('bigints', { skip: !esV.hasBigInts }, function (st) { forEach(v.bigints, function (bigint) { var buffer = new ArrayBuffer(8); ES.SetValueInBuffer(buffer, 0, 'BigUint64', bigint, true, order); @@ -11016,7 +10806,7 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { }); test('StringToBigInt', function (t) { - t.test('actual BigInts', { skip: !hasBigInts }, function (st) { + t.test('actual BigInts', { skip: !esV.hasBigInts }, function (st) { forEach(v.bigints, function (bigint) { st.equal( ES.StringToBigInt(String(bigint)), @@ -11048,7 +10838,7 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { st.end(); }); - t.test('BigInt not supported', { skip: hasBigInts }, function (st) { + t.test('BigInt not supported', { skip: esV.hasBigInts }, function (st) { st['throws']( function () { ES.StringToBigInt('0'); }, SyntaxError, @@ -11091,7 +10881,7 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { }); test('thisBigIntValue', function (t) { - t.test('actual BigInts', { skip: !hasBigInts }, function (st) { + t.test('actual BigInts', { skip: !esV.hasBigInts }, function (st) { st.equal(ES.thisBigIntValue(BigInt(42)), BigInt(42)); st.equal(ES.thisBigIntValue(Object(BigInt(42))), BigInt(42)); @@ -11101,7 +10891,7 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { forEach(v.nonBigInts, function (nonBigInt) { t['throws']( function () { ES.thisBigIntValue(nonBigInt); }, - hasBigInts ? TypeError : SyntaxError, + esV.hasBigInts ? TypeError : SyntaxError, debug(nonBigInt) + ' is not a BigInt' ); }); @@ -11117,7 +10907,7 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { ), function (nonBigIntCoercible) { t['throws']( function () { ES.ToBigInt(nonBigIntCoercible); }, - hasBigInts ? TypeError : SyntaxError, + esV.hasBigInts ? TypeError : SyntaxError, debug(nonBigIntCoercible) + ' throws' ); }); @@ -11125,12 +10915,12 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { forEach(v.symbols, function (sym) { t['throws']( function () { ES.ToBigInt(sym); }, - hasBigInts ? TypeError : SyntaxError, + esV.hasBigInts ? TypeError : SyntaxError, debug(sym) + ' throws' ); }); - t.test('actual BigInts', { skip: !hasBigInts }, function (st) { + t.test('actual BigInts', { skip: !esV.hasBigInts }, function (st) { st.equal(ES.ToBigInt(true), BigInt(1), 'true becomes 1n'); st.equal(ES.ToBigInt(false), BigInt(0), 'true becomes 0n'); @@ -11185,7 +10975,7 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { t.end(); }); - test('ToBigInt64', { skip: !hasBigInts }, function (t) { + test('ToBigInt64', { skip: !esV.hasBigInts }, function (t) { var twoSixtyThreeMinusOne = twoSixtyThree - BigInt(1); var negTwoSixtyThreeMinusOne = -twoSixtyThree - BigInt(1); @@ -11206,7 +10996,7 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { t.end(); }); - test('ToBigUint64', { skip: !hasBigInts }, function (t) { + test('ToBigUint64', { skip: !esV.hasBigInts }, function (t) { var twoSixtyFourMinusOne = twoSixtyFour - BigInt(1); var twoSixtyThreeMinusOne = twoSixtyThree - BigInt(1); var negTwoSixtyThreeMinusOne = -twoSixtyThree - BigInt(1); @@ -11267,17 +11057,17 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { test('UTF16DecodeSurrogatePair', function (t) { t['throws']( - function () { ES.UTF16DecodeSurrogatePair('a'.charCodeAt(0), trailingPoo.charCodeAt(0)); }, + function () { ES.UTF16DecodeSurrogatePair('a'.charCodeAt(0), esV.poo.trailing.charCodeAt(0)); }, TypeError, '"a" is not a leading surrogate' ); t['throws']( - function () { ES.UTF16DecodeSurrogatePair(leadingPoo.charCodeAt(0), 'b'.charCodeAt(0)); }, + function () { ES.UTF16DecodeSurrogatePair(esV.poo.leading.charCodeAt(0), 'b'.charCodeAt(0)); }, TypeError, '"b" is not a trailing surrogate' ); - t.equal(ES.UTF16DecodeSurrogatePair(leadingPoo.charCodeAt(0), trailingPoo.charCodeAt(0)), wholePoo); + t.equal(ES.UTF16DecodeSurrogatePair(esV.poo.leading.charCodeAt(0), esV.poo.trailing.charCodeAt(0)), esV.poo.whole); t.end(); }); @@ -11312,7 +11102,7 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { test('ToNumeric', function (t) { testToNumber(t, ES, ES.ToNumeric); - t.test('BigInts', { skip: !hasBigInts }, function (st) { + t.test('BigInts', { skip: !esV.hasBigInts }, function (st) { st.equal(ES.ToNumeric(BigInt(42)), BigInt(42), debug(BigInt(42)) + ' is ' + debug(BigInt(42))); st.equal(ES.ToNumeric(Object(BigInt(42))), BigInt(42), debug(Object(BigInt(42))) + ' is ' + debug(BigInt(42))); @@ -11340,7 +11130,7 @@ var es2020 = function ES2020(ES, ops, expectedMissing, skips) { }); t.deepEqual(ES.UTF16DecodeString('abc'), ['a', 'b', 'c'], 'code units get split'); - t.deepEqual(ES.UTF16DecodeString('a' + wholePoo + 'c'), ['a', wholePoo, 'c'], 'code points get split too'); + t.deepEqual(ES.UTF16DecodeString('a' + esV.poo.whole + 'c'), ['a', esV.poo.whole, 'c'], 'code points get split too'); t.end(); }); @@ -11494,7 +11284,7 @@ var es2021 = function ES2021(ES, ops, expectedMissing, skips) { ); }); - t.test('BigInt support', { skip: !hasBigInts }, function (st) { + t.test('BigInt support', { skip: !esV.hasBigInts }, function (st) { forEach(v.bigints, function (bigint) { st['throws']( function () { ES.ApplyStringOrNumericBinaryOperator(Number(bigint), '+', bigint); }, @@ -11626,7 +11416,7 @@ var es2021 = function ES2021(ES, ops, expectedMissing, skips) { }); test('CloneArrayBuffer', function (t) { - forEach(unknowns, function (nonArrayBuffer) { + forEach(esV.unknowns, function (nonArrayBuffer) { t['throws']( function () { ES.CloneArrayBuffer(nonArrayBuffer, 0, 0, Object); }, TypeError, @@ -11704,7 +11494,7 @@ var es2021 = function ES2021(ES, ops, expectedMissing, skips) { ); }); - t.equal(ES.CodePointsToString([0xD83D, 0xDCA9]), wholePoo, 'code points are converted to a string'); + t.equal(ES.CodePointsToString([0xD83D, 0xDCA9]), esV.poo.whole, 'code points are converted to a string'); t.end(); }); @@ -11756,7 +11546,7 @@ var es2021 = function ES2021(ES, ops, expectedMissing, skips) { }); forEach([].concat( - unknowns, + esV.unknowns, [[]] ), function (nonTA) { t['throws']( @@ -11768,12 +11558,12 @@ var es2021 = function ES2021(ES, ops, expectedMissing, skips) { t.test('actual typed arrays', { skip: availableTypedArrays.length === 0 }, function (st) { forEach(availableTypedArrays, function (TypedArray) { - var isBigInt = isBigIntTAType(TypedArray); + var isBigInt = esV.isBigIntTAType(TypedArray); var Z = isBigInt ? safeBigInt : Number; var ta = new global[TypedArray](8); - st.test('can detach', { skip: !canDetach }, function (s2t) { + st.test('can detach', { skip: !esV.canDetach }, function (s2t) { var taD = new global[TypedArray](8); ES.DetachArrayBuffer(taD.buffer); @@ -11826,7 +11616,7 @@ var es2021 = function ES2021(ES, ops, expectedMissing, skips) { t.equal(false, ES.IsIntegralNumber(i + 0.2), (i + 0.2) + ' is not integer'); } t.equal(true, ES.IsIntegralNumber(-0), '-0 is integer'); - forEach(notInts, function (notInt) { + forEach(esV.notInts, function (notInt) { t.equal(false, ES.IsIntegralNumber(notInt), debug(notInt) + ' is not integer'); }); t.equal(false, ES.IsIntegralNumber(v.uncoercibleObject), 'uncoercibleObject is not integer'); @@ -11847,7 +11637,7 @@ var es2021 = function ES2021(ES, ops, expectedMissing, skips) { test('SetTypedArrayFromArrayLike', function (t) { forEach([].concat( - unknowns, + esV.unknowns, [[]] ), function (nonTA) { t['throws']( @@ -11880,7 +11670,7 @@ var es2021 = function ES2021(ES, ops, expectedMissing, skips) { 'source: must not be a TypedArray' ); - st.test('can detach', { skip: !canDetach }, function (s2t) { + st.test('can detach', { skip: !esV.canDetach }, function (s2t) { var arr = new Uint8Array(0); ES.DetachArrayBuffer(arr.buffer); @@ -11894,7 +11684,7 @@ var es2021 = function ES2021(ES, ops, expectedMissing, skips) { }); forEach(availableTypedArrays, function (name) { - var isBigInt = isBigIntTAType(name); + var isBigInt = esV.isBigIntTAType(name); var Z = isBigInt ? safeBigInt : Number; var TA = global[name]; @@ -11911,7 +11701,7 @@ var es2021 = function ES2021(ES, ops, expectedMissing, skips) { st.deepEqual(ta, new TA([Z(1), Z(10), Z(3)]), name + ': target is updated'); }); - st.test('getters are supported, and can detach', { skip: !$defineProperty || !canDetach }, function (s2t) { + st.test('getters are supported, and can detach', { skip: !$defineProperty || !esV.canDetach }, function (s2t) { var ta = new Uint8Array([1, 2, 3]); var obj = { length: 1 }; $defineProperty(obj, '0', { get: function () { ES.DetachArrayBuffer(ta.buffer); return 10; } }); @@ -11933,7 +11723,7 @@ var es2021 = function ES2021(ES, ops, expectedMissing, skips) { test('SetTypedArrayFromTypedArray', { skip: availableTypedArrays.length === 0 }, function (t) { forEach([].concat( - unknowns, + esV.unknowns, [[]] ), function (nonTA) { t['throws']( @@ -11965,7 +11755,7 @@ var es2021 = function ES2021(ES, ops, expectedMissing, skips) { 'targetOffset: ' + debug(Infinity) + ' is not a finite integer' ); - t.test('can detach', { skip: !canDetach }, function (st) { + t.test('can detach', { skip: !esV.canDetach }, function (st) { var arr = new Uint8Array(0); ES.DetachArrayBuffer(arr.buffer); @@ -11985,7 +11775,7 @@ var es2021 = function ES2021(ES, ops, expectedMissing, skips) { }); forEach(availableTypedArrays, function (name) { - var isBigInt = isBigIntTAType(name); + var isBigInt = esV.isBigIntTAType(name); var Z = isBigInt ? safeBigInt : Number; var TA = global[name]; @@ -12011,7 +11801,7 @@ var es2021 = function ES2021(ES, ops, expectedMissing, skips) { } }); - t.test('mixed content type', { skip: !hasBigInts || typeof BigInt64Array !== 'function' }, function (st) { + t.test('mixed content type', { skip: !esV.hasBigInts || typeof BigInt64Array !== 'function' }, function (st) { var bta = new BigInt64Array([$BigInt(0)]); var nta = new Float64Array([0]); @@ -12030,7 +11820,7 @@ var es2021 = function ES2021(ES, ops, expectedMissing, skips) { st.end(); }); - t.test('different type, same content type', { skip: !hasBigInts || typeof BigInt64Array !== 'function' }, function (st) { + t.test('different type, same content type', { skip: !esV.hasBigInts || typeof BigInt64Array !== 'function' }, function (st) { var bta = new Float32Array([10, 11]); ES.SetTypedArrayFromTypedArray(bta, 0, new Float64Array([0, 1])); st.deepEqual(bta, new Float32Array([0, 1])); @@ -12128,7 +11918,7 @@ var es2021 = function ES2021(ES, ops, expectedMissing, skips) { ); }); - forEach(notInts, function (nonIntegerNumber) { + forEach(esV.notInts, function (nonIntegerNumber) { t['throws']( function () { ES.SplitMatch('', nonIntegerNumber, ''); }, TypeError, @@ -12150,8 +11940,8 @@ var es2021 = function ES2021(ES, ops, expectedMissing, skips) { t.equal(ES.SplitMatch('a', 0, 'ab'), 'not-matched', 'R longer than S yields false'); - var s = 'a' + wholePoo + 'c'; - t.equal(ES.SplitMatch(s, 1, wholePoo), 3, debug(wholePoo) + ' is found at index 1, before index 3, in ' + debug(s)); + var s = 'a' + esV.poo.whole + 'c'; + t.equal(ES.SplitMatch(s, 1, esV.poo.whole), 3, debug(esV.poo.whole) + ' is found at index 1, before index 3, in ' + debug(s)); t.end(); }); @@ -12179,7 +11969,7 @@ var es2021 = function ES2021(ES, ops, expectedMissing, skips) { ); }); - var str = 'abc' + wholePoo + 'abc'; + var str = 'abc' + esV.poo.whole + 'abc'; t.equal(ES.StringIndexOf(str, 'a', 0), 0, 'a: first index found'); t.equal(ES.StringIndexOf(str, 'a', 1), 5, 'a: second index found'); t.equal(ES.StringIndexOf(str, 'a', 6), -1, 'a: second index not found'); @@ -12192,12 +11982,12 @@ var es2021 = function ES2021(ES, ops, expectedMissing, skips) { t.equal(ES.StringIndexOf(str, 'c', 3), 7, 'c: second index found'); t.equal(ES.StringIndexOf(str, 'c', 8), -1, 'c: second index not found'); - t.equal(ES.StringIndexOf(str, leadingPoo, 0), 3, 'first half of ' + wholePoo + ' found'); - t.equal(ES.StringIndexOf(str, leadingPoo, 4), -1, 'first half of ' + wholePoo + ' not found'); - t.equal(ES.StringIndexOf(str, trailingPoo, 0), 4, 'second half of ' + wholePoo + ' found'); - t.equal(ES.StringIndexOf(str, trailingPoo, 5), -1, 'second half of ' + wholePoo + ' not found'); - t.equal(ES.StringIndexOf(str, wholePoo, 0), 3, wholePoo + ' found'); - t.equal(ES.StringIndexOf(str, wholePoo, 4), -1, wholePoo + ' not found'); + t.equal(ES.StringIndexOf(str, esV.poo.leading, 0), 3, 'first half of ' + esV.poo.whole + ' found'); + t.equal(ES.StringIndexOf(str, esV.poo.leading, 4), -1, 'first half of ' + esV.poo.whole + ' not found'); + t.equal(ES.StringIndexOf(str, esV.poo.trailing, 0), 4, 'second half of ' + esV.poo.whole + ' found'); + t.equal(ES.StringIndexOf(str, esV.poo.trailing, 5), -1, 'second half of ' + esV.poo.whole + ' not found'); + t.equal(ES.StringIndexOf(str, esV.poo.whole, 0), 3, esV.poo.whole + ' found'); + t.equal(ES.StringIndexOf(str, esV.poo.whole, 4), -1, esV.poo.whole + ' not found'); t.equal(ES.StringIndexOf('', 'a', 0), -1, 'empty string contains nothing'); for (var i = 0; i < str.length; i += 1) { @@ -12217,7 +12007,7 @@ var es2021 = function ES2021(ES, ops, expectedMissing, skips) { }); t.deepEqual(ES.StringToCodePoints('abc'), ['a', 'b', 'c'], 'code units get split'); - t.deepEqual(ES.StringToCodePoints('a' + wholePoo + 'c'), ['a', wholePoo, 'c'], 'code points get split too'); + t.deepEqual(ES.StringToCodePoints('a' + esV.poo.whole + 'c'), ['a', esV.poo.whole, 'c'], 'code points get split too'); t.end(); }); @@ -12231,7 +12021,7 @@ var es2021 = function ES2021(ES, ops, expectedMissing, skips) { ); }); - forEach(notInts, function (nonIntegerNumber) { + forEach(esV.notInts, function (nonIntegerNumber) { t['throws']( function () { ES.substring('', nonIntegerNumber); }, TypeError, @@ -12295,17 +12085,17 @@ var es2021 = function ES2021(ES, ops, expectedMissing, skips) { test('UTF16SurrogatePairToCodePoint', function (t) { t['throws']( - function () { ES.UTF16SurrogatePairToCodePoint('a'.charCodeAt(0), trailingPoo.charCodeAt(0)); }, + function () { ES.UTF16SurrogatePairToCodePoint('a'.charCodeAt(0), esV.poo.trailing.charCodeAt(0)); }, TypeError, '"a" is not a leading surrogate' ); t['throws']( - function () { ES.UTF16SurrogatePairToCodePoint(leadingPoo.charCodeAt(0), 'b'.charCodeAt(0)); }, + function () { ES.UTF16SurrogatePairToCodePoint(esV.poo.leading.charCodeAt(0), 'b'.charCodeAt(0)); }, TypeError, '"b" is not a trailing surrogate' ); - t.equal(ES.UTF16SurrogatePairToCodePoint(leadingPoo.charCodeAt(0), trailingPoo.charCodeAt(0)), wholePoo); + t.equal(ES.UTF16SurrogatePairToCodePoint(esV.poo.leading.charCodeAt(0), esV.poo.trailing.charCodeAt(0)), esV.poo.whole); t.end(); }); @@ -12331,8 +12121,8 @@ var es2021 = function ES2021(ES, ops, expectedMissing, skips) { '0x10FFFF + 1 is > 0x10FFFF' ); - t.equal(ES.UTF16EncodeCodePoint(0xd83d), leadingPoo.charAt(0), '0xD83D is the first half of ' + wholePoo); - t.equal(ES.UTF16EncodeCodePoint(0xdca9), trailingPoo.charAt(0), '0xD83D is the last half of ' + wholePoo); + t.equal(ES.UTF16EncodeCodePoint(0xd83d), esV.poo.leading.charAt(0), '0xD83D is the first half of ' + esV.poo.whole); + t.equal(ES.UTF16EncodeCodePoint(0xdca9), esV.poo.trailing.charAt(0), '0xD83D is the last half of ' + esV.poo.whole); t.equal(ES.UTF16EncodeCodePoint(0x10000), '𐀀', '0x10000 is "𐀀"'); t.end(); @@ -12340,7 +12130,7 @@ var es2021 = function ES2021(ES, ops, expectedMissing, skips) { test('ValidateAtomicAccess', function (t) { forEach([].concat( - unknowns, + esV.unknowns, [[]] ), function (nonTA) { t['throws']( @@ -12375,7 +12165,7 @@ var es2021 = function ES2021(ES, ops, expectedMissing, skips) { 'a requestIndex > length throws' ); - var elementSize = elementSizes['$' + TypedArray]; + var elementSize = esV.elementSizes['$' + TypedArray]; st.equal(ES.ValidateAtomicAccess(ta, 0), elementSize * 0, TypedArray + ': requestIndex of 0 gives 0'); st.equal(ES.ValidateAtomicAccess(ta, 1), elementSize * 1, TypedArray + ': requestIndex of 1 gives ' + (elementSize * 1)); @@ -12403,7 +12193,7 @@ var es2021 = function ES2021(ES, ops, expectedMissing, skips) { }); forEach([].concat( - unknowns, + esV.unknowns, [[]] ), function (nonTA) { t['throws']( @@ -12462,7 +12252,7 @@ var es2021 = function ES2021(ES, ops, expectedMissing, skips) { }); test('WeakRefDeref', function (t) { - forEach(unknowns, function (nonWeakRef) { + forEach(esV.unknowns, function (nonWeakRef) { t['throws']( function () { ES.WeakRefDeref(nonWeakRef); }, TypeError, @@ -12694,7 +12484,7 @@ var es2022 = function ES2022(ES, ops, expectedMissing, skips) { }); forEach([].concat( - unknowns, + esV.unknowns, { '[[StartIndex]]': -1 }, { '[[StartIndex]]': 1.2, '[[EndIndex]]': 0 }, { '[[StartIndex]]': 1, '[[EndIndex]]': 0 } @@ -12742,7 +12532,7 @@ var es2022 = function ES2022(ES, ops, expectedMissing, skips) { }); forEach([].concat( - unknowns, + esV.unknowns, { '[[StartIndex]]': -1 }, { '[[StartIndex]]': 1.2, '[[EndIndex]]': 0 }, { '[[StartIndex]]': 1, '[[EndIndex]]': 0 } @@ -12797,7 +12587,7 @@ var es2022 = function ES2022(ES, ops, expectedMissing, skips) { ); }); - var strWithWholePoo = 'a' + wholePoo + 'c'; + var strWithWholePoo = 'a' + esV.poo.whole + 'c'; t.equal(ES.GetStringIndex(strWithWholePoo, 0), 0, 'index 0 yields 0'); t.equal(ES.GetStringIndex(strWithWholePoo, 1), 1, 'index 1 yields 1'); t.equal(ES.GetStringIndex(strWithWholePoo, 2), 3, 'index 2 yields 3'); @@ -13060,7 +12850,7 @@ var es2022 = function ES2022(ES, ops, expectedMissing, skips) { test('IsStrictlyEqual', function (t) { t.test('same types use ===', function (st) { - forEach(unknowns, function (value) { + forEach(esV.unknowns, function (value) { st.equal(ES.IsStrictlyEqual(value, value), value === value, debug(value) + ' is strictly equal to itself'); }); st.end(); @@ -13097,7 +12887,7 @@ var es2022 = function ES2022(ES, ops, expectedMissing, skips) { test('IsLooselyEqual', function (t) { t.test('same types use ===', function (st) { - forEach(unknowns, function (value) { + forEach(esV.unknowns, function (value) { st.equal(ES.IsLooselyEqual(value, value), value === value, debug(value) + ' is abstractly equal to itself'); }); st.end(); @@ -13119,7 +12909,7 @@ var es2022 = function ES2022(ES, ops, expectedMissing, skips) { [Number(String(v.coercibleObject)), v.coercibleObject], [Number(v.coercibleObject), v.coercibleObject], [String(Number(v.coercibleObject)), v.coercibleObject] - ].concat(hasBigInts ? [ + ].concat(esV.hasBigInts ? [ [BigInt(0), 0], [0, BigInt(0)], [BigInt(1), 1], @@ -13208,7 +12998,7 @@ var es2022 = function ES2022(ES, ops, expectedMissing, skips) { t.equal(ES.IsLessThan(v.coercibleObject, '3', false), false, '!LeftFirst: coercible object is not less than "3"'); t.equal(ES.IsLessThan('3', v.coercibleObject, false), false, '!LeftFirst: "3" is not less than coercible object'); - t.test('BigInts are supported', { skip: !hasBigInts }, function (st) { + t.test('BigInts are supported', { skip: !esV.hasBigInts }, function (st) { st.equal(ES.IsLessThan($BigInt(0), '1', true), true, 'LeftFirst: 0n is less than "1"'); st.equal(ES.IsLessThan('1', $BigInt(0), true), false, 'LeftFirst: "1" is not less than 0n'); st.equal(ES.IsLessThan($BigInt(0), '1', false), true, '!LeftFirst: 0n is less than "1"'); @@ -13261,12 +13051,12 @@ var es2022 = function ES2022(ES, ops, expectedMissing, skips) { forEach([].concat( v.strings, - wholePoo + esV.poo.whole ), function (string) { t.equal(ES.IsStringWellFormedUnicode(string), true, debug(string) + ' is well-formed unicode'); }); - forEach([leadingPoo, trailingPoo], function (badString) { + forEach([esV.poo.leading, esV.poo.trailing], function (badString) { t.equal(ES.IsStringWellFormedUnicode(badString), false, debug(badString) + ' is not well-formed unicode'); }); @@ -13527,7 +13317,7 @@ var es2022 = function ES2022(ES, ops, expectedMissing, skips) { }); test('StringToBigInt', function (t) { - t.test('actual BigInts', { skip: !hasBigInts }, function (st) { + t.test('actual BigInts', { skip: !esV.hasBigInts }, function (st) { forEach(v.bigints, function (bigint) { st.equal( ES.StringToBigInt(String(bigint)), @@ -13559,7 +13349,7 @@ var es2022 = function ES2022(ES, ops, expectedMissing, skips) { st.end(); }); - t.test('BigInt not supported', { skip: hasBigInts }, function (st) { + t.test('BigInt not supported', { skip: esV.hasBigInts }, function (st) { st['throws']( function () { ES.StringToBigInt('0'); }, SyntaxError, @@ -13611,7 +13401,7 @@ var es2022 = function ES2022(ES, ops, expectedMissing, skips) { }); test('TypedArrayElementSize', function (t) { - forEach(unknowns, function (nonTA) { + forEach(esV.unknowns, function (nonTA) { t['throws']( function () { ES.TypedArrayElementSize(nonTA); }, TypeError, @@ -13620,7 +13410,7 @@ var es2022 = function ES2022(ES, ops, expectedMissing, skips) { }); forEach(availableTypedArrays, function (TA) { - var elementSize = elementSizes['$' + TA]; + var elementSize = esV.elementSizes['$' + TA]; var ta = new global[TA](0); @@ -13638,7 +13428,7 @@ var es2022 = function ES2022(ES, ops, expectedMissing, skips) { }); test('TypedArrayElementType', function (t) { - forEach(unknowns, function (nonTA) { + forEach(esV.unknowns, function (nonTA) { t['throws']( function () { ES.TypedArrayElementType(nonTA); }, TypeError, @@ -13716,7 +13506,7 @@ var es2023 = function ES2023(ES, ops, expectedMissing, skips) { ); }); - t.test('BigInts are supported', { skip: !hasBigInts }, function (st) { + t.test('BigInts are supported', { skip: !esV.hasBigInts }, function (st) { forEach([].concat( v.nonIntegerNumbers, 0, @@ -13848,7 +13638,7 @@ var es2023 = function ES2023(ES, ops, expectedMissing, skips) { ); }); - t.equal(ES.Canonicalize(rer, leadingPoo), leadingPoo, 'when IgnoreCase is false, ch is returned'); + t.equal(ES.Canonicalize(rer, esV.poo.leading), esV.poo.leading, 'when IgnoreCase is false, ch is returned'); forEach(keys(caseFolding.C), function (input) { var output = caseFolding.C[input]; @@ -13942,7 +13732,7 @@ var es2023 = function ES2023(ES, ops, expectedMissing, skips) { TypeError, 'one String argument throws a TypeError' ); - if (hasBigInts) { + if (esV.hasBigInts) { t['throws']( function () { ES.CompareTypedArrayElements(1, twoSixtyFour); }, TypeError, @@ -14815,7 +14605,7 @@ var es2023 = function ES2023(ES, ops, expectedMissing, skips) { }); test('IteratorStep', function (t) { - forEach(unknowns, function (nonIteratorRecord) { + forEach(esV.unknowns, function (nonIteratorRecord) { t['throws']( function () { ES.IteratorStep(nonIteratorRecord); }, TypeError, @@ -15019,7 +14809,7 @@ var es2023 = function ES2023(ES, ops, expectedMissing, skips) { test('SetTypedArrayFromArrayLike', function (t) { forEach([].concat( - unknowns, + esV.unknowns, [[]] ), function (nonTA) { t['throws']( @@ -15052,7 +14842,7 @@ var es2023 = function ES2023(ES, ops, expectedMissing, skips) { 'source: must not be a TypedArray' ); - st.test('can detach', { skip: !canDetach }, function (s2t) { + st.test('can detach', { skip: !esV.canDetach }, function (s2t) { var arr = new Uint8Array(0); ES.DetachArrayBuffer(arr.buffer); @@ -15066,7 +14856,7 @@ var es2023 = function ES2023(ES, ops, expectedMissing, skips) { }); forEach(availableTypedArrays, function (name) { - var isBigInt = isBigIntTAType(name); + var isBigInt = esV.isBigIntTAType(name); var Z = isBigInt ? safeBigInt : Number; var TA = global[name]; @@ -15083,7 +14873,7 @@ var es2023 = function ES2023(ES, ops, expectedMissing, skips) { st.deepEqual(ta, new TA([Z(1), Z(10), Z(3)]), name + ': target is updated'); }); - st.test('getters are supported, and can detach', { skip: !defineProperty.oDP || !canDetach }, function (s2t) { + st.test('getters are supported, and can detach', { skip: !defineProperty.oDP || !esV.canDetach }, function (s2t) { var ta = new Uint8Array([1, 2, 3]); var obj = { length: 1 }; defineProperty.oDP(obj, '0', { get: function () { ES.DetachArrayBuffer(ta.buffer); return 10; } }); @@ -15220,7 +15010,7 @@ var es2023 = function ES2023(ES, ops, expectedMissing, skips) { test('TimeZoneString', function (t) { forEach([].concat( v.nonIntegerNumbers, - nonFiniteNumbers + esV.nonFiniteNumbers ), function (nonIntegerNumber) { t['throws']( function () { ES.TimeZoneString(nonIntegerNumber); }, @@ -15238,7 +15028,7 @@ var es2023 = function ES2023(ES, ops, expectedMissing, skips) { test('TypedArrayCreateSameType', function (t) { t.test('no Typed Array support', { skip: availableTypedArrays.length > 0 }, function (st) { - forEach(unknowns, function (nonTA) { + forEach(esV.unknowns, function (nonTA) { st['throws']( function () { ES.TypedArrayCreateSameType(nonTA, []); }, SyntaxError, @@ -15258,7 +15048,7 @@ var es2023 = function ES2023(ES, ops, expectedMissing, skips) { }); t.test('Typed Array support', { skip: availableTypedArrays.length === 0 }, function (st) { - forEach(unknowns, function (nonTA) { + forEach(esV.unknowns, function (nonTA) { st['throws']( function () { ES.TypedArrayCreateSameType(nonTA, []); }, TypeError, @@ -15310,7 +15100,7 @@ var es2023 = function ES2023(ES, ops, expectedMissing, skips) { }); test('WordCharacters', function (t) { - forEach(unknowns, function (nonRER) { + forEach(esV.unknowns, function (nonRER) { t['throws']( function () { ES.WordCharacters(nonRER); }, TypeError, @@ -15418,7 +15208,7 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { test('ArrayBufferByteLength', function (t) { var order = 'UNORDERED'; - forEach(unknowns, function (nonAB) { + forEach(esV.unknowns, function (nonAB) { t['throws']( function () { ES.ArrayBufferByteLength(nonAB, order); }, TypeError, @@ -15459,7 +15249,7 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { }); test('ArrayBufferCopyAndDetach', function (t) { - forEach(unknowns, function (nonAB) { + forEach(esV.unknowns, function (nonAB) { t['throws']( function () { ES.ArrayBufferCopyAndDetach(nonAB, 0, 'FIXED-LENGTH'); }, TypeError, @@ -15470,7 +15260,7 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { t.test('ArrayBuffers supported', { skip: typeof ArrayBuffer !== 'function' }, function (st) { var ab = new Uint8Array([1, 2, 3, 4]).buffer; - st.test('can not detach', { skip: canDetach }, function (s2t) { + st.test('can not detach', { skip: esV.canDetach }, function (s2t) { s2t['throws']( function () { ES.ArrayBufferCopyAndDetach(new ArrayBuffer(8), 0, 'FIXED-LENGTH'); }, SyntaxError, @@ -15480,7 +15270,7 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { s2t.end(); }); - st.test('can detach', { skip: !canDetach }, function (s2t) { + st.test('can detach', { skip: !esV.canDetach }, function (s2t) { forEach(v.nonStrings, function (nonString) { s2t['throws']( function () { ES.ArrayBufferCopyAndDetach(ab, 0, nonString); }, @@ -16174,7 +15964,7 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { var isTypedArray = true; var order = 'UNORDERED'; - forEach(unknowns, function (nonAB) { + forEach(esV.unknowns, function (nonAB) { t['throws']( function () { ES.GetValueFromBuffer(nonAB, 0, 'INT8', isTypedArray, order); }, TypeError, @@ -16191,7 +15981,7 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { ); }); - forEach(invalidTATypes, function (nonString) { + forEach(esV.invalidTATypes, function (nonString) { st['throws']( function () { ES.GetValueFromBuffer(new ArrayBuffer(8), 0, nonString, isTypedArray, order); }, TypeError, @@ -16221,7 +16011,7 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { ); }); - st.test('can detach', { skip: !canDetach }, function (s2t) { + st.test('can detach', { skip: !esV.canDetach }, function (s2t) { var buffer = new ArrayBuffer(8); s2t.equal(ES.DetachArrayBuffer(buffer), null, 'detaching returns null'); @@ -16236,9 +16026,9 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { forEach(bufferTestCases, function (testCase, name) { st.test(name + ': ' + debug(testCase.value), function (s2t) { - forEach(allTypes, function (type) { - var isBigInt = isBigIntTAType(type); - var view = new DataView(new ArrayBuffer(elementSizes.$Float64Array)); + forEach(esV.allTypes, function (type) { + var isBigInt = esV.isBigIntTAType(type); + var view = new DataView(new ArrayBuffer(esV.elementSizes.$Float64Array)); var method = type === 'Uint8C' ? 'Uint8' : type; // var value = unserialize(testCase.value); var result = testCase[type === 'Uint8C' ? 'Uint8Clamped' : type]; @@ -16308,7 +16098,7 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { }); test('GetViewByteLength', function (t) { - forEach(unknowns, function (nonDVWBWRecord) { + forEach(esV.unknowns, function (nonDVWBWRecord) { t['throws']( function () { ES.GetViewByteLength(nonDVWBWRecord); }, TypeError, @@ -16356,7 +16146,7 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { } ); - st.test('can detach', { skip: !canDetach }, function (s2t) { + st.test('can detach', { skip: !esV.canDetach }, function (s2t) { var dab = new ArrayBuffer(1); var ddv = new DataView(dab); @@ -16489,7 +16279,7 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { }); test('HasEitherUnicodeFlag', function (t) { - forEach(unknowns, function (nonRER) { + forEach(esV.unknowns, function (nonRER) { t['throws']( function () { ES.HasEitherUnicodeFlag(nonRER); }, TypeError, @@ -16538,7 +16328,7 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { }); test('IsArrayBufferViewOutOfBounds', function (t) { - forEach(unknowns, function (nonABV) { + forEach(esV.unknowns, function (nonABV) { t['throws']( function () { ES.IsArrayBufferViewOutOfBounds(nonABV); }, TypeError, @@ -16559,7 +16349,7 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { st.equal(ES.IsArrayBufferViewOutOfBounds(ta), false, debug(ta) + ' is not out of bounds'); }); - st.test('can detach', { skip: !canDetach }, function (s2t) { + st.test('can detach', { skip: !esV.canDetach }, function (s2t) { ES.DetachArrayBuffer(ab); s2t.equal(ES.IsArrayBufferViewOutOfBounds(dv), true, 'DataView with detached buffer is out of bounds'); @@ -16583,7 +16373,7 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { }); test('IsBigIntElementType', function (t) { - forEach(bigIntTypes, function (type) { + forEach(esV.bigIntTypes, function (type) { t.equal( ES.IsBigIntElementType(type.toUpperCase()), true, @@ -16591,7 +16381,7 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { ); }); - forEach(numberTypes, function (type) { + forEach(esV.numberTypes, function (type) { t.equal( ES.IsBigIntElementType(type.toUpperCase()), false, @@ -16603,7 +16393,7 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { }); test('IsFixedLengthArrayBuffer', function (t) { - forEach(unknowns, function (nonAB) { + forEach(esV.unknowns, function (nonAB) { t['throws']( function () { ES.IsFixedLengthArrayBuffer(nonAB); }, TypeError, @@ -16627,7 +16417,7 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { }); test('IsNoTearConfiguration', function (t) { - forEach(unclampedIntegerTypes, function (type) { + forEach(esV.unclampedIntegerTypes, function (type) { t.equal( ES.IsNoTearConfiguration(type.toUpperCase()), true, @@ -16635,7 +16425,7 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { ); }); - forEach(bigIntTypes, function (type) { + forEach(esV.bigIntTypes, function (type) { t.equal( ES.IsNoTearConfiguration(type.toUpperCase(), 'INIT'), false, @@ -16655,7 +16445,7 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { ); }); - forEach(clampedTypes, function (type) { + forEach(esV.clampedTypes, function (type) { t.equal( ES.IsNoTearConfiguration(type.toUpperCase()), false, @@ -16668,7 +16458,7 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { test('IsTypedArrayOutOfBounds', function (t) { forEach([].concat( - unknowns, + esV.unknowns, [[]] ), function (nonTAWBWR) { t['throws']( @@ -16678,7 +16468,7 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { ); }); - t.test('detached buffer', { skip: !canDetach }, function (st) { + t.test('detached buffer', { skip: !esV.canDetach }, function (st) { var ab = new ArrayBuffer(8); var ta = new Uint8Array(ab); @@ -16705,7 +16495,7 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { }); test('IsUnclampedIntegerElementType', function (t) { - forEach(unclampedIntegerTypes, function (type) { + forEach(esV.unclampedIntegerTypes, function (type) { t.equal( ES.IsUnclampedIntegerElementType(type.toUpperCase()), true, @@ -16714,8 +16504,8 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { }); forEach([].concat( - clampedTypes, - nonUnclampedIntegerTypes + esV.clampedTypes, + esV.nonUnclampedIntegerTypes ), function (type) { t.equal( ES.IsUnclampedIntegerElementType(type.toUpperCase()), @@ -16728,7 +16518,7 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { }); test('IsUnsignedElementType', function (t) { - forEach(unsignedElementTypes, function (type) { + forEach(esV.unsignedElementTypes, function (type) { t.equal( ES.IsUnsignedElementType(type.toUpperCase()), true, @@ -16736,7 +16526,7 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { ); }); - forEach(signedElementTypes, function (type) { + forEach(esV.signedElementTypes, function (type) { t.equal( ES.IsUnsignedElementType(type.toUpperCase()), false, @@ -16748,7 +16538,7 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { }); test('IsViewOutOfBounds', function (t) { - forEach(unknowns, function (nonDVWBWRecord) { + forEach(esV.unknowns, function (nonDVWBWRecord) { t['throws']( function () { ES.IsViewOutOfBounds(nonDVWBWRecord); }, TypeError, @@ -16759,7 +16549,7 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { t.test('DataViews supported', { skip: typeof DataView !== 'function' }, function (st) { var ab = new ArrayBuffer(8); - st.test('can detach', { skip: !canDetach }, function (s2t) { + st.test('can detach', { skip: !esV.canDetach }, function (s2t) { var dab = new ArrayBuffer(1); var ddv = new DataView(dab); @@ -16796,7 +16586,7 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { }); test('IteratorStepValue', function (t) { - forEach(unknowns, function (nonIteratorRecord) { + forEach(esV.unknowns, function (nonIteratorRecord) { t['throws']( function () { ES.IteratorStepValue(nonIteratorRecord); }, TypeError, @@ -17036,7 +16826,7 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { }); test('NumericToRawBytes', function (t) { - forEach(nonTATypes, function (nonTAType) { + forEach(esV.nonTATypes, function (nonTAType) { t['throws']( function () { ES.NumericToRawBytes(nonTAType, 0, false); }, TypeError, @@ -17064,8 +16854,8 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { var value = unserialize(testCase.value); t.test(name + ': ' + value, function (st) { - forEach(allTypes, function (type) { - var isBigInt = isBigIntTAType(type); + forEach(esV.allTypes, function (type) { + var isBigInt = esV.isBigIntTAType(type); var hasBigEndian = type !== 'Int8' && type !== 'Uint8' && type !== 'Uint8C'; // the 8-bit types are special, they don't have big-endian var result = testCase[type === 'Uint8C' ? 'Uint8Clamped' : type]; @@ -17107,7 +16897,7 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { }); t.test('BigInt64', function (st) { - st.test('bigints available', { skip: !hasBigInts }, function (s2t) { + st.test('bigints available', { skip: !esV.hasBigInts }, function (s2t) { forEach([ [BigInt(0), [0, 0, 0, 0, 0, 0, 0, 0]], [BigInt(1), [1, 0, 0, 0, 0, 0, 0, 0]], @@ -17149,7 +16939,7 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { }); t.test('BigUint64', function (st) { - st.test('bigints available', { skip: !hasBigInts }, function (s2t) { + st.test('bigints available', { skip: !esV.hasBigInts }, function (s2t) { forEach([ [BigInt(0), [0, 0, 0, 0, 0, 0, 0, 0]], [BigInt(1), [1, 0, 0, 0, 0, 0, 0, 0]], @@ -17194,7 +16984,7 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { }); test('RawBytesToNumeric', function (t) { - forEach(nonTATypes, function (nonTAType) { + forEach(esV.nonTATypes, function (nonTAType) { t['throws']( function () { ES.RawBytesToNumeric(nonTAType, [], false); }, TypeError, @@ -17202,7 +16992,7 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { ); }); - forEach(unknowns, function (nonArray) { + forEach(esV.unknowns, function (nonArray) { t['throws']( function () { ES.RawBytesToNumeric('INT8', nonArray, false); }, TypeError, @@ -17228,7 +17018,7 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { forEach(bufferTestCases, function (testCase, name) { var value = unserialize(testCase.value); t.test(name + ': ' + value, function (st) { - forEach(allTypes, function (type) { + forEach(esV.allTypes, function (type) { var result = testCase[type === 'Uint8C' ? 'Uint8Clamped' : type]; var hasBigEndian = type !== 'Int8' && type !== 'Uint8' && type !== 'Uint8C'; // the 8-bit types are special, they don't have big-endian @@ -17384,7 +17174,7 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { st.end(); }); - t.test('bigint types, no bigints', { skip: hasBigInts }, function (st) { + t.test('bigint types, no bigints', { skip: esV.hasBigInts }, function (st) { st['throws']( function () { ES.RawBytesToNumeric('BIGINT64', [0, 0, 0, 0, 0, 0, 0, 0], false); }, SyntaxError, @@ -17404,7 +17194,7 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { test('SetValueInBuffer', function (t) { var order = 'UNORDERED'; - forEach(unknowns, function (nonAB) { + forEach(esV.unknowns, function (nonAB) { t['throws']( function () { ES.SetValueInBuffer(nonAB, 0, 'INT8', 0, true, order); }, TypeError, @@ -17421,7 +17211,7 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { ); }); - forEach(invalidTATypes, function (invalidType) { + forEach(esV.invalidTATypes, function (invalidType) { st['throws']( function () { ES.SetValueInBuffer(new ArrayBuffer(8), 0, invalidType, 0, true, order); }, TypeError, @@ -17443,7 +17233,7 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { ); }); - if (hasBigInts) { + if (esV.hasBigInts) { st['throws']( function () { ES.SetValueInBuffer(new ArrayBuffer(8), 0, 'INT8', $BigInt(0), true, order); }, TypeError, @@ -17463,7 +17253,7 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { 'invalid order' ); - st.test('can detach', { skip: !canDetach }, function (s2t) { + st.test('can detach', { skip: !esV.canDetach }, function (s2t) { var buffer = new ArrayBuffer(8); s2t.equal(ES.DetachArrayBuffer(buffer), null, 'detaching returns null'); @@ -17479,16 +17269,16 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { }); forEach(bufferTestCases, function (testCase, name) { - forEach(allTypes, function (type) { - var isBigInt = isBigIntTAType(type); + forEach(esV.allTypes, function (type) { + var isBigInt = esV.isBigIntTAType(type); var Z = isBigInt ? safeBigInt : Number; var hasBigEndian = type !== 'Int8' && type !== 'Uint8' && type !== 'Uint8C'; // the 8-bit types are special, they don't have big-endian var result = testCase[type === 'Uint8C' ? 'Uint8Clamped' : type]; var value = unserialize(testCase.value); - var elementSize = elementSizes['$' + (type === 'Uint8C' ? 'Uint8Clamped' : type) + 'Array']; + var elementSize = esV.elementSizes['$' + (type === 'Uint8C' ? 'Uint8Clamped' : type) + 'Array']; - var buffer = new ArrayBuffer(elementSizes.$Float64Array); + var buffer = new ArrayBuffer(esV.elementSizes.$Float64Array); if (isBigInt) { st['throws']( @@ -17644,7 +17434,7 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { }); test('ThisBigIntValue', function (t) { - t.test('actual BigInts', { skip: !hasBigInts }, function (st) { + t.test('actual BigInts', { skip: !esV.hasBigInts }, function (st) { st.equal(ES.ThisBigIntValue(BigInt(42)), BigInt(42)); st.equal(ES.ThisBigIntValue(Object(BigInt(42))), BigInt(42)); @@ -17654,7 +17444,7 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { forEach(v.nonBigInts, function (nonBigInt) { t['throws']( function () { ES.ThisBigIntValue(nonBigInt); }, - hasBigInts ? TypeError : SyntaxError, + esV.hasBigInts ? TypeError : SyntaxError, debug(nonBigInt) + ' is not a BigInt' ); }); @@ -17717,7 +17507,7 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { }); test('ThisSymbolValue', function (t) { - forEach(allButSyms, function (nonSymbol) { + forEach(esV.allButSyms, function (nonSymbol) { t['throws']( function () { ES.ThisSymbolValue(nonSymbol); }, v.hasSymbols ? TypeError : SyntaxError, @@ -17726,7 +17516,7 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { }); t.test('no native Symbols', { skip: v.hasSymbols }, function (st) { - forEach(unknowns, function (value) { + forEach(esV.unknowns, function (value) { st['throws']( function () { ES.ThisSymbolValue(value); }, SyntaxError, @@ -17755,7 +17545,7 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { test('TypedArrayByteLength', function (t) { forEach([].concat( - unknowns, + esV.unknowns, [[]] ), function (nonTAWBWR) { t['throws']( @@ -17772,7 +17562,7 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { var ta = new TA(8); var record = ES.MakeTypedArrayWithBufferWitnessRecord(ta, 'UNORDERED'); - var elementSize = elementSizes['$' + TypedArray]; + var elementSize = esV.elementSizes['$' + TypedArray]; tat.equal(ES.TypedArrayByteLength(record), 8 * elementSize, 'fixed length array, returns byteLength'); @@ -17782,7 +17572,7 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { tat.equal(ES.TypedArrayByteLength(zRecord), 0, 'fixed zero length array, returns zero'); - tat.test('can detach', { skip: !canDetach }, function (s2t) { + tat.test('can detach', { skip: !esV.canDetach }, function (s2t) { ES.DetachArrayBuffer(ta.buffer); record = ES.MakeTypedArrayWithBufferWitnessRecord(ta, 'UNORDERED'); @@ -17907,7 +17697,7 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { }); test('TypedArrayElementType', function (t) { - forEach(unknowns, function (nonTA) { + forEach(esV.unknowns, function (nonTA) { t['throws']( function () { ES.TypedArrayElementType(nonTA); }, TypeError, @@ -17932,7 +17722,7 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { }); test('TypedArrayGetElement', function (t) { - forEach(unknowns, function (nonTA) { + forEach(esV.unknowns, function (nonTA) { t['throws']( function () { ES.TypedArrayGetElement(nonTA, 0); }, TypeError, @@ -17952,7 +17742,7 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { }); forEach(availableTypedArrays, function (TypedArray) { - var isBigInt = isBigIntTAType(TypedArray); + var isBigInt = esV.isBigIntTAType(TypedArray); var Z = isBigInt ? safeBigInt : Number; var TA = global[TypedArray]; @@ -17972,7 +17762,7 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { test('TypedArrayLength', function (t) { forEach([].concat( - unknowns, + esV.unknowns, [[]] ), function (nonTAWBWR) { t['throws']( @@ -17991,7 +17781,7 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { tat.equal(ES.TypedArrayLength(record), 8, 'fixed length array, returns byteLength'); - tat.test('can detach', { skip: !canDetach }, function (s2t) { + tat.test('can detach', { skip: !esV.canDetach }, function (s2t) { ES.DetachArrayBuffer(ta.buffer); record = ES.MakeTypedArrayWithBufferWitnessRecord(ta, 'UNORDERED'); @@ -18007,7 +17797,7 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { // TODO: actual TA byteLength auto, but not fixed length? (may not be possible) - var elementSize = elementSizes['$' + type]; + var elementSize = esV.elementSizes['$' + type]; tat.test( 'non-fixed length, return floor((byteLength - byteOffset) / elementSize)', @@ -18029,7 +17819,7 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { tat.test( 'non-fixed length, detached throws', - { skip: !('resizable' in ArrayBuffer.prototype) || !canDetach }, + { skip: !('resizable' in ArrayBuffer.prototype) || !esV.canDetach }, function (tsat) { var rab = new ArrayBuffer(17, { maxByteLength: 64 }); var arr = new TA(rab, 8); @@ -18063,7 +17853,7 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { }); test('TypedArraySetElement', function (t) { - forEach(unknowns, function (nonTA) { + forEach(esV.unknowns, function (nonTA) { t['throws']( function () { ES.TypedArraySetElement(nonTA, 0, 0); }, TypeError, @@ -18073,7 +17863,7 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { t.test('actual typed arrays', { skip: availableTypedArrays.length === 0 }, function (st) { forEach(availableTypedArrays, function (typedArray) { - var isBigInt = isBigIntTAType(typedArray); + var isBigInt = esV.isBigIntTAType(typedArray); var Z = isBigInt ? safeBigInt : Number; var TA = global[typedArray]; var ta = new TA(16); @@ -18096,7 +17886,7 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { 'non-number/bigint-coercible value ' + debug(v.uncoercibleObject) + ' throws' ); - st.test('can detach', { skip: !canDetach }, function (s2t) { + st.test('can detach', { skip: !esV.canDetach }, function (s2t) { ES.DetachArrayBuffer(ta.buffer); s2t.equal(ta[0], undefined, 'is initially undefined'); @@ -18115,7 +17905,7 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { test('ValidateAtomicAccess', function (t) { forEach([].concat( - unknowns, + esV.unknowns, [[]] ), function (nonTAWBWR) { t['throws']( @@ -18151,7 +17941,7 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { 'a requestIndex > length throws' ); - var elementSize = elementSizes['$' + TypedArray]; + var elementSize = esV.elementSizes['$' + TypedArray]; st.equal(ES.ValidateAtomicAccess(taRecord, 0), elementSize * 0, TypedArray + ': requestIndex of 0 gives 0'); st.equal(ES.ValidateAtomicAccess(taRecord, 1), elementSize * 1, TypedArray + ': requestIndex of 1 gives ' + (elementSize * 1)); @@ -18171,7 +17961,7 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { test('ValidateAtomicAccessOnIntegerTypedArray', function (t) { forEach([].concat( - unknowns, + esV.unknowns, [[]] ), function (nonTA) { t['throws']( @@ -18215,7 +18005,7 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { 'a requestIndex > length throws' ); - var elementSize = elementSizes['$' + TypedArray]; + var elementSize = esV.elementSizes['$' + TypedArray]; st.equal(ES.ValidateAtomicAccessOnIntegerTypedArray(ta, 0), elementSize * 0, TypedArray + ': requestIndex of 0 gives 0'); st.equal(ES.ValidateAtomicAccessOnIntegerTypedArray(ta, 1), elementSize * 1, TypedArray + ': requestIndex of 1 gives ' + (elementSize * 1)); @@ -18265,7 +18055,7 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { }); forEach([].concat( - unknowns, + esV.unknowns, [[]] ), function (nonTA) { t['throws']( @@ -18317,7 +18107,7 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { var order = 'UNORDERED'; forEach([].concat( - unknowns, + esV.unknowns, [[]] ), function (nonTA) { t['throws']( @@ -18335,7 +18125,7 @@ var es2024 = function ES2024(ES, ops, expectedMissing, skips) { debug(ta) + ' is a TypedArray' ); - st.test('can detach', { skip: !canDetach }, function (s2t) { + st.test('can detach', { skip: !esV.canDetach }, function (s2t) { ES.DetachArrayBuffer(ta.buffer); s2t['throws'](