Commit Graph

293 Commits

Author SHA1 Message Date
Richard Gibson 703873e1ca Test Array.prototype.findLast* length clamping 2023-01-30 15:32:14 +01:00
Philip Chimento 7c9a885b79 Array.fromAsync: Boilerplate tests
Here are some of the standard tests for property metadata of the
Array.fromAsync property and for the built-in function object. These don't
require doing anything asynchronously, so can be considered separately
from the Async Helpers RFC.
2022-12-17 13:18:46 -08:00
Richard Gibson 8cd563f978
Intl: Add substantive tests for Array.prototype.toLocaleString (#3741) 2022-12-05 10:51:55 +01:00
Philip Chimento d87a7da6e1 Replace Object.hasOwnProperty.call with Object.prototype.hasOwnProperty.call
While we're at it, use assert() instead of assert.sameValue() for brevity,
if we are not specifically testing that the return value of hasOwnProperty
is the value true or false; and add more informative assertion messages to
help with debugging.

In some cases, the Object.hasOwnProperty.call could be replaced with
verifyProperty(), if the property descriptor was also being verified at
the same time.

This fixes some tests that were faulty to begin with: a common mistake was
Object.hasOwnProperty(obj, prop) which is probably going to return false
when that's not what you want.

The only instances left of `Object.hasOwnProperty` are one regression test
in implementation-contributed which I can't tell if it was intentionally
needed to trigger the regression, and a few instances of
`Object.hasOwnProperty('prototype')` which would defeat the purpose to
convert into `Object.prototype.hasOwnProperty.call(Object, 'prototype')`
form.

Closes: #3524
2022-11-30 16:04:02 -08:00
Shu-yu Guo ade328d530 Fix toSpliced mutate-while-iterating test 2022-10-25 09:50:41 +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
Jordan Harband 8f19bb4a45
Fix features in tests from #3354 and #3353 2022-09-14 11:30:22 -07:00
Justin Ridgewell 9592077530 Update groupToMap tests 2022-09-14 11:38:07 -07:00
polsevev ce511219e8 add tests for array.prototype.groupByToMap 2022-09-14 11:38:07 -07:00
Justin Ridgewell e7af14502e Test callback throwing 2022-09-14 11:02:48 -07:00
Justin Ridgewell 95f869ce0d Test non-property key throws 2022-09-14 11:02:48 -07:00
Justin Ridgewell 457185507e Add test for get access throwing 2022-09-14 11:02:48 -07:00
Justin Ridgewell 6cdb375d8c Add test for length conversion 2022-09-14 11:02:48 -07:00
Justin Ridgewell 22fe1b44b2 Update group tests 2022-09-14 11:02:48 -07:00
polsevev 5bd6844df5 added tests for groupBy 2022-09-14 11:02:48 -07:00
Yusuke Suzuki f74cee5f59 Rename Array#groupBy and Array#groupByToMap to Array#group and Array#groupToMap
TC39 decided to rename them to avoid web-compat issue[1].
This change follows to it.

[1]: https://github.com/tc39/proposal-array-grouping/pull/39
2022-08-03 13:29:11 -07:00
Jordan Harband 28b31c0bf1 use `isConstructor` assertion in "non-constructor" tests 2022-04-27 12:23:50 -04:00
legendecas 50dc96e59e Split Array.prototype.Symbol.unscopables tests for features 2022-03-10 17:04:16 -05:00
legendecas d8fb00d741 Add missing feature flag array-grouping 2022-03-10 17:04:16 -05:00
legendecas ec39db5877 Test array grouping Symbol.unscopables values 2022-02-16 09:57:44 -05:00
Alexey Shvayka 5cc9a6bda6 Add Array.prototype.unshift() tests 2022-02-08 15:45:38 -05:00
Alexey Shvayka 37ffcfb7ed Add Array.prototype.shift() tests 2022-02-08 15:45:38 -05:00
Alexey Shvayka 1323cc3152 Add Array.prototype.push() tests 2022-02-08 15:45:38 -05:00
Alexey Shvayka 014ca9fcc3 Add Array.prototype.pop() tests 2022-02-08 15:45:38 -05:00
Csaba Osztrogonác bd1acb51a4 tools: enforce restriction on YAML includes key
Includes key should use flow notation to be able parsed easier
as suggested in https://github.com/tc39/test262/issues/1997

Added this check to the linting script and updated tests accordingly.
2022-01-05 17:27:58 -05:00
Mike Pennisi 08a9fc2b97 Fix: correct Resizable ArrayBuffer/Array tests
Prior to this patch, the tests for certain Array prototype methods
incorrectly expected all elements to be "visited" even when a given
property was not present according to HasProperty.

Update the tests to reflect the fact that under such conditions, the
removed element is not visited.
2021-12-18 11:50:47 -05:00
Mike Pennisi 6d5975defc Remove duplicated constructor tests
A number of tests were found to be duplicative based on an analysis of
file contents (included below). Eliminate the duplication by removing
the version of each test with less precise metadata. In cases where this
removal could technically be considered a reduction in coverage,
preserve the verification of additional semantics in the remaining test.

    $ git grep -El 'new\s+\w+.prototype' | sed 's/[^\/]\+$//g' | sort | uniq -c | grep -vE '^\s+1 ' | awk '{print $2}' | xargs grep -Elr 'new\s+\w+.prototype'
    test/built-ins/Array/prototype/join/S15.4.4.5_A6.7.js
    test/built-ins/Array/prototype/join/not-a-constructor.js
    test/built-ins/Array/prototype/pop/not-a-constructor.js
    test/built-ins/Array/prototype/pop/S15.4.4.6_A5.7.js
    test/built-ins/Array/prototype/push/S15.4.4.7_A6.7.js
    test/built-ins/Array/prototype/push/not-a-constructor.js
    test/built-ins/Array/prototype/shift/not-a-constructor.js
    test/built-ins/Array/prototype/shift/S15.4.4.9_A5.7.js
    test/built-ins/Array/prototype/slice/not-a-constructor.js
    test/built-ins/Array/prototype/slice/S15.4.4.10_A5.7.js
    test/built-ins/Array/prototype/sort/not-a-constructor.js
    test/built-ins/Array/prototype/sort/S15.4.4.11_A7.7.js
    test/built-ins/Array/prototype/splice/S15.4.4.12_A5.7.js
    test/built-ins/Array/prototype/splice/not-a-constructor.js
    test/built-ins/Array/prototype/toLocaleString/S15.4.4.3_A4.7.js
    test/built-ins/Array/prototype/toLocaleString/not-a-constructor.js
    test/built-ins/Array/prototype/toString/S15.4.4.2_A4.7.js
    test/built-ins/Array/prototype/toString/not-a-constructor.js
    test/built-ins/Array/prototype/unshift/S15.4.4.13_A5.7.js
    test/built-ins/Array/prototype/unshift/not-a-constructor.js
    test/built-ins/Function/prototype/apply/S15.3.4.3_A8_T1.js
    test/built-ins/Function/prototype/apply/S15.3.4.3_A8_T2.js
    test/built-ins/Function/prototype/apply/not-a-constructor.js
    test/built-ins/Function/prototype/call/not-a-constructor.js
    test/built-ins/Function/prototype/call/S15.3.4.4_A7_T2.js
    test/built-ins/Function/prototype/call/S15.3.4.4_A7_T1.js
    test/built-ins/Function/prototype/toString/S15.3.4.2_A7.js
    test/built-ins/Function/prototype/toString/not-a-constructor.js
    test/built-ins/Object/prototype/hasOwnProperty/S15.2.4.5_A7.js
    test/built-ins/Object/prototype/hasOwnProperty/not-a-constructor.js
    test/built-ins/Object/prototype/propertyIsEnumerable/not-a-constructor.js
    test/built-ins/Object/prototype/propertyIsEnumerable/S15.2.4.7_A7.js
    test/built-ins/Object/prototype/toLocaleString/S15.2.4.3_A7.js
    test/built-ins/Object/prototype/toLocaleString/not-a-constructor.js
    test/built-ins/Object/prototype/toString/not-a-constructor.js
    test/built-ins/Object/prototype/toString/not-ctor.js
    test/built-ins/Object/prototype/valueOf/not-a-constructor.js
    test/built-ins/Object/prototype/valueOf/S15.2.4.4_A7.js
2021-12-14 13:38:51 -05:00
Nicolò Ribaudo 2b2d35de69
Delete duplicate "`Array#reverse` is not a constructor" test (#3342)
It's already tested by test/built-ins/Array/prototype/reverse/not-a-constructor.js
2021-12-10 14:09:36 -05:00
rwaldron a5d8e8e997 test: Add more Array.from tests for array-like. Closes gh-3336 2021-12-07 09:40:23 -05: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
Rick Waldron fc975b171d
Transform compareArray -> assert.compareArray: test/built-ins/Array/**/*.js (#3238) 2021-10-08 16:16:32 -04:00
Mike Pennisi a6834093aa Improve coverage by invoking functions as intended
Some tests which include function declarations designed to verify
behavior do not reference those functions. Insert the references
necessary for those functions to serve their intended purpose.
2021-10-05 16:22:56 -04: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 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
Mickey Rose 836111dc3c
remove redundant throw from assert.throws() test functions (#3167) 2021-08-26 07:55:52 -07:00
rwaldron 21e627b35d Transform legacy format to harness assertions 2021-08-11 10:42:40 -04:00
rwaldron 08cf542e1b Remove "//CHECK#\d" 2021-08-11 10:20:11 -04:00
Rick Waldron 452c0e5c61
Automated assertion message update: Array * (#3140)
* Automated assertion message update: Array.from

* Automated assertion message update: Array.isArray

* Automated assertion message update: Array length property

* Automated assertion message update: Array.of

* Automated assertion message update: Array

* Automated assertion message update: Array.prototype.at

* Automated assertion message update: Array.prototype.concat

* Automated assertion message update: compareArray -> assert.compareArray
2021-08-10 14:51:54 -07:00
Shu-yu Guo 5a6577bcc9
Add missing array-find-from-last feature to unscopables test (#3130) 2021-08-03 13:17:38 -07: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 5da8030779 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 6c5e421806 Add unscopable tests 2021-07-28 13:51:37 -04:00
Wenlu Wang a4aeea09ae Avoid useless spec statement 2021-07-28 13:51:37 -04:00
Wenlu Wang 3bb6d6480e Add findLastIndex tests 2021-07-28 13:51:37 -04:00
Wenlu Wang 275e7f1595 Add tests for proposal array find from last 2021-07-28 13:51:37 -04:00
Rick Waldron 99ab8cce08
chore: migrate $ERROR -> throw new Test262Error in test/built-ins/Array (#3071) 2021-07-21 11:53:23 -07:00
Alexey Shvayka 6e61dd7754
Test Array's toString() with non-callable "join" (#2973)
* Test Array's toString() with non-callable "join"

* Remove Array.prototype.join modifications
2021-04-15 20:51:08 -04:00