Commit Graph

176 Commits

Author SHA1 Message Date
Philip Chimento be0abd93cd Add copies of resizable ArrayBuffer species constructor tests to BigInt folders
This adds copies of the tests added in the previous commit, to the
respective BigInt folders, editing them to use the testBigIntTypedArray
helper instead of the testTypedArray helper.

See: #3723
2023-03-31 16:52:42 -07:00
Aditi 8330bd6567 Add resizable ArrayBuffer tests in %%TypedArray%% 2023-03-31 16:52:42 -07:00
Yusuke Suzuki 83a46bfe0e
test/built-ins/TypedArray/prototype/map/callbackfn-resize.js test result is incorrect (#3721)
%TypedArray%.prototype.map's iteration count does not change even though the source view is resized during the iteration.
And since result is just returning index, then result array should be [0, 1, 2].
2022-11-18 14:17:12 -05:00
Linus Groh 5a858cc0c4 Add missing includes to toSorted/toReversed this-value-invalid.js tests
Otherwise $DETACHBUFFER() is not defined in those files.
2022-10-18 14:05:01 +02:00
Nicolò Ribaudo 6f4601d095
Add "Change Array by Copy" tests (stage 3) (#3464)
Co-authored-by: Ashley Claymore <acutmore@users.noreply.github.com>
Co-authored-by: Tim Chevalier <tjc@igalia.com>
Co-authored-by: Ms2ger <Ms2ger@igalia.com>
2022-10-18 10:16:20 +02:00
Shu-yu Guo 1c19242ae4 Remove check for per-iteration detach check in TypedArray.prototype.set
Note that this test currently unintentionally passes, because a
TypeError is thrown for failing to convert the undefined returned from
the getter to a BigInt. But since this test was intended to test
detaching, it's no longer valid and should still be removed.

See https://github.com/tc39/test262/pull/3465#issuecomment-1098388916
2022-04-13 21:24:57 -04:00
Shu-yu Guo d7c0a2076c Remove check for per-comparator call detach check in TypedArray.prototype.sort
This updates tests in line with the normative change in
https://github.com/tc39/ecma262/pull/2723
2022-04-05 11:25:05 -04:00
Shu-yu Guo 3ac6b73369 Add test that TypedArray.prototype.set doesn't throw if a getter for an element detaches 2022-04-05 11:18:45 -04:00
Shu-yu Guo 8b29141224 Remove check for per-iteration detach check in TypedArray.prototype.set
This updates tests in line with the normative change in
https://github.com/tc39/ecma262/pull/2646
2022-04-05 11:18:45 -04:00
Mike Pennisi eb153de85b Add tests: resizing ArrayBuffer during iteration
The Resizable ArrayBuffer proposal allows implementations to reject any
resize operation, so the tests must accommodate that possibility.

Mitigate the complexity this entails by minimizing branches and by
deferring assertions to locations with shallow call stacks.
2021-11-09 13:27:58 -05:00
Mike Pennisi d9ddf80479 Revert "Merge pull request #3219 from tc39/rwaldron/migrate-comparearray"
This reverts commit b690cb67be, reversing
changes made to 50dd431dff. This is
necessary because the reverted changeset reduced coverage by an unknown
extent.
2021-10-01 10:18:47 -04:00
rwaldron 4847d9db5a chore: update test/**/*.js to use assert.compareArray wherever applicable 2021-09-24 12:58:15 -04:00
Mike Pennisi 50dd431dff Focus test for BigInt v. of `copyWithin` method
Prior to this commit, a test for %TypedArray%.prototype.copyWithin
provided a TypedArray instance as the first argument. That argument that
is interpreted as a number, so in relying on the conversion, the test
verified behavior beyond what it purported to test.

Simplify the test by using the desired number value directly.
2021-09-24 11:21:19 -04:00
Mike Pennisi de6583d61d Use BigInt values idiomatically
Prior to this commit, a number of tests used non-BigInt values where
BigInt value are commonly used. Although this was technically
permissible to validate the behavior under test, the atypical usage
patterns tended to obscure the tests' purpose. Replace with more
appropriate values.
2021-09-24 11:20:58 -04:00
Mike Pennisi 741db35b65 Correct arguments for BigInt-accepting methods 2021-09-24 11:20:29 -04:00
Mike Pennisi 8fad17a506 Focus tests for `copyWithin` methods
Prior to this commit, a test for %TypedArray%.prototype.copyWithin
provided a TypedArray instance as the first argument. That argument that
is interpreted as a number, so in relying on the conversion, the test
verified behavior beyond what it purported to test.

Simplify the test by using the desired number value directly, and extend
the tests for type coercion to cover object values.
2021-09-23 15:20:34 -04:00
Mike Pennisi e6b64517a4 Correct assertion messages and improve coverage
Following a recent normative change to the Resizable ArrayBuffer
proposal [1], the term "out of bounds" no longer applies to
"length-tracking" TypedArrays whose underlying ArrayBuffer has been
resized to match their byte offset.

Reflect this in the tests by renaming the condition from "out of bounds"
to "on boundary" and by adding new assertions for true "out of bounds"
conditions.

[1] https://github.com/tc39/proposal-resizablearraybuffer/pull/70
2021-09-23 15:16:43 -04:00
Mike Pennisi 1b72bcd857 Correct mistakes in support of proposal change
Ensure that when the ArrayBuffer of a length-tracking TypedArray is
resized to the address matching the TypedArray's byte offset, the
TypedArray is *not* considered "out of bounds."
2021-09-23 15:16:15 -04:00
legendecas 7c3d29686b Add test for byteOffset coverage in %typedarray%.prototype.copywithin 2021-09-13 10:09:41 -04:00
Rick Waldron 1667f56c04
Coverage for BigUint64Array & BigInt64Array backed by resizable / growable buffers. Fixes gh-3112 (#3154) 2021-09-02 11:19:53 -07:00
Mike Pennisi 07caa4a2df Support normative change to Resizable ArrayBuffer
A recent normative change to the Resizable ArrayBuffer modified the
criteria for a TypedArray becoming "out of bounds." Following the
change, TypedArrays which track the length of their underlying
ArrayBuffer instance are no longer considered "out of bounds" when the
ArrayBuffer is resized such that its size matches the TypedArray's
offset exactly.

https://github.com/tc39/proposal-resizablearraybuffer/pull/70

The majority of this patch's changes extend coverage to include cases
for both "on boundary" and "out of bounds" without reflecting any new
semantics. Two changes describe observable differences in the new
version of the algorithm:

- out-of-bounds-when-species-retrieved-different-type.js
- out-of-bounds-when-species-retrieved-same-type.js
2021-08-25 16:14:56 -04:00
Mike Pennisi ab353c6e73 Correct tests and improve documentation
The tests for the "Array findFromLast" proposal were originally authored
based on related tests that had already been merged to the repository's
`main` branch [1]. While those new tests were under review, a number of
tests for the Resizable ArrayBuffer proposal were found to be incorrect
[2]. The problem was fixed for the tests in `main`, but because the
corresponding tests for "Array findFromLast" were not yet merged, the
error persisted there [3].

Apply the same correction to the new tests.

[1] https://github.com/tc39/test262/issues/3111
[2] https://github.com/tc39/test262/pull/3113
[3] https://github.com/tc39/test262/pull/3045
2021-08-02 12:20:09 -04:00
Wenlu Wang 915f7e79be Fix incorrect case 2021-07-28 13:53:14 -04:00
Wenlu Wang 74727cd4ed Fix CR issues 2021-07-28 13:53:14 -04:00
Wenlu Wang 6a6211e495 Fix format 2021-07-28 13:53:13 -04:00
Wenlu Wang 3d82bd7ffb Fix format 2021-07-28 13:53:13 -04:00
Wenlu Wang ed2addaa73 Fix format 2021-07-28 13:53:13 -04:00
rwaldron 4b54d54113 Fix copyrights and features metadata 2021-07-28 13:53:12 -04:00
Wenlu Wang 41e946d00b Fix format 2021-07-28 13:51:38 -04:00
Wenlu Wang 642a180e62 Fix minor typo 2021-07-28 13:51:38 -04:00
Wenlu Wang f354da8ba4 Add typedarray findLastIndex 2021-07-28 13:51:38 -04:00
Wenlu Wang cb54d119e3 Add typedarray find last tests 2021-07-28 13:51:37 -04:00
Mike Pennisi 8428e70367 Correct tests and improve documentation 2021-07-28 11:04:49 -04:00
jugglinmike ebb6c34fa5
Resizable ArrayBuffer: TypedArray methods (#3027)
* ResizableArrayBuffer: TypedArray.prototype.set

* Resizable ArrayBuffer: TypedArray methods

The files in this patch are highly similar. Only the test for
`TypedArray.prototype.copyWithin` was written manually. The others were
generated from that test via the following script:

    #!/bin/bash

    set -eu

    names_cb='
    every
    filter
    find
    findIndex
    forEach
    map
    reduce
    reduceRight
    some
    '
    names_num='
    at
    fill
    includes
    indexOf
    join
    lastIndexOf
    slice
    '
    names_none='
    entries
    values
    keys
    reverse
    sort
    toLocaleString
    values
    '

    for name in $(printf "${names_cb} ${names_num} ${names_none}"); do
      lower=$(echo ${name} | tr '[:upper:]' '[:lower:]')
      if echo "$names_cb" | grep -xq $name; then
        value='() => {}'
      elif echo "$names_num" | grep -xq $name; then
        value='0'
      else
        value=''
      fi

      if [[ "${name}" == 'at' ]]; then
        features_addition='TypedArray.prototype.at, '
      else
        features_addition=''
      fi

      sed \
        -e "s/copywithin/${lower}/g" \
        -e "s/copyWithin/${name}/g" \
        -e "s/${name}(.*);/${name}(${value});/g" \
        -e "s/resizable-arraybuffer/${features_addition}resizable-arraybuffer/g" \
        ./test/built-ins/TypedArray/prototype/copyWithin/return-abrupt-from-this-out-of-bounds.js \
        > ./test/built-ins/TypedArray/prototype/${name}/return-abrupt-from-this-out-of-bounds.js
    done
2021-06-25 15:33:36 -04:00
jugglinmike f734c2d547
Resizable ArrayBuffer: TypedArray accessors (#3028)
* Add "feature" for "Resizable ArrayBuffer" proposal

* Resizable ArrayBuffer: TypedArray accessors
2021-06-25 13:38:51 -04:00
Yusuke Suzuki 93a2ba8c28 Fix BigInt TypedArrays tests
1. test/built-ins/TypedArray/prototype/findIndex/BigInt/predicate-may-detach-buffer.js
It is not updated when a60a67ea88 is landed. This patch fixes it.

2. test/built-ins/TypedArray/prototype/filter/BigInt/callbackfn-detachbuffer.js
After detaching, BigInt64Array/BigUint64Array will produce undefined for indexed access. And
if `filter`'s callback says `true` for these results, we need to store `ToBigInt(undefined)`
to a newly resulted BigInt64Array/BigUint64Array and this will throw an error. But this test
assumed it does not throw. This patch fixed flag so that we do not throw that error while keeping
detached typed arrays tested.
2021-02-03 22:10:52 -05:00
Rick Waldron de091de9f6 Include indexOf(undefined, ...) and lastIndexOf(undefined, ...) 2020-12-16 11:59:56 -05:00
Rick Waldron 167e596a64 Align detached buffer semantics with web reality, R6. Fixes gh-2915 2020-12-16 11:59:56 -05:00
Rick Waldron 96aff62fb2 IntegerIndexedElementSet should always indicate success. Ref: tc39/ecma262/pull/2210 2020-12-02 15:06:36 -05:00
Ross Kirsling 73798cbc61
Fix typos for at/prop-desc tests. (#2908) 2020-11-19 02:32:38 -08:00
Leo Balter 65bd4432f9 Fix missing renames for item->at
Ref #2905
2020-11-18 15:18:14 -05:00
Ross Kirsling df1bce9c2e Rename item() to at(). 2020-11-18 13:31:11 -05:00
Rick Waldron 3c58228465 Align detached buffer semantics with web reality, R4. Fixes gh-2879 2020-11-02 12:20:44 -05:00
Rick Waldron 224c0ce19e Replace unicode characters that pyyaml cannot read 2020-10-29 13:49:09 -04:00
Rick Waldron 0001489473 Update test/built-ins/TypedArray/prototype/forEach/callbackfn-detachbuffer.js
Co-authored-by: Ross Kirsling <rkirsling@gmail.com>
2020-10-21 20:14:36 -04:00
Rick Waldron a60a67ea88 Align detached buffer semantics with web reality, R3 2020-10-21 20:14:36 -04:00
Rick Waldron f2a8384d4d Align detached buffer semantics with web reality, R1 2020-10-16 20:38:21 -04:00
Rick Waldron 59463a2dd7 Cleanups 2020-10-09 13:46:50 -04:00
Rick Waldron bf900a30b2 Create and assign feature: "align-detached-buffer-semantics-with-web-reality" 2020-10-09 13:46:50 -04:00
Rick Waldron 47be1e83e2 [[Delete]] ( P ) 2020-10-09 13:46:50 -04:00