Skip to content

Commit

Permalink
improve some tests
Browse files Browse the repository at this point in the history
  • Loading branch information
zloirock committed Sep 5, 2022
1 parent 6ca3e61 commit ce987cb
Show file tree
Hide file tree
Showing 40 changed files with 149 additions and 173 deletions.
21 changes: 20 additions & 1 deletion tests/helpers/constants.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export const NATIVE = GLOBAL.NATIVE || false;

export const NODE = Object.prototype.toString.call(GLOBAL.process).slice(8, -1) === 'process';

export const TYPED_ARRAYS = {
const $TYPED_ARRAYS = {
Float32Array: 4,
Float64Array: 8,
Int8Array: 1,
Expand All @@ -26,6 +26,25 @@ export const TYPED_ARRAYS = {
Uint8ClampedArray: 1,
};

export const TYPED_ARRAYS = [];

for (const name in $TYPED_ARRAYS) TYPED_ARRAYS.push({
name,
TypedArray: GLOBAL[name],
bytes: $TYPED_ARRAYS[name],
$: Number,
});

export const TYPED_ARRAYS_WITH_BIG_INT = TYPED_ARRAYS.slice();

for (const name of ['BigInt64Array', 'BigUint64Array']) if (GLOBAL[name]) TYPED_ARRAYS_WITH_BIG_INT.push({
name,
TypedArray: GLOBAL[name],
bytes: 8,
// eslint-disable-next-line es-x/no-bigint -- safe
$: BigInt,
});

export const LITTLE_ENDIAN = (() => {
try {
return new GLOBAL.Uint8Array(new GLOBAL.Uint16Array([1]).buffer)[0] === 1;
Expand Down
8 changes: 4 additions & 4 deletions tests/tests/es.array-buffer.is-view.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { GLOBAL, TYPED_ARRAYS } from '../helpers/constants';
import { TYPED_ARRAYS } from '../helpers/constants';

QUnit.test('ArrayBuffer.isView', assert => {
const { isView } = ArrayBuffer;
Expand All @@ -7,9 +7,9 @@ QUnit.test('ArrayBuffer.isView', assert => {
assert.name(isView, 'isView');
assert.looksNative(isView);
assert.nonEnumerable(ArrayBuffer, 'isView');
for (const name in TYPED_ARRAYS) {
if (GLOBAL[name]) {
assert.true(isView(new GLOBAL[name]([1])), `${ name } - true`);
for (const { name, TypedArray } of TYPED_ARRAYS) {
if (TypedArray) {
assert.true(isView(new TypedArray([1])), `${ name } - true`);
}
}
assert.true(isView(new DataView(new ArrayBuffer(1))), 'DataView - true');
Expand Down
13 changes: 6 additions & 7 deletions tests/tests/es.typed-array.at.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,13 @@
import { DESCRIPTORS, GLOBAL, TYPED_ARRAYS } from '../helpers/constants';
import { DESCRIPTORS, TYPED_ARRAYS } from '../helpers/constants';

if (DESCRIPTORS) QUnit.test('%TypedArrayPrototype%.indexOf', assert => {
// we can't implement %TypedArrayPrototype% in all engines, so run all tests for each typed array constructor
for (const name in TYPED_ARRAYS) {
const TypedArray = GLOBAL[name];
for (const { name, TypedArray } of TYPED_ARRAYS) {
const { at } = TypedArray.prototype;
assert.isFunction(at);
assert.arity(at, 1);
assert.name(at, 'at');
assert.looksNative(at);
assert.isFunction(at, `${ name }::at is function`);
assert.arity(at, 1, `${ name }::at arity is 1`);
assert.name(at, 'at', `${ name }::at name is 'at'`);
assert.looksNative(at, `${ name }::at looks native`);
assert.same(1, new TypedArray([1, 2, 3]).at(0));
assert.same(2, new TypedArray([1, 2, 3]).at(1));
assert.same(3, new TypedArray([1, 2, 3]).at(2));
Expand Down
8 changes: 2 additions & 6 deletions tests/tests/es.typed-array.constructors.js
Original file line number Diff line number Diff line change
@@ -1,14 +1,10 @@
import { DESCRIPTORS, GLOBAL, NATIVE, TYPED_ARRAYS } from '../helpers/constants';
import { DESCRIPTORS, NATIVE, TYPED_ARRAYS } from '../helpers/constants';
import { createIterable } from '../helpers/helpers';

const Symbol = GLOBAL.Symbol || {};
const { keys, getOwnPropertyDescriptor, getPrototypeOf, defineProperty, assign } = Object;

if (DESCRIPTORS) {
for (const name in TYPED_ARRAYS) {
const bytes = TYPED_ARRAYS[name];
const TypedArray = GLOBAL[name];

for (const { name, TypedArray, bytes } of TYPED_ARRAYS) {
QUnit.test(`${ name } constructor`, assert => {
assert.isFunction(TypedArray);
assert.arity(TypedArray, 3);
Expand Down
5 changes: 2 additions & 3 deletions tests/tests/es.typed-array.copy-within.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { DESCRIPTORS, GLOBAL, TYPED_ARRAYS } from '../helpers/constants';
import { DESCRIPTORS, TYPED_ARRAYS } from '../helpers/constants';

if (DESCRIPTORS) QUnit.test('%TypedArrayPrototype%.copyWithin', assert => {
// we can't implement %TypedArrayPrototype% in all engines, so run all tests for each typed array constructor
for (const name in TYPED_ARRAYS) {
const TypedArray = GLOBAL[name];
for (const { name, TypedArray } of TYPED_ARRAYS) {
const { copyWithin } = TypedArray.prototype;
assert.isFunction(copyWithin, `${ name }::copyWithin is function`);
assert.arity(copyWithin, 2, `${ name }::copyWithin arity is 2`);
Expand Down
5 changes: 2 additions & 3 deletions tests/tests/es.typed-array.every.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { DESCRIPTORS, GLOBAL, TYPED_ARRAYS } from '../helpers/constants';
import { DESCRIPTORS, TYPED_ARRAYS } from '../helpers/constants';

if (DESCRIPTORS) QUnit.test('%TypedArrayPrototype%.every', assert => {
// we can't implement %TypedArrayPrototype% in all engines, so run all tests for each typed array constructor
for (const name in TYPED_ARRAYS) {
const TypedArray = GLOBAL[name];
for (const { name, TypedArray } of TYPED_ARRAYS) {
const { every } = TypedArray.prototype;
assert.isFunction(every, `${ name }::every is function`);
assert.arity(every, 1, `${ name }::every arity is 1`);
Expand Down
5 changes: 2 additions & 3 deletions tests/tests/es.typed-array.fill.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
import { createConversionChecker } from '../helpers/helpers';
import { DESCRIPTORS, GLOBAL, TYPED_ARRAYS } from '../helpers/constants';
import { DESCRIPTORS, TYPED_ARRAYS } from '../helpers/constants';

if (DESCRIPTORS) QUnit.test('%TypedArrayPrototype%.fill', assert => {
// we can't implement %TypedArrayPrototype% in all engines, so run all tests for each typed array constructor
for (const name in TYPED_ARRAYS) {
const TypedArray = GLOBAL[name];
for (const { name, TypedArray } of TYPED_ARRAYS) {
const { fill } = TypedArray.prototype;
assert.isFunction(fill, `${ name }::fill is function`);
assert.arity(fill, 1, `${ name }::fill arity is 1`);
Expand Down
5 changes: 2 additions & 3 deletions tests/tests/es.typed-array.filter.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { DESCRIPTORS, GLOBAL, TYPED_ARRAYS } from '../helpers/constants';
import { DESCRIPTORS, TYPED_ARRAYS } from '../helpers/constants';

if (DESCRIPTORS) QUnit.test('%TypedArrayPrototype%.filter', assert => {
// we can't implement %TypedArrayPrototype% in all engines, so run all tests for each typed array constructor
for (const name in TYPED_ARRAYS) {
const TypedArray = GLOBAL[name];
for (const { name, TypedArray } of TYPED_ARRAYS) {
const { filter } = TypedArray.prototype;
assert.isFunction(filter, `${ name }::filter is function`);
assert.arity(filter, 1, `${ name }::filter arity is 1`);
Expand Down
5 changes: 2 additions & 3 deletions tests/tests/es.typed-array.find-index.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { DESCRIPTORS, GLOBAL, TYPED_ARRAYS } from '../helpers/constants';
import { DESCRIPTORS, TYPED_ARRAYS } from '../helpers/constants';

if (DESCRIPTORS) QUnit.test('%TypedArrayPrototype%.findIndex', assert => {
// we can't implement %TypedArrayPrototype% in all engines, so run all tests for each typed array constructor
for (const name in TYPED_ARRAYS) {
const TypedArray = GLOBAL[name];
for (const { name, TypedArray } of TYPED_ARRAYS) {
const { findIndex } = TypedArray.prototype;
assert.isFunction(findIndex, `${ name }::findIndex is function`);
assert.arity(findIndex, 1, `${ name }::findIndex arity is 1`);
Expand Down
5 changes: 2 additions & 3 deletions tests/tests/es.typed-array.find.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { DESCRIPTORS, GLOBAL, TYPED_ARRAYS } from '../helpers/constants';
import { DESCRIPTORS, TYPED_ARRAYS } from '../helpers/constants';

if (DESCRIPTORS) QUnit.test('%TypedArrayPrototype%.find', assert => {
// we can't implement %TypedArrayPrototype% in all engines, so run all tests for each typed array constructor
for (const name in TYPED_ARRAYS) {
const TypedArray = GLOBAL[name];
for (const { name, TypedArray } of TYPED_ARRAYS) {
const { find } = TypedArray.prototype;
assert.isFunction(find, `${ name }::find is function`);
assert.arity(find, 1, `${ name }::find arity is 1`);
Expand Down
5 changes: 2 additions & 3 deletions tests/tests/es.typed-array.for-each.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { DESCRIPTORS, GLOBAL, TYPED_ARRAYS } from '../helpers/constants';
import { DESCRIPTORS, TYPED_ARRAYS } from '../helpers/constants';

if (DESCRIPTORS) QUnit.test('%TypedArrayPrototype%.forEach', assert => {
// we can't implement %TypedArrayPrototype% in all engines, so run all tests for each typed array constructor
for (const name in TYPED_ARRAYS) {
const TypedArray = GLOBAL[name];
for (const { name, TypedArray } of TYPED_ARRAYS) {
const { forEach } = TypedArray.prototype;
assert.isFunction(forEach, `${ name }::forEach is function`);
assert.arity(forEach, 1, `${ name }::forEach arity is 1`);
Expand Down
34 changes: 17 additions & 17 deletions tests/tests/es.typed-array.from.js
Original file line number Diff line number Diff line change
@@ -1,44 +1,44 @@
import { DESCRIPTORS, GLOBAL, NATIVE, TYPED_ARRAYS } from '../helpers/constants';
import { DESCRIPTORS, NATIVE, TYPED_ARRAYS_WITH_BIG_INT } from '../helpers/constants';
import { createIterable } from '../helpers/helpers';

if (DESCRIPTORS) QUnit.test('%TypedArray%.from', assert => {
// we can't implement %TypedArray% in all engines, so run all tests for each typed array constructor
for (const name in TYPED_ARRAYS) {
const TypedArray = GLOBAL[name];
for (const { name, TypedArray, $ } of TYPED_ARRAYS_WITH_BIG_INT) {
assert.isFunction(TypedArray.from, `${ name }.from is function`);
assert.arity(TypedArray.from, 1, `${ name }.from arity is 1`);
assert.name(TypedArray.from, 'from', `${ name }.from name is 'from'`);
assert.looksNative(TypedArray.from, `${ name }.from looks native`);
let instance = TypedArray.from([1, 2, 3]);
let instance = TypedArray.from([$(1), $(2), $(3)]);
assert.true(instance instanceof TypedArray, 'correct instance with array');
assert.arrayEqual(instance, [1, 2, 3], 'correct elements with array');
assert.deepEqual(instance, new TypedArray([$(1), $(2), $(3)]), 'correct elements with array');
instance = TypedArray.from({
0: 1,
1: 2,
2: 3,
0: $(1),
1: $(2),
2: $(3),
length: 3,
});
assert.true(instance instanceof TypedArray, 'correct instance with array-like');
assert.arrayEqual(instance, [1, 2, 3], 'correct elements with array-like');
instance = TypedArray.from(createIterable([1, 2, 3]));
assert.deepEqual(instance, new TypedArray([$(1), $(2), $(3)]), 'correct elements with array-like');
instance = TypedArray.from(createIterable([$(1), $(2), $(3)]));
assert.true(instance instanceof TypedArray, 'correct instance with iterable');
assert.arrayEqual(instance, [1, 2, 3], 'correct elements with iterable');
assert.arrayEqual(TypedArray.from([1, 2, 3], it => it * it), [1, 4, 9], 'accept callback');
assert.arrayEqual(TypedArray.from([{ valueOf() { return 2; } }]), [2], 'passed array with object convertible to primitive');
assert.arrayEqual(TypedArray.from(createIterable([{ valueOf() { return 2; } }])), [2], 'passed iterable with object convertible to primitive');
assert.deepEqual(instance, new TypedArray([$(1), $(2), $(3)]), 'correct elements with iterable');
assert.deepEqual(TypedArray.from([1, 2, 3], it => String(it * it)), new TypedArray([$(1), $(4), $(9)]), 'accept callback');
assert.deepEqual(TypedArray.from([{ valueOf() { return $(2); } }]), new TypedArray([$(2)]), 'passed array with object convertible to primitive');
assert.deepEqual(TypedArray.from(createIterable([{ valueOf() { return $(2); } }])), new TypedArray([$(2)]), 'passed iterable with object convertible to primitive');
const context = {};
TypedArray.from([1], function (value, key) {
TypedArray.from([$(1)], function (value, key) {
assert.same(arguments.length, 2, 'correct number of callback arguments');
assert.same(value, 1, 'correct value in callback');
assert.same(value, $(1), 'correct value in callback');
assert.same(key, 0, 'correct index in callback');
assert.same(this, context, 'correct callback context');
return $(1);
}, context);
assert.throws(() => TypedArray.from.call(undefined, []), "isn't generic #1");
if (NATIVE) {
assert.throws(() => TypedArray.from.call(Array, []), "isn't generic #2");
assert.notThrows(() => TypedArray.from({
0: $(1),
length: -1,
0: 1,
}, () => {
throw new Error();
}), 'uses ToLength');
Expand Down
5 changes: 2 additions & 3 deletions tests/tests/es.typed-array.includes.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { DESCRIPTORS, GLOBAL, TYPED_ARRAYS } from '../helpers/constants';
import { DESCRIPTORS, TYPED_ARRAYS } from '../helpers/constants';

if (DESCRIPTORS) QUnit.test('%TypedArrayPrototype%.includes', assert => {
// we can't implement %TypedArrayPrototype% in all engines, so run all tests for each typed array constructor
for (const name in TYPED_ARRAYS) {
const TypedArray = GLOBAL[name];
for (const { name, TypedArray } of TYPED_ARRAYS) {
const { includes } = TypedArray.prototype;
assert.isFunction(includes, `${ name }::includes is function`);
assert.arity(includes, 1, `${ name }::includes arity is 1`);
Expand Down
5 changes: 2 additions & 3 deletions tests/tests/es.typed-array.index-of.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { DESCRIPTORS, GLOBAL, TYPED_ARRAYS } from '../helpers/constants';
import { DESCRIPTORS, TYPED_ARRAYS } from '../helpers/constants';

if (DESCRIPTORS) QUnit.test('%TypedArrayPrototype%.indexOf', assert => {
// we can't implement %TypedArrayPrototype% in all engines, so run all tests for each typed array constructor
for (const name in TYPED_ARRAYS) {
const TypedArray = GLOBAL[name];
for (const { name, TypedArray } of TYPED_ARRAYS) {
const { indexOf } = TypedArray.prototype;
assert.isFunction(indexOf, `${ name }::indexOf is function`);
assert.arity(indexOf, 1, `${ name }::indexOf arity is 1`);
Expand Down
12 changes: 4 additions & 8 deletions tests/tests/es.typed-array.iterator.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,7 @@ const Symbol = GLOBAL.Symbol || {};

if (DESCRIPTORS) QUnit.test('%TypedArrayPrototype%.keys', assert => {
// we can't implement %TypedArrayPrototype% in all engines, so run all tests for each typed array constructor
for (const name in TYPED_ARRAYS) {
const TypedArray = GLOBAL[name];
for (const { name, TypedArray } of TYPED_ARRAYS) {
const { keys } = TypedArray.prototype;
assert.isFunction(keys, `${ name }::keys is function`);
assert.arity(keys, 0, `${ name }::keys arity is 0`);
Expand Down Expand Up @@ -37,8 +36,7 @@ if (DESCRIPTORS) QUnit.test('%TypedArrayPrototype%.keys', assert => {

if (DESCRIPTORS) QUnit.test('%TypedArrayPrototype%.values', assert => {
// we can't implement %TypedArrayPrototype% in all engines, so run all tests for each typed array constructor
for (const name in TYPED_ARRAYS) {
const TypedArray = GLOBAL[name];
for (const { name, TypedArray } of TYPED_ARRAYS) {
const { values } = TypedArray.prototype;
assert.isFunction(values, `${ name }::values is function`);
assert.arity(values, 0, `${ name }::values arity is 0`);
Expand Down Expand Up @@ -70,8 +68,7 @@ if (DESCRIPTORS) QUnit.test('%TypedArrayPrototype%.values', assert => {

if (DESCRIPTORS) QUnit.test('%TypedArrayPrototype%.entries', assert => {
// we can't implement %TypedArrayPrototype% in all engines, so run all tests for each typed array constructor
for (const name in TYPED_ARRAYS) {
const TypedArray = GLOBAL[name];
for (const { name, TypedArray } of TYPED_ARRAYS) {
const { entries } = TypedArray.prototype;
assert.isFunction(entries, `${ name }::entries is function`);
assert.arity(entries, 0, `${ name }::entries arity is 0`);
Expand Down Expand Up @@ -103,8 +100,7 @@ if (DESCRIPTORS) QUnit.test('%TypedArrayPrototype%.entries', assert => {

if (DESCRIPTORS) QUnit.test('%TypedArrayPrototype%.@@iterator', assert => {
// we can't implement %TypedArrayPrototype% in all engines, so run all tests for each typed array constructor
for (const name in TYPED_ARRAYS) {
const TypedArray = GLOBAL[name];
for (const { name, TypedArray } of TYPED_ARRAYS) {
assert.isIterable(TypedArray.prototype, `${ name } is iterable`);
assert.arity(TypedArray.prototype[Symbol.iterator], 0, `${ name }::@@iterator arity is 0`);
assert.name(TypedArray.prototype[Symbol.iterator], 'values', `${ name }::@@iterator name is 'values'`);
Expand Down
5 changes: 2 additions & 3 deletions tests/tests/es.typed-array.join.js
Original file line number Diff line number Diff line change
@@ -1,10 +1,9 @@
/* eslint-disable unicorn/require-array-join-separator -- required for testing */
import { DESCRIPTORS, GLOBAL, TYPED_ARRAYS } from '../helpers/constants';
import { DESCRIPTORS, TYPED_ARRAYS } from '../helpers/constants';

if (DESCRIPTORS) QUnit.test('%TypedArrayPrototype%.join', assert => {
// we can't implement %TypedArrayPrototype% in all engines, so run all tests for each typed array constructor
for (const name in TYPED_ARRAYS) {
const TypedArray = GLOBAL[name];
for (const { name, TypedArray } of TYPED_ARRAYS) {
const { join } = TypedArray.prototype;
assert.isFunction(join, `${ name }::join is function`);
assert.arity(join, 1, `${ name }::join arity is 1`);
Expand Down
5 changes: 2 additions & 3 deletions tests/tests/es.typed-array.last-index-of.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { DESCRIPTORS, GLOBAL, TYPED_ARRAYS } from '../helpers/constants';
import { DESCRIPTORS, TYPED_ARRAYS } from '../helpers/constants';

if (DESCRIPTORS) QUnit.test('%TypedArrayPrototype%.lastIndexOf', assert => {
// we can't implement %TypedArrayPrototype% in all engines, so run all tests for each typed array constructor
for (const name in TYPED_ARRAYS) {
const TypedArray = GLOBAL[name];
for (const { name, TypedArray } of TYPED_ARRAYS) {
const { lastIndexOf } = TypedArray.prototype;
assert.isFunction(lastIndexOf, `${ name }::lastIndexOf is function`);
assert.arity(lastIndexOf, 1, `${ name }::lastIndexOf arity is 1`);
Expand Down
5 changes: 2 additions & 3 deletions tests/tests/es.typed-array.map.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { DESCRIPTORS, GLOBAL, TYPED_ARRAYS } from '../helpers/constants';
import { DESCRIPTORS, TYPED_ARRAYS } from '../helpers/constants';

if (DESCRIPTORS) QUnit.test('%TypedArrayPrototype%.map', assert => {
// we can't implement %TypedArrayPrototype% in all engines, so run all tests for each typed array constructor
for (const name in TYPED_ARRAYS) {
const TypedArray = GLOBAL[name];
for (const { name, TypedArray } of TYPED_ARRAYS) {
const { map } = TypedArray.prototype;
assert.isFunction(map, `${ name }::map is function`);
assert.arity(map, 1, `${ name }::map arity is 1`);
Expand Down
5 changes: 2 additions & 3 deletions tests/tests/es.typed-array.of.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { DESCRIPTORS, GLOBAL, NATIVE, TYPED_ARRAYS } from '../helpers/constants';
import { DESCRIPTORS, NATIVE, TYPED_ARRAYS } from '../helpers/constants';

if (DESCRIPTORS) QUnit.test('%TypedArray%.of', assert => {
// we can't implement %TypedArray% in all engines, so run all tests for each typed array constructor
for (const name in TYPED_ARRAYS) {
const TypedArray = GLOBAL[name];
for (const { name, TypedArray } of TYPED_ARRAYS) {
assert.isFunction(TypedArray.of, `${ name }.of is function`);
assert.arity(TypedArray.of, 0, `${ name }.of arity is 0`);
assert.name(TypedArray.of, 'of', `${ name }.of name is 'of'`);
Expand Down
5 changes: 2 additions & 3 deletions tests/tests/es.typed-array.reduce-right.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { DESCRIPTORS, GLOBAL, TYPED_ARRAYS } from '../helpers/constants';
import { DESCRIPTORS, TYPED_ARRAYS } from '../helpers/constants';

if (DESCRIPTORS) QUnit.test('%TypedArrayPrototype%.reduceRight', assert => {
// we can't implement %TypedArrayPrototype% in all engines, so run all tests for each typed array constructor
for (const name in TYPED_ARRAYS) {
const TypedArray = GLOBAL[name];
for (const { name, TypedArray } of TYPED_ARRAYS) {
const { reduceRight } = TypedArray.prototype;
assert.isFunction(reduceRight, `${ name }::reduceRight is function`);
assert.arity(reduceRight, 1, `${ name }::reduceRight arity is 1`);
Expand Down
5 changes: 2 additions & 3 deletions tests/tests/es.typed-array.reduce.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { DESCRIPTORS, GLOBAL, TYPED_ARRAYS } from '../helpers/constants';
import { DESCRIPTORS, TYPED_ARRAYS } from '../helpers/constants';

if (DESCRIPTORS) QUnit.test('%TypedArrayPrototype%.reduce', assert => {
// we can't implement %TypedArrayPrototype% in all engines, so run all tests for each typed array constructor
for (const name in TYPED_ARRAYS) {
const TypedArray = GLOBAL[name];
for (const { name, TypedArray } of TYPED_ARRAYS) {
const { reduce } = TypedArray.prototype;
assert.isFunction(reduce, `${ name }::reduce is function`);
assert.arity(reduce, 1, `${ name }::reduce arity is 1`);
Expand Down
5 changes: 2 additions & 3 deletions tests/tests/es.typed-array.reverse.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,8 @@
import { DESCRIPTORS, GLOBAL, TYPED_ARRAYS } from '../helpers/constants';
import { DESCRIPTORS, TYPED_ARRAYS } from '../helpers/constants';

if (DESCRIPTORS) QUnit.test('%TypedArrayPrototype%.reverse', assert => {
// we can't implement %TypedArrayPrototype% in all engines, so run all tests for each typed array constructor
for (const name in TYPED_ARRAYS) {
const TypedArray = GLOBAL[name];
for (const { name, TypedArray } of TYPED_ARRAYS) {
const { reverse } = TypedArray.prototype;
assert.isFunction(reverse, `${ name }::reverse is function`);
assert.arity(reverse, 0, `${ name }::reverse arity is 0`);
Expand Down

0 comments on commit ce987cb

Please sign in to comment.