Skip to content

Commit

Permalink
change the way disabling of some asserts, fix a typo
Browse files Browse the repository at this point in the history
  • Loading branch information
zloirock committed Nov 20, 2024
1 parent 4c9e63d commit 72bde71
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 12 deletions.
5 changes: 3 additions & 2 deletions tests/unit-global/es.array-buffer.detached.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,9 @@ QUnit.test('ArrayBuffer#detached', assert => {
structuredClone(detached, { transfer: [detached] });
} catch { /* empty */ }

if (detached.length === 0) {
assert.same(detached.detached, true, 'detached');
if (detached.byteLength === 0) {
// works incorrectly in ancient WebKit
assert.skip.true(detached.detached, true, 'detached');
}

if (DESCRIPTORS) {
Expand Down
12 changes: 7 additions & 5 deletions tests/unit-global/es.array-buffer.transfer-to-fixed-length.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ if (transferToFixedLength) QUnit.test('ArrayBuffer#transferToFixedLength', asser
assert.looksNative(transferToFixedLength);
assert.nonEnumerable(ArrayBuffer.prototype, 'transferToFixedLength');

// works incorrectly in ancient webkit
const DETACHED = false; // 'detached' in ArrayBuffer.prototype;
const DETACHED = 'detached' in ArrayBuffer.prototype;

const array = [0, 1, 2, 3, 4, 5, 6, 7];

Expand All @@ -21,7 +20,8 @@ if (transferToFixedLength) QUnit.test('ArrayBuffer#transferToFixedLength', asser
assert.notSame(transferred, buffer, 'returns new buffer 1');
assert.true(transferred instanceof ArrayBuffer, 'returns ArrayBuffer 1');
assert.same(buffer.byteLength, 0, 'original array length 1');
if (DETACHED) assert.true(buffer.detached, 'original array detached 1');
// works incorrectly in ancient WebKit
if (DETACHED) assert.skip.true(buffer.detached, 'original array detached 1');
assert.same(transferred.byteLength, 8, 'proper transferred byteLength 1');
assert.arrayEqual(bufferToArray(transferred), array, 'properly copied 1');

Expand All @@ -30,7 +30,8 @@ if (transferToFixedLength) QUnit.test('ArrayBuffer#transferToFixedLength', asser
assert.notSame(transferred, buffer, 'returns new buffer 2');
assert.true(transferred instanceof ArrayBuffer, 'returns ArrayBuffer 2');
assert.same(buffer.byteLength, 0, 'original array length 2');
if (DETACHED) assert.true(buffer.detached, 'original array detached 2');
// works incorrectly in ancient WebKit
if (DETACHED) assert.skip.true(buffer.detached, 'original array detached 2');
assert.same(transferred.byteLength, 5, 'proper transferred byteLength 2');
assert.arrayEqual(bufferToArray(transferred), array.slice(0, 5), 'properly copied 2');

Expand All @@ -39,7 +40,8 @@ if (transferToFixedLength) QUnit.test('ArrayBuffer#transferToFixedLength', asser
assert.notSame(transferred, buffer, 'returns new buffer 3');
assert.true(transferred instanceof ArrayBuffer, 'returns ArrayBuffer 3');
assert.same(buffer.byteLength, 0, 'original array length 3');
if (DETACHED) assert.true(buffer.detached, 'original array detached 3');
// works incorrectly in ancient WebKit
if (DETACHED) assert.skip.true(buffer.detached, 'original array detached 3');
assert.same(transferred.byteLength, 16, 'proper transferred byteLength 3');
assert.arrayEqual(bufferToArray(transferred), [...array, 0, 0, 0, 0, 0, 0, 0, 0], 'properly copied 3');

Expand Down
12 changes: 7 additions & 5 deletions tests/unit-global/es.array-buffer.transfer.js
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,7 @@ if (transfer) QUnit.test('ArrayBuffer#transfer', assert => {
assert.looksNative(transfer);
assert.nonEnumerable(ArrayBuffer.prototype, 'transfer');

// works incorrectly in ancient webkit
const DETACHED = false; // 'detached' in ArrayBuffer.prototype;
const DETACHED = 'detached' in ArrayBuffer.prototype;

const array = [0, 1, 2, 3, 4, 5, 6, 7];

Expand All @@ -21,7 +20,8 @@ if (transfer) QUnit.test('ArrayBuffer#transfer', assert => {
assert.notSame(transferred, buffer, 'returns new buffer 1');
assert.true(transferred instanceof ArrayBuffer, 'returns ArrayBuffer 1');
assert.same(buffer.byteLength, 0, 'original array length 1');
if (DETACHED) assert.true(buffer.detached, 'original array detached 1');
// works incorrectly in ancient WebKit
if (DETACHED) assert.skip.true(buffer.detached, 'original array detached 1');
assert.same(transferred.byteLength, 8, 'proper transferred byteLength 1');
assert.arrayEqual(bufferToArray(transferred), array, 'properly copied 1');

Expand All @@ -30,7 +30,8 @@ if (transfer) QUnit.test('ArrayBuffer#transfer', assert => {
assert.notSame(transferred, buffer, 'returns new buffer 2');
assert.true(transferred instanceof ArrayBuffer, 'returns ArrayBuffer 2');
assert.same(buffer.byteLength, 0, 'original array length 2');
if (DETACHED) assert.true(buffer.detached, 'original array detached 2');
// works incorrectly in ancient WebKit
if (DETACHED) assert.skip.true(buffer.detached, 'original array detached 2');
assert.same(transferred.byteLength, 5, 'proper transferred byteLength 2');
assert.arrayEqual(bufferToArray(transferred), array.slice(0, 5), 'properly copied 2');

Expand All @@ -39,7 +40,8 @@ if (transfer) QUnit.test('ArrayBuffer#transfer', assert => {
assert.notSame(transferred, buffer, 'returns new buffer 3');
assert.true(transferred instanceof ArrayBuffer, 'returns ArrayBuffer 3');
assert.same(buffer.byteLength, 0, 'original array length 3');
if (DETACHED) assert.true(buffer.detached, 'original array detached 3');
// works incorrectly in ancient WebKit
if (DETACHED) assert.skip.true(buffer.detached, 'original array detached 3');
assert.same(transferred.byteLength, 16, 'proper transferred byteLength 3');
assert.arrayEqual(bufferToArray(transferred), [...array, 0, 0, 0, 0, 0, 0, 0, 0], 'properly copied 3');

Expand Down

0 comments on commit 72bde71

Please sign in to comment.