Skip to content

Commit

Permalink
refactor tests
Browse files Browse the repository at this point in the history
  • Loading branch information
zloirock committed Dec 9, 2021
1 parent 1bee4f2 commit 5fd4508
Show file tree
Hide file tree
Showing 12 changed files with 29 additions and 29 deletions.
4 changes: 2 additions & 2 deletions tests/pure/esnext.array.to-reversed.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ QUnit.test('Array#toReversed', assert => {
assert.isFunction(toReversed);

let array = [1, 2];
assert.notStrictEqual(toReversed(array), array, 'immutable');
assert.notSame(toReversed(array), array, 'immutable');
assert.deepEqual(toReversed([1, 2.2, 3.3]), [3.3, 2.2, 1], 'basic');

const object = {};
Expand Down Expand Up @@ -47,7 +47,7 @@ QUnit.test('Array#toReversed', assert => {
array.constructor = { [Symbol.species]: function () {
return { foo: 1 };
} };
assert.ok(toReversed(array) instanceof Array, 'non-generic');
assert.true(toReversed(array) instanceof Array, 'non-generic');

if (STRICT) {
assert.throws(() => toReversed(null, () => { /* empty */ }, 1), TypeError);
Expand Down
8 changes: 4 additions & 4 deletions tests/pure/esnext.array.to-sorted.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ QUnit.test('Array#toSorted', assert => {
assert.isFunction(toSorted);

let array = [1];
assert.notStrictEqual(toSorted(array), array, 'immutable');
assert.notSame(toSorted(array), array, 'immutable');
assert.deepEqual(toSorted([1, 3, 2]), [1, 2, 3], '#1');
assert.deepEqual(toSorted([1, 3, 2, 11]), [1, 11, 2, 3], '#2');
assert.deepEqual(toSorted([1, -1, 3, NaN, 2, 0, 11, -0]), [-1, 0, -0, 1, 11, 2, 3, NaN], '#1');
Expand Down Expand Up @@ -79,9 +79,9 @@ QUnit.test('Array#toSorted', assert => {
expected[index] = index - 2 * mod + 3;
}

assert.same(String(toSorted(array, (a, b) => (a / 4 | 0) - (b / 4 | 0))), String(expected), 'stable #1');
assert.arrayEqual(toSorted(array, (a, b) => (a / 4 | 0) - (b / 4 | 0)), expected, 'stable #1');

assert.ok(1 / toSorted([0, -0])[0] > 0, '-0');
assert.true(1 / toSorted([0, -0])[0] > 0, '-0');

let result = '';
array = [];
Expand Down Expand Up @@ -123,7 +123,7 @@ QUnit.test('Array#toSorted', assert => {
array.constructor = { [Symbol.species]: function () {
return { foo: 1 };
} };
assert.ok(toSorted(array) instanceof Array, 'non-generic');
assert.true(toSorted(array) instanceof Array, 'non-generic');

if (STRICT) {
assert.throws(() => toSorted(null), TypeError, 'ToObject(this)');
Expand Down
4 changes: 2 additions & 2 deletions tests/pure/esnext.array.to-spliced.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ QUnit.test('Array#toSpliced', assert => {
assert.isFunction(toSpliced);

let array = [1, 2, 3, 4, 5];
assert.notStrictEqual(toSpliced(array, 2), array);
assert.notSame(toSpliced(array, 2), array);
assert.deepEqual(toSpliced([1, 2, 3, 4, 5], 2), [1, 2]);
assert.deepEqual(toSpliced([1, 2, 3, 4, 5], -2), [1, 2, 3]);
assert.deepEqual(toSpliced([1, 2, 3, 4, 5], 2, 2), [1, 2, 5]);
Expand All @@ -24,5 +24,5 @@ QUnit.test('Array#toSpliced', assert => {
array.constructor = { [Symbol.species]: function () {
return { foo: 1 };
} };
assert.ok(toSpliced(array) instanceof Array, 'non-generic');
assert.true(toSpliced(array) instanceof Array, 'non-generic');
});
4 changes: 2 additions & 2 deletions tests/pure/esnext.array.with.js
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ QUnit.test('Array#with', assert => {
assert.isFunction(withAt);

let array = [1, 2, 3, 4, 5];
assert.notStrictEqual(withAt(array, 2, 1), array);
assert.notSame(withAt(array, 2, 1), array);
assert.deepEqual(withAt([1, 2, 3, 4, 5], 2, 6), [1, 2, 6, 4, 5]);
assert.deepEqual(withAt([1, 2, 3, 4, 5], -2, 6), [1, 2, 3, 6, 5]);

Expand All @@ -25,5 +25,5 @@ QUnit.test('Array#with', assert => {
array.constructor = { [Symbol.species]: function () {
return { foo: 1 };
} };
assert.ok(withAt(array, 1, 2) instanceof Array, 'non-generic');
assert.true(withAt(array, 1, 2) instanceof Array, 'non-generic');
});
6 changes: 3 additions & 3 deletions tests/tests/esnext.array.to-reversed.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ QUnit.test('Array#toReversed', assert => {
assert.nonEnumerable(Array.prototype, 'toReversed');

let array = [1, 2];
assert.notStrictEqual(array.toReversed(), array, 'immutable');
assert.notSame(array.toReversed(), array, 'immutable');

assert.deepEqual([1, 2.2, 3.3].toReversed(), [3.3, 2.2, 1], 'basic');

Expand Down Expand Up @@ -51,12 +51,12 @@ QUnit.test('Array#toReversed', assert => {
array.constructor = { [Symbol.species]: function () {
return { foo: 1 };
} };
assert.ok(array.toReversed() instanceof Array, 'non-generic');
assert.true(array.toReversed() instanceof Array, 'non-generic');

if (STRICT) {
assert.throws(() => toReversed.call(null, () => { /* empty */ }, 1), TypeError);
assert.throws(() => toReversed.call(undefined, () => { /* empty */ }, 1), TypeError);
}

assert.ok('toReversed' in Array.prototype[Symbol.unscopables], 'In Array#@@unscopables');
assert.true('toReversed' in Array.prototype[Symbol.unscopables], 'In Array#@@unscopables');
});
10 changes: 5 additions & 5 deletions tests/tests/esnext.array.to-sorted.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ QUnit.test('Array#toSorted', assert => {
assert.nonEnumerable(Array.prototype, 'toSorted');

let array = [1];
assert.notStrictEqual(array.toSorted(), array, 'immutable');
assert.notSame(array.toSorted(), array, 'immutable');

assert.deepEqual([1, 3, 2].toSorted(), [1, 2, 3], '#1');
assert.deepEqual([1, 3, 2, 11].toSorted(), [1, 11, 2, 3], '#2');
Expand Down Expand Up @@ -83,9 +83,9 @@ QUnit.test('Array#toSorted', assert => {
expected[index] = index - 2 * mod + 3;
}

assert.same(String(array.toSorted((a, b) => (a / 4 | 0) - (b / 4 | 0))), String(expected), 'stable #1');
assert.arrayEqual(array.toSorted((a, b) => (a / 4 | 0) - (b / 4 | 0)), expected, 'stable #1');

assert.ok(1 / [0, -0].toSorted()[0] > 0, '-0');
assert.true(1 / [0, -0].toSorted()[0] > 0, '-0');

let result = '';
array = [];
Expand Down Expand Up @@ -127,12 +127,12 @@ QUnit.test('Array#toSorted', assert => {
array.constructor = { [Symbol.species]: function () {
return { foo: 1 };
} };
assert.ok(array.toSorted() instanceof Array, 'non-generic');
assert.true(array.toSorted() instanceof Array, 'non-generic');

if (STRICT) {
assert.throws(() => toSorted.call(null), TypeError, 'ToObject(this)');
assert.throws(() => toSorted.call(undefined), TypeError, 'ToObject(this)');
}

assert.ok('toSorted' in Array.prototype[Symbol.unscopables], 'In Array#@@unscopables');
assert.true('toSorted' in Array.prototype[Symbol.unscopables], 'In Array#@@unscopables');
});
6 changes: 3 additions & 3 deletions tests/tests/esnext.array.to-spliced.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ QUnit.test('Array#toSpliced', assert => {
assert.nonEnumerable(Array.prototype, 'toSpliced');

let array = [1, 2, 3, 4, 5];
assert.notStrictEqual(array.toSpliced(2), array, 'immutable');
assert.notSame(array.toSpliced(2), array, 'immutable');

assert.deepEqual([1, 2, 3, 4, 5].toSpliced(2), [1, 2]);
assert.deepEqual([1, 2, 3, 4, 5].toSpliced(-2), [1, 2, 3]);
Expand All @@ -28,7 +28,7 @@ QUnit.test('Array#toSpliced', assert => {
return { foo: 1 };
} };

assert.ok(array.toSpliced() instanceof Array, 'non-generic');
assert.true(array.toSpliced() instanceof Array, 'non-generic');

assert.ok('toSpliced' in Array.prototype[Symbol.unscopables], 'In Array#@@unscopables');
assert.true('toSpliced' in Array.prototype[Symbol.unscopables], 'In Array#@@unscopables');
});
4 changes: 2 additions & 2 deletions tests/tests/esnext.array.with.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ QUnit.test('Array#with', assert => {
assert.nonEnumerable(Array.prototype, 'with');

let array = [1, 2, 3, 4, 5];
assert.notStrictEqual(array.with(2, 1), array, 'immutable');
assert.notSame(array.with(2, 1), array, 'immutable');

assert.deepEqual([1, 2, 3, 4, 5].with(2, 6), [1, 2, 6, 4, 5]);
assert.deepEqual([1, 2, 3, 4, 5].with(-2, 6), [1, 2, 3, 6, 5]);
Expand All @@ -29,5 +29,5 @@ QUnit.test('Array#with', assert => {
array.constructor = { [Symbol.species]: function () {
return { foo: 1 };
} };
assert.ok(array.with(1, 2) instanceof Array, 'non-generic');
assert.true(array.with(1, 2) instanceof Array, 'non-generic');
});
2 changes: 1 addition & 1 deletion tests/tests/esnext.typed-array.to-reversed.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ if (DESCRIPTORS) QUnit.test('%TypedArrayPrototype%.toReversed', assert => {
assert.looksNative(toReversed, `${ name }::toReversed looks native`);

const array = new TypedArray([1, 2]);
assert.notStrictEqual(array.toReversed(), array, 'immutable');
assert.notSame(array.toReversed(), array, 'immutable');
assert.arrayEqual(new TypedArray([1, 2, 3, 4]).toReversed(), [4, 3, 2, 1], 'works #1');
assert.arrayEqual(new TypedArray([1, 2, 3]).toReversed(), [3, 2, 1], 'works #2');

Expand Down
6 changes: 3 additions & 3 deletions tests/tests/esnext.typed-array.to-sorted.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,11 +12,11 @@ if (DESCRIPTORS) QUnit.test('%TypedArrayPrototype%.toSorted', assert => {
assert.looksNative(toSorted, `${ name }::toSorted looks native`);

let array = new TypedArray([1]);
assert.notStrictEqual(array.toSorted(), array, 'immutable');
assert.notSame(array.toSorted(), array, 'immutable');

if (name.indexOf('Float') === 0) {
assert.deepEqual(new TypedArray([1, -1, 3, NaN, 2, 0, 11, -0]).toSorted(), new TypedArray([-1, -0, 0, 1, 2, 3, 11, NaN]), '#1');
assert.ok(1 / new TypedArray([0, -0]).toSorted()[0] < 0, '-0');
assert.true(1 / new TypedArray([0, -0]).toSorted()[0] < 0, '-0');
assert.deepEqual(new TypedArray([NaN, 1, NaN]).toSorted(), new TypedArray([1, NaN, NaN]), 'NaN');
}

Expand All @@ -33,7 +33,7 @@ if (DESCRIPTORS) QUnit.test('%TypedArrayPrototype%.toSorted', assert => {

array = array.toSorted((a, b) => (a / 4 | 0) - (b / 4 | 0));

assert.same(String(array), String(expected), 'stable #1');
assert.arrayEqual(array, expected, 'stable #1');

let result = '';
array = new TypedArray(520);
Expand Down
2 changes: 1 addition & 1 deletion tests/tests/esnext.typed-array.to-spliced.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ if (DESCRIPTORS) QUnit.test('%TypedArrayPrototype%.toSpliced', assert => {
assert.looksNative(toSpliced, `${ name }::toSpliced looks native`);

const array = new TypedArray([1, 2, 3, 4, 5]);
assert.notStrictEqual(array.toSpliced(2), array, 'immutable');
assert.notSame(array.toSpliced(2), array, 'immutable');

assert.deepEqual(new TypedArray([1, 2, 3, 4, 5]).toSpliced(2), new TypedArray([1, 2]));
assert.deepEqual(new TypedArray([1, 2, 3, 4, 5]).toSpliced(-2), new TypedArray([1, 2, 3]));
Expand Down
2 changes: 1 addition & 1 deletion tests/tests/esnext.typed-array.with.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@ if (DESCRIPTORS) QUnit.test('%TypedArrayPrototype%.with', assert => {
assert.looksNative(withAt, `${ name }::with looks native`);

const array = new TypedArray([1, 2, 3, 4, 5]);
assert.notStrictEqual(array.with(2, 1), array, 'immutable');
assert.notSame(array.with(2, 1), array, 'immutable');

assert.deepEqual(new TypedArray([1, 2, 3, 4, 5]).with(2, 6), new TypedArray([1, 2, 6, 4, 5]));
assert.deepEqual(new TypedArray([1, 2, 3, 4, 5]).with(-2, 6), new TypedArray([1, 2, 3, 6, 5]));
Expand Down

0 comments on commit 5fd4508

Please sign in to comment.