Skip to content

Commit 1cd9571

Browse files
ivankraptomato
authored andcommitted
Use $DETACHBUFFER helper in test/staging/sm/
Switch the tests in test/staging/sm/ that use `$262.detachArrayBuffer` directly to the style in non-staging tests: add `includes: detachArrayBuffer.js` and use `$DETACHBUFFER` helper (except for a few cross-realm calls).
1 parent a8bc723 commit 1cd9571

29 files changed

+86
-62
lines changed

test/staging/sm/Atomics/detached-buffers.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// This code is governed by the BSD license found in the LICENSE file.
33

44
/*---
5+
includes: [detachArrayBuffer.js]
56
description: |
67
pending
78
esid: pending
@@ -19,7 +20,7 @@ const intArrayConstructors = [
1920
function badValue(ta) {
2021
return {
2122
valueOf() {
22-
$262.detachArrayBuffer(ta.buffer);
23+
$DETACHBUFFER(ta.buffer);
2324
return 0;
2425
}
2526
};

test/staging/sm/DataView/detach-after-construction.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// This code is governed by the BSD license found in the LICENSE file.
33

44
/*---
5+
includes: [detachArrayBuffer.js]
56
description: |
67
pending
78
esid: pending
@@ -10,6 +11,6 @@ esid: pending
1011
var buf = new ArrayBuffer([1,2]);
1112
var bufView = new DataView(buf);
1213

13-
$262.detachArrayBuffer(buf);
14+
$DETACHBUFFER(buf);
1415

1516
assert.throws(TypeError, () => bufView.getInt8(0));

test/staging/sm/DataView/get-set-index-range.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// This code is governed by the BSD license found in the LICENSE file.
33

44
/*---
5+
includes: [detachArrayBuffer.js]
56
description: |
67
pending
78
esid: pending
@@ -31,7 +32,7 @@ for (let fun of ['getInt8', 'getInt16']) {
3132

3233
// ToIndex is called before detachment check, so we can tell the difference
3334
// between a ToIndex failure and a real out of bounds failure.
34-
$262.detachArrayBuffer(buffer);
35+
$DETACHBUFFER(buffer);
3536

3637
check(view);
3738

test/staging/sm/TypedArray/constructor-buffer-sequence.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// This code is governed by the BSD license found in the LICENSE file.
33

44
/*---
5+
includes: [detachArrayBuffer.js]
56
description: |
67
pending
78
esid: pending
@@ -15,7 +16,7 @@ const otherGlobal = $262.createRealm().global;
1516
function* createBuffers(lengths = [0, 8]) {
1617
for (let length of lengths) {
1718
let buffer = new ArrayBuffer(length);
18-
yield {buffer, detach: () => $262.detachArrayBuffer(buffer)};
19+
yield {buffer, detach: () => $DETACHBUFFER(buffer)};
1920
}
2021

2122
for (let length of lengths) {

test/staging/sm/TypedArray/constructor-non-detached.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,18 @@
22
// This code is governed by the BSD license found in the LICENSE file.
33

44
/*---
5-
includes: [sm/non262-TypedArray-shell.js]
5+
includes: [sm/non262-TypedArray-shell.js, detachArrayBuffer.js]
66
description: |
77
pending
88
esid: pending
99
---*/
1010
for (var constructor of typedArrayConstructors) {
1111
var buf = new constructor();
12-
$262.detachArrayBuffer(buf.buffer);
12+
$DETACHBUFFER(buf.buffer);
1313
assert.throws(TypeError, () => new constructor(buf));
1414

1515
var buffer = new ArrayBuffer();
16-
$262.detachArrayBuffer(buffer);
16+
$DETACHBUFFER(buffer);
1717
assert.throws(TypeError, () => new constructor(buffer));
1818
}
1919

test/staging/sm/TypedArray/detached-array-buffer-checks.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// This code is governed by the BSD license found in the LICENSE file.
33

44
/*---
5+
includes: [detachArrayBuffer.js]
56
description: |
67
pending
78
esid: pending
@@ -11,7 +12,7 @@ esid: pending
1112
// all relevant functions.
1213
let buffer = new ArrayBuffer(32);
1314
let array = new Int32Array(buffer);
14-
$262.detachArrayBuffer(buffer);
15+
$DETACHBUFFER(buffer);
1516

1617
// A nice poisoned callable to ensure that we fail on a detached buffer check
1718
// before a method attempts to do anything with its arguments.

test/staging/sm/TypedArray/fill-detached.js

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// This code is governed by the BSD license found in the LICENSE file.
33

44
/*---
5+
includes: [detachArrayBuffer.js]
56
description: |
67
pending
78
esid: pending
@@ -11,7 +12,7 @@ esid: pending
1112
function DetachArrayBufferValue(buffer, value) {
1213
return {
1314
valueOf() {
14-
$262.detachArrayBuffer(buffer);
15+
$DETACHBUFFER(buffer);
1516
return value;
1617
}
1718
};
@@ -20,7 +21,7 @@ function DetachArrayBufferValue(buffer, value) {
2021
function DetachTypedArrayValue(ta, value) {
2122
return {
2223
valueOf() {
23-
$262.detachArrayBuffer(ta.buffer);
24+
$DETACHBUFFER(ta.buffer);
2425
return value;
2526
}
2627
};

test/staging/sm/TypedArray/from_typedarray_fastpath_detached.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// This code is governed by the BSD license found in the LICENSE file.
33

44
/*---
5+
includes: [detachArrayBuffer.js]
56
description: |
67
pending
78
esid: pending
@@ -10,7 +11,7 @@ esid: pending
1011
// checks for detached buffers.
1112

1213
var ta = new Int32Array(4);
13-
$262.detachArrayBuffer(ta.buffer);
14+
$DETACHBUFFER(ta.buffer);
1415

1516
assert.throws(TypeError, () => Int32Array.from(ta));
1617

test/staging/sm/TypedArray/set-detached-bigint.js

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// This code is governed by the BSD license found in the LICENSE file.
33

44
/*---
5+
includes: [detachArrayBuffer.js]
56
description: |
67
pending
78
esid: pending
@@ -10,7 +11,7 @@ let ta = new BigInt64Array(10);
1011

1112
let obj = {
1213
get length() {
13-
$262.detachArrayBuffer(ta.buffer);
14+
$DETACHBUFFER(ta.buffer);
1415
return 1;
1516
},
1617
0: {

test/staging/sm/TypedArray/set-detached.js

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22
// This code is governed by the BSD license found in the LICENSE file.
33

44
/*---
5+
includes: [detachArrayBuffer.js]
56
description: |
67
pending
78
esid: pending
@@ -22,7 +23,7 @@ class ExpectedError extends Error {}
2223

2324
// No detached check on function entry.
2425
for (let {typedArray, buffer} of createTypedArrays()) {
25-
$262.detachArrayBuffer(buffer);
26+
$DETACHBUFFER(buffer);
2627

2728
assert.throws(ExpectedError, () => typedArray.set(null, {
2829
valueOf() {
@@ -40,7 +41,7 @@ for (let [offset, error] of [[0, TypeError], [1000000, TypeError], [-1, RangeErr
4041
for (let {typedArray, buffer} of createTypedArrays()) {
4142
assert.throws(error, () => typedArray.set(source, {
4243
valueOf() {
43-
$262.detachArrayBuffer(buffer);
44+
$DETACHBUFFER(buffer);
4445
return offset;
4546
}
4647
}));
@@ -51,7 +52,7 @@ for (let [offset, error] of [[0, TypeError], [1000000, TypeError], [-1, RangeErr
5152
// Tests when called with detached typed array as source.
5253
for (let {typedArray} of createTypedArrays()) {
5354
for (let {typedArray: source, buffer: sourceBuffer} of createTypedArrays()) {
54-
$262.detachArrayBuffer(sourceBuffer);
55+
$DETACHBUFFER(sourceBuffer);
5556

5657
assert.throws(ExpectedError, () => typedArray.set(source, {
5758
valueOf() {
@@ -70,7 +71,7 @@ for (let [offset, error] of [[0, TypeError], [1000000, TypeError], [-1, RangeErr
7071
for (let {typedArray: source, buffer: sourceBuffer} of createTypedArrays()) {
7172
assert.throws(error, () => typedArray.set(source, {
7273
valueOf() {
73-
$262.detachArrayBuffer(sourceBuffer);
74+
$DETACHBUFFER(sourceBuffer);
7475
return offset;
7576
}
7677
}));
@@ -88,7 +89,7 @@ for (let src of [ta => ta, ta => new Int32Array(ta.buffer), ta => new Float32Arr
8889
let source = src(typedArray);
8990
assert.throws(TypeError, () => typedArray.set(source, {
9091
valueOf() {
91-
$262.detachArrayBuffer(buffer);
92+
$DETACHBUFFER(buffer);
9293
return 0;
9394
}
9495
}));
@@ -102,7 +103,7 @@ for (let offset of [() => 0, ta => Math.min(1, ta.length), ta => Math.max(0, ta.
102103
for (let {typedArray, buffer} of createTypedArrays()) {
103104
let source = {
104105
get length() {
105-
$262.detachArrayBuffer(buffer);
106+
$DETACHBUFFER(buffer);
106107
return 0;
107108
}
108109
};
@@ -118,7 +119,7 @@ for (let offset of [() => 0, ta => Math.min(1, ta.length), ta => Math.max(0, ta.
118119
let source = {
119120
length: {
120121
valueOf() {
121-
$262.detachArrayBuffer(buffer);
122+
$DETACHBUFFER(buffer);
122123
return 0;
123124
}
124125
}
@@ -133,7 +134,7 @@ for (let {typedArray, buffer} of createTypedArrays()) {
133134
let source = {
134135
length: {
135136
valueOf() {
136-
$262.detachArrayBuffer(buffer);
137+
$DETACHBUFFER(buffer);
137138
return 1;
138139
}
139140
}
@@ -153,7 +154,7 @@ for (let {typedArray, buffer} of createTypedArrays()) {
153154
},
154155
length: {
155156
valueOf() {
156-
$262.detachArrayBuffer(buffer);
157+
$DETACHBUFFER(buffer);
157158
return 1;
158159
}
159160
}
@@ -174,7 +175,7 @@ for (let {typedArray, buffer} of createTypedArrays()) {
174175
},
175176
length: {
176177
valueOf() {
177-
$262.detachArrayBuffer(buffer);
178+
$DETACHBUFFER(buffer);
178179
return 1;
179180
}
180181
}
@@ -188,7 +189,7 @@ for (let {typedArray, buffer} of createTypedArrays()) {
188189
let source = Object.defineProperties([], {
189190
0: {
190191
get() {
191-
$262.detachArrayBuffer(buffer);
192+
$DETACHBUFFER(buffer);
192193
return 1;
193194
}
194195
}
@@ -207,7 +208,7 @@ for (let {typedArray, buffer} of createTypedArrays()) {
207208
let source = Object.defineProperties([], {
208209
0: {
209210
get() {
210-
$262.detachArrayBuffer(buffer);
211+
$DETACHBUFFER(buffer);
211212
return 1;
212213
}
213214
},
@@ -232,7 +233,7 @@ for (let {typedArray, buffer} of createTypedArrays()) {
232233
for (let {typedArray, buffer} of createTypedArrays()) {
233234
let source = [{
234235
valueOf() {
235-
$262.detachArrayBuffer(buffer);
236+
$DETACHBUFFER(buffer);
236237
return 1;
237238
}
238239
}];
@@ -249,7 +250,7 @@ for (let {typedArray, buffer} of createTypedArrays()) {
249250
let accessed = false;
250251
let source = [{
251252
valueOf() {
252-
$262.detachArrayBuffer(buffer);
253+
$DETACHBUFFER(buffer);
253254
return 1;
254255
}
255256
}, {

0 commit comments

Comments
 (0)