Bug 1892041 - Part 2: Update test262. r=spidermonkey-reviewers,dminor
[gecko.git] / js / src / tests / test262 / built-ins / TypedArray / prototype / join / separator-tostring-once-after-resized.js
blobfdae9040c5520b115b00b02276df51151ad630cc
1 // |reftest| shell-option(--enable-arraybuffer-resizable) skip-if(!ArrayBuffer.prototype.resize||!xulRuntime.shell) -- resizable-arraybuffer is not enabled unconditionally, requires shell-options
2 // Copyright (C) 2024 AndrĂ© Bargull. All rights reserved.
3 // This code is governed by the BSD license found in the LICENSE file.
5 /*---
6 esid: sec-%typedarray%.prototype.join
7 description: >
8   ToString is called once when the array is resized.
9 info: |
10   %TypedArray%.prototype.join ( separator )
12   ...
13   2. Let taRecord be ? ValidateTypedArray(O, seq-cst).
14   3. Let len be TypedArrayLength(taRecord).
15   ...
16   5. Else, let sep be ? ToString(separator).
17   ...
19 features: [TypedArray, resizable-arraybuffer]
20 ---*/
22 let rab = new ArrayBuffer(3, {maxByteLength: 5});
23 let ta = new Int8Array(rab);
25 let callCount = 0;
27 let index = {
28   toString() {
29     callCount++;
30     rab.resize(0);
31     return "-";
32   }
35 assert.sameValue(callCount, 0);
37 let r = ta.join(index);
39 assert.sameValue(callCount, 1);
40 assert.sameValue(r, "--");
42 reportCompare(0, 0);